From 7a704673d7acdf7daa4d646fccbbe7a130a5b3ed Mon Sep 17 00:00:00 2001 From: WangRunji Date: Sun, 24 Feb 2019 23:59:02 +0800 Subject: [PATCH] save fsbase to TrapFrame on x86_64 --- kernel/src/arch/x86_64/interrupt/trap.asm | 15 +++++++++++++++ kernel/src/arch/x86_64/interrupt/trapframe.rs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/kernel/src/arch/x86_64/interrupt/trap.asm b/kernel/src/arch/x86_64/interrupt/trap.asm index a12d6ee..98eeaf1 100644 --- a/kernel/src/arch/x86_64/interrupt/trap.asm +++ b/kernel/src/arch/x86_64/interrupt/trap.asm @@ -20,6 +20,14 @@ __alltraps: push r14 push r15 + # push fs.base + xor rax, rax + mov ecx, 0xC0000100 + rdmsr # msr[ecx] => edx:eax + shl rdx, 32 + or rdx, rax + push rdx + mov rdi, rsp call rust_trap @@ -29,6 +37,13 @@ trap_ret: mov rdi, rsp call set_return_rsp + # pop fs.base + pop rax + mov rdx, rax + shr rdx, 32 + mov ecx, 0xC0000100 + wrmsr # msr[ecx] <= edx:eax + pop r15 pop r14 pop r13 diff --git a/kernel/src/arch/x86_64/interrupt/trapframe.rs b/kernel/src/arch/x86_64/interrupt/trapframe.rs index 6f76103..5322a62 100644 --- a/kernel/src/arch/x86_64/interrupt/trapframe.rs +++ b/kernel/src/arch/x86_64/interrupt/trapframe.rs @@ -2,6 +2,8 @@ #[repr(C)] pub struct TrapFrame { // Pushed by __alltraps at 'trap.asm' + pub fsbase: usize, + pub r15: usize, pub r14: usize, pub r13: usize,