Add the implied rules for G and B extensions
v3 cover Add the implied rules for G and B extensions
From: Frank Chang <[email protected]>
Add the implied rules for G and B extensions to enable the implied extensions.
Changelog:
v3: Keep riscv_cpu_validate_g() and riscv_cpu_validate_b() but remove
the auto-enables as the implied extensions can be enabled by the implied rules.
v2: Remove riscv_cpu_validate_g() and riscv_cpu_validate_b() as the
implied extensions can be enabled by the implied rules.
Frank Chang (1):
target/riscv: Add standard B extension implied rule
Jim Shu (1):
target/riscv: Add the implied rule for G extension
target/riscv/cpu.c | 26 ++++++++++++++++++++++++- target/riscv/tcg/tcg-cpu.c | 39 +++++++------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-)
--
2.43.0
PATCH v3 1/2 target/riscv: Add the implied rule for G extension
From: Jim Shu <[email protected]>
Add the missing implied rule from G to imafd_zicsr_zifencei. We can also remove the auto-enables in riscv_cpu_validate_g() as IMAFD, Zicsr, Zifencei extensions can be enabled by the implied rule.
--- target/riscv/cpu.c | 14 +++++++++++++- target/riscv/tcg/tcg-cpu.c | 21 ++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-)
target/riscv/cpu.c +13 -1
@@ -2248,6 +2248,18 @@ static RISCVCPUImpliedExtsRule RVV_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule RVG_IMPLIED = { + .is_misa = true, + .ext =RVG , + .implied_misa_exts =RVI |RVM |RVA |RVF |RVD , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zicsr), +CPU_CFG_OFFSET (ext_zifencei), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zcb), .implied_multi_exts = {
@@ -2635,7 +2647,7 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , - &RVM_IMPLIED , &RVV_IMPLIED ,NULL + &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED ,NULL };RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
target/riscv/tcg/tcg-cpu.c +4 -17
@@ -545,30 +545,17 @@ static void riscv_cpu_validate_g(RISCVCPU *cpu)continue ; } -if (!cpu_misa_ext_is_user_set (bit)) { -riscv_cpu_write_misa_bit (cpu, bit, true); -continue ; - } -if (send_warn) {warn_report (warn_msg,riscv_get_misa_ext_name (bit)); } } -if (!cpu->cfg.ext_zicsr) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zicsr))) { - cpu->cfg.ext_zicsr = true; - }else if (send_warn) { -warn_report (warn_msg,"zicsr" ); - } +if (!cpu->cfg.ext_zicsr && send_warn) { +warn_report (warn_msg,"zicsr" ); } -if (!cpu->cfg.ext_zifencei) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zifencei))) { - cpu->cfg.ext_zifencei = true; - }else if (send_warn) { -warn_report (warn_msg,"zifencei" ); - } +if (!cpu->cfg.ext_zifencei && send_warn) { +warn_report (warn_msg,"zifencei" ); } }
Signature · 1 line
2.43.0
PATCH v3 2/2 target/riscv: Add standard B extension implied rule
In reply to [email protected]From: Frank Chang <[email protected]>
Add the missing implied rule for standard B extension. Standard B extension implies Zba, Zbb, Zbs extensions. We can also remove the auto-enables in riscv_cpu_validate_b() as Zba, Zbb, Zbs extensions can be enabled by the implied rule.
RISC-V B spec: https://github.com/riscv/riscv-b
--- target/riscv/cpu.c | 14 +++++++++++++- target/riscv/tcg/tcg-cpu.c | 18 +++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
target/riscv/cpu.c +13 -1
@@ -2260,6 +2260,17 @@ static RISCVCPUImpliedExtsRule RVG_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule RVB_IMPLIED = { + .is_misa = true, + .ext =RVB , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zba),CPU_CFG_OFFSET (ext_zbb), +CPU_CFG_OFFSET (ext_zbs), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zcb), .implied_multi_exts = {
@@ -2647,7 +2658,8 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , - &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED ,NULL + &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED , + &RVB_IMPLIED ,NULL };RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
target/riscv/tcg/tcg-cpu.c +3 -15
@@ -564,27 +564,15 @@ static void riscv_cpu_validate_b(RISCVCPU *cpu)const char *warn_msg ="RVB mandates disabled extension %s" ;if (!cpu->cfg.ext_zba) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zba))) { - cpu->cfg.ext_zba = true; - }else { -warn_report (warn_msg,"zba" ); - } +warn_report (warn_msg,"zba" ); }if (!cpu->cfg.ext_zbb) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zbb))) { - cpu->cfg.ext_zbb = true; - }else { -warn_report (warn_msg,"zbb" ); - } +warn_report (warn_msg,"zbb" ); }if (!cpu->cfg.ext_zbs) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zbs))) { - cpu->cfg.ext_zbs = true; - }else { -warn_report (warn_msg,"zbs" ); - } +warn_report (warn_msg,"zbs" ); } }
Signature · 1 line
2.43.0
Quoted 11 lines · On Fri, 24 Apr 2026 at 05:30, <[email protected]> wrote:
From: Frank Chang <[email protected]>
Add the implied rules for G and B extensions to enable the implied extensions.
Changelog:
v3: Keepriscv_cpu_validate_g()andriscv_cpu_validate_b()but remove
the auto-enables as the implied extensions can be enabled by the implied rules.
Quoted 8 lines
v2: Remove
riscv_cpu_validate_g()andriscv_cpu_validate_b()as the
implied extensions can be enabled by the implied rules.Frank Chang (1):
target/riscv: Add standard B extension implied ruleJim Shu (1):
target/riscv: Add the implied rule for G extension
Reminder to riscv folks -- please put "target/riscv" or similar in the subject of your cover letter, so that people who aren't interested in riscv patches can skip over it rather than wondering which of the many possible areas of QEMU "G and B extensions" might be talking about...
thanks
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 11 lines · On Fri, 24 Apr 2026 at 05:30, <[email protected]> wrote:
From: Frank Chang <[email protected]>
Add the implied rules for G and B extensions to enable the implied extensions.
Changelog:
v3: Keepriscv_cpu_validate_g()andriscv_cpu_validate_b()but remove
the auto-enables as the implied extensions can be enabled by the implied rules.Quoted 8 lines
v2: Remove
riscv_cpu_validate_g()andriscv_cpu_validate_b()as the
implied extensions can be enabled by the implied rules.Frank Chang (1):
target/riscv: Add standard B extension implied ruleJim Shu (1):
target/riscv: Add the implied rule for G extension
Quoted 9 lines
Reminder to riscv folks -- please put "target/riscv" or similar in the subject of your cover letter, so that people who aren't interested in riscv patches can skip over it rather than wondering which of the many possible areas of QEMU "G and B extensions" might be talking about...
thanks
-- PMM
Agh, sorry for missing that.
I read the mail after sending out another patchset:
https://lore.kernel.org/qemu-devel/[email protected]/
I will fix it in the later patchsets.
Sorry for the disturbance
Regard,
Frank Chang