public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Andrew Fish <afish@apple.com>, devel@edk2.groups.io
Cc: wuchenye1995 <wuchenye1995@gmail.com>,
	zhoujianjay <zhoujianjay@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	berrange@redhat.com,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	qemu-devel@nongnu.org, discuss <discuss@edk2.groups.io>
Subject: Re: [edk2-devel] A problem with live migration of UEFI virtual machines
Date: Fri, 28 Feb 2020 12:47:08 +0100	[thread overview]
Message-ID: <2e3771cf-089c-aecd-49a7-3034a30fc443@redhat.com> (raw)
In-Reply-To: <284BFC25-8534-4147-8616-DE7C410DB681@apple.com>

On 02/28/20 05:04, Andrew Fish wrote:

> Maybe I was overcomplicating this. Given your explanation I think the part I'm missing is OVMF is implying FLASH layout, in this split model, based on the size of the OVMF_CODE.fd and OVMF_VARS.fd.  Given that if OVMF_CODE.fd gets bigger the variable address changes from a QEMU point of view. So basically it is the QEMU  API that is making assumptions about the relative layout of the FD in the split model that makes a migration to larger ROM not work.

No, QEMU does not make any assumptions here. QEMU simply grabs both
pflash chips (the order is not random, it can be specified on the
command line -- in fact the QEMU user is expected to specify in the
right order), and then QEMU maps them in decreasing address order from
4GB in guest-phys address space.

If we enlarge OVMF_CODE.fd, then the base address of the varstore
(PcdOvmfFlashNvStorageVariableBase) will sink. That's not a problem per
se, because QEMU doesn't know about PcdOvmfFlashNvStorageVariableBase at
all. QEMU will simply map the varstore, automatically, where the
enlarged OVMF_CODE.fd will look for it.

> Basically the -pflash API does not support changing the size of the ROM without moving NVRAM given the way it is currently defined.

Let me put it like this: the NVRAM gets moved by virtue of how OVMF is
built, and by how QEMU maps the pflash chips into guest-phys address
space. They are in sync, automatically.

The problem is when the NVRAM is internally restructured, or resized --
the new OVMF_CODE.fd binary will reflect this with changed PCDs, and
look for "stuff" at those addresses. But if you still try to use an old
(differently sized, or differently structured) varstore file, while QEMU
will happily map it, parts of the NVRAM will just not end up in places
where OVMF_CODE.fd expects them.

> 
> Given the above it seems like the 2 options are:
> 1) Pad OVMF_CODE.fd to be very large so there is room to grow.

There's already room to grow, *inside* OVMF_CODE.fd. As I've shown
elsewhere in this thread, even the 2MB build has approx. 457 KB free in
the DXEFV volume, even without link-time optimization and without
DEBUG/ASSERT stripping, if you don't enable additional features.

> 2) Add some feature to QUEM that allows the variable store address to not be based on OVMF_CODE.fd size. 

Yes, this has been proposed over time.

It wouldn't help with the case when you change the internal structure of
the NVRAM, and try to run an incompatible OVMF_CODE.fd against that.

> I did see this [1] and combined with your email I either understand, or I'm still confused? :)
> 
> I'm not saying we need to change anything, I'm just trying to make sure I understand how OVMF and QEMU are tied to together. 

I think the most interesting function for you could be
pc_system_flash_map(), in "hw/i386/pc_sysfw.c", in the QEMU source.

> 
> [1] https://www.redhat.com/archives/libvir-list/2019-January/msg01031.html


Thanks
Laszlo


  reply	other threads:[~2020-02-28 11:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 17:06 A problem with live migration of UEFI virtual machines "wuchenye1995
2020-02-11 17:39 ` Alex Bennée
2020-02-24 15:28   ` Daniel P. Berrangé
2020-02-25 17:53     ` [edk2-devel] " Laszlo Ersek
2020-02-25 18:56       ` Andrew Fish
2020-02-25 20:40         ` Laszlo Ersek
2020-02-25 21:35           ` Andrew Fish
2020-02-26  9:42             ` Laszlo Ersek
2020-02-28  3:20               ` Zhoujian (jay)
2020-02-28 11:29                 ` Laszlo Ersek
2020-02-28  4:04               ` Andrew Fish
2020-02-28 11:47                 ` Laszlo Ersek [this message]
2020-02-28 11:50                   ` Laszlo Ersek
2020-03-02 12:32               ` Dr. David Alan Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2020-02-10  4:39 wuchenye1995
2020-02-10 20:20 ` [edk2-devel] " Laszlo Ersek

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=2e3771cf-089c-aecd-49a7-3034a30fc443@redhat.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