summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2012-09-14 16:42:54 +0200
committerMichael Brown2012-09-14 16:42:54 +0200
commit73eb3f17db3ff0a57a52507eafb5ef78eb5dc66e (patch)
tree40e8a24989186167640249b752c99671809cb458 /src
parent[int13] Use correct size when estimating floppy disk geometry (diff)
downloadipxe-73eb3f17db3ff0a57a52507eafb5ef78eb5dc66e.tar.gz
ipxe-73eb3f17db3ff0a57a52507eafb5ef78eb5dc66e.tar.xz
ipxe-73eb3f17db3ff0a57a52507eafb5ef78eb5dc66e.zip
[int13] Zero all possible registers when jumping to a boot sector
At least one boot sector (the DUET boot sector used for bootstrapping EFI from a non-EFI system) fails to initialise the high words of registers before using them in calculations, leading to undefined behaviour. Work around such broken boot sectors by explicitly zeroing the contents of all registers apart from %cs:%ip and %ss:%sp. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/arch/i386/image/bootsector.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/arch/i386/image/bootsector.c b/src/arch/i386/image/bootsector.c
index 289be7d70..faf21c6fc 100644
--- a/src/arch/i386/image/bootsector.c
+++ b/src/arch/i386/image/bootsector.c
@@ -80,9 +80,22 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
"movw %%ss, %%ax\n\t"
"movw %%ax, %%cs:saved_ss\n\t"
"movw %%sp, %%cs:saved_sp\n\t"
- /* Jump to boot sector */
+ /* Prepare jump to boot sector */
"pushw %%bx\n\t"
"pushw %%di\n\t"
+ /* Clear all registers */
+ "xorl %%eax, %%eax\n\t"
+ "xorl %%ebx, %%ebx\n\t"
+ "xorl %%ecx, %%ecx\n\t"
+ "xorl %%edx, %%edx\n\t"
+ "xorl %%esi, %%esi\n\t"
+ "xorl %%edi, %%edi\n\t"
+ "xorl %%ebp, %%ebp\n\t"
+ "movw %%ax, %%ds\n\t"
+ "movw %%ax, %%es\n\t"
+ "movw %%ax, %%fs\n\t"
+ "movw %%ax, %%gs\n\t"
+ /* Jump to boot sector */
"sti\n\t"
"lret\n\t"
/* Preserved variables */