Print this page
Use `iretq` method of jumping to 32-bit so VirtualBox (and maybe QEMU/KVM too?)
can cope and not get its `ljmp <mem48>` emulation bug(s) tickled.
@@ -1,9 +1,9 @@
/*
* Parts copyright Michael Brown <mbrown@fensystems.co.uk>
*
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
/* CR0: protection enabled */
@@ -60,11 +60,18 @@
leaq entry_gdtr(%rip), %rax
lgdt (%rax)
/* Load our new %cs. */
- ljmp *newcs_vector
+ movq %rsp, %rax
+ pushq $GDTSEL_DATA
+ pushq %rax
+ pushf
+ pushq $GDTSEL_CODE
+ lea newcs(%rip), %rax
+ pushq %rax
+ iretq
.code32
newcs:
movw $GDTSEL_DATA, %ax
@@ -106,13 +113,10 @@
movq %rsi, %rsp
jmp *%rdx
.data
-newcs_vector:
- .long newcs, GDTSEL_CODE
-
.align 16
entry_gdt:
/* null entry */
.word 0x0, 0x0
.byte 0x0, 0x0, 0x0, 0x0