Hi,
after upgrading to edk2-stable202211 recently, we got user reports[0]
about QEMU virtual machines with '-cpu host' on AMD Ryzen hosts not
booting correctly anymore. A workaround seems to be assigning more
memory to the VM.

I was able to reproduce the issue locally (with QEMU 7.2 and an Ubuntu
20.04 VM, kernel 5.15) and bisecting led me to this patch, i.e. commit
bbda386d25 ("OvmfPkg/PlatformInitLib: detect physical address space"),
as the first bad one.

With edk2-stable202205 or when reverting the commit, my VM boots with
only 512 MiB of assigned memory. With the commit, with 512 MiB it cannot
even initialize the display, with 750 MiB it runs into a different error
during Linux boot, and with 900 MiB it boots fine again.

So it seems that having a larger PhysMemAddressWidth requires more
memory? Is this expected and does running VMs with this version simply
require more memory now? Is there a way to avoid that?

Happy to provide additional information if needed!

Best Regards,
Fiona

[0]: https://forum.proxmox.com/threads/124193/
[1]: host CPU model: AMD Ryzen Threadripper 2920X 12-Core Processor
[2]: QEMU command line:
> ./qemu-system-x86_64 \
>   -accel 'kvm' \
>   -chardev 
> 'socket,id=qmp,path=/var/run/qemu-server/141.qmp,server=on,wait=off' \
>   -mon 'chardev=qmp,mode=control' \
>   -pidfile /var/run/qemu-server/141.pid \
>   -drive 
> 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE_4M.fd'
>  \
>   -drive 
> 'if=pflash,unit=1,id=drive-efidisk0,cache=writeback,format=raw,file=rbd:rbdkvm/vm-141-disk-1:conf=/etc/pve/ceph.conf:id=admin:keyring=/etc/pve/priv/ceph/rbdkvm.keyring:rbd_cache_policy=writeback,size=540672'
>  \
>   -smp '1,sockets=1,cores=1,maxcpus=1' \
>   -vnc 'unix:/var/run/qemu-server/141.vnc,password=on' \
>   -cpu host \
>   -m 512 \
>   -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
>   -device 'pci-bridge,id=pci.3,chassis_nr=3,bus=pci.0,addr=0x5' \
>   -device 'VGA,id=vga,bus=pci.1,addr=0x2' \
>   -device 'virtio-scsi-pci,id=virtioscsi0,bus=pci.3,addr=0x1' \
>   -drive 
> 'file=rbd:rbdkvm/vm-141-disk-0:conf=/etc/pve/ceph.conf:id=admin:keyring=/etc/pve/priv/ceph/rbdkvm.keyring,if=none,id=drive-scsi0,format=raw,cache=none,aio=io_uring,detect-zeroes=on'
>  \
>   -device 
> 'scsi-hd,bus=virtioscsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,bootindex=100'
>  \
>   -machine 'type=pc'


Am 04.10.22 um 15:47 schrieb Gerd Hoffmann:
> Try detect physical address space, when successful use it.
> Otherwise go continue using the current guesswork code path.
> 
> Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
> ---
>  OvmfPkg/Library/PlatformInitLib/MemDetect.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c 
> b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> index 143a01ceb01e..16ecbfadc30c 100644
> --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> @@ -761,6 +761,19 @@ PlatformAddressWidthInitialization (
>      FirstNonAddress = PlatformGetFirstNonAddress (PlatformInfoHob);
>    }
>  
> +  PlatformAddressWidthFromCpuid (PlatformInfoHob, TRUE);
> +  if (PlatformInfoHob->PhysMemAddressWidth != 0) {
> +    // physical address width is known
> +    PlatformInfoHob->FirstNonAddress = FirstNonAddress;
> +    return;
> +  }
> +
> +  //
> +  // physical address width is NOT known
> +  //   -> do some guess work, mostly based on installed memory
> +  //   -> try be conservstibe to stay below the guaranteed minimum of
> +  //      36 phys bits (aka 64 GB).
> +  //
>    PhysMemAddressWidth = (UINT8)HighBitSet64 (FirstNonAddress);
>  
>    //



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101282): https://edk2.groups.io/g/devel/message/101282
Mute This Topic: https://groups.io/mt/94113631/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to