Signed-off-by: Anton Johansson <[email protected]>
---
target/riscv/tcg/pmp.c | 5 +++--
target/riscv/tcg/meson.build | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/target/riscv/tcg/pmp.c b/target/riscv/tcg/pmp.c
index 99345d63dc..2d7194de10 100644
--- a/target/riscv/tcg/pmp.c
+++ b/target/riscv/tcg/pmp.c
@@ -638,19 +638,20 @@ uint64_t pmpaddr_csr_read(CPURISCVState *env, uint32_t
addr_index)
if (addr_index < pmp_regions) {
val = env->pmp_state.pmp[addr_index].addr_reg;
int g = pmp_get_granularity_g(env);
+ const unsigned long_bits = target_long_bits();
switch (pmp_get_a_field(env->pmp_state.pmp[addr_index].cfg_reg)) {
case PMP_AMATCH_OFF:
/* fallthrough */
case PMP_AMATCH_TOR:
/* Bit [g-1:0] read all zero */
- if (g >= 1 && g < TARGET_LONG_BITS) {
+ if (g >= 1 && g < long_bits) {
uint64_t granule = 1ULL << g;
val = ROUND_DOWN(val, granule);
}
break;
case PMP_AMATCH_NAPOT:
/* Bit [g-2:0] read all one */
- if (g >= 2 && g < TARGET_LONG_BITS) {
+ if (g >= 2 && g < long_bits) {
val = deposit64(val, 0, g - 1, -1ULL);
}
break;
diff --git a/target/riscv/tcg/meson.build b/target/riscv/tcg/meson.build
index 69dadfd662..0aaba9cf34 100644
--- a/target/riscv/tcg/meson.build
+++ b/target/riscv/tcg/meson.build
@@ -17,7 +17,6 @@ riscv_ss.add(files(
riscv_system_ss.add(files(
'debug.c',
- 'pmp.c',
))
@@ -35,4 +34,5 @@ riscv_common_system_ss.add(files(
'pmu.c',
'tcg-cpu.c',
'th_csr.c',
+ 'pmp.c',
))
--
2.52.0