qemu-kvm/kvm-x86-lpc9-let-firmware-negotiate-CPU-hotplug-with-SMI.patch
Danilo C. L. de Paula 88e6244f97 * Thu Oct 08 2020 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 5.1.0-13.el8_3
- kvm-x86-lpc9-let-firmware-negotiate-CPU-hotplug-with-SMI.patch [bz#1846886]
- kvm-x86-cpuhp-prevent-guest-crash-on-CPU-hotplug-when-br.patch [bz#1846886]
- kvm-x86-cpuhp-refuse-cpu-hot-unplug-request-earlier-if-n.patch [bz#1846886]
- Resolves: bz#1846886
  (Guest hit soft lockup or reboots if hotplug vcpu under ovmf)
2020-10-08 16:47:39 -04:00

111 lines
4.3 KiB
Diff

From e2d32096071d7175d11b444db80e25709d6bf3d4 Mon Sep 17 00:00:00 2001
From: Igor Mammedov <imammedo@redhat.com>
Date: Mon, 5 Oct 2020 15:27:01 -0400
Subject: [PATCH 1/3] x86: lpc9: let firmware negotiate 'CPU hotplug with SMI'
features
RH-Author: Igor Mammedov <imammedo@redhat.com>
Message-id: <20201005152703.1555401-2-imammedo@redhat.com>
Patchwork-id: 98549
O-Subject: [RHEL-AV-8.3.0 qemu-kvm PATCH 1/3] x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
Bugzilla: 1846886
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1846886
BRANCH: rhel-av-8.3.0
UPSTREAM: Merged
BREW: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=31759628
Upstream commit: 00dc02d284ea
It will allow firmware to notify QEMU that firmware requires SMI
being triggered on CPU hot[un]plug, so that it would be able to account
for hotplugged CPU and relocate it to new SMM base and/or safely remove
CPU on unplug.
Using negotiated features, follow up patches will insert SMI upcall
into AML code, to make sure that firmware processes hotplug before
guest OS would attempt to use new CPU.
Conflicts:
hw/i386/pc.c
move x-smi-cpu-hotplug chunk from missing pc_compat_5_1[] compat props
to pc_rhel_compat[] to disable cpu hotplug for [ovmf+smi] config
(should be moved to versioned q35 machine type later, when RHEL gets
complete feature and we decide to support it downstream)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200923094650.1301166-2-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/i386/pc.c | 2 ++
hw/isa/lpc_ich9.c | 13 +++++++++++++
include/hw/i386/ich9.h | 2 ++
3 files changed, 17 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index ac2cc79fca2..6e0a3f391b0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -358,6 +358,8 @@ GlobalProperty pc_rhel_compat[] = {
{ TYPE_X86_CPU, "vmx-exit-load-perf-global-ctrl", "off" },
/* bz 1508330 */
{ "vfio-pci", "x-no-geforce-quirks", "on" },
+ /* BZ 1846886 */
+ { "ICH9-LPC", "x-smi-cpu-hotplug", "off" },
};
const size_t pc_rhel_compat_len = G_N_ELEMENTS(pc_rhel_compat);
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index cd6e169d47a..19f32bed3e9 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -373,6 +373,15 @@ static void smi_features_ok_callback(void *opaque)
/* guest requests invalid features, leave @features_ok at zero */
return;
}
+ if (!(guest_features & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT)) &&
+ guest_features & (BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT) |
+ BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT))) {
+ /*
+ * cpu hot-[un]plug with SMI requires SMI broadcast,
+ * leave @features_ok at zero
+ */
+ return;
+ }
/* valid feature subset requested, lock it down, report success */
lpc->smi_negotiated_features = guest_features;
@@ -747,6 +756,10 @@ static Property ich9_lpc_properties[] = {
DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true),
DEFINE_PROP_BIT64("x-smi-broadcast", ICH9LPCState, smi_host_features,
ICH9_LPC_SMI_F_BROADCAST_BIT, true),
+ DEFINE_PROP_BIT64("x-smi-cpu-hotplug", ICH9LPCState, smi_host_features,
+ ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT, true),
+ DEFINE_PROP_BIT64("x-smi-cpu-hotunplug", ICH9LPCState, smi_host_features,
+ ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT, false),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
index a98d10b252d..d1bb3f7bf0e 100644
--- a/include/hw/i386/ich9.h
+++ b/include/hw/i386/ich9.h
@@ -247,5 +247,7 @@ typedef struct ICH9LPCState {
/* bit positions used in fw_cfg SMI feature negotiation */
#define ICH9_LPC_SMI_F_BROADCAST_BIT 0
+#define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT 1
+#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT 2
#endif /* HW_ICH9_H */
--
2.27.0