From: Hou Weiying <weiying_...@outlook.com> Add a config option to enable experimental support for ePMP. This is disabled by default and can be enabled with 'x-epmp=true'.
Signed-off-by: Hongzheng-Li <ethan.lee....@gmail.com> Signed-off-by: Hou Weiying <weiying_...@outlook.com> Signed-off-by: Myriad-Dreamin <camiy...@gmail.com> --- target/riscv/cpu.c | 9 +++++++++ target/riscv/cpu.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 059d71f2c7..79fa9d3c2f 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -407,6 +407,14 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.pmp) { set_feature(env, RISCV_FEATURE_PMP); + + /* + * Enhanced PMP should only be available + * on harts with PMP support + */ + if (cpu->cfg.epmp) { + set_feature(env, RISCV_FEATURE_EPMP); + } } /* If misa isn't set (rv32 and rv64 machines) set it here */ @@ -509,6 +517,7 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index d0e7f5b9c5..afdc9fa2bf 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -77,6 +77,7 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, + RISCV_FEATURE_EPMP, RISCV_FEATURE_MISA }; @@ -202,6 +203,7 @@ struct CPURISCVState { /* physical memory protection */ pmp_table_t pmp_state; + target_ulong mseccfg; /* machine specific rdtime callback */ uint64_t (*rdtime_fn)(void); @@ -272,6 +274,7 @@ typedef struct RISCVCPU { char *user_spec; bool mmu; bool pmp; + bool epmp; } cfg; } RISCVCPU; -- 2.20.1