Fix previous mode detection by reading CS from the trap frame and sanitize segment restoration
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#define TrapSegEs 330
|
||||
#define TrapSegFs 332
|
||||
#define TrapSegGs 334
|
||||
#define TrapSegCs 480
|
||||
#define TrapRsp 496
|
||||
#define TrapSegSs 504
|
||||
|
||||
|
||||
Reference in New Issue
Block a user