Skip to content

Commit a0021f4

Browse files
author
maxv
committed
Switch to the temporary stack right away when booted via multiboot. GRUB
happens to give a correct stack, but it is not guaranteed by the spec. This temporary stack will be reset later, which is fine. Fixes PR/50245.
1 parent 2540366 commit a0021f4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sys/arch/i386/i386/locore.S

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $ */
1+
/* $NetBSD: locore.S,v 1.150 2017/08/10 14:13:45 maxv Exp $ */
22

33
/*
44
* Copyright-o-rama!
@@ -128,7 +128,7 @@
128128
*/
129129

130130
#include <machine/asm.h>
131-
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.149 2017/07/29 12:34:34 maxv Exp $");
131+
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.150 2017/08/10 14:13:45 maxv Exp $");
132132

133133
#include "opt_copy_symtab.h"
134134
#include "opt_ddb.h"
@@ -342,11 +342,13 @@ _C_LABEL(Multiboot_Header):
342342
jne 1f
343343

344344
/*
345-
* Indeed, a multiboot-compliant boot loader executed us. We copy
346-
* the received Multiboot information structure into kernel's data
347-
* space to process it later -- after we are relocated. It will
348-
* be safer to run complex C code than doing it at this point.
345+
* Indeed, a multiboot-compliant boot loader executed us. We switch
346+
* to the temporary stack, and copy the received Multiboot information
347+
* structure into kernel's data space to process it later -- after we
348+
* are relocated. It will be safer to run complex C code than doing it
349+
* at this point.
349350
*/
351+
movl $_RELOC(tmpstk),%esp
350352
pushl %ebx /* Address of Multiboot information */
351353
call _C_LABEL(multiboot_pre_reloc)
352354
addl $4,%esp

0 commit comments

Comments
 (0)