SysCall: Restored nonvolatile registers for IA32, X64.

This commit is contained in:
Mikhail Krichanov 2024-09-02 11:14:11 +03:00
parent 65f3047224
commit 7ad8cac11d
2 changed files with 30 additions and 13 deletions

View File

@ -176,10 +176,14 @@ ASM_PFX(CoreBootServices):
global ASM_PFX(CallRing3) global ASM_PFX(CallRing3)
ASM_PFX(CallRing3): ASM_PFX(CallRing3):
cli cli
; Save nonvolatile registers EBX, EBP, EDI, ESI, ESP.
push ebx
push ebp
push edi
push esi
; Save Core Stack pointers. ; Save Core Stack pointer.
mov [ASM_PFX(CoreEsp)], esp mov [ASM_PFX(CoreEsp)], esp
mov [ASM_PFX(CoreEbp)], ebp
push dword [ASM_PFX(gRing3EntryPoint)] push dword [ASM_PFX(gRing3EntryPoint)]
push dword [ASM_PFX(gRing3CallStackTop)] push dword [ASM_PFX(gRing3CallStackTop)]
@ -189,7 +193,7 @@ ASM_PFX(CallRing3):
; Prepare SYSEXIT arguments. ; Prepare SYSEXIT arguments.
pop ecx pop ecx
pop edx pop edx
mov eax, [esp + 4] ; Data mov eax, [esp + 4 * 5] ; Data
; Switch to User Stack. ; Switch to User Stack.
mov ebp, ecx mov ebp, ecx
@ -200,7 +204,10 @@ ASM_PFX(CallRing3):
coreReturnAddress: coreReturnAddress:
mov esp, [ASM_PFX(CoreEsp)] mov esp, [ASM_PFX(CoreEsp)]
mov ebp, [ASM_PFX(CoreEbp)] pop esi
pop edi
pop ebp
pop ebx
call ASM_PFX(DisableSMAP) call ASM_PFX(DisableSMAP)
mov eax, [edx + 2 * 4] ; User Argument 1 mov eax, [edx + 2 * 4] ; User Argument 1
@ -214,6 +221,3 @@ coreReturnAddress:
SECTION .data SECTION .data
ASM_PFX(CoreEsp): ASM_PFX(CoreEsp):
resd 1 resd 1
ASM_PFX(CoreEbp):
resd 1

View File

@ -195,10 +195,18 @@ ASM_PFX(CallRing3):
pushfq pushfq
pop r11 pop r11
cli cli
; Save nonvolatile registers RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15.
push rbx
push rbp
push rdi
push rsi
push r12
push r13
push r14
push r15
; Save Core Stack pointers. ; Save Core Stack pointer.
mov [ASM_PFX(CoreRsp)], rsp mov [ASM_PFX(CoreRsp)], rsp
mov [ASM_PFX(CoreRbp)], rbp
; Save input Arguments. ; Save input Arguments.
mov r8, [ASM_PFX(gRing3CallStackTop)] mov r8, [ASM_PFX(gRing3CallStackTop)]
@ -220,7 +228,15 @@ o64 sysret
coreReturnAddress: coreReturnAddress:
mov rsp, [ASM_PFX(CoreRsp)] mov rsp, [ASM_PFX(CoreRsp)]
mov rbp, [ASM_PFX(CoreRbp)] pop r15
pop r14
pop r13
pop r12
pop rsi
pop rdi
pop rbp
pop rbx
mov rax, rdx mov rax, rdx
sti sti
ret ret
@ -228,6 +244,3 @@ coreReturnAddress:
SECTION .data SECTION .data
ASM_PFX(CoreRsp): ASM_PFX(CoreRsp):
resq 1 resq 1
ASM_PFX(CoreRbp):
resq 1