Skip to content

Commit

Permalink
x86, setup: preemptively save/restore edi and ebp around INT 15 E820
Browse files Browse the repository at this point in the history
Impact: BIOS bugproofing

Since there are BIOSes known to clobber %ebx and %esi for INT 15 E820,
assume there is something out there clobbering %edi and/or %ebp too,
and don't wait for it to fail.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
H. Peter Anvin committed Mar 29, 2009
1 parent 01522df commit 32ec7fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions arch/x86/boot/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int detect_memory_e820(void)
{
int count = 0;
u32 next = 0;
u32 size, id;
u32 size, id, edi;
u8 err;
struct e820entry *desc = boot_params.e820_map;

Expand All @@ -29,10 +29,11 @@ static int detect_memory_e820(void)

/* Important: %edx and %esi are clobbered by some BIOSes,
so they must be either used for the error output
or explicitly marked clobbered. */
asm("int $0x15; setc %0"
or explicitly marked clobbered. Given that, assume there
is something out there clobbering %ebp and %edi, too. */
asm("pushl %%ebp; int $0x15; popl %%ebp; setc %0"
: "=d" (err), "+b" (next), "=a" (id), "+c" (size),
"=m" (*desc)
"=D" (edi), "=m" (*desc)
: "D" (desc), "d" (SMAP), "a" (0xe820)
: "esi");

Expand Down

0 comments on commit 32ec7fd

Please sign in to comment.