Skip to contentSkip to conversation

KVM: remove support for kernel-irqchip=off

PATCH In review Paolo Bonzini 2 participants 3 messages Dec 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: remove support for kernel-irqchip=off

-machine kernel-irqchip=off is broken for many guest OSes; kernel-irqchip=split is the replacement that works, so remove the deprecated support for the former.

---
 docs/about/deprecated.rst       |  7 -------
 docs/about/removed-features.rst |  7 +++++++
 hw/i386/amd_iommu.c             |  2 +-
 hw/i386/intel_iommu.c           |  4 ++--
 include/hw/i386/apic_internal.h |  2 +-
 target/i386/cpu-sysemu.c        | 15 +++++++++++----
 6 files changed, 22 insertions(+), 15 deletions(-)
docs/about/deprecated.rst +0 -7
index b28f50b22fa9..f1575a52cb4d 100644
@@ -58,13 +58,6 @@ and will cause a warning.
 The replacement for the ``nodelay`` short-form boolean option is ``nodelay=on``
 rather than ``delay=off``.
 
-Userspace local APIC with KVM (x86, since 6.0)
-''''''''''''''''''''''''''''''''''''''''''''''
-
-Using ``-M kernel-irqchip=off`` with x86 machine types that include a local
-APIC is deprecated.  The ``split`` setting is supported, as is using
-``-M kernel-irqchip=off`` with the ISA PC machine type.
-
 hexadecimal sizes with scaling multipliers (since 6.0)
 ''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
docs/about/removed-features.rst +7 -0
index 91c9dce6d6e0..76c2178cd39e 100644
@@ -625,6 +625,13 @@ MIPS "Trap-and-Emulate" KVM support (removed in 8.0)
 The MIPS "Trap-and-Emulate" KVM host and guest support was removed
 from Linux in 2021, and is not supported anymore by QEMU either.
 
+Userspace local APIC with KVM (x86, removed 8.0)
+''''''''''''''''''''''''''''''''''''''''''''''''
+
+``-M kernel-irqchip=off`` cannot be used on KVM if the CPU model includes
+a local APIC.  The ``split`` setting is supported, as is using ``-M
+kernel-irqchip=off`` when the CPU does not have a local APIC.
+
 System emulator machines
 ------------------------
 
hw/i386/amd_iommu.c +1 -1
index 725f69095b9e..bcd016f5c5a5 100644
@@ -1368,7 +1368,7 @@ static MemTxResult amdvi_mem_ir_write(void *opaque, hwaddr addr,
         return MEMTX_ERROR;
     }
 
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);
 
     trace_amdvi_mem_ir_write(to.address, to.data);
     return MEMTX_OK;
hw/i386/intel_iommu.c +2 -2
index a08ee85edf2a..98a5c304a7d7 100644
@@ -396,7 +396,7 @@ static void vtd_generate_interrupt(IntelIOMMUState *s, hwaddr mesg_addr_reg,
 
     trace_vtd_irq_generate(msi.address, msi.data);
 
-    apic_get_class()->send_msi(&msi);
+    apic_get_class(NULL)->send_msi(&msi);
 }
 
 /* Generate a fault event to software via MSI if conditions are met.
@@ -3529,7 +3529,7 @@ static MemTxResult vtd_mem_ir_write(void *opaque, hwaddr addr,
         return MEMTX_ERROR;
     }
 
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);
 
     return MEMTX_OK;
 }
include/hw/i386/apic_internal.h +1 -1
index c175e7e71816..968b6648b3a4 100644
@@ -226,6 +226,6 @@ static inline int apic_get_bit(uint32_t *tab, int index)
     return !!(tab[i] & mask);
 }
 
-APICCommonClass *apic_get_class(void);
+APICCommonClass *apic_get_class(Error **errp);
 
 #endif /* QEMU_APIC_INTERNAL_H */
target/i386/cpu-sysemu.c +11 -4
index fc97213a73cf..28115edf44f7 100644
@@ -247,12 +247,16 @@ void x86_cpu_machine_reset_cb(void *opaque)
     cpu_reset(CPU(cpu));
 }
 
-APICCommonClass *apic_get_class(void)
+APICCommonClass *apic_get_class(Error **errp)
 {
     const char *apic_type = "apic";
 
     /* TODO: in-kernel irqchip for hvf */
-    if (kvm_apic_in_kernel()) {
+    if (kvm_enabled()) {
+        if (!kvm_apic_in_kernel()) {
+            error_setg(errp, "KVM does not support userspace APIC");
+            return NULL;
+        }
         apic_type = "kvm-apic";
     } else if (xen_enabled()) {
         apic_type = "xen-apic";
@@ -266,10 +270,13 @@ APICCommonClass *apic_get_class(void)
 void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
 {
     APICCommonState *apic;
-    ObjectClass *apic_class = OBJECT_CLASS(apic_get_class());
+    APICCommonClass *apic_class = apic_get_class(errp);
 
-    cpu->apic_state = DEVICE(object_new_with_class(apic_class));
+    if (!apic_class) {
+        return;
+    }
 
+    cpu->apic_state = DEVICE(object_new_with_class(OBJECT_CLASS(apic_class)));
     object_property_add_child(OBJECT(cpu), "lapic",
                               OBJECT(cpu->apic_state));
     object_unref(OBJECT(cpu->apic_state));
Signature · 1 line
2.38.1
#1 lore raw
Quoted 19 lines · Paolo Bonzini

-machine kernel-irqchip=off is broken for many guest OSes; kernel-irqchip=split is the replacement that works, so remove the deprecated support for the former.

---
  docs/about/deprecated.rst       |  7 -------
  docs/about/removed-features.rst |  7 +++++++
  hw/i386/amd_iommu.c             |  2 +-
  hw/i386/intel_iommu.c           |  4 ++--
  include/hw/i386/apic_internal.h |  2 +-
  target/i386/cpu-sysemu.c        | 15 +++++++++++----
  6 files changed, 22 insertions(+), 15 deletions(-)
hw/i386/amd_iommu.c +0 -0
index 725f69095b9e..bcd016f5c5a5 100644

hw/i386/amd_iommu.c static MemTxResult amdvi_mem_ir_write(void *opaque, hwaddr addr, · line 1371

Quoted 5 lines
hw/i386/amd_iommu.c +1 -1
@@ -1368,7 +1368,7 @@ static MemTxResult amdvi_mem_ir_write(void *opaque, hwaddr addr,
          return MEMTX_ERROR;
      }
 
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);

&error_fatal?

Quoted 44 lines
hw/i386/intel_iommu.c +2 -2
index a08ee85edf2a..98a5c304a7d7 100644
@@ -396,7 +396,7 @@ static void vtd_generate_interrupt(IntelIOMMUState *s, hwaddr mesg_addr_reg,
 
      trace_vtd_irq_generate(msi.address, msi.data);
 
-    apic_get_class()->send_msi(&msi);
+    apic_get_class(NULL)->send_msi(&msi);
  }
 
  /* Generate a fault event to software via MSI if conditions are met.
@@ -3529,7 +3529,7 @@ static MemTxResult vtd_mem_ir_write(void *opaque, hwaddr addr,
          return MEMTX_ERROR;
      }
 
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);
 
      return MEMTX_OK;
  }
  #endif /* QEMU_APIC_INTERNAL_H */
target/i386/cpu-sysemu.c +6 -2
index fc97213a73cf..28115edf44f7 100644
@@ -247,12 +247,16 @@ void x86_cpu_machine_reset_cb(void *opaque)
      cpu_reset(CPU(cpu));
  }
 
-APICCommonClass *apic_get_class(void)
+APICCommonClass *apic_get_class(Error **errp)
  {
      const char *apic_type = "apic";
 
      /* TODO: in-kernel irqchip for hvf */
-    if (kvm_apic_in_kernel()) {
+    if (kvm_enabled()) {
+        if (!kvm_apic_in_kernel()) {
+            error_setg(errp, "KVM does not support userspace APIC");
+            return NULL;
+        }
#2 lore raw
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 13 lines · Paolo Bonzini

-machine kernel-irqchip=off is broken for many guest OSes; kernel-irqchip=split
is the replacement that works, so remove the deprecated support for the former.

---
  docs/about/deprecated.rst       |  7 ------- docs/about/removed-features.rst |  7 +++++++ hw/i386/amd_iommu.c             |  2 +- hw/i386/intel_iommu.c           |  4 ++-- include/hw/i386/apic_internal.h |  2 +- target/i386/cpu-sysemu.c        | 15 +++++++++++----

  6 files changed, 22 insertions(+), 15 deletions(-)
Quoted 12 lines

hw/i386/amd_iommu.c static MemTxResult amdvi_mem_ir_write(void · line 1371

Quoted 10 lines
hw/i386/amd_iommu.c +1 -1
index 725f69095b9e..bcd016f5c5a5 100644
@@ -1368,7 +1368,7 @@ static MemTxResult amdvi_mem_ir_write(void 
 *opaque, hwaddr addr,
           return MEMTX_ERROR;
       }
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);

&error_fatal?

Eh, &error_abort instead.

Quoted 40 lines
Quoted 39 lines
hw/i386/intel_iommu.c +2 -2
index a08ee85edf2a..98a5c304a7d7 100644
@@ -396,7 +396,7 @@ static void vtd_generate_interrupt(IntelIOMMUState 
 *s, hwaddr mesg_addr_reg,
       trace_vtd_irq_generate(msi.address, msi.data);
-    apic_get_class()->send_msi(&msi);
+    apic_get_class(NULL)->send_msi(&msi);
   }
   /* Generate a fault event to software via MSI if conditions are met.
@@ -3529,7 +3529,7 @@ static MemTxResult vtd_mem_ir_write(void 
 *opaque, hwaddr addr,
           return MEMTX_ERROR;
       }
-    apic_get_class()->send_msi(&to);
+    apic_get_class(NULL)->send_msi(&to);
       return MEMTX_OK;
   }
 

  #endif /* QEMU_APIC_INTERNAL_H */

target/i386/cpu-sysemu.c +6 -2
index fc97213a73cf..28115edf44f7 100644
@@ -247,12 +247,16 @@ void x86_cpu_machine_reset_cb(void *opaque)
       cpu_reset(CPU(cpu));
   }
-APICCommonClass *apic_get_class(void)
+APICCommonClass *apic_get_class(Error **errp)
   {
       const char *apic_type = "apic";
       /* TODO: in-kernel irqchip for hvf */
-    if (kvm_apic_in_kernel()) {
+    if (kvm_enabled()) {
+        if (!kvm_apic_in_kernel()) {
+            error_setg(errp, "KVM does not support userspace APIC");
+            return NULL;
+        }