@@ -12,7 +12,10 @@
static void generate_fdt_nodes(void *fdt, struct kvm *kvm, u32 gic_phandle)
{
int timer_interrupts[4] = {13, 14, 11, 10};
- gic__generate_fdt_nodes(fdt, gic_phandle, KVM_DEV_TYPE_ARM_VGIC_V2);
+ gic__generate_fdt_nodes(fdt, gic_phandle,
+ kvm->cfg.arch.gicv3 ?
+ KVM_DEV_TYPE_ARM_VGIC_V3 :
+ KVM_DEV_TYPE_ARM_VGIC_V2);
timer__generate_fdt_nodes(fdt, kvm, timer_interrupts);
}
@@ -3,7 +3,9 @@
#define ARM_OPT_ARCH_RUN(cfg) \
OPT_BOOLEAN('\0', "aarch32", &(cfg)->aarch32_guest, \
- "Run AArch32 guest"),
+ "Run AArch32 guest"), \
+ OPT_BOOLEAN('\0', "gicv3", &(cfg)->gicv3, \
+ "use a GICv3 interrupt controller in the guest"),
#include "arm-common/kvm-config-arch.h"
@@ -76,6 +76,7 @@ static int gic__create_device(struct kvm *kvm, u32 type)
case KVM_DEV_TYPE_ARM_VGIC_V3:
dist_attr.attr = KVM_VGIC_V3_ADDR_TYPE_DIST;
redist_addr = dist_addr - nr_redists * ARM_GIC_REDIST_SIZE;
+ pr_info("creating GICv3 KVM device");
break;
default:
return -ENODEV;
@@ -119,6 +120,17 @@ static int gic__create_irqchip(struct kvm *kvm)
return err;
}
+static int gicv3__init_irqchip(struct kvm *kvm)
+{
+ if (kvm->nrcpus > 255) {
+ pr_warning("%d CPUS greater than maximum of %d -- truncating\n",
+ kvm->nrcpus, 255);
+ kvm->nrcpus = 255;
+ }
+
+ return gic__create_device(kvm, KVM_DEV_TYPE_ARM_VGIC_V3);
+}
+
static int gicv2__init_irqchip(struct kvm *kvm)
{
int err;
@@ -150,6 +162,9 @@ int gic__init_irqchip(struct kvm *kvm, u32 type)
switch (type) {
case KVM_DEV_TYPE_ARM_VGIC_V2:
return gicv2__init_irqchip(kvm);
+ case KVM_DEV_TYPE_ARM_VGIC_V3:
+ nr_redists = kvm->cfg.nrcpus;
+ return gicv3__init_irqchip(kvm);
}
return -ENODEV;
}
@@ -196,6 +211,8 @@ void gic__generate_fdt_nodes(void *fdt, u32 phandle, u32 type)
compatible = "arm,gic-v3";
reg_prop[2] = ARM_GIC_DIST_BASE - nr_redists * ARM_GIC_REDIST_SIZE;
reg_prop[3] = ARM_GIC_REDIST_SIZE * nr_redists;
+ pr_info("creating FDT for a GICv3 with %d redistributors",
+ nr_redists);
break;
default:
return;
@@ -7,6 +7,7 @@ struct kvm_config_arch {
const char *dump_dtb_filename;
unsigned int force_cntfrq;
bool aarch32_guest;
+ bool gicv3;
};
#define OPT_ARCH_RUN(pfx, cfg) \
@@ -80,6 +80,8 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
MADV_MERGEABLE);
/* Initialise the virtual GIC. */
- if (gic__init_irqchip(kvm, KVM_DEV_TYPE_ARM_VGIC_V2))
+ if (gic__init_irqchip(kvm, kvm->cfg.arch.gicv3 ?
+ KVM_DEV_TYPE_ARM_VGIC_V3 :
+ KVM_DEV_TYPE_ARM_VGIC_V2))
die("Failed to initialise virtual GIC");
}
Add the command line parameter "--gicv3" to request GICv3 emulation in the kernel. Connect that to the already existing GICv3 code. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- tools/kvm/arm/aarch64/arm-cpu.c | 5 ++++- .../kvm/arm/aarch64/include/kvm/kvm-config-arch.h | 4 +++- tools/kvm/arm/gic.c | 17 +++++++++++++++++ tools/kvm/arm/include/arm-common/kvm-config-arch.h | 1 + tools/kvm/arm/kvm.c | 4 +++- 5 files changed, 28 insertions(+), 3 deletions(-)