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