* 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)
This commit is contained in:
Danilo C. L. de Paula 2020-10-08 16:47:39 -04:00
parent a7bf1d2d7c
commit 88e6244f97
4 changed files with 291 additions and 1 deletions

View File

@ -0,0 +1,99 @@
From 98eced5d367a6a69006cab1ea2b77c2c2622694a Mon Sep 17 00:00:00 2001
From: Igor Mammedov <imammedo@redhat.com>
Date: Mon, 5 Oct 2020 15:27:02 -0400
Subject: [PATCH 2/3] x86: cpuhp: prevent guest crash on CPU hotplug when
broadcast SMI is in use
RH-Author: Igor Mammedov <imammedo@redhat.com>
Message-id: <20201005152703.1555401-3-imammedo@redhat.com>
Patchwork-id: 98550
O-Subject: [RHEL-AV-8.3.0 qemu-kvm PATCH 2/3] x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is in use
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: c5be7517d658
There were reports of guest crash on CPU hotplug, when using q35 machine
type and OVMF with SMM, due to hotplugged CPU trying to process SMI at
default SMI handler location without it being relocated by firmware first.
Fix it by refusing hotplug if firmware hasn't negotiated CPU hotplug with
SMI support while SMI broadcast is in use.
Conflicts:
hw/i386/x86.c
cpu wiring routines were moved to x86.c upstream
to be shared with micro vm, so the second hunk
has to be put into pc_cpu_pre_plug() and s/x86ms/pcms/.
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-3-imammedo@redhat.com>
Tested-by: Laszlo Ersek <lersek@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/acpi/ich9.c | 12 +++++++++++-
hw/i386/pc.c | 11 +++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 43ad1ff9278..37286a03288 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -423,10 +423,20 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) &&
- !lpc->pm.acpi_memory_hotplug.is_enabled)
+ !lpc->pm.acpi_memory_hotplug.is_enabled) {
error_setg(errp,
"memory hotplug is not enabled: %s.memory-hotplug-support "
"is not set", object_get_typename(OBJECT(lpc)));
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+ uint64_t negotiated = lpc->smi_negotiated_features;
+
+ if (negotiated & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT) &&
+ !(negotiated & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+ error_setg(errp, "cpu hotplug with SMI wasn't enabled by firmware");
+ error_append_hint(errp, "update machine type to newer than 5.1 "
+ "and firmware that suppors CPU hotplug with SMM");
+ }
+ }
}
void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6e0a3f391b0..0332589359b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1761,6 +1761,17 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
return;
}
+ if (pcms->acpi_dev) {
+ Error *local_err = NULL;
+
+ hotplug_handler_pre_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
+ &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ }
+
init_topo_info(&topo_info, x86ms);
env->nr_dies = x86ms->smp_dies;
--
2.27.0

View File

@ -0,0 +1,68 @@
From 77c5df3ab28f294f7b21d33a2f6116b0889292ed Mon Sep 17 00:00:00 2001
From: Igor Mammedov <imammedo@redhat.com>
Date: Mon, 5 Oct 2020 15:27:03 -0400
Subject: [PATCH 3/3] x86: cpuhp: refuse cpu hot-unplug request earlier if not
supported
RH-Author: Igor Mammedov <imammedo@redhat.com>
Message-id: <20201005152703.1555401-4-imammedo@redhat.com>
Patchwork-id: 98551
O-Subject: [RHEL-AV-8.3.0 qemu-kvm PATCH 3/3] x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
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: b48ad7c02ba7
CPU hot-unplug with SMM requires firmware participation to prevent
guest crash (i.e. CPU can be removed only after OS _and_ firmware
were prepared for the action).
Previous patches introduced ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT
feature bit, which is advertised by firmware when it has support
for CPU hot-unplug. Use it to check if guest is able to handle
unplug and make device_del fail gracefully if hot-unplug feature
hasn't been negotiated.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200923094650.1301166-4-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/acpi/ich9.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 37286a03288..f6c6c6a916a 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -475,6 +475,18 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
!lpc->pm.cpu_hotplug_legacy) {
+ uint64_t negotiated = lpc->smi_negotiated_features;
+
+ if (negotiated & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT) &&
+ !(negotiated & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT))) {
+ error_setg(errp, "cpu hot-unplug with SMI wasn't enabled "
+ "by firmware");
+ error_append_hint(errp, "update machine type to a version having "
+ "x-smi-cpu-hotunplug=on and firmware that "
+ "supports CPU hot-unplug with SMM");
+ return;
+ }
+
acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp_state,
dev, errp);
} else {
--
2.27.0

View File

@ -0,0 +1,110 @@
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

View File

@ -69,7 +69,7 @@ Obsoletes: %1-rhev
Summary: QEMU is a machine emulator and virtualizer
Name: qemu-kvm
Version: 5.1.0
Release: 12%{?dist}
Release: 13%{?dist}
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
Epoch: 15
License: GPLv2 and GPLv2+ and CC-BY
@ -207,6 +207,12 @@ Patch68: kvm-vhost-vsock-pci-force-virtio-version-1.patch
Patch69: kvm-vhost-user-vsock-pci-force-virtio-version-1.patch
# For bz#1868449 - vhost_vsock error: device is modern-only, use disable-legacy=on
Patch70: kvm-vhost-vsock-ccw-force-virtio-version-1.patch
# For bz#1846886 - Guest hit soft lockup or reboots if hotplug vcpu under ovmf
Patch71: kvm-x86-lpc9-let-firmware-negotiate-CPU-hotplug-with-SMI.patch
# For bz#1846886 - Guest hit soft lockup or reboots if hotplug vcpu under ovmf
Patch72: kvm-x86-cpuhp-prevent-guest-crash-on-CPU-hotplug-when-br.patch
# For bz#1846886 - Guest hit soft lockup or reboots if hotplug vcpu under ovmf
Patch73: kvm-x86-cpuhp-refuse-cpu-hot-unplug-request-earlier-if-n.patch
BuildRequires: wget
BuildRequires: rpm-build
@ -1172,6 +1178,13 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
%changelog
* 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)
* Mon Oct 05 2020 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 5.1.0-12.el8_3
- kvm-virtio-skip-legacy-support-check-on-machine-types-le.patch [bz#1868449]
- kvm-vhost-vsock-pci-force-virtio-version-1.patch [bz#1868449]