RISCVCPUConfig related cleanups
cover RISCVCPUConfig related cleanups
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce riscv_cpu_cfg()" from [1] because we use the riscv_cpu_cfg() API.
[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: use env_archcpu() in ctr() target/riscv/csr.c: simplify mctr()
target/riscv/csr.c: use riscv_cpu_cfg() to avoid env_cpu() pointers target/riscv/csr.c: avoid env_archcpu() usages when reading
RISCVCPUConfig
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 target/riscv/csr.c: use env_archcpu() in ctr()
We don't need to use env_cpu() and CPUState().
--- target/riscv/csr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/riscv/csr.c +1 -2
@@ -108,8 +108,7 @@ static RISCVException vs(CPURISCVState *env, int csrno)static RISCVException ctr (CPURISCVState *env,int csrno) {#if !defined(CONFIG_USER_ONLY ) -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +RISCVCPU *cpu =env_archcpu (env);int ctr_index;target_ulong ctr_mask;int base_csrno =CSR_CYCLE ;
Signature · 1 line
2.39.2
Re: [PATCH 1/4] target/riscv/csr.c: use env_archcpu() in ctr()
Quoted 12 lines · Daniel Henrique Barboza
We don't need to use
env_cpu()andCPUState().Signed-off-by Daniel Henrique Barboza <[email protected]>--- target/riscv/csr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/riscv/csr.c +0
-0
target/riscv/csr.c static RISCVException vs(CPURISCVState *env, int csrno) · line 114
Quoted 9 lines
target/riscv/csr.c +1
-2@@ -108,8 +108,7 @@ static RISCVException vs(CPURISCVState *env, int csrno)static RISCVException ctr (CPURISCVState *env,int csrno) {#if !defined(CONFIG_USER_ONLY ) -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +RISCVCPU *cpu =env_archcpu (env);int ctr_index;target_ulong ctr_mask;int base_csrno =CSR_CYCLE ;
This has been done by previous patchset from Bin Meng:
https://lists.nongnu.org/archive/html/qemu-riscv/2023-02/msg00276.html
Regards,
Weiwei Li
PATCH 2/4 target/riscv/csr.c: simplify mctr()
In reply to Daniel Henrique BarbozaUse riscv_cpu_cfg() to retrieve pmu_num.
--- target/riscv/csr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
target/riscv/csr.c +2 -3
@@ -165,8 +165,7 @@ static RISCVException ctr32(CPURISCVState *env, int csrno)#if !defined(CONFIG_USER_ONLY )static RISCVException mctr (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +int pmu_num =riscv_cpu_cfg (env)->pmu_num;int ctr_index;int base_csrno =CSR_MHPMCOUNTER3 ;
@@ -175,7 +174,7 @@ static RISCVException mctr(CPURISCVState *env, int csrno) base_csrno +=0x80 ; } ctr_index = csrno - base_csrno; -if (!cpu->cfg.pmu_num || ctr_index >= cpu->cfg.pmu_num) { +if (!pmu_num || ctr_index >= pmu_num) {/* The PMU is not enabled or counter is out of range*/ return RISCV_EXCP_ILLEGAL_INST ; }
Signature · 1 line
2.39.2
Re: [PATCH 2/4] target/riscv/csr.c: simplify mctr()
Quoted 4 lines · Daniel Henrique Barboza
Use
riscv_cpu_cfg()to retrievepmu_num.Signed-off-by Daniel Henrique Barboza <[email protected]>---
Weiwei Li
Quoted 26 lines
target/riscv/csr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)target/riscv/csr.c +2
-3@@ -165,8 +165,7 @@ static RISCVException ctr32(CPURISCVState *env, int csrno)#if !defined(CONFIG_USER_ONLY )static RISCVException mctr (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); +int pmu_num =riscv_cpu_cfg (env)->pmu_num;int ctr_index;int base_csrno =CSR_MHPMCOUNTER3 ;@@ -175,7 +174,7 @@ static RISCVException mctr(CPURISCVState *env, int csrno) base_csrno +=0x80 ; } ctr_index = csrno - base_csrno; -if (!cpu->cfg.pmu_num || ctr_index >= cpu->cfg.pmu_num) { +if (!pmu_num || ctr_index >= pmu_num) {/* The PMU is not enabled or counter is out of range*/ return RISCV_EXCP_ILLEGAL_INST ; }
PATCH 3/4 target/riscv/csr.c: use riscv_cpu_cfg() to avoid env_cpu() pointers
In reply to Daniel Henrique BarbozaA common trend in this file is to retrieve a RISCVCPU pointer by first retrieving a CPUState pointer via env_cpu(). The CPU pointer is used only to access the RISCVCPUConfig object and nothing else.
Let's use riscv_cpu_cfg() to access what we need directly without these 2 pointers.
--- target/riscv/csr.c | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-)
target/riscv/csr.c +12 -38
@@ -46,10 +46,8 @@ static RISCVException smstateen_acc_ok(CPURISCVState *env, int index, uint64_t bit) {bool virt =riscv_cpu_virt_enabled (env); -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (env->priv ==PRV_M || !cpu->cfg.ext_smstateen) { +if (env->priv ==PRV_M || !riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_NONE ; }
@@ -81,7 +79,7 @@ static RISCVException fs(CPURISCVState *env, int csrno) {#if !defined(CONFIG_USER_ONLY )if (!env->debugger && !riscv_cpu_fp_enabled (env) && - !RISCV_CPU (env_cpu (env))->cfg.ext_zfinx) { + !riscv_cpu_cfg (env)->ext_zfinx) {return RISCV_EXCP_ILLEGAL_INST ; }#endif
@@ -90,11 +88,9 @@ static RISCVException fs(CPURISCVState *env, int csrno)static RISCVException vs (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (env->misa_ext &RVV || - cpu->cfg.ext_zve32f || cpu->cfg.ext_zve64f) { +riscv_cpu_cfg (env)->ext_zve32f || +riscv_cpu_cfg (env)->ext_zve64f) {#if !defined(CONFIG_USER_ONLY )if (!env->debugger && !riscv_cpu_vector_enabled (env)) {return RISCV_EXCP_ILLEGAL_INST ;
@@ -193,10 +189,7 @@ static RISCVException mctr32(CPURISCVState *env, int csrno)static RISCVException sscofpmf (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_sscofpmf) { +if (!riscv_cpu_cfg (env)->ext_sscofpmf) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -319,10 +312,7 @@ static RISCVException umode32(CPURISCVState *env, int csrno)static RISCVException mstateen (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -331,10 +321,7 @@ static RISCVException mstateen(CPURISCVState *env, int csrno)static RISCVException hstateen_pred (CPURISCVState *env,int csrno,int base) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -361,10 +348,8 @@ static RISCVException sstateen(CPURISCVState *env, int csrno) {bool virt =riscv_cpu_virt_enabled (env);int index = csrno -CSR_SSTATEEN0 ; -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -916,11 +901,9 @@ static RISCVException read_timeh(CPURISCVState *env, int csrno,static RISCVException sstc (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs);bool hmode_check = false; -if (!cpu->cfg.ext_sstc || !env->rdtime_fn) { +if (!riscv_cpu_cfg (env)->ext_sstc || !env->rdtime_fn) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -1150,30 +1133,21 @@ static RISCVException write_ignore(CPURISCVState *env, int csrno,static RISCVException read_mvendorid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.mvendorid; + *val =riscv_cpu_cfg (env)->mvendorid;return RISCV_EXCP_NONE ; }static RISCVException read_marchid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.marchid; + *val =riscv_cpu_cfg (env)->marchid;return RISCV_EXCP_NONE ; }static RISCVException read_mimpid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.mimpid; + *val =riscv_cpu_cfg (env)->mimpid;return RISCV_EXCP_NONE ; }
Signature · 1 line
2.39.2
Re: [PATCH 3/4] target/riscv/csr.c: use riscv_cpu_cfg() to avoid env_cpu() pointers
Quoted 10 lines · Daniel Henrique Barboza
A common trend in this file is to retrieve a RISCVCPU pointer by first retrieving a CPUState pointer via
env_cpu(). The CPU pointer is used only to access the RISCVCPUConfig object and nothing else.Let's use
riscv_cpu_cfg()to access what we need directly without these 2 pointers.Suggested-by LIU Zhiwei <[email protected]>Signed-off-by Daniel Henrique Barboza <[email protected]>---
Weiwei Li
Quoted 137 lines
target/riscv/csr.c | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-)target/riscv/csr.c +12
-38@@ -46,10 +46,8 @@ static RISCVException smstateen_acc_ok(CPURISCVState *env, int index, uint64_t bit) {bool virt =riscv_cpu_virt_enabled (env); -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (env->priv ==PRV_M || !cpu->cfg.ext_smstateen) { +if (env->priv ==PRV_M || !riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_NONE ; }@@ -81,7 +79,7 @@ static RISCVException fs(CPURISCVState *env, int csrno) {#if !defined(CONFIG_USER_ONLY )if (!env->debugger && !riscv_cpu_fp_enabled (env) && - !RISCV_CPU (env_cpu (env))->cfg.ext_zfinx) { + !riscv_cpu_cfg (env)->ext_zfinx) {return RISCV_EXCP_ILLEGAL_INST ; }#endif @@ -90,11 +88,9 @@ static RISCVException fs(CPURISCVState *env, int csrno)static RISCVException vs (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (env->misa_ext &RVV || - cpu->cfg.ext_zve32f || cpu->cfg.ext_zve64f) { +riscv_cpu_cfg (env)->ext_zve32f || +riscv_cpu_cfg (env)->ext_zve64f) {#if !defined(CONFIG_USER_ONLY )if (!env->debugger && !riscv_cpu_vector_enabled (env)) {return RISCV_EXCP_ILLEGAL_INST ;@@ -193,10 +189,7 @@ static RISCVException mctr32(CPURISCVState *env, int csrno)static RISCVException sscofpmf (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_sscofpmf) { +if (!riscv_cpu_cfg (env)->ext_sscofpmf) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -319,10 +312,7 @@ static RISCVException umode32(CPURISCVState *env, int csrno)static RISCVException mstateen (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -331,10 +321,7 @@ static RISCVException mstateen(CPURISCVState *env, int csrno)static RISCVException hstateen_pred (CPURISCVState *env,int csrno,int base) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -361,10 +348,8 @@ static RISCVException sstateen(CPURISCVState *env, int csrno) {bool virt =riscv_cpu_virt_enabled (env);int index = csrno -CSR_SSTATEEN0 ; -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); -if (!cpu->cfg.ext_smstateen) { +if (!riscv_cpu_cfg (env)->ext_smstateen) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -916,11 +901,9 @@ static RISCVException read_timeh(CPURISCVState *env, int csrno,static RISCVException sstc (CPURISCVState *env,int csrno) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs);bool hmode_check = false; -if (!cpu->cfg.ext_sstc || !env->rdtime_fn) { +if (!riscv_cpu_cfg (env)->ext_sstc || !env->rdtime_fn) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -1150,30 +1133,21 @@ static RISCVException write_ignore(CPURISCVState *env, int csrno,static RISCVException read_mvendorid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.mvendorid; + *val =riscv_cpu_cfg (env)->mvendorid;return RISCV_EXCP_NONE ; }static RISCVException read_marchid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.marchid; + *val =riscv_cpu_cfg (env)->marchid;return RISCV_EXCP_NONE ; }static RISCVException read_mimpid (CPURISCVState *env,int csrno,target_ulong *val) { -CPUState *cs =env_cpu (env); -RISCVCPU *cpu =RISCV_CPU (cs); - - *val = cpu->cfg.mimpid; + *val =riscv_cpu_cfg (env)->mimpid;return RISCV_EXCP_NONE ; }
PATCH 4/4 target/riscv/csr.c: avoid env_archcpu() usages when reading RISCVCPUConfig
In reply to Daniel Henrique BarbozaRetrieving the CPU pointer using env_archcpu() just to access cpu->cfg can be avoided by using riscv_cpu_cfg().
--- target/riscv/csr.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
target/riscv/csr.c +9 -23
@@ -213,9 +213,7 @@ static RISCVException any32(CPURISCVState *env, int csrno)static int aia_any (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_smaia) { +if (!riscv_cpu_cfg (env)->ext_smaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -224,9 +222,7 @@ static int aia_any(CPURISCVState *env, int csrno)static int aia_any32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_smaia) { +if (!riscv_cpu_cfg (env)->ext_smaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -253,9 +249,7 @@ static int smode32(CPURISCVState *env, int csrno)static int aia_smode (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -264,9 +258,7 @@ static int aia_smode(CPURISCVState *env, int csrno)static int aia_smode32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -380,9 +372,7 @@ static RISCVException pointer_masking(CPURISCVState *env, int csrno)static int aia_hmode (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -391,9 +381,7 @@ static int aia_hmode(CPURISCVState *env, int csrno)static int aia_hmode32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -430,9 +418,7 @@ static RISCVException debug(CPURISCVState *env, int csrno)static RISCVException seed (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_zkr) { +if (!riscv_cpu_cfg (env)->ext_zkr) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -555,7 +541,7 @@ static RISCVException read_vl(CPURISCVState *env, int csrno,static int read_vlenb (CPURISCVState *env,int csrno,target_ulong *val) { - *val =env_archcpu (env)->cfg.vlen >>3 ; + *val =riscv_cpu_cfg (env)->vlen >>3 ;return RISCV_EXCP_NONE ; }
@@ -610,7 +596,7 @@ static RISCVException write_vstart(CPURISCVState *env, int csrno,* The vstart CSR is defined to have only enough writable bits * to hold the largest element index, i.e. lg2(VLEN) bits. */ - env->vstart = val & ~(~0ULL <<ctzl (env_archcpu (env)->cfg.vlen)); + env->vstart = val & ~(~0ULL <<ctzl (riscv_cpu_cfg (env)->vlen));return RISCV_EXCP_NONE ; }
Signature · 1 line
2.39.2
Re: [PATCH 4/4] target/riscv/csr.c: avoid env_archcpu() usages when reading RISCVCPUConfig
Quoted 5 lines · Daniel Henrique Barboza
Retrieving the CPU pointer using
env_archcpu()just to accesscpu->cfgcan be avoided by usingriscv_cpu_cfg().Suggested-by LIU Zhiwei <[email protected]>Signed-off-by Daniel Henrique Barboza <[email protected]>
Weiwei Li
Quoted 103 lines
--- target/riscv/csr.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)target/riscv/csr.c +9
-23@@ -213,9 +213,7 @@ static RISCVException any32(CPURISCVState *env, int csrno)static int aia_any (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_smaia) { +if (!riscv_cpu_cfg (env)->ext_smaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -224,9 +222,7 @@ static int aia_any(CPURISCVState *env, int csrno)static int aia_any32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_smaia) { +if (!riscv_cpu_cfg (env)->ext_smaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -253,9 +249,7 @@ static int smode32(CPURISCVState *env, int csrno)static int aia_smode (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -264,9 +258,7 @@ static int aia_smode(CPURISCVState *env, int csrno)static int aia_smode32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -380,9 +372,7 @@ static RISCVException pointer_masking(CPURISCVState *env, int csrno)static int aia_hmode (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -391,9 +381,7 @@ static int aia_hmode(CPURISCVState *env, int csrno)static int aia_hmode32 (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_ssaia) { +if (!riscv_cpu_cfg (env)->ext_ssaia) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -430,9 +418,7 @@ static RISCVException debug(CPURISCVState *env, int csrno)static RISCVException seed (CPURISCVState *env,int csrno) { -RISCVCPU *cpu =env_archcpu (env); - -if (!cpu->cfg.ext_zkr) { +if (!riscv_cpu_cfg (env)->ext_zkr) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -555,7 +541,7 @@ static RISCVException read_vl(CPURISCVState *env, int csrno,static int read_vlenb (CPURISCVState *env,int csrno,target_ulong *val) { - *val =env_archcpu (env)->cfg.vlen >>3 ; + *val =riscv_cpu_cfg (env)->vlen >>3 ;return RISCV_EXCP_NONE ; }@@ -610,7 +596,7 @@ static RISCVException write_vstart(CPURISCVState *env, int csrno,* The vstart CSR is defined to have only enough writable bits * to hold the largest element index, i.e. lg2(VLEN) bits. */ - env->vstart = val & ~(~0ULL <<ctzl (env_archcpu (env)->cfg.vlen)); + env->vstart = val & ~(~0ULL <<ctzl (riscv_cpu_cfg (env)->vlen));return RISCV_EXCP_NONE ; }
Quoted 7 lines · Daniel Henrique Barboza
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.
If you add
Based-on: <message-id>
to the cover letter, then patchew can stitch the two patch sets together in its git repository.
r~
Quoted 18 lines · Daniel Henrique Barboza
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading
RISCVCPUConfig
Quoted 3 lines
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)
r~
Quoted 18 lines · Daniel Henrique Barboza
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading
RISCVCPUConfig
Quoted 3 lines
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)
As I suggested in another patch, cpu_get_cfg() can also be used in vector_helper.c.
Regards,
Weiwei Li
Quoted 20 lines · liweiwei
Quoted 18 lines · Daniel Henrique Barboza
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading RISCVCPUConfig
Quoted 4 lines
Quoted 3 lines
target/riscv/csr.c| 90 +++++++++++++---------------------------------1 file changed, 24 insertions(+), 66 deletions(-)As I suggested in another patch,
cpu_get_cfg()can also be used invector_helper.c.
I decided to do it in a separated series together with the vector_helper.c change I did last week:
https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg07566.html
The vector_change I did prior eliminated some of the env_archcpu() we want to avoid so makes sense to one after the other.
Thanks,
Daniel
Quoted 6 lines
Regards,
Weiwei Li
Quoted 18 lines · On Fri, 24 Feb 2023 09:45:16 PST (-0800), [email protected] wrote:
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading
RISCVCPUConfig
Quoted 2 lines
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)
I just based these on that patch, which landed as d4ea711704 ("target/riscv: introduce riscv_cpu_cfg()"). That resulted in a handful of merge conflicts, but everything looked pretty mechanical. So it's queued up.
Thanks!
Hi Palmer,
Quoted 20 lines · Palmer Dabbelt
Quoted 18 lines · On Fri, 24 Feb 2023 09:45:16 PST (-0800), [email protected] wrote:
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading
RISCVCPUConfig
Quoted 8 lines
Quoted 2 lines
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)I just based these on that patch, which landed as
d4ea711704("target/riscv: introduceriscv_cpu_cfg()"). That resulted in a handful of merge conflicts, but everything looked pretty mechanical. So it's queued up.
As Weiwei pointed out in
https://lore.kernel.org/qemu-devel/[email protected]/,
patch#1 should be dropped.
But I see it was landed up in your tree @
https://github.com/palmer-dabbelt/qemu/commit/3c7d54f945f1b5b474ea35c0815a1618927c9384,
while my changes are already in tree @
https://github.com/palmer-dabbelt/qemu/commit/94e297071bc0a5965cc32c497a886f2cf9d32710.
Not sure why git doesn't figure that out ...
Regards,
Bin
Quoted 32 lines · Bin Meng
Hi Palmer,
Quoted 20 lines · Palmer Dabbelt
Quoted 18 lines · On Fri, 24 Feb 2023 09:45:16 PST (-0800), [email protected] wrote:
Hi,
These cleanups were suggested by LIU Zhiwei during the review of the RISCV_FEATURE_* cleanups, currently on version 7 [1].
These are dependent on the patch "[PATCH v7 01/10] target/riscv: introduce
riscv_cpu_cfg()" from [1] because we use theriscv_cpu_cfg()API.[1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg06467.html
Daniel Henrique Barboza (4):
target/riscv/csr.c: useenv_archcpu()inctr()target/riscv/csr.c: simplifymctr()
target/riscv/csr.c: useriscv_cpu_cfg()to avoidenv_cpu()pointerstarget/riscv/csr.c: avoidenv_archcpu()usages when reading
RISCVCPUConfigQuoted 8 lines
Quoted 2 lines
target/riscv/csr.c | 90 +++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)I just based these on that patch, which landed as
d4ea711704("target/riscv: introduceriscv_cpu_cfg()"). That resulted in a handful of merge conflicts, but everything looked pretty mechanical. So it's queued up.
Quoted 3 lines
As Weiwei pointed out in
https://lore.kernel.org/qemu-devel/[email protected]/,
patch#1 should be dropped.
Yeah, that's my bad. I should've send a v2 owithout patch 1 to avoid confusion.
Daniel
Quoted 10 lines
But I see it was landed up in your tree @
https://github.com/palmer-dabbelt/qemu/commit/3c7d54f945f1b5b474ea35c0815a1618927c9384,
while my changes are already in tree @
https://github.com/palmer-dabbelt/qemu/commit/94e297071bc0a5965cc32c497a886f2cf9d32710.Not sure why git doesn't figure that out ...
Regards,
Bin