From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) by mx.groups.io with SMTP id smtpd.web10.12737.1678975097541495456 for ; Thu, 16 Mar 2023 06:58:18 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: proxmox.com, ip: 94.136.29.106, mailfrom: f.ebner@proxmox.com) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A1407440BF; Thu, 16 Mar 2023 14:58:14 +0100 (CET) Message-ID: <5259991b-964c-4378-f206-9991053f7c7e@proxmox.com> Date: Thu, 16 Mar 2023 14:58:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 2/4] OvmfPkg/PlatformInitLib: detect physical address space To: Gerd Hoffmann , devel@edk2.groups.io Cc: Jordan Justen , Pawel Polawski , Jiewen Yao , Oliver Steffen , Ard Biesheuvel , Thomas Lamprecht References: <20221004134728.55499-1-kraxel@redhat.com> <20221004134728.55499-3-kraxel@redhat.com> From: f.ebner@proxmox.com In-Reply-To: <20221004134728.55499-3-kraxel@redhat.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > --- > 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); > > //