[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/36] target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap
From: |
Peter Maydell |
Subject: |
[PULL 33/36] target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap |
Date: |
Thu, 12 Mar 2020 16:44:56 +0000 |
From: Eric Auger <address@hidden>
Convert kvm_arm_vgic_probe() so that it returns a
bitmap of supported in-kernel emulation VGIC versions instead
of the max version: at the moment values can be v2 and v3.
This allows to expose the case where the host GICv3 also
supports GICv2 emulation. This will be useful to choose the
default version in KVM accelerated mode.
Signed-off-by: Eric Auger <address@hidden>
Reviewed-by: Andrew Jones <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
target/arm/kvm_arm.h | 3 +++
hw/arm/virt.c | 11 +++++++++--
target/arm/kvm.c | 14 ++++++++------
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index ae9e075d754..48bf5e16d58 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -15,6 +15,9 @@
#include "exec/memory.h"
#include "qemu/error-report.h"
+#define KVM_ARM_VGIC_V2 (1 << 0)
+#define KVM_ARM_VGIC_V3 (1 << 1)
+
/**
* kvm_arm_vcpu_init:
* @cs: CPUState
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e55cafa014b..a94bc5ddae5 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1554,11 +1554,18 @@ static void finalize_gic_version(VirtMachineState *vms)
vms->gic_version = VIRT_GIC_VERSION_3;
}
} else {
- vms->gic_version = kvm_arm_vgic_probe();
- if (!vms->gic_version) {
+ int probe_bitmap = kvm_arm_vgic_probe();
+
+ if (!probe_bitmap) {
error_report(
"Unable to determine GIC version supported by host");
exit(1);
+ } else {
+ if (probe_bitmap & KVM_ARM_VGIC_V3) {
+ vms->gic_version = VIRT_GIC_VERSION_3;
+ } else {
+ vms->gic_version = VIRT_GIC_VERSION_2;
+ }
}
}
} else if (vms->gic_version == VIRT_GIC_VERSION_NOSEL) {
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 85860e6f954..390077c5182 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -874,15 +874,17 @@ int kvm_arch_irqchip_create(KVMState *s)
int kvm_arm_vgic_probe(void)
{
+ int val = 0;
+
if (kvm_create_device(kvm_state,
KVM_DEV_TYPE_ARM_VGIC_V3, true) == 0) {
- return 3;
- } else if (kvm_create_device(kvm_state,
- KVM_DEV_TYPE_ARM_VGIC_V2, true) == 0) {
- return 2;
- } else {
- return 0;
+ val |= KVM_ARM_VGIC_V3;
}
+ if (kvm_create_device(kvm_state,
+ KVM_DEV_TYPE_ARM_VGIC_V2, true) == 0) {
+ val |= KVM_ARM_VGIC_V2;
+ }
+ return val;
}
int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level)
--
2.20.1
- [PULL 24/36] tests/boot_linux_console: Add a quick test for the OrangePi PC board, (continued)
- [PULL 24/36] tests/boot_linux_console: Add a quick test for the OrangePi PC board, Peter Maydell, 2020/03/12
- [PULL 25/36] tests/boot_linux_console: Add initrd test for the Orange Pi PC board, Peter Maydell, 2020/03/12
- [PULL 26/36] tests/boot_linux_console: Add a SD card test for the OrangePi PC board, Peter Maydell, 2020/03/12
- [PULL 20/36] hw/arm/allwinner-h3: add EMAC ethernet device, Peter Maydell, 2020/03/12
- [PULL 23/36] hw/arm/allwinner: add RTC device support, Peter Maydell, 2020/03/12
- [PULL 28/36] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC, Peter Maydell, 2020/03/12
- [PULL 31/36] hw/arm/virt: Introduce VirtGICType enum type, Peter Maydell, 2020/03/12
- [PULL 22/36] hw/arm/allwinner-h3: add SDRAM controller device, Peter Maydell, 2020/03/12
- [PULL 19/36] hw/arm/allwinner: add SD/MMC host controller, Peter Maydell, 2020/03/12
- [PULL 27/36] tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC, Peter Maydell, 2020/03/12
- [PULL 33/36] target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap,
Peter Maydell <=
- [PULL 30/36] hw/arm/virt: Document 'max' value in gic-version property description, Peter Maydell, 2020/03/12
- [PULL 34/36] hw/arm/virt: kvm: Restructure finalize_gic_version(), Peter Maydell, 2020/03/12
- [PULL 35/36] hw/arm/virt: kvm: allow gicv3 by default if v2 cannot work, Peter Maydell, 2020/03/12
- [PULL 29/36] docs: add Orange Pi PC document, Peter Maydell, 2020/03/12
- [PULL 32/36] hw/arm/virt: Introduce finalize_gic_version(), Peter Maydell, 2020/03/12
- [PULL 36/36] target/arm: kvm: Inject events at the last stage of sync, Peter Maydell, 2020/03/12
- Re: [PULL 00/36] target-arm queue, Peter Maydell, 2020/03/12