From: "Oliver Steffen" <osteffen@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Jordan Justen <jordan.l.justen@intel.com>,
Pawel Polawski <ppolawsk@redhat.com>,
Jiewen Yao <jiewen.yao@intel.com>
Subject: Re: [PATCH v2 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: refine flash detection
Date: Thu, 1 Jun 2023 01:22:31 -0700 [thread overview]
Message-ID: <CA+bRGFpa_3fRAchE7OcxQVd344BAp0cGnSL0GuFVZgPro3mQtA@mail.gmail.com> (raw)
In-Reply-To: <20230601060803.183520-1-kraxel@redhat.com>
Quoting Gerd Hoffmann (2023-06-01 08:08:03)
> Flash can be write-protected in qemu (which is usually the case for
> code). In case the variable store flash block is configured read-only
> ovmf wouldn't be able to store EFI variables there, so not setting up
> fvb in that case (and fallhack to emulation) is the better option.
I like the term "fallhack", I'll keep that in mind for future use >,<
> It'll avoid problems later due to flash writes failing.
>
> The patch tries to write back the original value read earlier, so flash
> content doesn't change in case the write succeeds. But the status we
> read back after the attempt to write will tell us whenever flash is
> writable or not.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> index 54f859de9ff9..a577aea55614 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> @@ -114,9 +114,17 @@ QemuFlashDetected (
> DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as RAM\n"));
> *Ptr = OriginalUint8;
> } else if (ProbeUint8 == CLEARED_ARRAY_STATUS) {
> - DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH\n"));
> - FlashDetected = TRUE;
> - *Ptr = READ_ARRAY_CMD;
> + *Ptr = WRITE_BYTE_CMD;
> + *Ptr = OriginalUint8;
> + *Ptr = READ_STATUS_CMD;
> + ProbeUint8 = *Ptr;
> + *Ptr = READ_ARRAY_CMD;
> + if (ProbeUint8 & 0x10 /* programming error */) {
> + DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, write-protected\n"));
> + } else {
> + DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, writable\n"));
> + FlashDetected = TRUE;
> + }
> }
> }
>
> --
> 2.40.1
>
- Oliver
next prev parent reply other threads:[~2023-06-01 8:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 6:08 [PATCH v2 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: refine flash detection Gerd Hoffmann
2023-06-01 8:22 ` Oliver Steffen [this message]
2023-06-01 9:07 ` 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=CA+bRGFpa_3fRAchE7OcxQVd344BAp0cGnSL0GuFVZgPro3mQtA@mail.gmail.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