target/riscv: Convert epmp from feature to ratified smepmp extension
PATCH 1/1 target/riscv: Convert epmp from feature to ratified smepmp extension
Smepmp is a ratified extension. This patch converts the existing epmp support as a feature to an extension. With this, "smepmp" string will be concatenated to riscv,isa in generated FDT.
Since the official name of the extension is Smepmp, the references to epmp have also been changed to smepmp.
--- target/riscv/cpu.c | 16 ++++++---------- target/riscv/cpu.h | 3 +-- target/riscv/csr.c | 8 +++++--- target/riscv/pmp.c | 13 +++++++++---- 4 files changed, 21 insertions(+), 19 deletions(-)
target/riscv/cpu.c +6 -10
@@ -103,6 +103,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zhinx, true,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin, true,PRIV_VERSION_1_12_0 , ext_zhinxmin),ISA_EXT_DATA_ENTRY (smaia, true,PRIV_VERSION_1_12_0 , ext_smaia), +ISA_EXT_DATA_ENTRY (smepmp, true,PRIV_VERSION_1_12_0 , ext_smepmp),ISA_EXT_DATA_ENTRY (ssaia, true,PRIV_VERSION_1_12_0 , ext_ssaia),ISA_EXT_DATA_ENTRY (sscofpmf, true,PRIV_VERSION_1_12_0 , ext_sscofpmf), ISA_EXT_DATA_ENTRY(sstc, true, PRIV_VERSION_1_12_0, ext_sstc),
@@ -325,7 +326,7 @@ static void rv32_ibex_cpu_init(Object *obj)register_cpu_props (DEVICE (obj));set_priv_version (env,PRIV_VERSION_1_11_0 ); cpu->cfg.mmu = false; - cpu->cfg.epmp = true; + cpu->cfg.ext_smepmp = true; }static void rv32_imafcu_nommu_cpu_init (Object *obj)
@@ -884,14 +885,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)if (cpu->cfg.pmp) {riscv_set_feature (env,RISCV_FEATURE_PMP ); - -/* -* Enhanced PMP should only be available -* on harts with PMP support -*/ -if (cpu->cfg.epmp) { -riscv_set_feature (env,RISCV_FEATURE_EPMP ); - } + }else { +/* smepmp requires pmp support */ + cpu->cfg.ext_smepmp = false; }if (cpu->cfg.debug) {
@@ -1051,6 +1047,7 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("Zve64f" ,RISCVCPU , cfg.ext_zve64f, false),DEFINE_PROP_BOOL ("mmu" ,RISCVCPU , cfg.mmu, true),DEFINE_PROP_BOOL ("pmp" ,RISCVCPU , cfg.pmp, true), +DEFINE_PROP_BOOL ("smepmp" ,RISCVCPU , cfg.ext_smepmp, false),DEFINE_PROP_BOOL ("sstc" ,RISCVCPU , cfg.ext_sstc, true), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),
@@ -1093,7 +1090,6 @@ static Property riscv_cpu_extensions[] = {/* These are experimental so mark with 'x-' */ DEFINE_PROP_BOOL ("x-j" ,RISCVCPU , cfg.ext_j, false),/* ePMP 0.9.3 */ -DEFINE_PROP_BOOL ("x-epmp" ,RISCVCPU , cfg.epmp, false),DEFINE_PROP_BOOL ("x-smaia" ,RISCVCPU , cfg.ext_smaia, false), DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false),
target/riscv/cpu.h +1 -2
@@ -87,7 +87,6 @@enum {RISCV_FEATURE_MMU ,RISCV_FEATURE_PMP , -RISCV_FEATURE_EPMP ,RISCV_FEATURE_MISA ,RISCV_FEATURE_DEBUG };
@@ -465,6 +464,7 @@ struct RISCVCPUConfig {bool ext_smaia;bool ext_ssaia;bool ext_sscofpmf; +bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s;
@@ -484,7 +484,6 @@ struct RISCVCPUConfig {uint16_t elen;bool mmu;bool pmp; -bool epmp;bool debug;bool short_isa_string;
target/riscv/csr.c +5 -3
@@ -426,9 +426,11 @@ static RISCVException pmp(CPURISCVState *env, int csrno)return RISCV_EXCP_ILLEGAL_INST ; } -static RISCVException epmp (CPURISCVState *env,int csrno) +static RISCVException smepmp (CPURISCVState *env,int csrno) { -if (env->priv ==PRV_M &&riscv_feature (env,RISCV_FEATURE_EPMP )) { +RISCVCPU *cpu =env_archcpu (env); + +if (env->priv ==PRV_M && cpu->cfg.ext_smepmp) {return RISCV_EXCP_NONE ; }
@@ -4259,7 +4261,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_VSIPH] = { "vsiph", aia_hmode32, NULL, NULL, rmw_vsiph }, /* Physical Memory Protection */ - [CSR_MSECCFG] = { "mseccfg", epmp, read_mseccfg, write_mseccfg, + [CSR_MSECCFG] = { "mseccfg", smepmp, read_mseccfg, write_mseccfg, .min_priv_ver = PRIV_VERSION_1_11_0 }, [CSR_PMPCFG0] = { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] = { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg },
target/riscv/pmp.c +9 -4
@@ -58,6 +58,11 @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index)return 0 ; } +static inline int smepmp_is_enabled (CPURISCVState *env) +{ +return (RISCV_CPU (env_cpu (env))->cfg.ext_smepmp); +} +/* * Count the number of active rules. */
@@ -88,7 +93,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)if (pmp_index <MAX_RISCV_PMPS ) {bool locked = true; -if (riscv_feature (env,RISCV_FEATURE_EPMP )) { +if (smepmp_is_enabled (env)) {/* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET (env)) { locked = false;
@@ -239,7 +244,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, {bool ret; -if (riscv_feature (env,RISCV_FEATURE_EPMP )) { +if (smepmp_is_enabled (env)) {if (MSECCFG_MMWP_ISSET (env)) {/* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set
@@ -265,7 +270,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, } } -if ((!riscv_feature (env,RISCV_FEATURE_PMP )) || (mode ==PRV_M )) { +if (!smepmp_is_enabled (env) || (mode ==PRV_M )) {/* * Privileged spec v1.10 states if HW doesn't implement any PMP entry * or no PMP entry matches an M-Mode access, the access succeeds.
@@ -348,7 +353,7 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,/* * Convert the PMP permissions to match the truth table in the -* ePMP spec. +* Smepmp spec. */ const uint8_t epmp_operation = ((env->pmp_state.pmp[i].cfg_reg & PMP_LOCK) >> 4) |
Signature · 1 line
2.39.1
Hey. Sorry for the delay, this patch went through the cracks :(
(CCing the reviewers)
(CCing qemu-devel as well)
Quoted 41 lines · Himanshu Chauhan
Smepmp is a ratified extension. This patch converts the existing epmp support as a feature to an extension. With this, "smepmp" string will be concatenated to riscv,isa in generated FDT.
Since the official name of the extension is Smepmp, the references to epmp have also been changed to smepmp.
Signed-off-by Himanshu Chauhan <[email protected]>--- target/riscv/cpu.c | 16 ++++++---------- target/riscv/cpu.h | 3 +-- target/riscv/csr.c | 8 +++++--- target/riscv/pmp.c | 13 +++++++++---- 4 files changed, 21 insertions(+), 19 deletions(-)target/riscv/cpu.c +2
-2@@ -103,6 +103,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zhinx, true,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin, true,PRIV_VERSION_1_12_0 , ext_zhinxmin),ISA_EXT_DATA_ENTRY (smaia, true,PRIV_VERSION_1_12_0 , ext_smaia), +ISA_EXT_DATA_ENTRY (smepmp, true,PRIV_VERSION_1_12_0 , ext_smepmp),ISA_EXT_DATA_ENTRY (ssaia, true,PRIV_VERSION_1_12_0 , ext_ssaia),ISA_EXT_DATA_ENTRY (sscofpmf, true,PRIV_VERSION_1_12_0 , ext_sscofpmf), ISA_EXT_DATA_ENTRY(sstc, true, PRIV_VERSION_1_12_0, ext_sstc),@@ -325,7 +326,7 @@ static void rv32_ibex_cpu_init(Object *obj)register_cpu_props (DEVICE (obj));set_priv_version (env,PRIV_VERSION_1_11_0 ); cpu->cfg.mmu = false; - cpu->cfg.epmp = true; + cpu->cfg.ext_smepmp = true; }static void rv32_imafcu_nommu_cpu_init (Object *obj)@@ -884,14 +885,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)if (cpu->cfg.pmp) {riscv_set_feature (env,RISCV_FEATURE_PMP ); -
target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev, Error **errp) · line 890
Quoted 10 lines
target/riscv/cpu.c +3
-7-/* -* Enhanced PMP should only be available -* on harts with PMP support -*/ -if (cpu->cfg.epmp) { -riscv_set_feature (env,RISCV_FEATURE_EPMP ); - } + }else { +/* smepmp requires pmp support */ + cpu->cfg.ext_smepmp = false;
I believe this and other chunk like it will collide with the work done in:
"[PATCH v7 00/10] make write_misa a no-op and FEATURE_* cleanups"
That series is already acked, so it would make the maintainer's life easier to base this patch on top of that. You can add a:
Based-on: [email protected] ("[PATCH v7 00/10] make write_misa a no-op and FEATURE_* cleanups")
at the start of the cover-letter to indicate the dependency.
Quoted 52 lines
target/riscv/cpu.c +1
-1}if (cpu->cfg.debug) {@@ -1051,6 +1047,7 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("Zve64f" ,RISCVCPU , cfg.ext_zve64f, false),DEFINE_PROP_BOOL ("mmu" ,RISCVCPU , cfg.mmu, true),DEFINE_PROP_BOOL ("pmp" ,RISCVCPU , cfg.pmp, true), +DEFINE_PROP_BOOL ("smepmp" ,RISCVCPU , cfg.ext_smepmp, false),DEFINE_PROP_BOOL ("sstc" ,RISCVCPU , cfg.ext_sstc, true), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),@@ -1093,7 +1090,6 @@ static Property riscv_cpu_extensions[] = {/* These are experimental so mark with 'x-' */ DEFINE_PROP_BOOL ("x-j" ,RISCVCPU , cfg.ext_j, false),/* ePMP 0.9.3 */ -DEFINE_PROP_BOOL ("x-epmp" ,RISCVCPU , cfg.epmp, false),DEFINE_PROP_BOOL ("x-smaia" ,RISCVCPU , cfg.ext_smaia, false), DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false),target/riscv/cpu.h +1
-2@@ -87,7 +87,6 @@enum {RISCV_FEATURE_MMU ,RISCV_FEATURE_PMP , -RISCV_FEATURE_EPMP ,RISCV_FEATURE_MISA ,RISCV_FEATURE_DEBUG };@@ -465,6 +464,7 @@ struct RISCVCPUConfig {bool ext_smaia;bool ext_ssaia;bool ext_sscofpmf; +bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s;@@ -484,7 +484,6 @@ struct RISCVCPUConfig {uint16_t elen;bool mmu;bool pmp; -bool epmp;bool debug;bool short_isa_string;target/riscv/csr.c +0
-0
target/riscv/csr.c static RISCVException pmp(CPURISCVState *env, int csrno) · line 433
Quoted 10 lines
target/riscv/csr.c +4
-2@@ -426,9 +426,11 @@ static RISCVException pmp(CPURISCVState *env, int csrno)return RISCV_EXCP_ILLEGAL_INST ; } -static RISCVException epmp (CPURISCVState *env,int csrno) +static RISCVException smepmp (CPURISCVState *env,int csrno) { -if (env->priv ==PRV_M &&riscv_feature (env,RISCV_FEATURE_EPMP )) { +RISCVCPU *cpu =env_archcpu (env); + +if (env->priv ==PRV_M && cpu->cfg.ext_smepmp) {
I did a recent cleanup in these code patterns by using a new riscv_cpu_cfg() API. If you rebase this patch on top of that series (which has the API) this code would become:
Quoted 21 lines
target/riscv/csr.c +1
-1-if (env->priv ==PRV_M &&riscv_feature (env,RISCV_FEATURE_EPMP )) { +if (env->priv ==PRV_M &&riscv_cpu_cfg (env)->ext_smepmp) {return RISCV_EXCP_NONE; }target/riscv/csr.c +1
-1@@ -4259,7 +4261,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_VSIPH] = { "vsiph", aia_hmode32, NULL, NULL, rmw_vsiph }, /* Physical Memory Protection */ - [CSR_MSECCFG] = { "mseccfg", epmp, read_mseccfg, write_mseccfg, + [CSR_MSECCFG] = { "mseccfg", smepmp, read_mseccfg, write_mseccfg, .min_priv_ver = PRIV_VERSION_1_11_0 }, [CSR_PMPCFG0] = { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] = { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg },target/riscv/pmp.c +0
-0
target/riscv/pmp.c static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) · line 65
Quoted 8 lines
target/riscv/pmp.c +5
-0@@ -58,6 +58,11 @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index)return 0 ; } +static inline int smepmp_is_enabled (CPURISCVState *env) +{ +return (RISCV_CPU (env_cpu (env))->cfg.ext_smepmp); +} +
I believe you can just read "riscv_cpu_cfg(env)->ext_smepmp" directly wherever you need instead of creating a new function
Quoted 39 lines
target/riscv/pmp.c +4
-4/* * Count the number of active rules. */ @@ -88,7 +93,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)if (pmp_index <MAX_RISCV_PMPS ) {bool locked = true; -if (riscv_feature (env,RISCV_FEATURE_EPMP )) { +if (smepmp_is_enabled (env)) {/* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET (env)) { locked = false;@@ -239,7 +244,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, {bool ret; -if (riscv_feature (env,RISCV_FEATURE_EPMP )) { +if (smepmp_is_enabled (env)) {if (MSECCFG_MMWP_ISSET (env)) {/* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set @@ -265,7 +270,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, } } -if ((!riscv_feature (env,RISCV_FEATURE_PMP )) || (mode ==PRV_M )) { +if (!smepmp_is_enabled (env) || (mode ==PRV_M )) {/* * Privileged spec v1.10 states if HW doesn't implement any PMP entry * or no PMP entry matches an M-Mode access, the access succeeds. @@ -348,7 +353,7 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,/* * Convert the PMP permissions to match the truth table in the -* ePMP spec. +* Smepmp spec. */ const uint8_t epmp_operation = ((env->pmp_state.pmp[i].cfg_reg & PMP_LOCK) >> 4) |
Quoted 195 lines · Daniel Henrique Barboza
Hey. Sorry for the delay, this patch went through the cracks :(
(CCing the reviewers)
(CCing qemu-devel as well)Quoted 40 lines · Himanshu Chauhan
Smepmp is a ratified extension. This patch converts the existing epmp support as a feature to an extension. With this, "smepmp" string will be concatenated to riscv,isa in generated FDT.
Since the official name of the extension is Smepmp, the references to epmp have also been changed to smepmp.
Signed-off-by Himanshu Chauhan <[email protected]>---
target/riscv/cpu.c | 16 ++++++---------- target/riscv/cpu.h | 3 +-- target/riscv/csr.c | 8 +++++--- target/riscv/pmp.c | 13 +++++++++---- 4 files changed, 21 insertions(+), 19 deletions(-)target/riscv/cpu.c +2
-2@@ -103,6 +103,7 @@ static const struct isa_ext_data isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(zhinx, true, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, true, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, true, PRIV_VERSION_1_12_0, ext_smaia), + ISA_EXT_DATA_ENTRY(smepmp, true, PRIV_VERSION_1_12_0, ext_smepmp), ISA_EXT_DATA_ENTRY(ssaia, true, PRIV_VERSION_1_12_0, ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, true, PRIV_VERSION_1_12_0, ext_sscofpmf), ISA_EXT_DATA_ENTRY(sstc, true, PRIV_VERSION_1_12_0, ext_sstc),@@ -325,7 +326,7 @@ static void rv32_ibex_cpu_init(Object *obj) register_cpu_props(DEVICE(obj)); set_priv_version(env, PRIV_VERSION_1_11_0); cpu->cfg.mmu = false; - cpu->cfg.epmp = true; + cpu->cfg.ext_smepmp = true; } static void rv32_imafcu_nommu_cpu_init(Object *obj)@@ -884,14 +885,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.pmp) { riscv_set_feature(env, RISCV_FEATURE_PMP); -target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev, · line 890
Quoted 10 lines
target/riscv/cpu.c +3
-7- /* - * Enhanced PMP should only be available - * on harts with PMP support - */ - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); - } + } else { + /* smepmp requires pmp support */ + cpu->cfg.ext_smepmp = false;I believe this and other chunk like it will collide with the work done in:
"[PATCH v7 00/10] make
write_misaa no-op and FEATURE_* cleanups"That series is already acked, so it would make the maintainer's life easier to base this patch on top of that. You can add a:
Based-on: [email protected] ("[PATCH v7 00/10] make
write_misaa no-op and FEATURE_* cleanups")at the start of the cover-letter to indicate the dependency.
Quoted 47 lines
target/riscv/cpu.c +1
-1} if (cpu->cfg.debug) {@@ -1051,6 +1047,7 @@ static Property riscv_cpu_extensions[] = { DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + DEFINE_PROP_BOOL("smepmp", RISCVCPU, cfg.ext_smepmp, false), DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),@@ -1093,7 +1090,6 @@ static Property riscv_cpu_extensions[] = { /* These are experimental so mark with 'x-' */ DEFINE_PROP_BOOL("x-j", RISCVCPU, cfg.ext_j, false), /* ePMP 0.9.3 */ - DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false),diff --git
a/target/riscv/cpu.hb/target/riscv/cpu.hindexbcf0826753..30fd29e578100644target/riscv/cpu.h +0
-1@@ -87,7 +87,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, - RISCV_FEATURE_EPMP, RISCV_FEATURE_MISA,
RISCV_FEATURE_DEBUG
};target/riscv/cpu.h +1
-0@@ -465,6 +464,7 @@ struct RISCVCPUConfig { bool ext_smaia; bool ext_ssaia; bool ext_sscofpmf; + bool ext_smepmp; bool rvv_ta_all_1s; bool rvv_ma_all_1s; @@ -484,7 +484,6 @@ struct RISCVCPUConfig {
uint16_telen;
bool mmu;
bool pmp;
- bool epmp;
bool debug;
boolshort_isa_string;target/riscv/csr.c +0
-0target/riscv/csr.c static RISCVException pmp(CPURISCVState *env, · line 434
Quoted 10 lines
target/riscv/csr.c +4
-1@@ -426,9 +426,11 @@ static RISCVException pmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } -static RISCVException epmp(CPURISCVState *env, int csrno) +static RISCVException smepmp(CPURISCVState *env, int csrno) { - if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + RISCVCPU *cpu = env_archcpu(env); + + if (env->priv == PRV_M && cpu->cfg.ext_smepmp) {I did a recent cleanup in these code patterns by using a new
riscv_cpu_cfg()API. If you rebase this patch on top of that series (which has the API) this code would become:Quoted 20 lines
target/riscv/csr.c +1
-1- if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (env->priv == PRV_M && riscv_cpu_cfg(env)->ext_smepmp) {return
RISCV_EXCP_NONE;
}
@@ -4259,7 +4261,7 @@riscv_csr_operationscsr_ops[CSR_TABLE_SIZE] = { [CSR_VSIPH] = { "vsiph",aia_hmode32, NULL, NULL,rmw_vsiph}, /* Physical Memory Protection */
- [CSR_MSECCFG] = { "mseccfg", epmp,read_mseccfg,write_mseccfg, + [CSR_MSECCFG] = { "mseccfg", smepmp,read_mseccfg,write_mseccfg,
.min_priv_ver = PRIV_VERSION_1_11_0 }, [CSR_PMPCFG0] = { "pmpcfg0", pmp,read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] = { "pmpcfg1", pmp,read_pmpcfg, write_pmpcfg },target/riscv/pmp.c +0
-0target/riscv/pmp.c static inline int pmp_is_locked(CPURISCVState · line 65
Quoted 8 lines
target/riscv/pmp.c +4
-0@@ -58,6 +58,11 @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) return 0; } +static inline int smepmp_is_enabled(CPURISCVState *env) +{ + return (RISCV_CPU(env_cpu(env))->cfg.ext_smepmp); +} +I believe you can just read "riscv_cpu_cfg(env)->ext_smepmp" directly wherever you need instead of creating a new function
Quoted 31 lines
target/riscv/pmp.c +0
-0/** Count the number of active rules. */
target/riscv/pmp.c +1
-0@@ -88,7 +93,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val) if (pmp_index < MAX_RISCV_PMPS) { bool locked = true; - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (smepmp_is_enabled(env)) { /* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET(env)) {locked = false;
target/riscv/pmp.c +1
-0@@ -239,7 +244,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, { bool ret; - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (smepmp_is_enabled(env)) { if (MSECCFG_MMWP_ISSET(env)) { /** The Machine Mode Whitelist Policy (mseccfg.MMWP) is set
target/riscv/pmp.c +1
-0@@ -265,7 +270,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, } } - if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { + if (!smepmp_is_enabled(env) || (mode == PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP entry* or no PMP entry matches an M-Mode access, the access succeeds.
target/riscv/pmp.c +0
-0@@ -348,7 +353,7 @@ int pmp_hart_has_privs(CPURISCVState *env,
Quoted 8 lines
Quoted 8 lines
target/riscv/pmp.c +1
-1target_ulong addr, /** Convert the PMP permissions to match the truth table in the -* ePMP spec. +* Smepmp spec. */ const
uint8_tepmp_operation= ((env->pmp_state.pmp[i].cfg_reg &PMP_LOCK) >> 4) |
Thanks Daniel. I will rebase, take care of the conflicts, comments and then resend it.
Regards
Himanshu