Commit b8b1d08b authored by Alexander van Heukelum's avatar Alexander van Heukelum Committed by Ingo Molnar

x86: entry_64.S: split out some macro's and move common code to paranoid_exit

Impact: cleanup

DISABLE_INTERRUPTS(CLBR_NONE)/TRACE_IRQS_OFF is now always
executed just before paranoid_exit. Move it there.

Split out paranoidzeroentry, paranoiderrorentry, and
paranoidzeroentry_ist to get more readable macro's.
Signed-off-by: default avatarAlexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent e2f6bc25
...@@ -1026,6 +1026,39 @@ END(spurious_interrupt) ...@@ -1026,6 +1026,39 @@ END(spurious_interrupt)
CFI_ENDPROC CFI_ENDPROC
.endm .endm
.macro paranoidzeroentry sym
INTR_FRAME
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq $-1 /* ORIG_RAX: no syscall to restart */
CFI_ADJUST_CFA_OFFSET 8
subq $15*8, %rsp
call save_paranoid
TRACE_IRQS_OFF
movq %rsp,%rdi /* pt_regs pointer */
xorl %esi,%esi /* no error code */
call \sym
jmp paranoid_exit /* %ebx: no swapgs flag */
CFI_ENDPROC
.endm
.macro paranoidzeroentry_ist sym ist
INTR_FRAME
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq $-1 /* ORIG_RAX: no syscall to restart */
CFI_ADJUST_CFA_OFFSET 8
subq $15*8, %rsp
call save_paranoid
TRACE_IRQS_OFF
movq %rsp,%rdi /* pt_regs pointer */
xorl %esi,%esi /* no error code */
movq %gs:pda_data_offset, %rbp
subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
call \sym
addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
jmp paranoid_exit /* %ebx: no swapgs flag */
CFI_ENDPROC
.endm
.macro errorentry sym .macro errorentry sym
XCPT_FRAME XCPT_FRAME
PARAVIRT_ADJUST_EXCEPTION_FRAME PARAVIRT_ADJUST_EXCEPTION_FRAME
...@@ -1042,27 +1075,20 @@ END(spurious_interrupt) ...@@ -1042,27 +1075,20 @@ END(spurious_interrupt)
.endm .endm
/* error code is on the stack already */ /* error code is on the stack already */
.macro paranoidentry sym ist=0 .macro paranoiderrorentry sym
subq $15*8, %rsp XCPT_FRAME
PARAVIRT_ADJUST_EXCEPTION_FRAME
subq $15*8,%rsp
CFI_ADJUST_CFA_OFFSET 15*8 CFI_ADJUST_CFA_OFFSET 15*8
call save_paranoid call save_paranoid
DEFAULT_FRAME 0 DEFAULT_FRAME 0
.if \ist
movq %gs:pda_data_offset, %rbp
.endif
TRACE_IRQS_OFF TRACE_IRQS_OFF
movq %rsp,%rdi movq %rsp,%rdi /* pt_regs pointer */
movq ORIG_RAX(%rsp),%rsi movq ORIG_RAX(%rsp),%rsi /* get error code */
movq $-1,ORIG_RAX(%rsp) movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
.if \ist
subq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
.endif
call \sym call \sym
.if \ist jmp paranoid_exit /* %ebx: no swapgs flag */
addq $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp) CFI_ENDPROC
.endif
DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF
.endm .endm
/* /*
...@@ -1081,6 +1107,8 @@ END(spurious_interrupt) ...@@ -1081,6 +1107,8 @@ END(spurious_interrupt)
/* ebx: no swapgs flag */ /* ebx: no swapgs flag */
KPROBE_ENTRY(paranoid_exit) KPROBE_ENTRY(paranoid_exit)
INTR_FRAME INTR_FRAME
DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF
testl %ebx,%ebx /* swapgs needed? */ testl %ebx,%ebx /* swapgs needed? */
jnz paranoid_restore jnz paranoid_restore
testl $3,CS(%rsp) testl $3,CS(%rsp)
...@@ -1331,13 +1359,7 @@ END(device_not_available) ...@@ -1331,13 +1359,7 @@ END(device_not_available)
/* runs on exception stack */ /* runs on exception stack */
KPROBE_ENTRY(debug) KPROBE_ENTRY(debug)
INTR_FRAME paranoidzeroentry_ist do_debug, DEBUG_STACK
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq $0
CFI_ADJUST_CFA_OFFSET 8
paranoidentry do_debug, DEBUG_STACK
jmp paranoid_exit
CFI_ENDPROC
KPROBE_END(debug) KPROBE_END(debug)
/* runs on exception stack */ /* runs on exception stack */
...@@ -1351,14 +1373,12 @@ KPROBE_ENTRY(nmi) ...@@ -1351,14 +1373,12 @@ KPROBE_ENTRY(nmi)
DEFAULT_FRAME 0 DEFAULT_FRAME 0
/* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
movq %rsp,%rdi movq %rsp,%rdi
movq ORIG_RAX(%rsp),%rsi movq $-1,%rsi
movq $-1,ORIG_RAX(%rsp)
call do_nmi call do_nmi
DISABLE_INTERRUPTS(CLBR_NONE)
#ifdef CONFIG_TRACE_IRQFLAGS #ifdef CONFIG_TRACE_IRQFLAGS
/* paranoidexit; without TRACE_IRQS_OFF */ /* paranoidexit; without TRACE_IRQS_OFF */
/* ebx: no swapgs flag */ /* ebx: no swapgs flag */
nmi_exit: DISABLE_INTERRUPTS(CLBR_NONE)
testl %ebx,%ebx /* swapgs needed? */ testl %ebx,%ebx /* swapgs needed? */
jnz nmi_restore jnz nmi_restore
testl $3,CS(%rsp) testl $3,CS(%rsp)
...@@ -1398,13 +1418,7 @@ nmi_schedule: ...@@ -1398,13 +1418,7 @@ nmi_schedule:
KPROBE_END(nmi) KPROBE_END(nmi)
KPROBE_ENTRY(int3) KPROBE_ENTRY(int3)
INTR_FRAME paranoidzeroentry_ist do_int3, DEBUG_STACK
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq $0
CFI_ADJUST_CFA_OFFSET 8
paranoidentry do_int3, DEBUG_STACK
jmp paranoid_exit
CFI_ENDPROC
KPROBE_END(int3) KPROBE_END(int3)
ENTRY(overflow) ENTRY(overflow)
...@@ -1425,11 +1439,7 @@ END(coprocessor_segment_overrun) ...@@ -1425,11 +1439,7 @@ END(coprocessor_segment_overrun)
/* runs on exception stack */ /* runs on exception stack */
ENTRY(double_fault) ENTRY(double_fault)
XCPT_FRAME paranoiderrorentry do_double_fault
PARAVIRT_ADJUST_EXCEPTION_FRAME
paranoidentry do_double_fault
jmp paranoid_exit
CFI_ENDPROC
END(double_fault) END(double_fault)
ENTRY(invalid_TSS) ENTRY(invalid_TSS)
...@@ -1442,11 +1452,7 @@ END(segment_not_present) ...@@ -1442,11 +1452,7 @@ END(segment_not_present)
/* runs on exception stack */ /* runs on exception stack */
ENTRY(stack_segment) ENTRY(stack_segment)
XCPT_FRAME paranoiderrorentry do_stack_segment
PARAVIRT_ADJUST_EXCEPTION_FRAME
paranoidentry do_stack_segment
jmp paranoid_exit
CFI_ENDPROC
END(stack_segment) END(stack_segment)
KPROBE_ENTRY(general_protection) KPROBE_ENTRY(general_protection)
...@@ -1468,13 +1474,7 @@ END(spurious_interrupt_bug) ...@@ -1468,13 +1474,7 @@ END(spurious_interrupt_bug)
#ifdef CONFIG_X86_MCE #ifdef CONFIG_X86_MCE
/* runs on exception stack */ /* runs on exception stack */
ENTRY(machine_check) ENTRY(machine_check)
INTR_FRAME paranoidzeroentry do_machine_check
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq $0
CFI_ADJUST_CFA_OFFSET 8
paranoidentry do_machine_check
jmp paranoid_exit
CFI_ENDPROC
END(machine_check) END(machine_check)
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment