From 403f18da523af95e3bde405489b7afff688f11cf Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sat, 2 Oct 2021 22:17:22 +0200 Subject: [PATCH] multiboot: Zero out all undefined GPRs before handoff --- stage23/protos/multiboot1.32.c | 16 ++++++++++------ stage23/protos/multiboot2.32.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/stage23/protos/multiboot1.32.c b/stage23/protos/multiboot1.32.c index 8c8786ac..c6fda4f6 100644 --- a/stage23/protos/multiboot1.32.c +++ b/stage23/protos/multiboot1.32.c @@ -25,15 +25,19 @@ __attribute__((noreturn)) void multiboot1_spinup_32( asm volatile ( "cld\n\t" - "pushl $0x18\n\t" - "pushl %%edi\n\t" + "push %2\n\t" - "movl $0x2BADB002, %%eax\n\t" + "xor %%ecx, %%ecx\n\t" + "xor %%edx, %%edx\n\t" + "xor %%esi, %%esi\n\t" + "xor %%edi, %%edi\n\t" + "xor %%ebp, %%ebp\n\t" - "lret\n\t" + "ret\n\t" : - : "D" (entry_point), - "b" (multiboot1_info) + : "a" (0x2badb002), + "b" (multiboot1_info), + "r" (entry_point) : "memory" ); diff --git a/stage23/protos/multiboot2.32.c b/stage23/protos/multiboot2.32.c index a96b3068..1991e378 100644 --- a/stage23/protos/multiboot2.32.c +++ b/stage23/protos/multiboot2.32.c @@ -25,15 +25,19 @@ __attribute__((noreturn)) void multiboot2_spinup_32( asm volatile ( "cld\n\t" - "pushl $0x18\n\t" - "pushl %%edi\n\t" + "push %2\n\t" - "movl $0x36D76289, %%eax\n\t" + "xor %%ecx, %%ecx\n\t" + "xor %%edx, %%edx\n\t" + "xor %%esi, %%esi\n\t" + "xor %%edi, %%edi\n\t" + "xor %%ebp, %%ebp\n\t" - "lret\n\t" + "ret\n\t" : - : "D" (entry_point), - "b" (multiboot2_info) + : "a" (0x36d76289), + "b" (multiboot2_info), + "r" (entry_point) : "memory" );