riscv: Modify minimum VLEN rule
v2 cover riscv: Modify minimum VLEN rule
According to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This patchset provides following modifications:
* Replace the checkings of standard V with the checkings of Zve32x
* Introduces a check rule for VLEN and ELEN
* Modifies the minimum VLEN based on the vector extensions
Extension Minimum VLEN
V 128
Zve64[d|f|x] 64 Zve32[f|x] 32
v1: [email protected]
- Rebase to riscv-to-apply.next branch
- Add patch 1 to replace checking RVV by checking Zve32x
Max Chou (2):
target/riscv: rvv: Replace checking V by checking Zve32x target/riscv: rvv: Modify minimum VLEN according to enabled vector
extensions
target/riscv/cpu.c | 2 +- target/riscv/csr.c | 3 ++- target/riscv/machine.c | 3 ++- target/riscv/riscv-qmp-cmds.c | 2 +- target/riscv/tcg/tcg-cpu.c | 21 ++++++++++++++++++--- 5 files changed, 24 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 target/riscv: rvv: Replace checking V by checking Zve32x
The Zve32x extension will be applied by the V and Zve* extensions. Therefore we can replace the original V checking with Zve32x checking for both the V and Zve* extensions.
--- target/riscv/cpu.c | 2 +- target/riscv/csr.c | 3 ++- target/riscv/machine.c | 3 ++- target/riscv/riscv-qmp-cmds.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)
target/riscv/cpu.c +1 -1
@@ -604,7 +604,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) } } } -if (riscv_has_ext (env,RVV ) && (flags &CPU_DUMP_VPU )) { +if (riscv_cpu_cfg (env)->ext_zve32x && (flags &CPU_DUMP_VPU )) {static const int dump_rvv_csrs[] = {CSR_VSTART ,CSR_VXSAT ,
target/riscv/csr.c +2 -1
@@ -2004,7 +2004,8 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,if (riscv_has_ext (env,RVF )) { mask |=MSTATUS_FS ; } -if (riscv_has_ext (env,RVV )) { + +if (riscv_cpu_cfg (env)->ext_zve32x) { mask |=MSTATUS_VS ; }
target/riscv/machine.c +2 -1
@@ -131,7 +131,8 @@ static bool vector_needed(void *opaque)RISCVCPU *cpu = opaque;CPURISCVState *env = &cpu->env; -return riscv_has_ext (env,RVV ); +return kvm_enabled () ?riscv_has_ext (env,RVV ) : +riscv_cpu_cfg (env)->ext_zve32x; }static const VMStateDescription vmstate_vector = {
target/riscv/riscv-qmp-cmds.c +1 -1
@@ -342,7 +342,7 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) }if (reg_is_vreg (name)) { -if (!riscv_has_ext (env,RVV )) { +if (!riscv_cpu_cfg (env)->ext_zve32x) {return -EINVAL ; }
target/riscv/tcg/tcg-cpu.c +1 -1
@@ -660,7 +660,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } -if (riscv_has_ext (env,RVV )) { +if (cpu->cfg.ext_zve32x) {riscv_cpu_validate_v (env, &cpu->cfg, &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);
Signature · 1 line
2.43.0
Re: [PATCH v2 1/2] target/riscv: rvv: Replace checking V by checking Zve32x
Quoted 6 lines · Max Chou
The Zve32x extension will be applied by the V and Zve* extensions. Therefore we can replace the original V checking with Zve32x checking for both the V and Zve* extensions.
Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 79 lines
--- target/riscv/cpu.c | 2 +- target/riscv/csr.c | 3 ++- target/riscv/machine.c | 3 ++- target/riscv/riscv-qmp-cmds.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-)target/riscv/cpu.c +1
-1@@ -604,7 +604,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) } } } -if (riscv_has_ext (env,RVV ) && (flags &CPU_DUMP_VPU )) { +if (riscv_cpu_cfg (env)->ext_zve32x && (flags &CPU_DUMP_VPU )) {static const int dump_rvv_csrs[] = {CSR_VSTART ,CSR_VXSAT ,target/riscv/csr.c +2
-1@@ -2004,7 +2004,8 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,if (riscv_has_ext (env,RVF )) { mask |=MSTATUS_FS ; } -if (riscv_has_ext (env,RVV )) { + +if (riscv_cpu_cfg (env)->ext_zve32x) { mask |=MSTATUS_VS ; }target/riscv/machine.c +2
-1@@ -131,7 +131,8 @@ static bool vector_needed(void *opaque)RISCVCPU *cpu = opaque;CPURISCVState *env = &cpu->env; -return riscv_has_ext (env,RVV ); +return kvm_enabled () ?riscv_has_ext (env,RVV ) : +riscv_cpu_cfg (env)->ext_zve32x; }static const VMStateDescription vmstate_vector = {target/riscv/riscv-qmp-cmds.c +1
-1@@ -342,7 +342,7 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) }if (reg_is_vreg (name)) { -if (!riscv_has_ext (env,RVV )) { +if (!riscv_cpu_cfg (env)->ext_zve32x) {return -EINVAL ; }target/riscv/tcg/tcg-cpu.c +1
-2@@ -660,7 +660,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } -if (riscv_has_ext (env,RVV )) { +if (cpu->cfg.ext_zve32x) {riscv_cpu_validate_v (env, &cpu->cfg, &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err); --2.43.0
PATCH v2 2/2 target/riscv: rvv: Modify minimum VLEN according to enabled vector extensions
In reply to Max ChouAccording to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This commit modifies the minimum VLEN based on the vector extensions and introduces a check rule for VLEN and ELEN.
Extension Minimum VLEN
* V 128
* Zve64[d|f|x] 64 * Zve32[f|x] 32
--- target/riscv/tcg/tcg-cpu.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
target/riscv/tcg/tcg-cpu.c +17 -2
@@ -416,12 +416,21 @@ static void riscv_cpu_validate_misa_priv(CPURISCVState *env, Error **errp)static void riscv_cpu_validate_v (CPURISCVState *env,RISCVCPUConfig *cfg,Error **errp) { +uint32_t min_vlen;uint32_t vlen = cfg->vlenb <<3 ; -if (vlen >RV_VLEN_MAX || vlen <128 ) { +if (riscv_has_ext (env,RVV )) { + min_vlen =128 ; + }else if (cfg->ext_zve64x) { + min_vlen =64 ; + }else if (cfg->ext_zve32x) { + min_vlen =32 ; + } + +if (vlen >RV_VLEN_MAX || vlen < min_vlen) {error_setg (errp,"Vector extension implementation only supports VLEN " -"in the range [128, %d]" ,RV_VLEN_MAX ); +"in the range [%d, %d]" , min_vlen,RV_VLEN_MAX );return ; }
@@ -431,6 +440,12 @@ static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, "in the range [8, 64]");return ; } + +if (vlen < cfg->elen) { +error_setg (errp,"Vector extension implementation requires VLEN " +"to be greater than or equal to ELEN" ); +return ; + } }static void riscv_cpu_disable_priv_spec_isa_exts (RISCVCPU *cpu)
Signature · 1 line
2.43.0
Re: [PATCH v2 2/2] target/riscv: rvv: Modify minimum VLEN according to enabled vector extensions
Quoted 11 lines · Max Chou
According to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This commit modifies the minimum VLEN based on the vector extensions and introduces a check rule for VLEN and ELEN.
Extension Minimum VLEN
* V 128* Zve64[d|f|x] 64 * Zve32[f|x] 32Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 49 lines
--- target/riscv/tcg/tcg-cpu.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)target/riscv/tcg/tcg-cpu.c +17
-3@@ -416,12 +416,21 @@ static void riscv_cpu_validate_misa_priv(CPURISCVState *env, Error **errp)static void riscv_cpu_validate_v (CPURISCVState *env,RISCVCPUConfig *cfg,Error **errp) { +uint32_t min_vlen;uint32_t vlen = cfg->vlenb <<3 ; -if (vlen >RV_VLEN_MAX || vlen <128 ) { +if (riscv_has_ext (env,RVV )) { + min_vlen =128 ; + }else if (cfg->ext_zve64x) { + min_vlen =64 ; + }else if (cfg->ext_zve32x) { + min_vlen =32 ; + } + +if (vlen >RV_VLEN_MAX || vlen < min_vlen) {error_setg (errp,"Vector extension implementation only supports VLEN " -"in the range [128, %d]" ,RV_VLEN_MAX ); +"in the range [%d, %d]" , min_vlen,RV_VLEN_MAX );return ; }@@ -431,6 +440,12 @@ static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, "in the range [8, 64]");return ; } + +if (vlen < cfg->elen) { +error_setg (errp,"Vector extension implementation requires VLEN " +"to be greater than or equal to ELEN" ); +return ; + } }static void riscv_cpu_disable_priv_spec_isa_exts (RISCVCPU *cpu) --2.43.0
Alistair Francis
AppliedQuoted 13 lines · Max Chou
According to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This patchset provides following modifications:
* Replace the checkings of standard V with the checkings of Zve32x
* Introduces a check rule for VLEN and ELEN
* Modifies the minimum VLEN based on the vector extensionsExtension Minimum VLEN
V 128Zve64[d|f|x] 64 Zve32[f|x] 32
Quoted 8 lines
v1: [email protected]
- Rebase to riscv-to-apply.next branch
- Add patch 1 to replace checking RVV by checking Zve32xMax Chou (2):
target/riscv: rvv: Replace checking V by checking Zve32x target/riscv: rvv: Modify minimum VLEN according to enabled vector
extensions
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 12 lines
target/riscv/cpu.c | 2 +- target/riscv/csr.c | 3 ++- target/riscv/machine.c | 3 ++- target/riscv/riscv-qmp-cmds.c | 2 +- target/riscv/tcg/tcg-cpu.c | 21 ++++++++++++++++++--- 5 files changed, 24 insertions(+), 7 deletions(-)--
2.43.0
Quoted 12 lines · Max Chou
According to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This patchset provides following modifications:
* Replace the checkings of standard V with the checkings of Zve32x
* Introduces a check rule for VLEN and ELEN
* Modifies the minimum VLEN based on the vector extensionsExtension Minimum VLEN
V 128Zve64[d|f|x] 64 Zve32[f|x] 32
Quoted 8 lines
v1: [email protected]
- Rebase to riscv-to-apply.next branch
- Add patch 1 to replace checking RVV by checking Zve32xMax Chou (2):
target/riscv: rvv: Replace checking V by checking Zve32x target/riscv: rvv: Modify minimum VLEN according to enabled vector
extensions
Is this a qemu-stable material?
(these changes does not apply directly to 10.1.x, probably the MonitorDef change in the first patch here can be dropped)
Thanks,
/mjt
Quoted 17 lines · Michael Tokarev
Quoted 16 lines · Max Chou
According to the RISC-V unprivileged specification, the VLEN should be greater or equal to the ELEN. This patchset provides following modifications:
* Replace the checkings of standard V with the checkings of Zve32x
* Introduces a check rule for VLEN and ELEN
* Modifies the minimum VLEN based on the vector extensionsExtension Minimum VLEN
V 128
Zve64[d|f|x] 64
Zve32[f|x] 32v1: [email protected]
- Rebase to riscv-to-apply.next branch
- Add patch 1 to replace checking RVV by checking Zve32x
Quoted 8 lines
Quoted 4 lines
Max Chou (2):
target/riscv: rvv: Replace checking V by checking Zve32x target/riscv: rvv: Modify minimum VLEN according to enabled vector extensionsIs this a qemu-stable material?
(these changes does not apply directly to 10.1.x, probably the MonitorDef change in the first patch here can be dropped)
Hi!
I've picked this series for qemu-stable 10.0 and 10.1 series. I still haven't received any reply from y previous email asking about these, so I'm a bit uncomfortable by picking this up for stable. But I'm releasing two stable releases today with these patches in.
Thanks,
/mjt
Hi Michael,
Apologies for the delayed response to your question about qemu-stable. Yes, I believe this patchset is appropriate for qemu-stable material. The changes fix the VLEN minimum value to properly align with the RISC-V specification requirements (VLEN >= ELEN), which could affect the correctness of RISC-V vector extension behavior in QEMU.
Thank you for picking this up for the stable 10.0 and 10.1 releases. This series is based on the riscv-to-apply.next branch (the VERSION file shows 10.1.50).
Thanks,
Max
Quoted 40 lines · Michael Tokarev
Quoted 18 lines · Michael Tokarev
Quoted 17 lines · Max Chou
According to the RISC-V unprivileged specification, the VLEN should be greater
or equal to the ELEN. This patchset provides following modifications:* Replace the checkings of standard V with the checkings of Zve32x
* Introduces a check rule for VLEN and ELEN
* Modifies the minimum VLEN based on the vector extensionsExtension Minimum VLEN
V 128Zve64[d|f|x] 64 Zve32[f|x] 32v1: [email protected]
- Rebase to riscv-to-apply.next branch
- Add patch 1 to replace checking RVV by checking Zve32xQuoted 8 lines
Quoted 4 lines
Max Chou (2):
target/riscv: rvv: Replace checking V by checking Zve32x target/riscv: rvv: Modify minimum VLEN according to enabled vector
extensionsIs this a qemu-stable material?
(these changes does not apply directly to 10.1.x, probably the MonitorDef change in the first patch here can be dropped)Hi!
I've picked this series for qemu-stable 10.0 and 10.1 series. I still haven't received any reply from y previous email asking about these, so I'm a bit uncomfortable by picking this up for stable. But I'm releasing two stable releases today with these patches in.
Thanks,
/mjt