[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v3 26/35] spapr/xive: add a XIVE KVM device to the mac
From: |
Cédric Le Goater |
Subject: |
[Qemu-ppc] [PATCH v3 26/35] spapr/xive: add a XIVE KVM device to the machine |
Date: |
Thu, 19 Apr 2018 14:43:22 +0200 |
As the VM is connected to the KVM interrupt device at the init of the
machine, KVM support is added for XICS or for XIVE but not both at the
same time. This should change later on when KVM resets are supported.
Signed-off-by: Cédric Le Goater <address@hidden>
---
hw/intc/xics_kvm.c | 22 +++++++++++++++++++++-
hw/ppc/spapr.c | 34 +++++++++++++++++++++++-----------
2 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 89fb20e2c55c..e727397c4a4d 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -62,6 +62,11 @@ static void icp_get_kvm_state(ICPState *icp)
};
int ret;
+ /* A change of the interrupt mode can disable XICS */
+ if (kernel_xics_fd == -1) {
+ return;
+ }
+
/* ICP for this CPU thread is not in use, exiting */
if (!icp->cs) {
return;
@@ -102,6 +107,11 @@ static int icp_set_kvm_state(ICPState *icp, int version_id)
};
int ret;
+ /* Protect resets. A change of the interrupt mode can disable XICS */
+ if (kernel_xics_fd == -1) {
+ return 0;
+ }
+
/* ICP for this CPU thread is not in use, exiting */
if (!icp->cs) {
return 0;
@@ -135,7 +145,7 @@ static void icp_kvm_realize(ICPState *icp, Error **errp)
int ret;
if (kernel_xics_fd == -1) {
- abort();
+ return;
}
/*
@@ -192,6 +202,11 @@ static void ics_get_kvm_state(ICSState *ics)
};
int i;
+ /* A change of the interrupt mode can disable XICS */
+ if (kernel_xics_fd == -1) {
+ return;
+ }
+
for (i = 0; i < ics->nr_irqs; i++) {
ICSIRQState *irq = &ics->irqs[i];
int ret;
@@ -262,6 +277,11 @@ static int ics_set_kvm_state(ICSState *ics, int version_id)
};
int i;
+ /* Protect resets. A change of the interrupt mode can disable XICS */
+ if (kernel_xics_fd == -1) {
+ return 0;
+ }
+
for (i = 0; i < ics->nr_irqs; i++) {
ICSIRQState *irq = &ics->irqs[i];
int ret;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d05c83cdb322..c98ceeed9d6f 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -189,8 +189,7 @@ static void xics_system_init(MachineState *machine, int
nr_irqs, Error **errp)
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
if (kvm_enabled()) {
- if (machine_kernel_irqchip_allowed(machine) &&
- !xics_kvm_init(spapr, errp)) {
+ if (machine_kernel_irqchip_allowed(machine)) {
spapr->icp_type = TYPE_KVM_ICP;
spapr->ics = spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs, errp);
}
@@ -239,10 +238,16 @@ static void xive_system_init(MachineState *machine, int
nr_irqs, Error **errp)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
- /* We don't have KVM support yet, so check for irqchip=on */
- if (kvm_enabled() && machine_kernel_irqchip_required(machine)) {
- error_report("kernel_irqchip requested. no XIVE support");
- exit(1);
+ if (kvm_enabled()) {
+ if (machine_kernel_irqchip_allowed(machine)) {
+ spapr->nvt_type = TYPE_XIVE_NVT_KVM;
+ spapr->xive = spapr_xive_create(spapr, TYPE_SPAPR_XIVE_KVM,
+ nr_irqs, errp);
+ }
+ if (machine_kernel_irqchip_required(machine) && !spapr->xive) {
+ error_prepend(errp, "kernel_irqchip requested but unavailable: ");
+ return;
+ }
}
if (spapr->xive) {
@@ -1043,11 +1048,9 @@ static void
spapr_dt_ov5_platform_support(sPAPRMachineState *spapr, void *fdt,
} else {
val[3] = 0x00; /* Hash */
}
- /* TODO: introduce a kvmppc_has_cap_xive() ? Works with
- * irqchip=off for now
- */
- if (spapr->xive_exploitation) {
- val[1] = 0x80; /* OV5_XIVE_BOTH */
+ /* TODO: when under KVM, only advertise XIVE but not both mode */
+ if (spapr->xive_exploitation && kvmppc_has_cap_xive()) {
+ val[1] = 0x40; /* OV5_XIVE_EXPLOIT */
}
} else {
if (spapr->xive_exploitation) {
@@ -2580,6 +2583,15 @@ static void spapr_machine_init(MachineState *machine)
/* XIVE uses the full range of IRQ numbers. */
xive_system_init(machine, XICS_IRQ_BASE + XICS_IRQS_SPAPR,
&error_fatal);
+
+ /* TODO: initialize KVM for XIVE or for XICS but not for both */
+ if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
+ xive_kvm_init(spapr->xive, &error_fatal);
+ }
+ } else {
+ if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
+ xics_kvm_init(spapr, &error_fatal);
+ }
}
/* Set up containers for ibm,client-architecture-support negotiated options
--
2.13.6
- [Qemu-ppc] [PATCH v3 16/35] spapr: introduce a helper to map the XIVE memory regions, (continued)
- [Qemu-ppc] [PATCH v3 16/35] spapr: introduce a helper to map the XIVE memory regions, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 17/35] spapr: add XIVE support to spapr_qirq(), Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 18/35] spapr: introduce a spapr_icp_create() helper, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 19/35] spapr: toggle the ICP depending on the selected interrupt mode, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 20/35] spapr: add support to dump XIVE information, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 21/35] spapr: advertise XIVE exploitation mode in CAS, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 22/35] spapr: add classes for the XIVE models, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 23/35] target/ppc/kvm: add Linux KVM definitions for XIVE, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 24/35] spapr/xive: add common realize routine for KVM, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 25/35] spapr/xive: add KVM support, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 26/35] spapr/xive: add a XIVE KVM device to the machine,
Cédric Le Goater <=
- [Qemu-ppc] [PATCH v3 27/35] migration: discard non-migratable RAMBlocks, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 28/35] intc: introduce a CPUIntc interface, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 29/35] spapr/xive, xics: use the CPU_INTC handlers to reset KVM, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 30/35] spapr/xive, xics: reset KVM at machine reset, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 31/35] spapr/xive: raise migration priority of the machine, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 32/35] ppc/pnv: introduce a pnv_icp_create() helper, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 33/35] ppc: externalize ppc_get_vcpu_by_pir(), Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 34/35] ppc/pnv: add XIVE support, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 35/35] ppc/pnv: add a PSI bridge model for POWER9 processor, Cédric Le Goater, 2018/04/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v3 00/35] ppc: support for the XIVE interrupt controller (POWER9), no-reply, 2018/04/21