bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/5] x86_64: fix stack handling on recursive interrupts for USER3


From: Luca Dariz
Subject: [PATCH 1/5] x86_64: fix stack handling on recursive interrupts for USER32
Date: Sat, 29 Jul 2023 19:47:49 +0200

* x86_64/locore.S: ensure the thread state is filled completely even
  on recursive interrups. The value of the segment selectors is not
  very important in this case, but we still need to align the stack to
  the bottom of i386_interrupt_state.
---
 x86_64/locore.S | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/x86_64/locore.S b/x86_64/locore.S
index 16b0dde5..ac7138b7 100644
--- a/x86_64/locore.S
+++ b/x86_64/locore.S
@@ -752,17 +752,17 @@ ENTRY(all_intrs)
        pushq   %r11
        cld                             /* clear direction flag */
 
-       movq    %rsp,%rdx               /* on an interrupt stack? */
-       and     $(~(INTSTACK_SIZE-1)),%rdx
-       cmpq    %ss:EXT(int_stack_base),%rdx
-       je      int_from_intstack       /* if not: */
-
        movq    %ds,%rdx                        /* save segment registers */
        pushq   %rdx
        movq    %es,%rdx
        pushq   %rdx
        PUSH_FSGS_ISR
 
+       movq    %rsp,%rdx               /* on an interrupt stack? */
+       and     $(~(INTSTACK_SIZE-1)),%rdx
+       cmpq    %ss:EXT(int_stack_base),%rdx
+       je      int_from_intstack       /* if not: */
+
        mov     %ss,%dx                 /* switch to kernel segments */
        mov     %dx,%ds
        mov     %dx,%es
@@ -830,6 +830,12 @@ int_from_intstack:
        jb      stack_overflowed        /* if not: */
        call    EXT(interrupt)          /* call interrupt routine */
 _return_to_iret_i:                     /* ( label for kdb_kintr) */
+       POP_FSGS_ISR
+       pop     %rdx
+       mov     %rdx,%es
+       pop     %rdx
+       mov     %rdx,%ds
+
        pop     %r11
        pop     %r10
        pop     %r9
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]