Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17784
-gerrit
commit b30fd3802d3b9a1c917a8b46c63f91f8bafd70bc Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sun Dec 4 22:17:37 2016 +0200
x86 SMM: Fix use with RELOCATABLE_RAMSTAGE
The value for _size was not evaluated correctly if ramstage is relocated, make the calculation runtime.
While touching it, move symbol declarations to header file.
Change-Id: I4402315945771acf1c86a81cac6d43f1fe99a2a2 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/cpu/amd/smm/smm_init.c | 6 ++---- src/cpu/x86/smm/smm_module_loader.c | 3 --- src/include/cpu/x86/smm.h | 4 ++++ src/soc/intel/sch/smi.c | 6 ++---- src/southbridge/intel/i82801dx/smi.c | 6 ++---- src/southbridge/intel/i82801gx/smi.c | 6 ++---- src/southbridge/intel/i82801ix/smi.c | 6 ++---- 7 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/src/cpu/amd/smm/smm_init.c b/src/cpu/amd/smm/smm_init.c index c87b701..4d04cf7 100644 --- a/src/cpu/amd/smm/smm_init.c +++ b/src/cpu/amd/smm/smm_init.c @@ -26,9 +26,6 @@ #include <cpu/x86/smm.h> #include <string.h>
-extern unsigned char _binary_smm_start; -extern unsigned char _binary_smm_size; - void smm_init(void) { msr_t msr, syscfg_orig, mtrr_aseg_orig; @@ -63,7 +60,8 @@ void smm_init(void)
enable_cache(); /* copy the real SMM handler */ - memcpy((void *)SMM_BASE, &_binary_smm_start, (size_t)&_binary_smm_size); + memcpy((void *)SMM_BASE, _binary_smm_start, + _binary_smm_end - _binary_smm_start); wbinvd(); disable_cache();
diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 139bce1..b8edf39 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -45,9 +45,6 @@ struct smm_stub_params { */ extern unsigned char _binary_smmstub_start[];
-/* This is the SMM handler that the stub calls. It is encoded as an rmodule. */ -extern unsigned char _binary_smm_start[]; - /* Per CPU minimum stack size. */ #define SMM_MINIMUM_STACK_SIZE 32
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index 8ea66ba..0489ece 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -485,6 +485,10 @@ void mainboard_smi_sleep(u8 slp_typ); void smi_release_lock(void); #endif
+/* This is the SMM handler. */ +extern unsigned char _binary_smm_start[]; +extern unsigned char _binary_smm_end[]; + /* Get PMBASE address */ u16 smm_get_pmbase(void);
diff --git a/src/soc/intel/sch/smi.c b/src/soc/intel/sch/smi.c index 24628e5..f79e963b 100644 --- a/src/soc/intel/sch/smi.c +++ b/src/soc/intel/sch/smi.c @@ -24,9 +24,6 @@ #include "chip.h" #include "sch.h"
-extern unsigned char _binary_smm_start; -extern unsigned char _binary_smm_size; - /* I945 */ #define SMRAM 0x9d #define D_OPEN (1 << 6) @@ -299,7 +296,8 @@ static void smm_install(void) D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); + memcpy((void *)0xa0000, _binary_smm_start, + _binary_smm_end - _binary_smm_start); wbinvd();
/* close the SMM memory window and enable normal SMM */ diff --git a/src/southbridge/intel/i82801dx/smi.c b/src/southbridge/intel/i82801dx/smi.c index 71ef5fd..93e2845 100644 --- a/src/southbridge/intel/i82801dx/smi.c +++ b/src/southbridge/intel/i82801dx/smi.c @@ -25,9 +25,6 @@ #include <string.h> #include "i82801dx.h"
-extern unsigned char _binary_smm_start; -extern unsigned char _binary_smm_size; - /* I945 */ #define SMRAM 0x90 #define D_OPEN (1 << 6) @@ -321,7 +318,8 @@ static void smm_install(void) D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); + memcpy((void *)0xa0000, _binary_smm_start, + _binary_smm_end - _binary_smm_start); wbinvd();
/* close the SMM memory window and enable normal SMM */ diff --git a/src/southbridge/intel/i82801gx/smi.c b/src/southbridge/intel/i82801gx/smi.c index 3487aab..c9d4cd9 100644 --- a/src/southbridge/intel/i82801gx/smi.c +++ b/src/southbridge/intel/i82801gx/smi.c @@ -25,9 +25,6 @@ #include <string.h> #include "i82801gx.h"
-extern unsigned char _binary_smm_start; -extern unsigned char _binary_smm_size; - /* I945 */ #define SMRAM 0x9d #define D_OPEN (1 << 6) @@ -345,7 +342,8 @@ static void smm_install(void) D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); + memcpy((void *)0xa0000, _binary_smm_start, + _binary_smm_end - _binary_smm_start); wbinvd(); }
diff --git a/src/southbridge/intel/i82801ix/smi.c b/src/southbridge/intel/i82801ix/smi.c index 358a1a9..421746d 100644 --- a/src/southbridge/intel/i82801ix/smi.c +++ b/src/southbridge/intel/i82801ix/smi.c @@ -26,9 +26,6 @@ #include <string.h> #include "i82801ix.h"
-extern unsigned char _binary_smm_start; -extern unsigned char _binary_smm_size; - /* I945/GM45 */ #define SMRAM 0x9d #define D_OPEN (1 << 6) @@ -344,7 +341,8 @@ static void smm_install(void) D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); + memcpy((void *)0xa0000, _binary_smm_start, + _binary_smm_end - _binary_smm_start); wbinvd(); }