From 17c9cfe2125736e49d335efcc624b53d213444ef Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Fri, 3 Dec 2021 17:15:10 +0100 Subject: [PATCH] src/mainboard/emulation/qemu-i440fx: Fix struct packing On x86_64 the struct isn't packed, causing the fw_cfg parser to return invalid memory entries (possible others as well) through fw_cfg. Fix that by packing all structs. Change-Id: Id1bab99f06be99674efe219dda443fb7d44be560 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/59872 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Angel Pons --- src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h b/src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h index e972f54261..817d1a58f5 100644 --- a/src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h +++ b/src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h @@ -69,18 +69,18 @@ typedef struct FWCfgFile { uint16_t select; /* write this to 0x510 to read it */ uint16_t reserved; char name[FW_CFG_MAX_FILE_PATH]; -} FWCfgFile; +} __packed FWCfgFile; typedef struct FWCfgFiles { uint32_t count; FWCfgFile f[]; -} FWCfgFiles; +} __packed FWCfgFiles; typedef struct FwCfgE820Entry { uint64_t address; uint64_t length; uint32_t type; -} FwCfgE820Entry __attribute((__aligned__(4))); +} __packed FwCfgE820Entry __attribute((__aligned__(4))); #define SMBIOS_FIELD_ENTRY 0 @@ -91,7 +91,7 @@ typedef struct FwCfgSmbios { uint8_t headertype; uint8_t tabletype; uint16_t fieldoffset; -} FwCfgSmbios; +} __packed FwCfgSmbios; /* FW_CFG_ID bits */ #define FW_CFG_VERSION 0x01 @@ -113,6 +113,6 @@ typedef struct FwCfgDmaAccess { uint32_t control; uint32_t length; uint64_t address; -} FwCfgDmaAccess; +} __packed FwCfgDmaAccess; #endif /* FW_CFG_IF_H */