diff options
author | Michael Brown <mcb30@ipxe.org> | 2016-02-18 14:38:41 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2016-02-18 15:12:51 +0000 |
commit | a3b4d6328c99c1c9bd731521e00bb8b495057931 (patch) | |
tree | 04e91621d78c47f37f5779121f113dcc2eb1157a /src/arch/x86/image/nbi.c | |
parent | 4e4727079b718a8c0c62629f7d0df2f492074853 (diff) | |
download | ipxe-a3b4d6328c99c1c9bd731521e00bb8b495057931.tar.gz |
[bios] Make uses of REAL_CODE() and PHYS_CODE() 64-bit clean
On a 64-bit CPU, any modification of a register by 32-bit or 16-bit
code will destroy the invisible upper 32 bits of the corresponding
64-bit register. For example: a 32-bit "pushl %eax" followed by a
"popl %eax" will zero the upper half of %rax. This differs from the
treatment of upper halves of 32-bit registers by 16-bit code: a
"pushw %ax" followed by a "popw %ax" will leave the upper 16 bits of
%eax unmodified.
Inline assembly generated using REAL_CODE() or PHYS_CODE() will
therefore have to preserve the upper halves of all registers, to avoid
clobbering registers that gcc expects to be preserved.
Output operands from REAL_CODE() and PHYS_CODE() assembly may
therefore contain undefined values in the upper 32 bits.
Fix by using explicit variable widths (e.g. uint32_t) for
non-discarded output operands, to ensure that undefined values in the
upper 32 bits of 64-bit registers are ignored.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86/image/nbi.c')
-rw-r--r-- | src/arch/x86/image/nbi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/arch/x86/image/nbi.c b/src/arch/x86/image/nbi.c index 99046144d..b691bee20 100644 --- a/src/arch/x86/image/nbi.c +++ b/src/arch/x86/image/nbi.c @@ -241,7 +241,7 @@ static int nbi_process_segments ( struct image *image, */ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) { int discard_D, discard_S, discard_b; - int rc; + int32_t rc; DBGC ( image, "NBI %p executing 16-bit image at %04x:%04x\n", image, imgheader->execaddr.segoff.segment, @@ -283,7 +283,7 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) { 0 }; int discard_D, discard_S, discard_b; - int rc; + int32_t rc; DBGC ( image, "NBI %p executing 32-bit image at %lx\n", image, imgheader->execaddr.linear ); |