public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: f.ebner@proxmox.com
To: Gerd Hoffmann <kraxel@redhat.com>, devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Pawel Polawski <ppolawsk@redhat.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Oliver Steffen <osteffen@redhat.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: Re: [PATCH v2 2/4] OvmfPkg/PlatformInitLib: detect physical address space
Date: Thu, 16 Mar 2023 14:58:07 +0100	[thread overview]
Message-ID: <5259991b-964c-4378-f206-9991053f7c7e@proxmox.com> (raw)
In-Reply-To: <20221004134728.55499-3-kraxel@redhat.com>

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 <kraxel@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);
>  
>    //


  reply	other threads:[~2023-03-16 13:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 13:47 [PATCH v2 0/4] OvmfPkg: make better use of physical address space Gerd Hoffmann
2022-10-04 13:47 ` [PATCH v2 1/4] OvmfPkg/PlatformInitLib: qemu cpuid physbits detection Gerd Hoffmann
2022-10-04 13:47 ` [PATCH v2 2/4] OvmfPkg/PlatformInitLib: detect physical address space Gerd Hoffmann
2023-03-16 13:58   ` f.ebner [this message]
2023-03-16 14:37     ` Gerd Hoffmann
2023-03-17 11:34       ` [edk2-devel] " Fiona Ebner
2023-03-17 14:01     ` Gerd Hoffmann
2023-03-20 14:20       ` Fiona Ebner
2023-03-20 15:58         ` Gerd Hoffmann
2022-10-04 13:47 ` [PATCH v2 3/4] OvmfPkg/PlatformInitLib: dynamic mmio window size Gerd Hoffmann
2023-03-15  8:54   ` [edk2-devel] " joeyli
2023-03-15  9:28     ` Gerd Hoffmann
2023-05-16 14:00   ` Fiona Ebner
2023-05-17  5:59     ` [edk2-devel] " Gerd Hoffmann
2023-05-17 13:38       ` Fiona Ebner
2023-05-22 11:12         ` Gerd Hoffmann
2023-05-22 13:36           ` Fiona Ebner
2022-10-04 13:47 ` [PATCH v2 4/4] OvmfPkg/PciHotPlugInitDxe: reserve more mmio space Gerd Hoffmann
2022-10-04 15:57   ` Laszlo Ersek
2022-10-05  5:01     ` Gerd Hoffmann
2022-10-06  8:50       ` Laszlo Ersek
2022-10-07 21:49 ` [edk2-devel] [PATCH v2 0/4] OvmfPkg: make better use of physical address space Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5259991b-964c-4378-f206-9991053f7c7e@proxmox.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox