Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/51980 )
Change subject: mb/prodrive/hermes: Properly pack EEPROM structures ......................................................................
mb/prodrive/hermes: Properly pack EEPROM structures
To pack a struct, the `__packed` attribute must come after the `struct` keyword. Moreover, unions cannot be packed (structs inside unions can, though). Correct uses of `__packed` so that EEPROM structs get packed.
Change-Id: I39d2c9ebc370605d5623b134189aa95a074ec7c3 Signed-off-by: Angel Pons th3fanbus@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/51980 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: wouter.eckhardt@prodrive-technologies.com Reviewed-by: Michael Niewöhner foss@mniewoehner.de --- M src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h 1 file changed, 17 insertions(+), 8 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, but someone else must approve Michael Niewöhner: Looks good to me, approved wouter.eckhardt@prodrive-technologies.com: Looks good to me, but someone else must approve
diff --git a/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h b/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h index e6e5f39..58ecb08 100644 --- a/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h +++ b/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h @@ -2,8 +2,8 @@
#include <soc/ramstage.h>
-__packed union eeprom_dimm_layout { - struct { +union eeprom_dimm_layout { + struct __packed { char name[50]; char manufacturer[50]; uint8_t ranks; @@ -16,10 +16,13 @@ uint8_t raw[0x80]; };
-__packed struct eeprom_board_layout { +_Static_assert(sizeof(union eeprom_dimm_layout) == 0x80, + "union eeprom_dimm_layout has invalid size!"); + +struct __packed eeprom_board_layout { uint32_t signature; union { - struct { + struct __packed { char cpu_name[50]; uint8_t cpu_count; uint32_t cpu_max_non_turbo_frequency; @@ -30,10 +33,13 @@ }; };
-__packed struct eeprom_board_settings { +_Static_assert(sizeof(struct eeprom_board_layout) == (617 + sizeof(uint32_t)), + "struct eeprom_board_layout has invalid size!"); + +struct __packed eeprom_board_settings { uint32_t signature; union { - struct { + struct __packed { uint8_t secureboot; uint8_t primary_video; uint8_t deep_sx_enabled; @@ -48,13 +54,16 @@ }; };
-__packed struct eeprom_bmc_settings { +_Static_assert(sizeof(struct eeprom_board_settings) == (9 + sizeof(uint32_t)), + "struct eeprom_board_settings has invalid size!"); + +struct __packed eeprom_bmc_settings { uint8_t pcie_mux; uint8_t hsi; };
/* The EEPROM on address 0x57 has the following vendor defined layout: */ -__packed struct eeprom_layout { +struct __packed eeprom_layout { union { uint8_t RawFSPMUPD[0x600]; FSPM_UPD mupd;