[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/33] hw/intc/arm_gic_kvm: Don't assume kernel can provide a GICv
From: |
Peter Maydell |
Subject: |
[PULL 33/33] hw/intc/arm_gic_kvm: Don't assume kernel can provide a GICv2 |
Date: |
Fri, 28 Feb 2020 16:38:40 +0000 |
In our KVM GICv2 realize function, we try to cope with old kernels
that don't provide the device control API (KVM_CAP_DEVICE_CTRL): we
try to use the device control, and if that fails we fall back to
assuming that the kernel has the old style KVM_CREATE_IRQCHIP and
that it will provide a GICv2.
This doesn't cater for the possibility of a kernel and hardware which
only provide a GICv3, which is very common now. On that setup we
will abort() later on in kvm_arm_pmu_set_irq() when we try to wire up
an interrupt to the GIC we failed to create:
qemu-system-aarch64: PMU: KVM_SET_DEVICE_ATTR: Invalid argument
qemu-system-aarch64: failed to set irq for PMU
Aborted
If the kernel advertises KVM_CAP_DEVICE_CTRL we should trust it if it
says it can't create a GICv2, rather than assuming it has one. We
can then produce a more helpful error message including a hint about
the most probable reason for the failure.
If the kernel doesn't advertise KVM_CAP_DEVICE_CTRL then it is truly
ancient by this point but we might as well still fall back to a
KVM_CREATE_IRQCHIP GICv2.
With this patch then the user misconfiguration which previously
caused an abort now prints:
qemu-system-aarch64: Initialization of device kvm-arm-gic failed: error
creating in-kernel VGIC: No such device
Perhaps the host CPU does not support GICv2?
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Andrew Jones <address@hidden>
Tested-by: Andrew Jones <address@hidden>
Message-id: address@hidden
---
hw/intc/arm_gic_kvm.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index 9deb15e7e69..d7df423a7a3 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -551,7 +551,16 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error
**errp)
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true,
&error_abort);
}
+ } else if (kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) {
+ error_setg_errno(errp, -ret, "error creating in-kernel VGIC");
+ error_append_hint(errp,
+ "Perhaps the host CPU does not support GICv2?\n");
} else if (ret != -ENODEV && ret != -ENOTSUP) {
+ /*
+ * Very ancient kernel without KVM_CAP_DEVICE_CTRL: assume that
+ * ENODEV or ENOTSUP mean "can't create GICv2 with KVM_CREATE_DEVICE",
+ * and that we will get a GICv2 via KVM_CREATE_IRQCHIP.
+ */
error_setg_errno(errp, -ret, "error creating in-kernel VGIC");
return;
}
--
2.20.1
- [PULL 30/33] target/arm: Implement v8.3-RCPC, (continued)
- [PULL 30/33] target/arm: Implement v8.3-RCPC, Peter Maydell, 2020/02/28
- [PULL 05/33] cpu/a9mpcore: Set number of GIC priority bits to 5, Peter Maydell, 2020/02/28
- [PULL 20/33] target/arm: Add formats for some vfp 2 and 3-register insns, Peter Maydell, 2020/02/28
- [PULL 22/33] target/arm: Split VMINMAXNM decode, Peter Maydell, 2020/02/28
- [PULL 25/33] tests/acceptance: Add a test for the N800 and N810 arm machines, Peter Maydell, 2020/02/28
- [PULL 26/33] tests/acceptance: Add a test for the integratorcp arm machine, Peter Maydell, 2020/02/28
- [PULL 17/33] target/arm: Move the vfp decodetree calls next to the base isa, Peter Maydell, 2020/02/28
- [PULL 21/33] target/arm: Split VFM decode, Peter Maydell, 2020/02/28
- [PULL 27/33] tests/acceptance: Extract boot_integratorcp() from test_integratorcp(), Peter Maydell, 2020/02/28
- [PULL 28/33] tests/acceptance/integratorcp: Verify Tux is displayed on framebuffer, Peter Maydell, 2020/02/28
- [PULL 33/33] hw/intc/arm_gic_kvm: Don't assume kernel can provide a GICv2,
Peter Maydell <=
- [PULL 31/33] target/arm: Implement v8.4-RCPC, Peter Maydell, 2020/02/28
- [PULL 32/33] target/arm: Implement ARMv8.3-CCIDX, Peter Maydell, 2020/02/28
- [PULL 19/33] target/arm: Remove ARM_FEATURE_VFP*, Peter Maydell, 2020/02/28
- Re: [PULL 00/33] target-arm queue, Peter Maydell, 2020/02/28