summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingjie Shen <shen497@purdue.edu>2026-08-31 18:14:24 -0400
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-09-03 10:36:41 +0000
commit76132a56892aa3178697d958991ac4d129cb7042 (patch)
treed98300cdf6ddc7cc73a61bddc7568866045d6b73
parent52f19aacd569aa0f1f264108ed518a96657f9088 (diff)
downloadedk2-76132a56892aa3178697d958991ac4d129cb7042.tar.gz
edk2-76132a56892aa3178697d958991ac4d129cb7042.zip
OvmfPkg/LoongArchVirt: Use FFS_FILE_SIZE to read FFS file size
Replace the open-coded read of the 3-byte FFS file Size[] field in FindFfsFileAndSection() with the FFS_FILE_SIZE() macro from Pi/PiFirmwareFile.h. The macro reads exactly the three Size[] bytes (endianness-safe) instead of a 4-byte load that over-reads the adjacent byte. No functional change. Verified by building the module for LOONGARCH64 with a GCC cross toolchain: build -p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc -a LOONGARCH64 \ -t GCC -b DEBUG -m OvmfPkg/LoongArchVirt/Sec/SecMain.inf SecMain.c compiles and links into SecMain.efi. Generated with the following Coccinelle semantic patch: ```smpl @@ EFI_FFS_FILE_HEADER *E; typedef UINT32; @@ ( - *(UINT32 *)(E->Size) & 0x00FFFFFF + FFS_FILE_SIZE (E) | - *(UINT32 *)E->Size & 0x00FFFFFF + FFS_FILE_SIZE (E) ) ``` Signed-off-by: Mingjie Shen <shen497@purdue.edu>
-rw-r--r--OvmfPkg/LoongArchVirt/Sec/SecMain.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/OvmfPkg/LoongArchVirt/Sec/SecMain.c b/OvmfPkg/LoongArchVirt/Sec/SecMain.c
index 6f541b1b89..10df18f3fd 100644
--- a/OvmfPkg/LoongArchVirt/Sec/SecMain.c
+++ b/OvmfPkg/LoongArchVirt/Sec/SecMain.c
@@ -207,7 +207,7 @@ FindFfsFileAndSection (
}
File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
- Size = *(UINT32 *)File->Size & 0xffffff;
+ Size = FFS_FILE_SIZE (File);
if (Size < (sizeof (*File) + sizeof (EFI_COMMON_SECTION_HEADER))) {
return EFI_VOLUME_CORRUPTED;
}