From 8f8b46a9b66175280adb4a225050deed2de8fe0a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 14 Jan 2017 16:38:33 +0100 Subject: [PATCH] Load null selectors to all data registers This is required for some instructions such as iretq (ss must be valid or 0). --- src/arch/x86_64/long_mode_init.asm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/arch/x86_64/long_mode_init.asm b/src/arch/x86_64/long_mode_init.asm index 83fa8f46..79b4c025 100644 --- a/src/arch/x86_64/long_mode_init.asm +++ b/src/arch/x86_64/long_mode_init.asm @@ -13,6 +13,14 @@ extern rust_main section .text bits 64 long_mode_start: + ; load 0 into all data segment registers + mov ax, 0 + mov ss, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + ; call rust main (with multiboot pointer in rdi) call rust_main .os_returned: