[edk2-devel] [PATCH 1/1] OvmfPkg/PlatformInitLib: catch QEMU's CPU hotplug reg block regression
Gerd Hoffmann
kraxel at redhat.com
Thu Jan 5 13:12:56 UTC 2023
On Wed, Jan 04, 2023 at 04:12:34PM +0100, Laszlo Ersek wrote:
> In QEMU v5.1.0, the CPU hotplug register block misbehaves: the negotiation
> protocol is (effectively) broken such that it suggests that switching from
> the legacy interface to the modern interface works, but in reality the
> switch never happens. The symptom has been witnessed when using TCG
> acceleration; KVM seems to mask the issue. The issue persists with the
> following (latest) stable QEMU releases: v5.2.0, v6.2.0, v7.2.0. Currently
> there is no stable release that addresses the problem.
>
> The QEMU bug confuses the Present and Possible counting in function
> PlatformMaxCpuCountInitialization(), in
> "OvmfPkg/Library/PlatformInitLib/Platform.c". OVMF ends up with Present=0
> Possible=1. This in turn further confuses MpInitLib in UefiCpuPkg (hence
> firmware-time multiprocessing will be broken). Worse, CPU hot(un)plug with
> SMI will be summarily broken in OvmfPkg/CpuHotplugSmm, which (considering
> the privilege level of SMM) is not that great.
>
> Detect the issue in PlatformMaxCpuCountInitialization(), and print an
> error message and *hang* if the issue is present.
>
> The problem was originally reported by Ard [0]. We analyzed it at [1] and
> [2]. A QEMU patch was sent at [3].
>
> [0] https://bugzilla.tianocore.org/show_bug.cgi?id=4234#c2
>
> [1] https://bugzilla.tianocore.org/show_bug.cgi?id=4234#c3
>
> [2] IO port write width clamping differs between TCG and KVM
> http://mid.mail-archive.com/aaedee84-d3ed-a4f9-21e7-d221a28d1683@redhat.com
> https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00199.html
>
> [3] acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block
> http://mid.mail-archive.com/20230104090138.214862-1-lersek@redhat.com
> https://lists.gnu.org/archive/html/qemu-devel/2023-01/msg00278.html
>
> NOTE: PlatformInitLib is used in the following platform DSCs:
>
> OvmfPkg/AmdSev/AmdSevX64.dsc
> OvmfPkg/CloudHv/CloudHvX64.dsc
> OvmfPkg/IntelTdx/IntelTdxX64.dsc
> OvmfPkg/Microvm/MicrovmX64.dsc
> OvmfPkg/OvmfPkgIa32.dsc
> OvmfPkg/OvmfPkgIa32X64.dsc
> OvmfPkg/OvmfPkgX64.dsc
>
> but I can only test this change with the last three platforms, running on
> QEMU.
>
> Test results:
>
> TCG QEMU OVMF result
> patched patched
> --- ------- ------- -------------------------------------------------
> 0 0 0 CPU counts OK (KVM masks the QEMU bug)
> 0 0 1 CPU counts OK (KVM masks the QEMU bug)
> 0 1 0 CPU counts OK (QEMU fix, but KVM masks the QEMU
> bug anyway)
> 0 1 1 CPU counts OK (QEMU fix, but KVM masks the QEMU
> bug anyway)
> 1 0 0 boot with broken CPU counts (original QEMU bug)
> 1 0 1 broken CPU count caught (boot hangs)
> 1 1 0 CPU counts OK (QEMU fix)
> 1 1 1 CPU counts OK (QEMU fix)
>
> Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
> Cc: Brijesh Singh <brijesh.singh at amd.com>
> Cc: Erdem Aktas <erdemaktas at google.com>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: James Bottomley <jejb at linux.ibm.com>
> Cc: Jiewen Yao <jiewen.yao at intel.com>
> Cc: Jordan Justen <jordan.l.justen at intel.com>
> Cc: Min Xu <min.m.xu at intel.com>
> Cc: Sebastien Boeuf <sebastien.boeuf at intel.com>
> Cc: Tom Lendacky <thomas.lendacky at amd.com>
> Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4250
> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel at redhat.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97988): https://edk2.groups.io/g/devel/message/97988
Mute This Topic: https://groups.io/mt/96051794/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list