diff options
-rw-r--r-- | i386/i386/locore.S | 36 | ||||
-rw-r--r-- | x86_64/locore.S | 69 |
2 files changed, 59 insertions, 46 deletions
diff --git a/i386/i386/locore.S b/i386/i386/locore.S index be412af0..8314e25a 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -39,6 +39,23 @@ #include <i386/cpu_number.h> #include <i386/xen.h> +#define PUSH_REGS_ISR \ + pushl %ecx ;\ + pushl %edx + +#define PUSH_AREGS_ISR \ + pushl %eax ;\ + PUSH_REGS_ISR + + +#define POP_REGS_ISR \ + popl %edx ;\ + popl %ecx + +#define POP_AREGS_ISR \ + POP_REGS_ISR ;\ + popl %eax + /* * Note that we have to load the kernel segment registers even if this * is a trap from the kernel, because the kernel uses user segment @@ -694,8 +711,7 @@ INTERRUPT(255) * old %eax on stack; interrupt number in %eax. */ ENTRY(all_intrs) - pushl %ecx /* save registers */ - pushl %edx + PUSH_REGS_ISR /* save registers */ cld /* clear direction flag */ CPU_NUMBER_NO_GS(%ecx) @@ -754,9 +770,8 @@ LEXT(return_to_iret) /* to find the return from calling interrupt) */ jnz ast_from_interrupt /* take it if so */ 1: POP_SEGMENTS_ISR /* restore segment regs */ - pop %edx - pop %ecx - pop %eax + POP_AREGS_ISR /* restore registers */ + iret /* return to caller */ int_from_intstack: @@ -765,9 +780,10 @@ int_from_intstack: jb stack_overflowed /* if not: */ call EXT(interrupt) /* call interrupt routine */ _return_to_iret_i: /* ( label for kdb_kintr) */ - pop %edx /* must have been on kernel segs */ - pop %ecx - pop %eax /* no ASTs */ + /* must have been on kernel segs */ + POP_AREGS_ISR /* restore registers */ + /* no ASTs */ + iret stack_overflowed: @@ -791,9 +807,7 @@ stack_overflowed: */ ast_from_interrupt: POP_SEGMENTS_ISR /* restore all registers ... */ - popl %edx - popl %ecx - popl %eax + POP_AREGS_ISR pushl $0 /* zero code */ pushl $0 /* zero trap number */ pusha /* save general registers */ diff --git a/x86_64/locore.S b/x86_64/locore.S index ed10665b..f0d1298d 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -80,6 +80,35 @@ popq %rcx ;\ popq %rax +#define PUSH_REGS_ISR \ + pushq %rcx ;\ + pushq %rdx ;\ + pushq %rsi ;\ + pushq %rdi ;\ + pushq %r8 ;\ + pushq %r9 ;\ + pushq %r10 ;\ + pushq %r11 + +#define PUSH_AREGS_ISR \ + pushq %rax ;\ + PUSH_REGS_ISR + + +#define POP_REGS_ISR \ + popq %r11 ;\ + popq %r10 ;\ + popq %r9 ;\ + popq %r8 ;\ + popq %rdi ;\ + popq %rsi ;\ + popq %rdx ;\ + popq %rcx + +#define POP_AREGS_ISR \ + POP_REGS_ISR ;\ + popq %rax + /* * Note that we have to load the kernel segment registers even if this * is a trap from the kernel, because the kernel uses user segment @@ -790,14 +819,7 @@ INTERRUPT(255) * interrupt stack. */ ENTRY(all_intrs) - pushq %rcx /* save registers */ - pushq %rdx - pushq %rsi - pushq %rdi - pushq %r8 - pushq %r9 - pushq %r10 - pushq %r11 + PUSH_REGS_ISR /* save registers */ cld /* clear direction flag */ PUSH_SEGMENTS_ISR(%rdx) /* save segment registers */ @@ -858,15 +880,7 @@ LEXT(return_to_iret) /* to find the return from calling interrupt) */ jnz ast_from_interrupt /* take it if so */ 1: POP_SEGMENTS_ISR(%rdx) /* restore segment regs */ - pop %r11 - pop %r10 - pop %r9 - pop %r8 - pop %rdi - pop %rsi - pop %rdx - pop %rcx - pop %rax + POP_AREGS_ISR /* restore registers */ iretq /* return to caller */ @@ -876,15 +890,8 @@ int_from_intstack: call EXT(interrupt) /* call interrupt routine */ _return_to_iret_i: /* ( label for kdb_kintr) */ POP_SEGMENTS_ISR(%rdx) - pop %r11 - pop %r10 - pop %r9 - pop %r8 - pop %rdi - pop %rsi - pop %rdx /* must have been on kernel segs */ - pop %rcx - pop %rax /* no ASTs */ + POP_AREGS_ISR /* restore registers */ + /* no ASTs */ iretq @@ -909,15 +916,7 @@ stack_overflowed: */ ast_from_interrupt: POP_SEGMENTS_ISR(%rdx) /* restore all registers ... */ - popq %r11 - popq %r10 - popq %r9 - popq %r8 - popq %rdi - popq %rsi - popq %rdx - popq %rcx - popq %rax + POP_AREGS_ISR pushq $0 /* zero code */ pushq $0 /* zero trap number */ pusha /* save general registers */ |