From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: MP services reports incorrect number of CPUs under QEMU without KVM To: devel@edk2.groups.io From: nicholasbishop@gmail.com X-Originating-Location: Brooklyn, New York, US (70.23.88.86) X-Originating-Platform: Linux Firefox 96 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Sat, 05 Mar 2022 12:33:17 -0800 Message-ID: Content-Type: multipart/alternative; boundary="gUuRzue4A64jTpvNHQNk" --gUuRzue4A64jTpvNHQNk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable When using EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors to get the number= of processors, I've found that when running in QEMU I only get the correct= value if KVM is enabled. If KVM is disabled, the number of processors is a= lways reported as 1. With debug logging enabled, I noticed a difference in the output from MaxCp= uCountInitialization. With `-enable-kvm -smp 4` it logs this: MaxCpuCountInitialization: BootCpuCount=3D4 mMaxCpuCount=3D4 But with just `-smp 4`, it logs this: MaxCpuCountInitialization: QEMU v2.7 reset bug: BootCpuCount=3D4 Present=3D= 0 MaxCpuCountInitialization: BootCpuCount=3D0 mMaxCpuCount=3D1 I'm not sure if this indicates a bug in QEMU or OVMF. Incidentally the "QEM= U v2.7" is hardcoded in OvmfPkg/PlatformPei/Platform.c, I'm actually testin= g under QEMU 6.1.0. Test code: https://github.com/nicholasbishop/edk2/blob/af920578e822cdeef020= 4e39df560f4a1f4bb537/Bug/Bug.c --gUuRzue4A64jTpvNHQNk Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable When using EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors to get the number= of processors, I've found that when running in QEMU I only get the correct= value if KVM is enabled. If KVM is disabled, the number of processors is a= lways reported as 1.

With debug logging enabled, I noticed a dif= ference in the output from MaxCpuCountInitialization.

With `-ena= ble-kvm -smp 4` it logs this:
MaxCpuCountInitialization: BootCpuCount= =3D4 mMaxCpuCount=3D4

But with just `-smp 4`, it logs this:
MaxCpuCountInitialization: QEMU v2.7 reset bug: BootCpuCount=3D4 Present= =3D0
MaxCpuCountInitialization: BootCpuCount=3D0 mMaxCpuCount=3D1

I'm not sure if this indicates a bug in QEMU or OVMF. Incidentally t= he "QEMU v2.7" is hardcoded in OvmfPkg/PlatformPei/Platform.c, I'm actually= testing under QEMU 6.1.0.

Test code: https://github.com/nichola= sbishop/edk2/blob/af920578e822cdeef0204e39df560f4a1f4bb537/Bug/Bug.c --gUuRzue4A64jTpvNHQNk--