target/riscv: Fix mstatus related problems
cover target/riscv: Fix mstatus related problems
This patchset tries to fix some problems in the fields of mstatus, such as make MPV only work when MPP != PRM.
The port is available here:
https://github.com/plctlab/plct-qemu/tree/plct-mpv-upstream
Weiwei Li (4):
target/riscv: Make MPV only work when MPP != PRV_M target/riscv: Remove check on mode for MPRV target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled target/riscv: Remove redundant assignment to SXL
target/riscv/cpu_helper.c | 5 +++-- target/riscv/csr.c | 14 ++++---------- target/riscv/op_helper.c | 3 ++- 3 files changed, 9 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/4 target/riscv: Make MPV only work when MPP != PRV_M
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
--- target/riscv/cpu_helper.c | 3 ++- target/riscv/op_helper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
target/riscv/cpu_helper.c +2 -1
@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); - virt =get_field (env->mstatus,MSTATUS_MPV ); + virt =get_field (env->mstatus,MSTATUS_MPV ) && + (mode !=PRV_M );if (virt) { status = env->vsstatus; }
target/riscv/op_helper.c +2 -1
@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env)riscv_raise_exception (env,RISCV_EXCP_INST_ACCESS_FAULT ,GETPC ()); } -target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ); +target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ) && + (prev_priv !=PRV_M ); mstatus =set_field (mstatus,MSTATUS_MIE ,get_field (mstatus,MSTATUS_MPIE )); mstatus =set_field (mstatus,MSTATUS_MPIE ,1 );
Signature · 1 line
2.25.1
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
Quoted 15 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 3 ++- target/riscv/op_helper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +0
-0
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 50
Quoted 6 lines
target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); - virt =get_field (env->mstatus,MSTATUS_MPV ); + virt =get_field (env->mstatus,MSTATUS_MPV ) && + (mode !=PRV_M );
This change makes more sense in patch 2 where you also removed the 'mode' check for MPRV. As it is now I read the code above and thought "but mode is guaranteed to be == PRV_M, so (mode != PRV_M) is guaranteed to be false every time".
The change in helper_mret() below is fine.
Thanks,
Daniel
Quoted 17 lines
target/riscv/cpu_helper.c +0
-0if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-1@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env)riscv_raise_exception (env,RISCV_EXCP_INST_ACCESS_FAULT ,GETPC ()); } -target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ); +target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ) && + (prev_priv !=PRV_M ); mstatus =set_field (mstatus,MSTATUS_MIE ,get_field (mstatus,MSTATUS_MPIE )); mstatus =set_field (mstatus,MSTATUS_MPIE ,1 );
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
Quoted 13 lines · Daniel Henrique Barboza
Quoted 10 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/cpu_helper.c| 3 ++-
target/riscv/op_helper.c | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 16 lines
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool · line 50
Quoted 11 lines
target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) if (mode == PRV_M && get_field(status, MSTATUS_MPRV)) { mode = get_field(env->mstatus, MSTATUS_MPP); - virt = get_field(env->mstatus, MSTATUS_MPV); + virt = get_field(env->mstatus, MSTATUS_MPV) && + (mode != PRV_M);This change makes more sense in patch 2 where you also removed the 'mode' check for MPRV. As it is now I read the code above and thought "but mode is guaranteed to be ==
PRV_M, so (mode !=PRV_M) is guaranteed to be false every time".
No, this 'mode' (get from MPP) is not the previous 'mode'(the current privilege mode).
Regards,
Weiwei Li
Quoted 23 lines
The change in
helper_mret()below is fine.Thanks,
Daniel
Quoted 16 lines
target/riscv/cpu_helper.c +0
-0if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-0@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env) riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } - target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV); + target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV) && + (prev_priv != PRV_M); mstatus = set_field(mstatus, MSTATUS_MIE, get_field(mstatus, MSTATUS_MPIE)); mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
Quoted 31 lines · Weiwei Li
Quoted 13 lines · Daniel Henrique Barboza
Quoted 10 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/cpu_helper.c| 3 ++-
target/riscv/op_helper.c | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)Quoted 15 lines
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 49
Quoted 10 lines
target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) if (mode == PRV_M && get_field(status, MSTATUS_MPRV)) { mode = get_field(env->mstatus, MSTATUS_MPP); - virt = get_field(env->mstatus, MSTATUS_MPV); + virt = get_field(env->mstatus, MSTATUS_MPV) && + (mode != PRV_M);This change makes more sense in patch 2 where you also removed the 'mode' check for MPRV. As it is now I read the code above and thought "but mode is guaranteed to be ==
PRV_M, so (mode !=PRV_M) is guaranteed to be false every time".
Quoted 1 line
No, this 'mode' (get from MPP) is not the previous 'mode'(the current privilege mode).
Oh, right:
Quoted 2 lines
Quoted 2 lines
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 48
Quoted 2 lines
target/riscv/cpu_helper.c +0
-0if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP );
'mode' is being reassigned here.
Quoted 29 lines
Regards,
Weiwei Li
Quoted 23 lines
The change in
helper_mret()below is fine.Thanks,
Daniel
Quoted 16 lines
target/riscv/cpu_helper.c +0
-0if (virt) { status = env->vsstatus;}
target/riscv/op_helper.c +2
-0@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env) riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } - target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV); + target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV) && + (prev_priv != PRV_M); mstatus = set_field(mstatus, MSTATUS_MIE, get_field(mstatus, MSTATUS_MPIE)); mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
In reply to Weiwei LiQuoted 6 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
Quoted 32 lines
target/riscv/cpu_helper.c | 3 ++- target/riscv/op_helper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); - virt =get_field (env->mstatus,MSTATUS_MPV ); + virt =get_field (env->mstatus,MSTATUS_MPV ) && + (mode !=PRV_M );if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-1@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env)riscv_raise_exception (env,RISCV_EXCP_INST_ACCESS_FAULT ,GETPC ()); } -target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ); +target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ) && + (prev_priv !=PRV_M ); mstatus =set_field (mstatus,MSTATUS_MIE ,get_field (mstatus,MSTATUS_MPIE )); mstatus =set_field (mstatus,MSTATUS_MPIE ,1 );
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
In reply to Weiwei LiQuoted 6 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>
Alistair
Quoted 37 lines
--- target/riscv/cpu_helper.c | 3 ++- target/riscv/op_helper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); - virt =get_field (env->mstatus,MSTATUS_MPV ); + virt =get_field (env->mstatus,MSTATUS_MPV ) && + (mode !=PRV_M );if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-2@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env)riscv_raise_exception (env,RISCV_EXCP_INST_ACCESS_FAULT ,GETPC ()); } -target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ); +target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ) && + (prev_priv !=PRV_M ); mstatus =set_field (mstatus,MSTATUS_MIE ,get_field (mstatus,MSTATUS_MPIE )); mstatus =set_field (mstatus,MSTATUS_MPIE ,1 ); --2.25.1
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
In reply to Weiwei LiQuoted 2 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Does MPP==PRV_M always indicate the MPV==0?
Zhiwei
Quoted 36 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 3 ++- target/riscv/op_helper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); - virt =get_field (env->mstatus,MSTATUS_MPV ); + virt =get_field (env->mstatus,MSTATUS_MPV ) && + (mode !=PRV_M );if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-1@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env)riscv_raise_exception (env,RISCV_EXCP_INST_ACCESS_FAULT ,GETPC ()); } -target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ); +target_ulong prev_virt =get_field (env->mstatus,MSTATUS_MPV ) && + (prev_priv !=PRV_M ); mstatus =set_field (mstatus,MSTATUS_MIE ,get_field (mstatus,MSTATUS_MPIE )); mstatus =set_field (mstatus,MSTATUS_MPIE ,1 );
Re: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
Quoted 5 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Does MPP==PRV_M always indicate the MPV==0?
No, I think . The spec doesn't restrict this. When MPP=PRV_M, MPV wll be 0 in normal case.
But users can set MPV=1 by write to mstatus CSR directly.
As described in spec, "When an MRET instruction is executed, the virtualization mode V is set to MPV, unless
MPP=3, in which case V remains 0."
MPV is just ignored if MPP = 3. This also can be seen in "table 9.5 Effect of MPRV on the translation and protection of explicit memory accesses".
Regards,
Weiwei Li
Quoted 38 lines
Zhiwei
Quoted 35 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/cpu_helper.c| 3 ++-
target/riscv/op_helper.c | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) if (mode == PRV_M && get_field(status, MSTATUS_MPRV)) { mode = get_field(env->mstatus, MSTATUS_MPP); - virt = get_field(env->mstatus, MSTATUS_MPV); + virt = get_field(env->mstatus, MSTATUS_MPV) && + (mode != PRV_M); if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-0@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env) riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } - target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV); + target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV) && + (prev_priv != PRV_M); mstatus = set_field(mstatus, MSTATUS_MIE, get_field(mstatus, MSTATUS_MPIE)); mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
LIU Zhiwei
Reviewed-byRe: [PATCH 1/4] target/riscv: Make MPV only work when MPP != PRV_M
Quoted 11 lines · Weiwei Li
Quoted 5 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
Upon MRET or explicit memory access with MPRV=1, MPV should be ignored when MPP=PRV_M.
Does MPP==PRV_M always indicate the MPV==0?
No, I think . The spec doesn't restrict this. When MPP=PRV_M, MPV wll be 0 in normal case.
But users can set MPV=1 by write to mstatus CSR directly.
Make sense. The fields specification(WARL and others) of mstatus and other CSR always not clear on the specification. Maybe I missed something. But I think this field could be written by the mode software.
Zhiwei
Quoted 49 lines
As described in spec, "When an MRET instruction is executed, the virtualization mode V is set to MPV, unless
MPP=3, in which case V remains 0."
MPV is just ignored if MPP = 3. This also can be seen in "table 9.5 Effect of MPRV on the translation and protection of explicit memory accesses".
Regards,
Weiwei Li
Quoted 38 lines
Zhiwei
Quoted 35 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/cpu_helper.c| 3 ++-
target/riscv/op_helper.c | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)target/riscv/cpu_helper.c +2
-1@@ -46,7 +46,8 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) if (mode == PRV_M && get_field(status, MSTATUS_MPRV)) { mode = get_field(env->mstatus, MSTATUS_MPP); - virt = get_field(env->mstatus, MSTATUS_MPV); + virt = get_field(env->mstatus, MSTATUS_MPV) && + (mode != PRV_M); if (virt) { status = env->vsstatus; }target/riscv/op_helper.c +2
-0@@ -335,7 +335,8 @@ target_ulong helper_mret(CPURISCVState *env) riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } - target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV); + target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV) && + (prev_priv != PRV_M); mstatus = set_field(mstatus, MSTATUS_MIE, get_field(mstatus, MSTATUS_MPIE)); mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
PATCH 2/4 target/riscv: Remove check on mode for MPRV
In reply to Weiwei LiNormally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu_helper.c +1 -1
@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus; -if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M );
Signature · 1 line
2.25.1
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 14 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +0
-0
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 47
Quoted 5 lines
target/riscv/cpu_helper.c +1
-1@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus; -if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) {
As I mentioned in patch 1 this is a good place to put this change:
- virt = get_field(env->mstatus, MSTATUS_MPV);
+ virt = get_field(env->mstatus, MSTATUS_MPV) &&
+ (mode != PRV_M);
if (virt) {
status = env->vsstatus;Thanks,
Daniel
Quoted 3 lines
target/riscv/cpu_helper.c +0
-0mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M );
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
In reply to Weiwei LiQuoted 6 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
Quoted 16 lines
target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +1
-1@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus; -if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) { mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M );
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
In reply to Weiwei LiQuoted 15 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +0
-0
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 47
Quoted 5 lines
target/riscv/cpu_helper.c +1
-1@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus; -if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) {
The original check is correct though, why remove it?
Alistair
Quoted 7 lines
target/riscv/cpu_helper.c +0
-1mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M ); --2.25.1
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 18 lines · Alistair Francis
Quoted 17 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +0
-0@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus;
Quoted 3 lines
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 47
Quoted 2 lines
target/riscv/cpu_helper.c +1
-1-if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) {The original check is correct though, why remove it?
Yeah. As described in the commit message, I think MPRV can only be set to 1 in M mode normally
which means check on MPRV is enough in this case. So I remove the check on mode here.
Regards,
Weiwei Li
Quoted 10 lines
Alistair
Quoted 7 lines
target/riscv/cpu_helper.c +0
-1mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M ); --2.25.1
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 21 lines · Weiwei Li
Quoted 18 lines · Alistair Francis
Quoted 17 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +0
-0@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus;
Quoted 6 lines
Quoted 3 lines
target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 47
Quoted 2 lines
target/riscv/cpu_helper.c +1
-1-if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) {The original check is correct though, why remove it?
Yeah. As described in the commit message, I think MPRV can only be set to 1 in M mode normally
That's true. I do feel that keeping the check makes the code easier to follow. Otherwise future developers need to check to see how MPRV can be set. The current code is explicit and obviously follows the spec.
For a performance gain I think it's worth making the trade off, but it doesn't sound like we really get any gain here.
Alistair
Quoted 19 lines
which means check on MPRV is enough in this case. So I remove the check on mode here.
Regards,
Weiwei Li
Quoted 10 lines
Alistair
Quoted 7 lines
target/riscv/cpu_helper.c +0
-1mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M ); --2.25.1
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 24 lines · Alistair Francis
Quoted 23 lines · Weiwei Li
Quoted 21 lines · Alistair Francis
Quoted 14 lines · Weiwei Li
Normally, MPRV can be set to 1 only in M mode (It will be cleared when returning to lower-privilege mode by MRET/SRET).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/cpu_helper.c +0
-0target/riscv/cpu_helper.c int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) · line 47
Quoted 5 lines
target/riscv/cpu_helper.c +1
-1@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)if (!ifetch) {uint64_t status = env->mstatus; -if (mode ==PRV_M &&get_field (status,MSTATUS_MPRV )) { +if (get_field (status,MSTATUS_MPRV )) {The original check is correct though, why remove it?
Quoted 8 lines
Quoted 2 lines
Yeah. As described in the commit message, I think MPRV can only be set to 1 in M mode normally
That's true. I do feel that keeping the check makes the code easier to follow. Otherwise future developers need to check to see how MPRV can be set. The current code is explicit and obviously follows the spec.
For a performance gain I think it's worth making the trade off, but it doesn't sound like we really get any gain here.
Yeah. It's acceptable to me.
Just another question: whether MPRV is truly limited to work on M mode?
I can only find following description in the note:
"The MPRV and MXR mechanisms *were* conceived to improve the efficiency of M-mode routines that emulate missing hardware features, e.g., misaligned loads and stores."
To some degree, It seems not limit them to work on other mode.
Even though MPRV normally can be set to 1 in M mode, it seems possible to set it to 1 in other mode by gdbstub.
Regards,
Weiwei Li
Quoted 18 lines
Alistair
Quoted 16 lines
which means check on MPRV is enough in this case. So I remove the check on mode here.
Regards,
Weiwei Li
Quoted 9 lines
Alistair
Quoted 7 lines
target/riscv/cpu_helper.c +0
-1mode =get_field (env->mstatus,MSTATUS_MPP ); virt =get_field (env->mstatus,MSTATUS_MPV ) && (mode !=PRV_M ); --2.25.1
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 1 line · Weiwei Li
Even though MPRV normally can be set to 1 in M mode, it seems possible to set it to 1 in other mode by gdbstub.
That would seem to be a gdbstub bug, since it is cleared on exit from M-mode, and cannot be set again until we re-enter M-mode.
r~
Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Quoted 4 lines · Richard Henderson
Quoted 1 line · Weiwei Li
Even though MPRV normally can be set to 1 in M mode, it seems possible to set it to 1 in other mode by gdbstub.
That would seem to be a gdbstub bug, since it is cleared on exit from M-mode, and cannot be set again until we re-enter M-mode.
Yeah, MPRV normally can be set only in M mode. However, gdbstub can bypass the check on privilege mode for CSRs access inriscv_csrrw_check.
Regards,
Weiwei Li
Quoted 3 lines
r~
PATCH 3/4 target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
In reply to Weiwei LiMPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
--- target/riscv/csr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
target/riscv/csr.c +4 -6
@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, }if (xl !=MXL_RV32 || env->debugger) { -/* -* RV32: MPV and GVA are not in mstatus. The current plan is to -* add them to mstatush. For now, we just don't support it. -*/ - mask |=MSTATUS_MPV |MSTATUS_GVA ; +if (riscv_has_ext (env,RVH )) { + mask |=MSTATUS_MPV |MSTATUS_GVA ; + }if ((val &MSTATUS64_UXL ) !=0 ) { mask |=MSTATUS64_UXL ; }
@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) {uint64_t valh = (uint64_t )val <<32 ; -uint64_t mask =MSTATUS_MPV |MSTATUS_GVA ; +uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Signature · 1 line
2.25.1
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 6 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
Quoted 31 lines
target/riscv/csr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +4
-6@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, }if (xl !=MXL_RV32 || env->debugger) { -/* -* RV32: MPV and GVA are not in mstatus. The current plan is to -* add them to mstatush. For now, we just don't support it. -*/ - mask |=MSTATUS_MPV |MSTATUS_GVA ; +if (riscv_has_ext (env,RVH )) { + mask |=MSTATUS_MPV |MSTATUS_GVA ; + }if ((val &MSTATUS64_UXL ) !=0 ) { mask |=MSTATUS64_UXL ; }@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) {uint64_t valh = (uint64_t )val <<32 ; -uint64_t mask =MSTATUS_MPV |MSTATUS_GVA ; +uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
In reply to Weiwei LiQuoted 6 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>
Alistair
Quoted 36 lines
--- target/riscv/csr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +4
-7@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, }if (xl !=MXL_RV32 || env->debugger) { -/* -* RV32: MPV and GVA are not in mstatus. The current plan is to -* add them to mstatush. For now, we just don't support it. -*/ - mask |=MSTATUS_MPV |MSTATUS_GVA ; +if (riscv_has_ext (env,RVH )) { + mask |=MSTATUS_MPV |MSTATUS_GVA ; + }if ((val &MSTATUS64_UXL ) !=0 ) { mask |=MSTATUS64_UXL ; }@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) {uint64_t valh = (uint64_t )val <<32 ; -uint64_t mask =MSTATUS_MPV |MSTATUS_GVA ; +uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask); --2.25.1
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
In reply to Weiwei LiQuoted 2 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Have you found the CSR field specifications for them, especially for GVA.
Zhiwei
Quoted 35 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/csr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +4
-6@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, }if (xl !=MXL_RV32 || env->debugger) { -/* -* RV32: MPV and GVA are not in mstatus. The current plan is to -* add them to mstatush. For now, we just don't support it. -*/ - mask |=MSTATUS_MPV |MSTATUS_GVA ; +if (riscv_has_ext (env,RVH )) { + mask |=MSTATUS_MPV |MSTATUS_GVA ; + }if ((val &MSTATUS64_UXL ) !=0 ) { mask |=MSTATUS64_UXL ; }@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) {uint64_t valh = (uint64_t )val <<32 ; -uint64_t mask =MSTATUS_MPV |MSTATUS_GVA ; +uint64_t mask =riscv_has_ext (env,RVH ) ?MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 6 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Have you found the CSR field specifications for them, especially for GVA.
Yeah. in the section 9.4.1 of the privilege spec:
"/The hypervisor extension adds two fields, MPV and GVA, to the machine-level mstatus or mstatush CSR/".
Regards,
Weiwei Li
Quoted 38 lines
Zhiwei
Quoted 35 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/csr.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +4
-6@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - /* - * RV32: MPV and GVA are not in mstatus. The current plan is to - * add them to mstatush. For now, we just don't support it. - */ - mask |= MSTATUS_MPV | MSTATUS_GVA; + if (riscv_has_ext(env, RVH)) { + mask |= MSTATUS_MPV | MSTATUS_GVA; + } if ((val & MSTATUS64_UXL) != 0) { mask |= MSTATUS64_UXL; }@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 4 lines · Weiwei Li
Quoted 2 lines · LIU Zhiwei
On 2023/5/29 20:17, Weiwei Li wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Have you found the CSR field specifications for them, especially for GVA.
Yeah. in the section 9.4.1 of the privilege spec:
"/The hypervisor extension adds two fields, MPV and GVA, to the machine-level mstatus or mstatush CSR/".
I mean the WARL or other CSR field specifications here.
Zhiwei
Quoted 44 lines
Regards,
Weiwei Li
Quoted 39 lines
Zhiwei
Quoted 36 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/csr.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +0
-2@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - /* - * RV32: MPV and GVA are not in mstatus. The current planis to
- * add them to mstatush. For now, we just don't support it. - */
- mask |=MSTATUS_MPV|MSTATUS_GVA;
+ if (riscv_has_ext(env, RVH)) {
+ mask |=MSTATUS_MPV|MSTATUS_GVA;
+ }
if ((val &MSTATUS64_UXL) != 0) {
mask |=MSTATUS64_UXL;
}target/riscv/csr.c +1
-1@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 9 lines · LIU Zhiwei
Quoted 7 lines · Weiwei Li
Quoted 5 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Have you found the CSR field specifications for them, especially for GVA.
Yeah. in the section 9.4.1 of the privilege spec:
"/The hypervisor extension adds two fields, MPV and GVA, to the machine-level mstatus or mstatush CSR/".
I mean the WARL or other CSR field specifications here.
I don't quite get your idea. The only specification for MPV and GVA I found is in section 9.4.1. The spec for most of mstatus fields can be found in Section 3.1.6 "Machine Status Registers (mstatus and mstatush)".
Regards,
Weiwei Li
Quoted 47 lines
Zhiwei
Quoted 44 lines
Regards,
Weiwei Li
Quoted 39 lines
Zhiwei
Quoted 36 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/csr.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +0
-2@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - /* - * RV32: MPV and GVA are not in mstatus. The current planis to
- * add them to mstatush. For now, we just don't support it. - */
- mask |=MSTATUS_MPV|MSTATUS_GVA;
+ if (riscv_has_ext(env, RVH)) {
+ mask |=MSTATUS_MPV|MSTATUS_GVA;
+ }
if ((val &MSTATUS64_UXL) != 0) {
mask |=MSTATUS64_UXL;
}target/riscv/csr.c +1
-1@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 13 lines · Weiwei Li
Quoted 11 lines · LIU Zhiwei
Quoted 9 lines · Weiwei Li
Quoted 6 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Have you found the CSR field specifications for them, especially for GVA.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Yeah. in the section 9.4.1 of the privilege spec:
"/The hypervisor extension adds two fields, MPV and GVA, to the machine-level mstatus or mstatush CSR/".
I mean the WARL or other CSR field specifications here.
I don't quite get your idea. The only specification for MPV and GVA I found is in section 9.4.1. The spec for most of mstatus fields can be found in Section 3.1.6 "Machine Status Registers (mstatus and mstatush)".
I mean is the GVA field read only or WARL(WPRI or WLRL) for the software? It could be written by the implementation. But I am not sure whether it could be written by the software.
Zhiwei
Quoted 52 lines
Regards,
Weiwei Li
Quoted 47 lines
Zhiwei
Quoted 44 lines
Regards,
Weiwei Li
Quoted 39 lines
Zhiwei
Quoted 36 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/csr.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +0
-2@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - /* - * RV32: MPV and GVA are not in mstatus. The current planis to
- * add them to mstatush. For now, we just don't support it. - */
- mask |=MSTATUS_MPV|MSTATUS_GVA;
+ if (riscv_has_ext(env, RVH)) {
+ mask |=MSTATUS_MPV|MSTATUS_GVA;
+ }
if ((val &MSTATUS64_UXL) != 0) {
mask |=MSTATUS64_UXL;
}target/riscv/csr.c +1
-1@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
Re: [PATCH 3/4] target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled
Quoted 17 lines · LIU Zhiwei
Quoted 15 lines · Weiwei Li
Quoted 13 lines · LIU Zhiwei
Quoted 11 lines · Weiwei Li
Quoted 6 lines · LIU Zhiwei
Quoted 2 lines · Weiwei Li
MPV and GVA bits are added by hypervisor extension to mstatus and mstatush (if MXLEN=32).
Have you found the CSR field specifications for them, especially for GVA.
Yeah. in the section 9.4.1 of the privilege spec:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
"/The hypervisor extension adds two fields, MPV and GVA, to the machine-level mstatus or mstatush CSR/".
I mean the WARL or other CSR field specifications here.
I don't quite get your idea. The only specification for MPV and GVA I found is in section 9.4.1. The spec for most of mstatus fields can be found in Section 3.1.6 "Machine Status Registers (mstatus and mstatush)".
I mean is the GVA field read only or WARL(WPRI or WLRL) for the software? It could be written by the implementation. But I am not sure whether it could be written by the software.
No, I didn't find any description about this.
Regards,
Weiwei Li
Quoted 55 lines
Zhiwei
Quoted 52 lines
Regards,
Weiwei Li
Quoted 47 lines
Zhiwei
Quoted 44 lines
Regards,
Weiwei Li
Quoted 39 lines
Zhiwei
Quoted 36 lines
Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
target/riscv/csr.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)target/riscv/csr.c +0
-2@@ -1311,11 +1311,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - /* - * RV32: MPV and GVA are not in mstatus. The currentplan is to
- * add them to mstatush. For now, we just don't support it. - */
- mask |=MSTATUS_MPV|MSTATUS_GVA;
+ if (riscv_has_ext(env, RVH)) {
+ mask |=MSTATUS_MPV|MSTATUS_GVA;
+ }
if ((val &MSTATUS64_UXL) != 0) {
mask |=MSTATUS64_UXL;
}target/riscv/csr.c +1
-1@@ -1351,7 +1349,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV |MSTATUS_GVA :0 ; env->mstatus = (env->mstatus & ~mask) | (valh & mask);
PATCH 4/4 target/riscv: Remove redundant assignment to SXL
In reply to Weiwei LiSXL is initialized as env->misa_mxl which is also the mxl value. So we can just remain it unchanged to keep it read-only.
--- target/riscv/csr.c | 4 ---- 1 file changed, 4 deletions(-)
target/riscv/csr.c +0 -4
@@ -1321,10 +1321,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = (mstatus & ~mask) | (val & mask); -if (xl >MXL_RV32 ) { -/* SXL field is for now read only */ - mstatus =set_field (mstatus,MSTATUS64_SXL , xl); - } env->mstatus = mstatus;/*
Signature · 1 line
2.25.1
Re: [PATCH 4/4] target/riscv: Remove redundant assignment to SXL
Quoted 6 lines · Weiwei Li
SXL is initialized as
env->misa_mxlwhich is also the mxl value. So we can just remain it unchanged to keep it read-only.Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>---
Quoted 18 lines
target/riscv/csr.c | 4 ---- 1 file changed, 4 deletions(-)target/riscv/csr.c +0
-4@@ -1321,10 +1321,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = (mstatus & ~mask) | (val & mask); -if (xl >MXL_RV32 ) { -/* SXL field is for now read only */ - mstatus =set_field (mstatus,MSTATUS64_SXL , xl); - } env->mstatus = mstatus;/*
Re: [PATCH 4/4] target/riscv: Remove redundant assignment to SXL
In reply to Weiwei LiQuoted 6 lines · Weiwei Li
SXL is initialized as
env->misa_mxlwhich is also the mxl value. So we can just remain it unchanged to keep it read-only.Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>
Alistair
Quoted 23 lines
--- target/riscv/csr.c | 4 ---- 1 file changed, 4 deletions(-)target/riscv/csr.c +0
-5@@ -1321,10 +1321,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = (mstatus & ~mask) | (val & mask); -if (xl >MXL_RV32 ) { -/* SXL field is for now read only */ - mstatus =set_field (mstatus,MSTATUS64_SXL , xl); - } env->mstatus = mstatus;/* -- 2.25.1
Re: [PATCH 4/4] target/riscv: Remove redundant assignment to SXL
In reply to Weiwei LiQuoted 14 lines · Weiwei Li
SXL is initialized as
env->misa_mxlwhich is also the mxl value. So we can just remain it unchanged to keep it read-only.Signed-off-by Weiwei Li <[email protected]>Signed-off-by Junqiang Wang <[email protected]>--- target/riscv/csr.c | 4 ---- 1 file changed, 4 deletions(-)target/riscv/csr.c +0
-0
target/riscv/csr.c static RISCVException write_mstatus(CPURISCVState *env, int csrno, · line 1327
Quoted 7 lines
target/riscv/csr.c +0
-4@@ -1321,10 +1321,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = (mstatus & ~mask) | (val & mask); -if (xl >MXL_RV32 ) { -/* SXL field is for now read only */ - mstatus =set_field (mstatus,MSTATUS64_SXL , xl); - }
Zhiwei
Quoted 3 lines
target/riscv/csr.c +0
-0env->mstatus = mstatus;/*