Add epmp to extensions list and rename it to smepmp
PATCH v2 1/1 Add epmp to extensions list and rename it to smepmp
From: Himanshu Chauhan <[email protected]>
Smepmp is a ratified extension which qemu refers to as epmp. Rename epmp to smepmp and add it to extension list so that it is added to the isa string.
---
Changes in v2:
====
- Rebase on latest riscv-to-apply.next
- Remove ePMP version comment
target/riscv/cpu.c | 8 +++----- target/riscv/cpu_cfg.h | 2 +- target/riscv/csr.c | 6 +++--- target/riscv/pmp.c | 12 ++++++------ target/riscv/tcg/tcg-cpu.c | 4 ++-- 5 files changed, 15 insertions(+), 17 deletions(-)
target/riscv/cpu.c +3 -5
@@ -133,7 +133,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin),ISA_EXT_DATA_ENTRY (smaia,PRIV_VERSION_1_12_0 , ext_smaia), -ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , epmp), +ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp),ISA_EXT_DATA_ENTRY (smstateen,PRIV_VERSION_1_12_0 , ext_smstateen),ISA_EXT_DATA_ENTRY (ssaia,PRIV_VERSION_1_12_0 , ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),
@@ -599,12 +599,11 @@ static void rv32_ibex_cpu_init(Object *obj)#ifndef CONFIG_USER_ONLY set_satp_mode_max_supported (cpu,VM_1_10_MBARE );#endif - cpu->cfg.epmp = true; -/* inherited from parent obj via riscv_cpu_init() */ cpu->cfg.ext_zifencei = true; cpu->cfg.ext_zicsr = true; cpu->cfg.pmp = true; + cpu->cfg.ext_smepmp = true; }static void rv32_imafcu_nommu_cpu_init (Object *obj)
@@ -1257,6 +1256,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zve64d" , ext_zve64d, false),MULTI_EXT_CFG_BOOL ("sstc" , ext_sstc, true), +MULTI_EXT_CFG_BOOL ("smepmp" , ext_smepmp, false),MULTI_EXT_CFG_BOOL ("smstateen" , ext_smstateen, false),MULTI_EXT_CFG_BOOL ("svadu" , ext_svadu, true), MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false),
@@ -1322,8 +1322,6 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = {/* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { -/* ePMP 0.9.3 */ -MULTI_EXT_CFG_BOOL ("x-epmp" , epmp, false),MULTI_EXT_CFG_BOOL ("x-smaia" , ext_smaia, false),MULTI_EXT_CFG_BOOL ("x-ssaia" , ext_ssaia, false),
target/riscv/cpu_cfg.h +1 -1
@@ -102,6 +102,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;
@@ -134,7 +135,6 @@ struct RISCVCPUConfig {uint16_t cboz_blocksize;bool mmu;bool pmp; -bool epmp;bool debug;bool misa_w;
target/riscv/csr.c +3 -3
@@ -524,9 +524,9 @@ 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 (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {return RISCV_EXCP_NONE ; }
@@ -4762,7 +4762,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 +6 -6
@@ -91,7 +91,7 @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)if (pmp_index <MAX_RISCV_PMPS ) {bool locked = true; -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET (env)) { locked = false;
@@ -340,9 +340,9 @@ bool 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 = +const uint8_t smepmp_operation = ((env->pmp_state.pmp[i].cfg_reg &PMP_LOCK ) >>4 ) | ((env->pmp_state.pmp[i].cfg_reg &PMP_READ ) <<2 ) | (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) |
@@ -367,7 +367,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,* If mseccfg.MML Bit set, do the enhanced pmp priv check */ if (mode ==PRV_M ) { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 1 :case 4 :
@@ -398,7 +398,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,g_assert_not_reached (); } }else { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 8 :case 9 :
@@ -574,7 +574,7 @@ void mseccfg_csr_write(CPURISCVState *env, target_ulong val) } } -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* Sticky bits */ val |= (env->mseccfg & (MSECCFG_MMWP |MSECCFG_MML ));if ((val ^ env->mseccfg) & (MSECCFG_MMWP |MSECCFG_MML )) {
target/riscv/tcg/tcg-cpu.c +2 -2
@@ -591,12 +591,12 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)return false; } -if (cpu->cfg.epmp && !cpu->cfg.pmp) { +if (cpu->cfg.ext_smepmp && !cpu->cfg.pmp) {/* * Enhanced PMP should only be available * on harts with PMP support */ -error_setg (errp,"Invalid configuration: EPMP requires PMP support" ); +error_setg (errp,"Invalid configuration: Smepmp requires PMP support" );return false; }
Signature · 1 line
2.34.1
Quoted 10 lines · Mayuresh Chitale
From: Himanshu Chauhan <[email protected]>
Smepmp is a ratified extension which qemu refers to as epmp. Rename epmp to smepmp and add it to extension list so that it is added to the isa string.
Signed-off-by Himanshu Chauhan <[email protected]>Signed-off-by Mayuresh Chitale <[email protected]>Reviewed-by Daniel Henrique Barboza <[email protected]>
Alistair
Quoted 177 lines
---
Changes in v2:
====
- Rebase on latest riscv-to-apply.next
- Remove ePMP version commenttarget/riscv/cpu.c | 8 +++----- target/riscv/cpu_cfg.h | 2 +- target/riscv/csr.c | 6 +++--- target/riscv/pmp.c | 12 ++++++------ target/riscv/tcg/tcg-cpu.c | 4 ++-- 5 files changed, 15 insertions(+), 17 deletions(-)target/riscv/cpu.c +3
-5@@ -133,7 +133,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin),ISA_EXT_DATA_ENTRY (smaia,PRIV_VERSION_1_12_0 , ext_smaia), -ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , epmp), +ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp),ISA_EXT_DATA_ENTRY (smstateen,PRIV_VERSION_1_12_0 , ext_smstateen),ISA_EXT_DATA_ENTRY (ssaia,PRIV_VERSION_1_12_0 , ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),@@ -599,12 +599,11 @@ static void rv32_ibex_cpu_init(Object *obj)#ifndef CONFIG_USER_ONLY set_satp_mode_max_supported (cpu,VM_1_10_MBARE );#endif - cpu->cfg.epmp = true; -/* inherited from parent obj via riscv_cpu_init() */ cpu->cfg.ext_zifencei = true; cpu->cfg.ext_zicsr = true; cpu->cfg.pmp = true; + cpu->cfg.ext_smepmp = true; }static void rv32_imafcu_nommu_cpu_init (Object *obj)@@ -1257,6 +1256,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zve64d" , ext_zve64d, false),MULTI_EXT_CFG_BOOL ("sstc" , ext_sstc, true), +MULTI_EXT_CFG_BOOL ("smepmp" , ext_smepmp, false),MULTI_EXT_CFG_BOOL ("smstateen" , ext_smstateen, false),MULTI_EXT_CFG_BOOL ("svadu" , ext_svadu, true), MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false),@@ -1322,8 +1322,6 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = {/* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { -/* ePMP 0.9.3 */ -MULTI_EXT_CFG_BOOL ("x-epmp" , epmp, false),MULTI_EXT_CFG_BOOL ("x-smaia" , ext_smaia, false),MULTI_EXT_CFG_BOOL ("x-ssaia" , ext_ssaia, false),target/riscv/cpu_cfg.h +1
-1@@ -102,6 +102,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;@@ -134,7 +135,6 @@ struct RISCVCPUConfig {uint16_t cboz_blocksize;bool mmu;bool pmp; -bool epmp;bool debug;bool misa_w;target/riscv/csr.c +3
-3@@ -524,9 +524,9 @@ 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 (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {return RISCV_EXCP_NONE ; }@@ -4762,7 +4762,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 +6
-6@@ -91,7 +91,7 @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)if (pmp_index <MAX_RISCV_PMPS ) {bool locked = true; -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET (env)) { locked = false;@@ -340,9 +340,9 @@ bool 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 = +const uint8_t smepmp_operation = ((env->pmp_state.pmp[i].cfg_reg &PMP_LOCK ) >>4 ) | ((env->pmp_state.pmp[i].cfg_reg &PMP_READ ) <<2 ) | (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) |@@ -367,7 +367,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,* If mseccfg.MML Bit set, do the enhanced pmp priv check */ if (mode ==PRV_M ) { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 1 :case 4 :@@ -398,7 +398,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,g_assert_not_reached (); } }else { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 8 :case 9 :@@ -574,7 +574,7 @@ void mseccfg_csr_write(CPURISCVState *env, target_ulong val) } } -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* Sticky bits */ val |= (env->mseccfg & (MSECCFG_MMWP |MSECCFG_MML ));if ((val ^ env->mseccfg) & (MSECCFG_MMWP |MSECCFG_MML )) {target/riscv/tcg/tcg-cpu.c +2
-3@@ -591,12 +591,12 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)return false; } -if (cpu->cfg.epmp && !cpu->cfg.pmp) { +if (cpu->cfg.ext_smepmp && !cpu->cfg.pmp) {/* * Enhanced PMP should only be available * on harts with PMP support */ -error_setg (errp,"Invalid configuration: EPMP requires PMP support" ); +error_setg (errp,"Invalid configuration: Smepmp requires PMP support" );return false; } --2.34.1
Alistair Francis
AppliedQuoted 10 lines · Mayuresh Chitale
From: Himanshu Chauhan <[email protected]>
Smepmp is a ratified extension which qemu refers to as epmp. Rename epmp to smepmp and add it to extension list so that it is added to the isa string.
Signed-off-by Himanshu Chauhan <[email protected]>Signed-off-by Mayuresh Chitale <[email protected]>Reviewed-by Daniel Henrique Barboza <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 177 lines
---
Changes in v2:
====
- Rebase on latest riscv-to-apply.next
- Remove ePMP version commenttarget/riscv/cpu.c | 8 +++----- target/riscv/cpu_cfg.h | 2 +- target/riscv/csr.c | 6 +++--- target/riscv/pmp.c | 12 ++++++------ target/riscv/tcg/tcg-cpu.c | 4 ++-- 5 files changed, 15 insertions(+), 17 deletions(-)target/riscv/cpu.c +3
-5@@ -133,7 +133,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin),ISA_EXT_DATA_ENTRY (smaia,PRIV_VERSION_1_12_0 , ext_smaia), -ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , epmp), +ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp),ISA_EXT_DATA_ENTRY (smstateen,PRIV_VERSION_1_12_0 , ext_smstateen),ISA_EXT_DATA_ENTRY (ssaia,PRIV_VERSION_1_12_0 , ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),@@ -599,12 +599,11 @@ static void rv32_ibex_cpu_init(Object *obj)#ifndef CONFIG_USER_ONLY set_satp_mode_max_supported (cpu,VM_1_10_MBARE );#endif - cpu->cfg.epmp = true; -/* inherited from parent obj via riscv_cpu_init() */ cpu->cfg.ext_zifencei = true; cpu->cfg.ext_zicsr = true; cpu->cfg.pmp = true; + cpu->cfg.ext_smepmp = true; }static void rv32_imafcu_nommu_cpu_init (Object *obj)@@ -1257,6 +1256,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zve64d" , ext_zve64d, false),MULTI_EXT_CFG_BOOL ("sstc" , ext_sstc, true), +MULTI_EXT_CFG_BOOL ("smepmp" , ext_smepmp, false),MULTI_EXT_CFG_BOOL ("smstateen" , ext_smstateen, false),MULTI_EXT_CFG_BOOL ("svadu" , ext_svadu, true), MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false),@@ -1322,8 +1322,6 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = {/* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { -/* ePMP 0.9.3 */ -MULTI_EXT_CFG_BOOL ("x-epmp" , epmp, false),MULTI_EXT_CFG_BOOL ("x-smaia" , ext_smaia, false),MULTI_EXT_CFG_BOOL ("x-ssaia" , ext_ssaia, false),target/riscv/cpu_cfg.h +1
-1@@ -102,6 +102,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;@@ -134,7 +135,6 @@ struct RISCVCPUConfig {uint16_t cboz_blocksize;bool mmu;bool pmp; -bool epmp;bool debug;bool misa_w;target/riscv/csr.c +3
-3@@ -524,9 +524,9 @@ 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 (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {return RISCV_EXCP_NONE ; }@@ -4762,7 +4762,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 +6
-6@@ -91,7 +91,7 @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)if (pmp_index <MAX_RISCV_PMPS ) {bool locked = true; -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET (env)) { locked = false;@@ -340,9 +340,9 @@ bool 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 = +const uint8_t smepmp_operation = ((env->pmp_state.pmp[i].cfg_reg &PMP_LOCK ) >>4 ) | ((env->pmp_state.pmp[i].cfg_reg &PMP_READ ) <<2 ) | (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) |@@ -367,7 +367,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,* If mseccfg.MML Bit set, do the enhanced pmp priv check */ if (mode ==PRV_M ) { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 1 :case 4 :@@ -398,7 +398,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,g_assert_not_reached (); } }else { -switch (epmp_operation) { +switch (smepmp_operation) {case 0 :case 8 :case 9 :@@ -574,7 +574,7 @@ void mseccfg_csr_write(CPURISCVState *env, target_ulong val) } } -if (riscv_cpu_cfg (env)->epmp) { +if (riscv_cpu_cfg (env)->ext_smepmp) {/* Sticky bits */ val |= (env->mseccfg & (MSECCFG_MMWP |MSECCFG_MML ));if ((val ^ env->mseccfg) & (MSECCFG_MMWP |MSECCFG_MML )) {target/riscv/tcg/tcg-cpu.c +2
-3@@ -591,12 +591,12 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)return false; } -if (cpu->cfg.epmp && !cpu->cfg.pmp) { +if (cpu->cfg.ext_smepmp && !cpu->cfg.pmp) {/* * Enhanced PMP should only be available * on harts with PMP support */ -error_setg (errp,"Invalid configuration: EPMP requires PMP support" ); +error_setg (errp,"Invalid configuration: Smepmp requires PMP support" );return false; } --2.34.1