Skip to contentSkip to conversation

hw/riscv/virt.c: check for 'ssaia' with KVM AIA

PATCH New Daniel Henrique Barboza 1 participant 2 messages Jun 16, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

cover hw/riscv/virt.c: check for 'ssaia' with KVM AIA

Hi,

This patch was inspired by my review and testing of the QEMU KVM AIA work. It's not dependent on it though, and can be reviewed and merged separately.

You'll need "[PATCH v2 00/18] target/riscv, KVM: fixes and enhancements" for this check to work properly. Otherwise the host value won't be passed through to cpu->cfg.ssaia.

Daniel Henrique Barboza (1):
hw/riscv/virt.c: check for 'ssaia' with KVM AIA

 hw/riscv/virt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/1 hw/riscv/virt.c: check for 'ssaia' with KVM AIA

KVM AIA relies on ext_ssaia support present in the host. At this moment we're not checking. A KVM guest is doomed to hung if we use any 'aia' option, aside from 'aia=none', and KVM does not support 'ssaia'.

Add a check for it. The placement is intentional: we need to check before riscv_imsic_realize(), where the TCG logic can force cpu->cfg.ext_ssaia to be 'true' and overwrite what KVM set before.

---
 hw/riscv/virt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/riscv/virt.c +12 -0
index f025a0fcaf..c192059186 100644
@@ -1409,6 +1409,18 @@ static void virt_machine_init(MachineState *machine)
                     RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
                     RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, true);
             }
+        } else {
+            /*
+             * With KVM enabled, check if the user wants to use AIA
+             * and we have the proper support for it.
+             */
+            RISCVCPU *cpu = &s->soc[i].harts[0];
+
+            if (s->aia_type != VIRT_AIA_TYPE_NONE && !cpu->cfg.ext_ssaia) {
+                error_report("Unable to set AIA: host does not "
+                             "have extension 'ssaia' enabled");
+                exit(1);
+            }
         }
 
         /* Per-socket interrupt controller */
Signature · 1 line
2.40.1