Add vtype.vill FIELD macro definition
v2 cover Add vtype.vill FIELD macro definition
Hi, all:
I improve compatibility with RV32 and RV64 by adjusting the FIELD definition of vtype.vill.
PATCH v1:
https://lore.kernel.org/qemu-devel/[email protected]/T
Chao Liu (1):
target/riscv: add VILL field for vtype register macro definition
target/riscv/cpu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.47.0
PATCH v2 1/1 target/riscv: add VILL field for vtype register macro definition
--- target/riscv/cpu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target/riscv/cpu.h +2 -1
@@ -170,7 +170,8 @@ FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) FIELD(VTYPE, VEDIV, 8, 2) -FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) +FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 12) +FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1) typedef struct PMUCTRState { /* Current value of a counter */
Signature · 1 line
2.47.0
Re: [PATCH v2 1/1] target/riscv: add VILL field for vtype register macro definition
Quoted 10 lines · Chao Liu
Signed-off-by Chao Liu <[email protected]>--- target/riscv/cpu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)target/riscv/cpu.h +0
-0
target/riscv/cpu.h FIELD(VTYPE, VSEW, 3, 3) · line 174
Quoted 6 lines
target/riscv/cpu.h +2
-1@@ -170,7 +170,8 @@ FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) FIELD(VTYPE, VEDIV, 8, 2) -FIELD (VTYPE ,RESERVED ,10 ,sizeof (target_ulong) *8 -11 ) +FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 12) +FIELD (VTYPE ,VILL ,sizeof (target_ulong) *8 -1 ,1 )
Still incorrect, for the same reason.
We support execution of rv32 cpus with qemu-system-riscv64, where sizeof(target_ulong) is always 8. We support SXL/UXL, which changes the behaviour at runtime.
And, really, why do you want to add a define that is never used?
r~
Re: [PATCH v2 1/1] target/riscv: add VILL field for vtype register macro definition
Quoted 20 lines · Richard Henderson
Quoted 10 lines · Chao Liu
Signed-off-by Chao Liu <[email protected]>---
target/riscv/cpu.h| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)target/riscv/cpu.h +0
-0target/riscv/cpu.h FIELD(VTYPE, VSEW, 3, 3) · line 174
Quoted 6 lines
target/riscv/cpu.h +2
-1@@ -170,7 +170,8 @@ FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) FIELD(VTYPE, VEDIV, 8, 2) -FIELD (VTYPE ,RESERVED ,10 ,sizeof (target_ulong) *8 -11 ) +FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 12) +FIELD (VTYPE ,VILL ,sizeof (target_ulong) *8 -1 ,1 )Still incorrect, for the same reason.
Quoted 6 lines
We support execution of rv32 cpus with qemu-system-riscv64, where
sizeof(target_ulong)is always 8. We support SXL/UXL, which changes the behaviour at runtime.And, really, why do you want to add a define that is never used?
r~
Thank you for your reply, I have understood it now.
Initially, by reading the RISC-V architecture manual and the QEMU source code, I noticed that the definition of vtype.vill was missing.
After your explanation, I reviewed the source code again and found that QEMU defines the vill field within the CPURISCVState. According to MXL_RV64 and MXL_RV32, when reading vtype, vill is incorporated into it.
Therefore, there is no need to add this definition, as it is not actually being used.
However, I still have one question:
since the goal is to enable qemu-system-riscv64 to support RV32, it seems somewhat unreasonable to have vtype.RESERVED fixed at "sizeof(target_ulong) * 8 - 12" and let the compiler calculate its bit width. The vtype.RESERVED field is [11:62] under RV64 and [11:30] under RV32.
Currently, it is used in the following context:
//target/riscv/vector_helper.c:34target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, target_ulong s2)
{
...
target_ulong reserved = s2 & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT,
xlen - 1 - R_VTYPE_RESERVED_SHIFT);
...
Regards,
Chao