Fix user apps randomly crashing (APIC, GDT layout, syscall entry)
All checks were successful
Build documentation / build-and-deploy (push) Successful in 23s

This commit is contained in:
2026-01-14 19:51:18 +01:00
parent 0d8f9e565f
commit d1d772cb42
23 changed files with 276 additions and 204 deletions

View File

@@ -7,39 +7,41 @@
pushq $z;
#define no_err(z) \
pushq $0; \
pushq $0; \
pushq $z;
#define make_intr_stub(x, n) \
.global amd64_intr ## n; \
amd64_intr ## n:; \
x(n); \
cli; \
;\
push_regs; \
;\
cld; \
;\
movq %rsp, %rdi; \
;\
movq %cr3, %rax; \
pushq %rax; \
;\
movq %rsp, %rbp; \
;\
subq $8, %rsp; \
andq $~0xF, %rsp; \
;\
callq amd64_intr_handler; \
;\
movq %rbp, %rsp; \
;\
popq %rax; \
movq %rax, %cr3
;\
pop_regs; \
addq $16, %rsp; \
;\
#define make_intr_stub(x, n) \
.global amd64_intr ## n; \
amd64_intr ## n:; \
x(n); \
cli; \
; \
push_regs; \
; \
movw $0x10, %ax; \
movw %ax, %ds; \
movw %ax, %es; \
; \
cld; \
; \
movq %rsp, %rdi; \
; \
movq %cr3, %rax; pushq %rax; \
; \
movq %rsp, %rbp; \
; \
subq $8, %rsp; \
andq $-16, %rsp; \
; \
callq amd64_intr_handler; \
; \
movq %rbp, %rsp; \
; \
popq %rax; movq %rax, %cr3; \
; \
pop_regs; \
addq $16, %rsp; \
; \
iretq;
@@ -95,3 +97,4 @@ make_intr_stub(no_err, 47)
make_intr_stub(no_err, SCHED_PREEMPT_TIMER)
make_intr_stub(no_err, TLB_SHOOTDOWN)
make_intr_stub(no_err, CPU_REQUEST_SCHED)
make_intr_stub(no_err, CPU_SPURIOUS)