public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: devel@edk2.groups.io, dbautista@newmexicoconsortium.org,
	David Edmondson <david.edmondson@oracle.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Leif Lindholm <leif@nuviainc.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg: Introduce 16MiB flash size for (primarily) Linuxboot
Date: Thu, 9 Sep 2021 14:10:11 +0200	[thread overview]
Message-ID: <20210909121011.alq44s4nboupo4nk@sirius.home.kraxel.org> (raw)
In-Reply-To: <00c6bca1-a715-0fee-799c-705ef9a9a7bd@redhat.com>

  Hi,

> * Why is QEMU using 2 flashes (CODE & DATA)?
> 
>   My historical understanding is when OVMF was started, QEMU flash
>   model was not supporting sector/bank (write/erase) protection.
> 
>   OVMF requirements were:
>   - CODE section ("secure", not modifiable by the guest)
>   - DATA section (modifiable)
> 
>   The easier way to get the CODE secure is to use different devices,
>   one enforced in "read-only" mode.

Matches my understanding.

>   Being a firmware for virtualized guests, it makes no sense to have
>   the guest upgrade the CODE: it is error-prone, and cheaper to do
>   directly on the host, rebooting the guest.

Having separate binaries also simplifies the host-side firmware update,
you can easily update CODE for all guests while the keeping per-guest
VARS file.

> * Why not use a ROM for the CODE section and flash for the DATA one?
> 
>   This is not clear to me. I suppose the firmware wanted to be able
>   to poll the hardware size, and the pflash allow that with CFI I/O
>   requests?

Size and mapping location are compile-time constants, I don't think ovmf
talks to the pflash to figure the size.

> * Could we replace the CODE pflash by a ROM device?
> 
>   QEMU provides the -fw_cfg device and versioned machines. To the best
>   of my knowledge it seems doable, with careful modifications in OVMF
>   and ArmVirt.

I think ovmf doesn't care.  It'll be more of an issue for qemu, IIRC the
pflash driver has some code to automagically place code and vars at the
correct location, but that'll require both parts of the firmware being
flash.  Might be easier to teach the pflash device to just map read-only
flash like a rom.

If you don't need persistent vars you can also try "-bios OVMF.fd".

> * Is there similar problems with DATA section?
> 
>   The biggest problem is the memory waste, the pflash model was
>   designed to be executable, modifiable, and as fast as possible
>   (for execution). This is achieved by copying the whole flash
>   content in an internal buffer. For DATA flash this is no speed
>   gain but high memory penalty.

Hmm, isn't that long solved?  IIRC kvm memslots can be configured to
only trap on writes since years.  Or is that something unrelated?

[ Disclaimer: I don't know much about the pflash internals ]

take care,
  Gerd


  reply	other threads:[~2021-09-09 12:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  5:26 [PATCH v2 0/1] OVMF: Introduce 16MiB Flash Size Devon Bautista
2021-09-03  5:26 ` [PATCH v2 1/1] OvmfPkg: Introduce 16MiB flash size for (primarily) Linuxboot Devon Bautista
2021-09-03  7:17   ` Gerd Hoffmann
2021-09-03 19:35     ` Devon Bautista
2021-09-06  8:37       ` Gerd Hoffmann
2021-09-07  0:55         ` Devon Bautista
2021-09-09  9:09   ` [edk2-devel] " Philippe Mathieu-Daudé
2021-09-09 12:10     ` Gerd Hoffmann [this message]
2021-10-19 23:03     ` Devon Bautista

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=20210909121011.alq44s4nboupo4nk@sirius.home.kraxel.org \
    --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