From cfcef96bb3c63342d4fb87cf0cda8e9dcaef9b2b Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 16 Jan 2024 18:11:04 +0100 Subject: [PATCH 5/6] OvmfPkg/VirtNorFlashDxe: ValidateFvHeader: unwritten state is EOL too RH-Author: Gerd Hoffmann RH-MergeRequest: 52: OvmfPkg/VirtNorFlashDxe: backport more fixes. RH-Jira: RHEL-20963 RH-Acked-by: Laszlo Ersek RH-Acked-by: Miroslav Rezanina RH-Commit: [5/6] 24a9f2d03eeaf61ea8f0ea5a40f0921994b08688 (kraxel.rh/centos-src-edk2) It is possible to find variable entries with State being 0xff, i.e. not updated since flash block erase. This indicates the variable driver could not complete the header write while appending a new entry, and therefore State was not set to VAR_HEADER_VALID_ONLY. This can only happen at the end of the variable list, so treat this as additional "end of variable list" condition. Signed-off-by: Gerd Hoffmann Reviewed-by: Laszlo Ersek Message-Id: <20240116171105.37831-6-kraxel@redhat.com> (cherry picked from commit 735d0a5e2e25c1577bf9bea7826da937ca38169d) --- OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c index 8fcd999ac6..c8b5e0be13 100644 --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c @@ -302,6 +302,11 @@ ValidateFvHeader ( break; } + if (VarHeader->State == 0xff) { + DEBUG ((DEBUG_INFO, "%a: end of var list (unwritten state)\n", __func__)); + break; + } + VarName = NULL; switch (VarHeader->State) { // usage: State = VAR_HEADER_VALID_ONLY -- 2.39.3