diff options
author | Tim Newsome <tim@sifive.com> | 2020-01-06 16:57:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-06 16:57:15 -0800 |
commit | 8b8db033ee118c3a35462b8e8b287652d5ec69d3 (patch) | |
tree | b2421e0681dc6a8bf3ba29f417b2bdb9c3c2874e | |
parent | 2c3f099b73be5079e509edfc5db554289fad2bcc (diff) | |
download | riscv-openocd-8b8db033ee118c3a35462b8e8b287652d5ec69d3.zip riscv-openocd-8b8db033ee118c3a35462b8e8b287652d5ec69d3.tar.gz riscv-openocd-8b8db033ee118c3a35462b8e8b287652d5ec69d3.tar.bz2 |
Upcast mask value to work with 64-bit physical (#436)
Change-Id: I00f0d2a3c79a431e1aa49c7478fa6c17e2fa5256
-rw-r--r-- | src/target/riscv/riscv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index beca76c..7e7f8ba 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -1453,6 +1453,9 @@ static int riscv_address_translate(struct target *target, else pte = buf_get_u64(buffer, 0, 64); + LOG_DEBUG("i=%d; PTE @0x%" TARGET_PRIxADDR " = 0x%" PRIx64, i, + pte_address, pte); + if (!(pte & PTE_V) || (!(pte & PTE_R) && (pte & PTE_W))) return ERROR_FAIL; @@ -1476,12 +1479,13 @@ static int riscv_address_translate(struct target *target, while (i < info->level) { ppn_value = pte >> info->pte_ppn_shift[i]; ppn_value &= info->pte_ppn_mask[i]; - *physical &= ~(info->pa_ppn_mask[i] << info->pa_ppn_shift[i]); + *physical &= ~(((target_addr_t) info->pa_ppn_mask[i]) << + info->pa_ppn_shift[i]); *physical |= (ppn_value << info->pa_ppn_shift[i]); i++; } - LOG_DEBUG("Virtual address: 0x%" TARGET_PRIxADDR, virtual); - LOG_DEBUG("Physical address: 0x%" TARGET_PRIxADDR, *physical); + LOG_DEBUG("0x%" TARGET_PRIxADDR " -> 0x%" TARGET_PRIxADDR, virtual, + *physical); return ERROR_OK; } |