[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 49/91] target/i386: Fix sanity check on max APIC ID / X2APIC enabl
From: |
Michael S. Tsirkin |
Subject: |
[PULL 49/91] target/i386: Fix sanity check on max APIC ID / X2APIC enablement |
Date: |
Mon, 16 May 2022 06:38:25 -0400 |
From: David Woodhouse <dwmw2@infradead.org>
The check on x86ms->apic_id_limit in pc_machine_done() had two problems.
Firstly, we need KVM to support the X2APIC API in order to allow IRQ
delivery to APICs >= 255. So we need to call/check kvm_enable_x2apic(),
which was done elsewhere in *some* cases but not all.
Secondly, microvm needs the same check. So move it from pc_machine_done()
to x86_cpus_init() where it will work for both.
The check in kvm_cpu_instance_init() is now redundant and can be dropped.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Claudio Fontana <cfontana@suse.de>
Message-Id: <20220314142544.150555-1-dwmw2@infradead.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc.c | 8 --------
hw/i386/x86.c | 16 ++++++++++++++++
target/i386/kvm/kvm-cpu.c | 2 +-
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 312eb9e400..15f37d8dc6 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -744,14 +744,6 @@ void pc_machine_done(Notifier *notifier, void *data)
/* update FW_CFG_NB_CPUS to account for -device added CPUs */
fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
}
-
-
- if (x86ms->apic_id_limit > 255 && !xen_enabled() &&
- !kvm_irqchip_in_kernel()) {
- error_report("current -smp configuration requires kernel "
- "irqchip support.");
- exit(EXIT_FAILURE);
- }
}
void pc_guest_info_init(PCMachineState *pcms)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 79ebdface6..f79e720cc2 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -38,6 +38,7 @@
#include "sysemu/replay.h"
#include "sysemu/sysemu.h"
#include "sysemu/cpu-timers.h"
+#include "sysemu/xen.h"
#include "trace.h"
#include "hw/i386/x86.h"
@@ -122,6 +123,21 @@ void x86_cpus_init(X86MachineState *x86ms, int
default_cpu_version)
*/
x86ms->apic_id_limit = x86_cpu_apic_id_from_index(x86ms,
ms->smp.max_cpus - 1) +
1;
+
+ /*
+ * Can we support APIC ID 255 or higher?
+ *
+ * Under Xen: yes.
+ * With userspace emulated lapic: no
+ * With KVM's in-kernel lapic: only if X2APIC API is enabled.
+ */
+ if (x86ms->apic_id_limit > 255 && !xen_enabled() &&
+ (!kvm_irqchip_in_kernel() || !kvm_enable_x2apic())) {
+ error_report("current -smp configuration requires kernel "
+ "irqchip and X2APIC API support.");
+ exit(EXIT_FAILURE);
+ }
+
possible_cpus = mc->possible_cpu_arch_ids(ms);
for (i = 0; i < ms->smp.cpus; i++) {
x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal);
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index 5eb955ce9a..7237378a7d 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -171,7 +171,7 @@ static void kvm_cpu_instance_init(CPUState *cs)
/* only applies to builtin_x86_defs cpus */
if (!kvm_irqchip_in_kernel()) {
x86_cpu_change_kvm_default("x2apic", "off");
- } else if (kvm_irqchip_is_split() && kvm_enable_x2apic()) {
+ } else if (kvm_irqchip_is_split()) {
x86_cpu_change_kvm_default("kvm-msi-ext-dest-id", "on");
}
--
MST
- [PULL 38/91] tests/acpi: q35: Allow addition of a CXL test., (continued)
- [PULL 38/91] tests/acpi: q35: Allow addition of a CXL test., Michael S. Tsirkin, 2022/05/16
- [PULL 40/91] tests/acpi: Add tables for CXL emulation., Michael S. Tsirkin, 2022/05/16
- [PULL 41/91] qtest/cxl: Add more complex test cases with CFMWs, Michael S. Tsirkin, 2022/05/16
- [PULL 42/91] docs/cxl: Add initial Compute eXpress Link (CXL) documentation., Michael S. Tsirkin, 2022/05/16
- [PULL 43/91] vhost: Track descriptor chain in private at SVQ, Michael S. Tsirkin, 2022/05/16
- [PULL 44/91] vhost: Fix device's used descriptor dequeue, Michael S. Tsirkin, 2022/05/16
- [PULL 45/91] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base, Michael S. Tsirkin, 2022/05/16
- [PULL 48/91] vhost: Fix element in vhost_svq_add failure, Michael S. Tsirkin, 2022/05/16
- [PULL 47/91] hw/virtio: Replace g_memdup() by g_memdup2(), Michael S. Tsirkin, 2022/05/16
- [PULL 46/91] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Michael S. Tsirkin, 2022/05/16
- [PULL 49/91] target/i386: Fix sanity check on max APIC ID / X2APIC enablement,
Michael S. Tsirkin <=
- [PULL 50/91] intel_iommu: Support IR-only mode without DMA translation, Michael S. Tsirkin, 2022/05/16
- [PULL 51/91] intel_iommu: Only allow interrupt remapping to be enabled if it's supported, Michael S. Tsirkin, 2022/05/16
- [PULL 52/91] intel_iommu: Fix irqchip / X2APIC configuration checks, Michael S. Tsirkin, 2022/05/16
- [PULL 53/91] intel-iommu: remove VTD_FR_RESERVED_ERR, Michael S. Tsirkin, 2022/05/16
- [PULL 54/91] intel-iommu: block output address in interrupt address range, Michael S. Tsirkin, 2022/05/16
- [PULL 55/91] intel-iommu: update root_scalable before switching as during post_load, Michael S. Tsirkin, 2022/05/16
- [PULL 56/91] intel-iommu: update iq_dw during post load, Michael S. Tsirkin, 2022/05/16
- [PULL 57/91] vhost_net: Print feature masks in hex, Michael S. Tsirkin, 2022/05/16
- [PULL 60/91] hw/virtio: add vhost_user_[read|write] trace points, Michael S. Tsirkin, 2022/05/16
- [PULL 58/91] hw/virtio: move virtio-pci.h into shared include space, Michael S. Tsirkin, 2022/05/16