Fix previous mode detection by reading CS from the trap frame and sanitize segment restoration
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 31s
Builds / ExectOS (i686, release) (push) Successful in 36s
Builds / ExectOS (amd64, release) (push) Successful in 38s

This commit is contained in:
2026-03-31 20:38:21 +02:00
parent 494b615dc2
commit 620fc24cd2
2 changed files with 2 additions and 6 deletions

View File

@@ -112,7 +112,7 @@ Ar\Type\Vector:
/* Test previous mode and swap GS if needed */
movl $0, TrapPreviousMode(%rbp)
mov %cs, %ax
mov TrapSegCs(%rbp), %ax
and $3, %al
mov %al, TrapPreviousMode(%rbp)
@@ -174,11 +174,6 @@ KernelModeReturn\Type\Vector:
/* Load MxCsr register */
ldmxcsr TrapMxCsr(%rbp)
/* Restore segment selectors */
mov TrapSegDs(%rbp), %ds
mov TrapSegEs(%rbp), %es
mov TrapSegFs(%rbp), %fs
/* Free stack space */
add $(TRAP_FRAME_SIZE - TRAP_REGISTERS_SIZE), %rsp

View File

@@ -56,6 +56,7 @@
#define TrapSegEs 330
#define TrapSegFs 332
#define TrapSegGs 334
#define TrapSegCs 480
#define TrapRsp 496
#define TrapSegSs 504