From f423acaedd62f67106f14bebdc9eaa823ac37774 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 11 Sep 2022 14:41:02 -0300 Subject: [PATCH] x86_64 isr: don't rely on the value of rbp --- src/arch/x86_64/isr.asm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/arch/x86_64/isr.asm b/src/arch/x86_64/isr.asm index 1013985d..4b9ab85b 100644 --- a/src/arch/x86_64/isr.asm +++ b/src/arch/x86_64/isr.asm @@ -58,11 +58,6 @@ section .text %macro popregs 0 add rsp, 24 ; cr2 gs fs - - cmp rbp,0x3b - jne .noswapgspop - swapgs - .noswapgspop: pop rax mov es,rax @@ -85,6 +80,13 @@ section .text pop rbp add rsp,8 ; remove error code + cmp qword [rsp+8], 0x3b ; user cs + jne .noswap + + swapgs + + .noswap: + %endmacro %macro isr 2