From 97ed78f64729400b87045c828d228b1e76a2ac50 Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Tue, 23 May 2023 13:56:52 +0800 Subject: soc/amd/smm: Sanity check the SMM TSEG size As per AMD64 Architecture Programmer's Manual, section 10.2.5 SMRAM Protected Areas: The TSEG range must be aligned to a 128 Kbyte boundary and the minimum TSEG size is 128 Kbytes. The SMM TSEG size should be less than SMM reserved size. AMD TSEG mask works like an MTRR. It needs to be aligned to it's size and it's size needs to be a power of 2. Change-Id: Ic4f557c7b77db6fc5ab2783ca4e2ebe7a4476e85 Signed-off-by: Zheng Bao Reviewed-on: https://review.coreboot.org/c/coreboot/+/75405 Reviewed-by: Paul Menzel Reviewed-by: Himanshu Sahdev Reviewed-by: Arthur Heymans Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai --- src/soc/amd/common/block/include/amdblocks/smm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/soc/amd/common/block') diff --git a/src/soc/amd/common/block/include/amdblocks/smm.h b/src/soc/amd/common/block/include/amdblocks/smm.h index fb2e488922..97b11be609 100644 --- a/src/soc/amd/common/block/include/amdblocks/smm.h +++ b/src/soc/amd/common/block/include/amdblocks/smm.h @@ -15,4 +15,16 @@ void lock_smm(void); /* See SMITYPE_* for list possible of events. GEVENTS are handled with mainboard_smi_gpi. */ void mainboard_handle_smi(int event); +#if CONFIG_SMM_TSEG_SIZE != 0 +#if (CONFIG_SMM_TSEG_SIZE <= CONFIG_SMM_RESERVED_SIZE) +# error "CONFIG_SMM_TSEG_SIZE <= CONFIG_SMM_RESERVED_SIZE" +#endif +#if (CONFIG_SMM_TSEG_SIZE < 0x20000) +# error "CONFIG_SMM_TSEG_SIZE must at least be 128KiB" +#endif +#if ((CONFIG_SMM_TSEG_SIZE & (CONFIG_SMM_TSEG_SIZE - 1)) != 0) +# error "CONFIG_SMM_TSEG_SIZE is not a power of 2" +#endif +#endif + #endif -- cgit v1.2.3