* [PATCH 1/2] OvmfPkg/QemuBootOrderLib: allow slash in rom filenames
2022-09-21 5:30 [PATCH 0/2] OvmfPkg/QemuBootOrderLib: StoreQemuBootOrder bugfix Gerd Hoffmann
@ 2022-09-21 5:30 ` Gerd Hoffmann
2022-09-21 5:30 ` [PATCH 2/2] OvmfPkg/QemuBootOrderLib: skip over unsupported entries in StoreQemuBootOrder Gerd Hoffmann
2022-09-28 10:49 ` [PATCH 0/2] OvmfPkg/QemuBootOrderLib: StoreQemuBootOrder bugfix Ard Biesheuvel
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2022-09-21 5:30 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Gerd Hoffmann, Oliver Steffen, Ard Biesheuvel,
Pawel Polawski, Jiewen Yao
See comment for details. Needed to avoid the parser abort,
so we can continue parsing the bootorder fw_cfg file.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
.../QemuBootOrderLib/QemuBootOrderLib.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 398de7fab4ba..374c6d8f5e91 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -432,6 +432,8 @@ ParseOfwNode (
OUT BOOLEAN *IsFinal
)
{
+ BOOLEAN AcceptSlash = FALSE;
+
//
// A leading slash is expected. End of string is tolerated.
//
@@ -464,6 +466,21 @@ ParseOfwNode (
return RETURN_INVALID_PARAMETER;
}
+ if (SubstringEq (OfwNode->DriverName, "rom")) {
+ //
+ // bug compatibility hack
+ //
+ // qemu passes fw_cfg filenames as rom unit address.
+ // The filenames have slashes:
+ // /rom@genroms/linuxboot_dma.bin
+ //
+ // Alow slashes in the unit address to avoid the parser trip up,
+ // so we can successfully parse the following lines (the rom
+ // entries themself are ignored).
+ //
+ AcceptSlash = TRUE;
+ }
+
//
// unit-address
//
@@ -475,7 +492,7 @@ ParseOfwNode (
OfwNode->UnitAddress.Ptr = *Ptr;
OfwNode->UnitAddress.Len = 0;
- while (IsPrintNotDelim (**Ptr)) {
+ while (IsPrintNotDelim (**Ptr) || (AcceptSlash && **Ptr == '/')) {
++*Ptr;
++OfwNode->UnitAddress.Len;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] OvmfPkg/QemuBootOrderLib: skip over unsupported entries in StoreQemuBootOrder
2022-09-21 5:30 [PATCH 0/2] OvmfPkg/QemuBootOrderLib: StoreQemuBootOrder bugfix Gerd Hoffmann
2022-09-21 5:30 ` [PATCH 1/2] OvmfPkg/QemuBootOrderLib: allow slash in rom filenames Gerd Hoffmann
@ 2022-09-21 5:30 ` Gerd Hoffmann
2022-09-28 10:49 ` [PATCH 0/2] OvmfPkg/QemuBootOrderLib: StoreQemuBootOrder bugfix Ard Biesheuvel
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2022-09-21 5:30 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Gerd Hoffmann, Oliver Steffen, Ard Biesheuvel,
Pawel Polawski, Jiewen Yao
When finding an unsupported entry just skip over and continue
with the next entry instead of stop processing altogether.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
.../QemuBootOrderLib/QemuBootOrderLib.c | 56 ++++++++++---------
1 file changed, 30 insertions(+), 26 deletions(-)
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
index 374c6d8f5e91..18646daa67e3 100644
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
@@ -1775,35 +1775,39 @@ StoreQemuBootOrder (
Translated,
&TranslatedSize
);
- while (!RETURN_ERROR (Status)) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ while (Status == EFI_SUCCESS ||
+ Status == EFI_UNSUPPORTED)
+ {
+ if (Status == EFI_SUCCESS) {
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- //
- // Convert the UEFI devpath prefix to binary representation.
- //
- ASSERT (Translated[TranslatedSize] == L'\0');
- DevicePath = ConvertTextToDevicePath (Translated);
- if (DevicePath == NULL) {
- Status = RETURN_OUT_OF_RESOURCES;
- goto FreeExtraPciRoots;
+ //
+ // Convert the UEFI devpath prefix to binary representation.
+ //
+ ASSERT (Translated[TranslatedSize] == L'\0');
+ DevicePath = ConvertTextToDevicePath (Translated);
+ if (DevicePath == NULL) {
+ Status = RETURN_OUT_OF_RESOURCES;
+ goto FreeExtraPciRoots;
+ }
+
+ UnicodeSPrint (
+ VariableName,
+ sizeof (VariableName),
+ L"QemuBootOrder%04d",
+ VariableIndex++
+ );
+ DEBUG ((DEBUG_INFO, "%a: %s = %s\n", __FUNCTION__, VariableName, Translated));
+ gRT->SetVariable (
+ VariableName,
+ &gQemuBootOrderGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ GetDevicePathSize (DevicePath),
+ DevicePath
+ );
+ FreePool (DevicePath);
}
- UnicodeSPrint (
- VariableName,
- sizeof (VariableName),
- L"QemuBootOrder%04d",
- VariableIndex++
- );
- DEBUG ((DEBUG_INFO, "%a: %s = %s\n", __FUNCTION__, VariableName, Translated));
- gRT->SetVariable (
- VariableName,
- &gQemuBootOrderGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- GetDevicePathSize (DevicePath),
- DevicePath
- );
- FreePool (DevicePath);
-
//
// Move to the next OFW devpath.
//
--
2.37.3
^ permalink raw reply related [flat|nested] 4+ messages in thread