diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-01-08 19:57:45 +1100 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-09-02 15:21:21 +0000 |
commit | 1104c278e396860567c4d20ff2b0868fa6b02696 (patch) | |
tree | 5fb2b38409feb02aef4041db3732e970b2164b9c | |
parent | 2ad1ddb3903b1057d16c72631f10b4a1f1934bb8 (diff) |
cpu/x86/smm: Fix explicit 'addr32' usage in clang builds
The addr32 prefix is required by binutils, because even when
given an explicit address which is greater than 64KiB, it will
throw a warning about truncation, and stupidly emit the opcode
with a 16-bit addressing mode and the wrong address.
However, in the case of LLVM, this doesn't happen, and is happy
to just use 32-bit addressing whenever it may require it. This
means that LLVM never really needs an explicit addr32 prefix to
use 32-bit addressing in 16-bit mode.
Change-Id: Ia160d3f7da6653ea24c8229dc26f265e5f15aabb
Also-by: Damien Zammit <damien@zamaudio.com>
Signed-off-by: Damien Zammit <damien@zamaudio.com>
Reviewed-on: https://review.coreboot.org/21219
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-rw-r--r-- | src/cpu/x86/smm/smmrelocate.S | 9 | ||||
-rw-r--r-- | src/include/compiler.h | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/cpu/x86/smm/smmrelocate.S b/src/cpu/x86/smm/smmrelocate.S index 4d388a99eb..b3be51d9c1 100644 --- a/src/cpu/x86/smm/smmrelocate.S +++ b/src/cpu/x86/smm/smmrelocate.S @@ -36,6 +36,9 @@ #error "Southbridge needs SMM handler support." #endif +// ADDR32() macro +#include <compiler.h> + #if IS_ENABLED(CONFIG_SMM_TSEG) #error "Don't use this file with TSEG." @@ -112,7 +115,7 @@ smm_relocation_start: */ mov $0x38000 + 0x7efc, %ebx - addr32 mov (%ebx), %al + ADDR32(mov) (%ebx), %al cmp $0x64, %al je 1f @@ -124,7 +127,7 @@ smm_relocation_start: smm_relocate: /* Get this CPU's LAPIC ID */ movl $LAPIC_ID, %esi - addr32 movl (%esi), %ecx + ADDR32(movl) (%esi), %ecx shr $24, %ecx /* calculate offset by multiplying the @@ -136,7 +139,7 @@ smm_relocate: movl $0xa0000, %eax subl %edx, %eax /* subtract offset, see above */ - addr32 movl %eax, (%ebx) + ADDR32(movl) %eax, (%ebx) /* The next section of code is potentially southbridge specific */ diff --git a/src/include/compiler.h b/src/include/compiler.h index a830239009..268064d0c2 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -26,4 +26,10 @@ #define __always_unused __attribute__((unused)) #define __must_check __attribute__((warn_unused_result)) +#if IS_ENABLED(CONFIG_COMPILER_LLVM_CLANG) +#define ADDR32(opcode) opcode +#else +#define ADDR32(opcode) addr32 opcode +#endif + #endif |