Load kernel CR3

This commit is contained in:
2026-01-11 03:45:32 +01:00
parent 5bf10c1218
commit f80a26e5eb
4 changed files with 16 additions and 0 deletions

View File

@@ -161,6 +161,8 @@ static void amd64_intr_exception (struct saved_regs* regs) {
/* Handle incoming interrupt, dispatch IRQ handlers. */ /* Handle incoming interrupt, dispatch IRQ handlers. */
void amd64_intr_handler (void* stack_ptr) { void amd64_intr_handler (void* stack_ptr) {
amd64_load_kernel_cr3 ();
struct saved_regs* regs = stack_ptr; struct saved_regs* regs = stack_ptr;
if (regs->trap <= 31) { if (regs->trap <= 31) {

View File

@@ -22,6 +22,9 @@
;\ ;\
movq %rsp, %rdi; \ movq %rsp, %rdi; \
;\ ;\
movq %cr3, %rax; \
pushq %rax; \
;\
movq %rsp, %rbp; \ movq %rsp, %rbp; \
;\ ;\
subq $8, %rsp; \ subq $8, %rsp; \
@@ -31,6 +34,9 @@
;\ ;\
movq %rbp, %rsp; \ movq %rbp, %rsp; \
;\ ;\
popq %rax; \
movq %rax, %cr3
;\
pop_regs; \ pop_regs; \
addq $16, %rsp; \ addq $16, %rsp; \
;\ ;\

View File

@@ -12,6 +12,8 @@
extern void amd64_syscall_entry (void); extern void amd64_syscall_entry (void);
int amd64_syscall_dispatch (void* stack_ptr) { int amd64_syscall_dispatch (void* stack_ptr) {
amd64_load_kernel_cr3 ();
struct saved_regs* regs = stack_ptr; struct saved_regs* regs = stack_ptr;
int syscall_num = regs->rax; int syscall_num = regs->rax;

View File

@@ -23,6 +23,9 @@ amd64_syscall_entry:
movq %rsp, %rdi movq %rsp, %rdi
movq %cr3, %rax
pushq %rax
movq %rsp, %rbp movq %rsp, %rbp
subq $8, %rsp subq $8, %rsp
@@ -32,6 +35,9 @@ amd64_syscall_entry:
movq %rbp, %rsp movq %rbp, %rsp
popq %rax
movq %rax, %cr3
pop_regs_skip_rax pop_regs_skip_rax
addq $56, %rsp addq $56, %rsp