MSR and syscall changes

- Moved MSR code to separate files with an enum class
- Implemented syscall_enable in C++ using new MSR calls
This commit is contained in:
Justin C. Miller
2018-09-15 00:37:49 -07:00
parent 62c559043d
commit 1308864061
9 changed files with 78 additions and 61 deletions

View File

@@ -1,35 +1,7 @@
%include "push_all.inc"
global syscall_enable
syscall_enable:
; IA32_EFER - set bit 0, syscall enable
mov rcx, 0xc0000080
rdmsr
or rax, 0x1
wrmsr
; IA32_STAR - cs for syscall
mov rcx, 0xc0000081
mov rax, 0 ; not used
mov rdx, 0x00180008 ; GDT:3 (user code), GDT:1 (kernel code)
wrmsr
; IA32_LSTAR - RIP for syscall
mov rcx, 0xc0000082
lea rax, [rel syscall_handler_prelude]
mov rdx, rax
shr rdx, 32
wrmsr
; IA32_FMASK - FLAGS mask inside syscall
mov rcx, 0xc0000084
mov rax, 0x200
mov rdx, 0
wrmsr
ret
extern syscall_handler
global syscall_handler_prelude
syscall_handler_prelude:
push 0 ; ss, doesn't matter here
push rsp