aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2015-07-03 12:26:38 +0100
committerWill Deacon <will.deacon@arm.com>2015-07-08 17:41:00 +0100
commit43d2781c273192b678b090f3e3c31edfbaeca54d (patch)
tree174e007d19a99edb0555492772433e192a6c1f28
parentbfb2c703767272be20b021892a6aee2f6f47fef3 (diff)
downloadkvmtool-43d2781c273192b678b090f3e3c31edfbaeca54d.tar.gz
arm: use new irqchip parameter to create different vGIC types
Currently we unconditionally create a virtual GICv2 in the guest. Add a --irqchip= parameter to let the user specify a different GIC type for the guest, when omitting this parameter it still defaults to --irqchip=gicv2. For now the only other supported type is --irqchip=gicv3 Signed-off-by: Andre Przywara <andre.przywara@arm.com> [will: use pr_err instead of fprintf] Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arm/aarch64/arm-cpu.c2
-rw-r--r--arm/gic.c16
-rw-r--r--arm/include/arm-common/kvm-config-arch.h9
-rw-r--r--arm/kvm.c2
4 files changed, 26 insertions, 3 deletions
diff --git a/arm/aarch64/arm-cpu.c b/arm/aarch64/arm-cpu.c
index f702b9e7..3dc8ea30 100644
--- a/arm/aarch64/arm-cpu.c
+++ b/arm/aarch64/arm-cpu.c
@@ -12,7 +12,7 @@
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, IRQCHIP_GICV2);
+ gic__generate_fdt_nodes(fdt, gic_phandle, kvm->cfg.arch.irqchip);
timer__generate_fdt_nodes(fdt, kvm, timer_interrupts);
}
diff --git a/arm/gic.c b/arm/gic.c
index efe4b42a..d6d6dd08 100644
--- a/arm/gic.c
+++ b/arm/gic.c
@@ -22,6 +22,22 @@ static int gic_fd = -1;
static u64 gic_redists_base;
static u64 gic_redists_size;
+int irqchip_parser(const struct option *opt, const char *arg, int unset)
+{
+ enum irqchip_type *type = opt->value;
+
+ if (!strcmp(arg, "gicv2")) {
+ *type = IRQCHIP_GICV2;
+ } else if (!strcmp(arg, "gicv3")) {
+ *type = IRQCHIP_GICV3;
+ } else {
+ pr_err("irqchip: unknown type \"%s\"\n", arg);
+ return -1;
+ }
+
+ return 0;
+}
+
static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
{
int err;
diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h
index a8ebd94a..f9c59421 100644
--- a/arm/include/arm-common/kvm-config-arch.h
+++ b/arm/include/arm-common/kvm-config-arch.h
@@ -8,8 +8,11 @@ struct kvm_config_arch {
unsigned int force_cntfrq;
bool virtio_trans_pci;
bool aarch32_guest;
+ enum irqchip_type irqchip;
};
+int irqchip_parser(const struct option *opt, const char *arg, int unset);
+
#define OPT_ARCH_RUN(pfx, cfg) \
pfx, \
ARM_OPT_ARCH_RUN(cfg) \
@@ -21,6 +24,10 @@ struct kvm_config_arch {
"updated to program CNTFRQ correctly*"), \
OPT_BOOLEAN('\0', "force-pci", &(cfg)->virtio_trans_pci, \
"Force virtio devices to use PCI as their default " \
- "transport"),
+ "transport"), \
+ OPT_CALLBACK('\0', "irqchip", &(cfg)->irqchip, \
+ "[gicv2|gicv3]", \
+ "Type of interrupt controller to emulate in the guest", \
+ irqchip_parser, NULL),
#endif /* ARM_COMMON__KVM_CONFIG_ARCH_H */
diff --git a/arm/kvm.c b/arm/kvm.c
index f9685c26..d0e4a20f 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -82,6 +82,6 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
MADV_MERGEABLE | MADV_HUGEPAGE);
/* Create the virtual GIC. */
- if (gic__create(kvm, IRQCHIP_GICV2))
+ if (gic__create(kvm, kvm->cfg.arch.irqchip))
die("Failed to create virtual GIC");
}