diff mbox series

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

Message ID 20230616172141.756386-2-dbarboza@ventanamicro.com
State New
Headers show
Series hw/riscv/virt.c: check for 'ssaia' with KVM AIA | expand

Commit Message

Daniel Henrique Barboza June 16, 2023, 5:21 p.m. UTC
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.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 hw/riscv/virt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index f025a0fcaf..c192059186 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -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 */