@samitouri / QOSamiQemu / commits / 65dbf4bfd2

target/riscv: Add the implied rule for G extension

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. Signed-off-by: Jim Shu <jim.shu@sifive.com> Reviewed-by: Frank Chang <frank.chang@sifive.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260528054213.678458-2-frank.chang@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Jim Shu committed May 28, 2026 at 13:42 UTC 65dbf4bfd22e04c7b9f716545f19553d1a810671
2 files changed +17 -18
target/riscv/cpu.c
+13 -1
@@ -2095,6 +2095,18 @@ static RISCVCPUImpliedExtsRule RVV_IMPLIED = {
2095 },
2096 };
2097
2098 +static RISCVCPUImpliedExtsRule RVG_IMPLIED = {
2099 + .is_misa = true,
2100 + .ext = RVG,
2101 + .implied_misa_exts = RVI | RVM | RVA | RVF | RVD,
2102 + .implied_multi_exts = {
2103 + CPU_CFG_OFFSET(ext_zicsr),
2104 + CPU_CFG_OFFSET(ext_zifencei),
2105 +
2106 + RISCV_IMPLIED_EXTS_RULE_END
2107 + },
2108 +};
2109 +
2110 static RISCVCPUImpliedExtsRule ZCB_IMPLIED = {
2111 .ext = CPU_CFG_OFFSET(ext_zcb),
2112 .implied_multi_exts = {
@@ -2502,7 +2514,7 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {
2514
2515 RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = {
2516 &RVA_IMPLIED, &RVD_IMPLIED, &RVF_IMPLIED,
2505 - &RVM_IMPLIED, &RVV_IMPLIED, NULL
2517 + &RVM_IMPLIED, &RVV_IMPLIED, &RVG_IMPLIED, NULL
2518 };
2519
2520 RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
target/riscv/tcg/tcg-cpu.c
+4 -17
@@ -498,30 +498,17 @@ static void riscv_cpu_validate_g(RISCVCPU *cpu)
498 continue;
499 }
500
501 - if (!cpu_misa_ext_is_user_set(bit)) {
502 - riscv_cpu_write_misa_bit(cpu, bit, true);
503 - continue;
504 - }
505 -
501 if (send_warn) {
502 warn_report(warn_msg, riscv_get_misa_ext_name(bit));
503 }
504 }
505
511 - if (!cpu->cfg.ext_zicsr) {
512 - if (!cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_zicsr))) {
513 - cpu->cfg.ext_zicsr = true;
514 - } else if (send_warn) {
515 - warn_report(warn_msg, "zicsr");
516 - }
506 + if (!cpu->cfg.ext_zicsr && send_warn) {
507 + warn_report(warn_msg, "zicsr");
508 }
509
519 - if (!cpu->cfg.ext_zifencei) {
520 - if (!cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_zifencei))) {
521 - cpu->cfg.ext_zifencei = true;
522 - } else if (send_warn) {
523 - warn_report(warn_msg, "zifencei");
524 - }
510 + if (!cpu->cfg.ext_zifencei && send_warn) {
511 + warn_report(warn_msg, "zifencei");
512 }
513 }
514