[coreboot] New patch to review for coreboot: 27036af x86: protect against abi assumptions from compiler

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Mar 19 01:58:58 CET 2013

Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2794


commit 27036af262fcd967479baa8cdb1223cf17cbd36f
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri Feb 8 22:31:33 2013 -0600

    x86: protect against abi assumptions from compiler
    Some of the functions called from assembly assume the standard
    x86 32-bit ABI of passing all arguments on the stack. However,
    that calling ABI can be changed by compiler flags. In order to
    protect against the current implicit calling convention annotate
    the functions called from assembly with the cdecl function
    attribute. That tells the compiler to use the stack based parameter
    calling convention.
    Change-Id: I83625e1f92c6821a664b191b6ce1250977cf037a
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
 src/cpu/intel/haswell/mp_init.c     | 3 ++-
 src/cpu/intel/haswell/smmrelocate.c | 6 +++---
 src/include/cpu/x86/smm.h           | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/cpu/intel/haswell/mp_init.c b/src/cpu/intel/haswell/mp_init.c
index 47683fb..7f15c39 100644
--- a/src/cpu/intel/haswell/mp_init.c
+++ b/src/cpu/intel/haswell/mp_init.c
@@ -149,7 +149,8 @@ static void cleanup_rom_caching(void)
 /* By the time APs call ap_init() caching has been setup, and microcode has
  * been loaded. */
-static void ap_init(unsigned int cpu, void *microcode_ptr)
+static void __attribute__((cdecl))
+ap_init(unsigned int cpu, void *microcode_ptr)
 	struct cpu_info *info;
diff --git a/src/cpu/intel/haswell/smmrelocate.c b/src/cpu/intel/haswell/smmrelocate.c
index 4312d79..2bf304e 100644
--- a/src/cpu/intel/haswell/smmrelocate.c
+++ b/src/cpu/intel/haswell/smmrelocate.c
@@ -85,8 +85,8 @@ static inline void write_uncore_emrr(struct smm_relocation_params *relo_params)
 /* The relocation work is actually performed in SMM context, but the code
  * resides in the ramstage module. This occurs by trampolining from the default
  * SMRAM entry point to here. */
-static void cpu_smm_do_relocation(void *arg, int cpu,
-                                  const struct smm_runtime *runtime)
+static void __attribute__((cdecl))
+cpu_smm_do_relocation(void *arg, int cpu, const struct smm_runtime *runtime)
 	em64t101_smm_state_save_area_t *save_state;
 	msr_t mtrr_cap;
@@ -209,7 +209,7 @@ static int install_relocation_handler(int num_cpus,
 		.num_concurrent_stacks = num_cpus,
 		.per_cpu_save_state_size = save_state_size,
 		.num_concurrent_save_states = 1,
-		.handler = &cpu_smm_do_relocation,
+		.handler = (smm_handler_t)&cpu_smm_do_relocation,
 		.handler_arg = (void *)relo_params,
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index b6a6c4e..62494a9 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -429,7 +429,7 @@ struct smm_runtime {
 	u8 apic_id_to_cpu[CONFIG_MAX_CPUS];
 } __attribute__ ((packed));
-typedef void (*smm_handler_t)(void *arg, int cpu,
+typedef void __attribute__((cdecl)) (*smm_handler_t)(void *arg, int cpu,
                               const struct smm_runtime *runtime);
 #ifdef __SMM__

More information about the coreboot mailing list