282 lines
9.4 KiB
Diff
282 lines
9.4 KiB
Diff
From 3899672db472c1ca530badd49d17726a1057f8af Mon Sep 17 00:00:00 2001
|
|
From: Thomas Huth <thuth@redhat.com>
|
|
Date: Fri, 5 Jun 2020 07:41:10 -0400
|
|
Subject: [PATCH 40/42] kvm: introduce kvm_kernel_irqchip_* functions
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
Message-id: <20200605074111.2185-3-thuth@redhat.com>
|
|
Patchwork-id: 97369
|
|
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 2/3] kvm: introduce kvm_kernel_irqchip_* functions
|
|
Bugzilla: 1756946
|
|
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
The KVMState struct is opaque, so provide accessors for the fields
|
|
that will be moved from current_machine to the accelerator. For now
|
|
they just forward to the machine object, but this will change.
|
|
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
(cherry picked from commit 4376c40dedb22530738eeb104a603e94ed03f719)
|
|
|
|
Conflicts:
|
|
accel/kvm/kvm-all.c
|
|
(contextual conflict due to missing other commits in downstream)
|
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
---
|
|
accel/kvm/kvm-all.c | 23 +++++++++++++++++++----
|
|
hw/ppc/e500.c | 5 ++---
|
|
hw/ppc/spapr_irq.c | 16 ++++------------
|
|
include/sysemu/kvm.h | 7 +++++--
|
|
target/arm/kvm.c | 8 ++++----
|
|
target/i386/kvm.c | 4 ++--
|
|
target/mips/kvm.c | 2 +-
|
|
target/ppc/kvm.c | 2 +-
|
|
target/s390x/kvm.c | 2 +-
|
|
9 files changed, 39 insertions(+), 30 deletions(-)
|
|
|
|
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
|
|
index 5007bdad96..b0250209f5 100644
|
|
--- a/accel/kvm/kvm-all.c
|
|
+++ b/accel/kvm/kvm-all.c
|
|
@@ -1772,7 +1772,7 @@ void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_irq irq, int gsi)
|
|
g_hash_table_insert(s->gsimap, irq, GINT_TO_POINTER(gsi));
|
|
}
|
|
|
|
-static void kvm_irqchip_create(MachineState *machine, KVMState *s)
|
|
+static void kvm_irqchip_create(KVMState *s)
|
|
{
|
|
int ret;
|
|
|
|
@@ -1790,9 +1790,9 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
|
|
|
|
/* First probe and see if there's a arch-specific hook to create the
|
|
* in-kernel irqchip for us */
|
|
- ret = kvm_arch_irqchip_create(machine, s);
|
|
+ ret = kvm_arch_irqchip_create(s);
|
|
if (ret == 0) {
|
|
- if (machine_kernel_irqchip_split(machine)) {
|
|
+ if (kvm_kernel_irqchip_split()) {
|
|
perror("Split IRQ chip mode not supported.");
|
|
exit(1);
|
|
} else {
|
|
@@ -2076,7 +2076,7 @@ static int kvm_init(MachineState *ms)
|
|
}
|
|
|
|
if (machine_kernel_irqchip_allowed(ms)) {
|
|
- kvm_irqchip_create(ms, s);
|
|
+ kvm_irqchip_create(s);
|
|
}
|
|
|
|
if (kvm_eventfds_allowed) {
|
|
@@ -2966,6 +2966,21 @@ static bool kvm_accel_has_memory(MachineState *ms, AddressSpace *as,
|
|
return false;
|
|
}
|
|
|
|
+bool kvm_kernel_irqchip_allowed(void)
|
|
+{
|
|
+ return machine_kernel_irqchip_allowed(current_machine);
|
|
+}
|
|
+
|
|
+bool kvm_kernel_irqchip_required(void)
|
|
+{
|
|
+ return machine_kernel_irqchip_required(current_machine);
|
|
+}
|
|
+
|
|
+bool kvm_kernel_irqchip_split(void)
|
|
+{
|
|
+ return machine_kernel_irqchip_split(current_machine);
|
|
+}
|
|
+
|
|
static void kvm_accel_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
AccelClass *ac = ACCEL_CLASS(oc);
|
|
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
|
|
index 91cd4c26f9..12b6a5b2a8 100644
|
|
--- a/hw/ppc/e500.c
|
|
+++ b/hw/ppc/e500.c
|
|
@@ -793,7 +793,6 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
|
|
MemoryRegion *ccsr,
|
|
IrqLines *irqs)
|
|
{
|
|
- MachineState *machine = MACHINE(pms);
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
|
|
DeviceState *dev = NULL;
|
|
SysBusDevice *s;
|
|
@@ -801,10 +800,10 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
|
|
if (kvm_enabled()) {
|
|
Error *err = NULL;
|
|
|
|
- if (machine_kernel_irqchip_allowed(machine)) {
|
|
+ if (kvm_kernel_irqchip_allowed()) {
|
|
dev = ppce500_init_mpic_kvm(pmc, irqs, &err);
|
|
}
|
|
- if (machine_kernel_irqchip_required(machine) && !dev) {
|
|
+ if (kvm_kernel_irqchip_required() && !dev) {
|
|
error_reportf_err(err,
|
|
"kernel_irqchip requested but unavailable: ");
|
|
exit(1);
|
|
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
|
|
index 9da423658a..f388d07bf9 100644
|
|
--- a/hw/ppc/spapr_irq.c
|
|
+++ b/hw/ppc/spapr_irq.c
|
|
@@ -75,12 +75,11 @@ int spapr_irq_init_kvm(SpaprInterruptControllerInitKvm fn,
|
|
uint32_t nr_servers,
|
|
Error **errp)
|
|
{
|
|
- MachineState *machine = MACHINE(qdev_get_machine());
|
|
Error *local_err = NULL;
|
|
|
|
- if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
|
|
+ if (kvm_enabled() && kvm_kernel_irqchip_allowed()) {
|
|
if (fn(intc, nr_servers, &local_err) < 0) {
|
|
- if (machine_kernel_irqchip_required(machine)) {
|
|
+ if (kvm_kernel_irqchip_required()) {
|
|
error_prepend(&local_err,
|
|
"kernel_irqchip requested but unavailable: ");
|
|
error_propagate(errp, local_err);
|
|
@@ -185,7 +184,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Error **errp)
|
|
*/
|
|
if (kvm_enabled() &&
|
|
spapr->irq == &spapr_irq_dual &&
|
|
- machine_kernel_irqchip_required(machine) &&
|
|
+ kvm_kernel_irqchip_required() &&
|
|
xics_kvm_has_broken_disconnect(spapr)) {
|
|
error_setg(errp, "KVM is too old to support ic-mode=dual,kernel-irqchip=on");
|
|
return -1;
|
|
@@ -288,20 +287,13 @@ uint32_t spapr_irq_nr_msis(SpaprMachineState *spapr)
|
|
|
|
void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
|
|
{
|
|
- MachineState *machine = MACHINE(spapr);
|
|
SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
|
|
|
|
- if (machine_kernel_irqchip_split(machine)) {
|
|
+ if (kvm_enabled() && kvm_kernel_irqchip_split()) {
|
|
error_setg(errp, "kernel_irqchip split mode not supported on pseries");
|
|
return;
|
|
}
|
|
|
|
- if (!kvm_enabled() && machine_kernel_irqchip_required(machine)) {
|
|
- error_setg(errp,
|
|
- "kernel_irqchip requested but only available with KVM");
|
|
- return;
|
|
- }
|
|
-
|
|
if (spapr_irq_check(spapr, errp) < 0) {
|
|
return;
|
|
}
|
|
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
index 9fe233b9bf..aaf2a502e8 100644
|
|
--- a/include/sysemu/kvm.h
|
|
+++ b/include/sysemu/kvm.h
|
|
@@ -519,10 +519,13 @@ void kvm_pc_gsi_handler(void *opaque, int n, int level);
|
|
void kvm_pc_setup_irq_routing(bool pci_enabled);
|
|
void kvm_init_irq_routing(KVMState *s);
|
|
|
|
+bool kvm_kernel_irqchip_allowed(void);
|
|
+bool kvm_kernel_irqchip_required(void);
|
|
+bool kvm_kernel_irqchip_split(void);
|
|
+
|
|
/**
|
|
* kvm_arch_irqchip_create:
|
|
* @KVMState: The KVMState pointer
|
|
- * @MachineState: The MachineState pointer
|
|
*
|
|
* Allow architectures to create an in-kernel irq chip themselves.
|
|
*
|
|
@@ -530,7 +533,7 @@ void kvm_init_irq_routing(KVMState *s);
|
|
* 0: irq chip was not created
|
|
* > 0: irq chip was created
|
|
*/
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s);
|
|
+int kvm_arch_irqchip_create(KVMState *s);
|
|
|
|
/**
|
|
* kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl
|
|
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
|
|
index 4be9497402..418bcedc3e 100644
|
|
--- a/target/arm/kvm.c
|
|
+++ b/target/arm/kvm.c
|
|
@@ -861,11 +861,11 @@ void kvm_arch_init_irq_routing(KVMState *s)
|
|
{
|
|
}
|
|
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
|
|
+int kvm_arch_irqchip_create(KVMState *s)
|
|
{
|
|
- if (machine_kernel_irqchip_split(ms)) {
|
|
- perror("-machine kernel_irqchip=split is not supported on ARM.");
|
|
- exit(1);
|
|
+ if (kvm_kernel_irqchip_split()) {
|
|
+ perror("-machine kernel_irqchip=split is not supported on ARM.");
|
|
+ exit(1);
|
|
}
|
|
|
|
/* If we can create the VGIC using the newer device control API, we
|
|
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
index fcc8f7d1f3..f5c17e0028 100644
|
|
--- a/target/i386/kvm.c
|
|
+++ b/target/i386/kvm.c
|
|
@@ -4532,10 +4532,10 @@ void kvm_arch_init_irq_routing(KVMState *s)
|
|
}
|
|
}
|
|
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
|
|
+int kvm_arch_irqchip_create(KVMState *s)
|
|
{
|
|
int ret;
|
|
- if (machine_kernel_irqchip_split(ms)) {
|
|
+ if (kvm_kernel_irqchip_split()) {
|
|
ret = kvm_vm_enable_cap(s, KVM_CAP_SPLIT_IRQCHIP, 0, 24);
|
|
if (ret) {
|
|
error_report("Could not enable split irqchip mode: %s",
|
|
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
|
|
index 578bc14625..de3e26ef1f 100644
|
|
--- a/target/mips/kvm.c
|
|
+++ b/target/mips/kvm.c
|
|
@@ -57,7 +57,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
return 0;
|
|
}
|
|
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
|
|
+int kvm_arch_irqchip_create(KVMState *s)
|
|
{
|
|
return 0;
|
|
}
|
|
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
|
|
index c77f9848ec..461dc6dae1 100644
|
|
--- a/target/ppc/kvm.c
|
|
+++ b/target/ppc/kvm.c
|
|
@@ -152,7 +152,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
return 0;
|
|
}
|
|
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
|
|
+int kvm_arch_irqchip_create(KVMState *s)
|
|
{
|
|
return 0;
|
|
}
|
|
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
|
|
index 84d7cadd09..c589ef9034 100644
|
|
--- a/target/s390x/kvm.c
|
|
+++ b/target/s390x/kvm.c
|
|
@@ -386,7 +386,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
return 0;
|
|
}
|
|
|
|
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
|
|
+int kvm_arch_irqchip_create(KVMState *s)
|
|
{
|
|
return 0;
|
|
}
|
|
--
|
|
2.27.0
|
|
|