Page MenuHomeFreeBSD

stand: fallback to hob list search to locate FDT
Needs ReviewPublic

Authored by zhaoxiaoqiang007_gmail.com on Sat, Sep 26, 2:35 PM.
Tags
None
Referenced Files
F173591054: D60045.id187747.diff
Sun, Sep 27, 1:14 AM
F173589551: D60045.diff
Sun, Sep 27, 12:59 AM
F173588875: D60045.diff
Sun, Sep 27, 12:53 AM
F173579884: D60045.id187747.diff
Sat, Sep 26, 11:32 PM
F173558830: D60045.diff
Sat, Sep 26, 8:33 PM
Subscribers

Details

Summary

Some firmware (e.g. the EDK2 ArmVirt and LoongArch platforms) does not
publish the device tree as a FDT_TABLE_GUID configuration table. Instead
a copy of the FDT is reachable through a FDT_HOB_GUID HOB on the HOB list,
which the firmware publishes as a configuration table of its own. Walk
the HOB list and return the FDT address if it is found there.

Signed-off-by: Xiaoqiang Zhao <zhaoxiaoqiang007@gmail.com>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77373
Build 74256: arc lint + arc unit

Event Timeline

sys/contrib/edk2/Include/Guid/HobList.h
22–25

HOB_LIST_GUID the exact same GUID as the existing HOB_LIST_TABLE_GUID workaround in stand/efi/loader/main.c (and the same as gEfiHobListGuid in MdePkg.dec). The main.c copy a // XXX EDK2 doesn't... workaround that is no longer needed now that you are adding the official EDK2 header. Please remove the local definition and use HOB_LIST_GUID everywhere.

--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -53,6 +53,7 @@
 
 #include <Guid/DebugImageInfoTable.h>
 #include <Guid/DxeServices.h>
+#include <Guid/HobList.h>
 #include <Guid/Mps.h>
 #include <Guid/SmBios.h>
 #include <Protocol/Rng.h>
@@ -94,8 +95,6 @@ struct arch_switch archsw = { /* MI/MD interface boundary */
 
 // XXX These are from ???? Maybe ACPI which needs to define them?
 // XXX EDK2 doesn't (or didn't as of Feb 2025)
-#define HOB_LIST_TABLE_GUID \
-    { 0x7739f24c, 0x93d7, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
 #define LZMA_DECOMPRESSION_GUID \
        { 0xee4e5898, 0x3914, 0x4259, {0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x3, 0xcf} }
 #define ARM_MP_CORE_INFO_TABLE_GUID \
@@ -114,7 +113,7 @@ EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
 EFI_GUID smbios = SMBIOS_TABLE_GUID;
 EFI_GUID smbios3 = SMBIOS3_TABLE_GUID;
 EFI_GUID dxe = DXE_SERVICES_TABLE_GUID;
-EFI_GUID hoblist = HOB_LIST_TABLE_GUID;
+EFI_GUID hoblist = HOB_LIST
 EFI_GUID lzmadecomp = LZMA_DECOMPRESSION_GUID;
 EFI_GUID mpcore = ARM_MP_CORE_INFO_TABLE_GUID;
 EFI_GUID esrt = ESRT_TABLE_GUID;
stand/efi/libefi/libefi.c
55

hob advances by hob->HobLength, HobLength is firmware-provided and never validated. A malformed HOB with HobLength == 0 causes this loop to spin forever.
minimal length check can be added at the start of the while loop:

		if (hob->HobLength < sizeof(EFI_HOB_GENERIC_HEADER))
			return (NULL);