x86: use asm .macro instead of cpp #define in entry_32.S
Impact: cleanup Use .macro instead of cpp #define where approriate. This cleans up code and will ease future changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
d627ded5ab
commit
f0d96110f9
|
@ -101,121 +101,127 @@
|
||||||
#define resume_userspace_sig resume_userspace
|
#define resume_userspace_sig resume_userspace
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAVE_ALL \
|
.macro SAVE_ALL
|
||||||
cld; \
|
cld
|
||||||
pushl %fs; \
|
pushl %fs
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
/*CFI_REL_OFFSET fs, 0;*/\
|
/*CFI_REL_OFFSET fs, 0;*/
|
||||||
pushl %es; \
|
pushl %es
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
/*CFI_REL_OFFSET es, 0;*/\
|
/*CFI_REL_OFFSET es, 0;*/
|
||||||
pushl %ds; \
|
pushl %ds
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
/*CFI_REL_OFFSET ds, 0;*/\
|
/*CFI_REL_OFFSET ds, 0;*/
|
||||||
pushl %eax; \
|
pushl %eax
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET eax, 0;\
|
CFI_REL_OFFSET eax, 0
|
||||||
pushl %ebp; \
|
pushl %ebp
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET ebp, 0;\
|
CFI_REL_OFFSET ebp, 0
|
||||||
pushl %edi; \
|
pushl %edi
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET edi, 0;\
|
CFI_REL_OFFSET edi, 0
|
||||||
pushl %esi; \
|
pushl %esi
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET esi, 0;\
|
CFI_REL_OFFSET esi, 0
|
||||||
pushl %edx; \
|
pushl %edx
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET edx, 0;\
|
CFI_REL_OFFSET edx, 0
|
||||||
pushl %ecx; \
|
pushl %ecx
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET ecx, 0;\
|
CFI_REL_OFFSET ecx, 0
|
||||||
pushl %ebx; \
|
pushl %ebx
|
||||||
CFI_ADJUST_CFA_OFFSET 4;\
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET ebx, 0;\
|
CFI_REL_OFFSET ebx, 0
|
||||||
movl $(__USER_DS), %edx; \
|
movl $(__USER_DS), %edx
|
||||||
movl %edx, %ds; \
|
movl %edx, %ds
|
||||||
movl %edx, %es; \
|
movl %edx, %es
|
||||||
movl $(__KERNEL_PERCPU), %edx; \
|
movl $(__KERNEL_PERCPU), %edx
|
||||||
movl %edx, %fs
|
movl %edx, %fs
|
||||||
|
.endm
|
||||||
|
|
||||||
#define RESTORE_INT_REGS \
|
.macro RESTORE_INT_REGS
|
||||||
popl %ebx; \
|
popl %ebx
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE ebx;\
|
CFI_RESTORE ebx
|
||||||
popl %ecx; \
|
popl %ecx
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE ecx;\
|
CFI_RESTORE ecx
|
||||||
popl %edx; \
|
popl %edx
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE edx;\
|
CFI_RESTORE edx
|
||||||
popl %esi; \
|
popl %esi
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE esi;\
|
CFI_RESTORE esi
|
||||||
popl %edi; \
|
popl %edi
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE edi;\
|
CFI_RESTORE edi
|
||||||
popl %ebp; \
|
popl %ebp
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE ebp;\
|
CFI_RESTORE ebp
|
||||||
popl %eax; \
|
popl %eax
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
CFI_RESTORE eax
|
CFI_RESTORE eax
|
||||||
|
.endm
|
||||||
|
|
||||||
#define RESTORE_REGS \
|
.macro RESTORE_REGS
|
||||||
RESTORE_INT_REGS; \
|
RESTORE_INT_REGS
|
||||||
1: popl %ds; \
|
1: popl %ds
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
/*CFI_RESTORE ds;*/\
|
/*CFI_RESTORE ds;*/
|
||||||
2: popl %es; \
|
2: popl %es
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
/*CFI_RESTORE es;*/\
|
/*CFI_RESTORE es;*/
|
||||||
3: popl %fs; \
|
3: popl %fs
|
||||||
CFI_ADJUST_CFA_OFFSET -4;\
|
CFI_ADJUST_CFA_OFFSET -4
|
||||||
/*CFI_RESTORE fs;*/\
|
/*CFI_RESTORE fs;*/
|
||||||
.pushsection .fixup,"ax"; \
|
.pushsection .fixup, "ax"
|
||||||
4: movl $0,(%esp); \
|
4: movl $0, (%esp)
|
||||||
jmp 1b; \
|
jmp 1b
|
||||||
5: movl $0,(%esp); \
|
5: movl $0, (%esp)
|
||||||
jmp 2b; \
|
jmp 2b
|
||||||
6: movl $0,(%esp); \
|
6: movl $0, (%esp)
|
||||||
jmp 3b; \
|
jmp 3b
|
||||||
.section __ex_table,"a";\
|
.section __ex_table, "a"
|
||||||
.align 4; \
|
.align 4
|
||||||
.long 1b,4b; \
|
.long 1b, 4b
|
||||||
.long 2b,5b; \
|
.long 2b, 5b
|
||||||
.long 3b,6b; \
|
.long 3b, 6b
|
||||||
.popsection
|
.popsection
|
||||||
|
.endm
|
||||||
|
|
||||||
#define RING0_INT_FRAME \
|
.macro RING0_INT_FRAME
|
||||||
CFI_STARTPROC simple;\
|
CFI_STARTPROC simple
|
||||||
CFI_SIGNAL_FRAME;\
|
CFI_SIGNAL_FRAME
|
||||||
CFI_DEF_CFA esp, 3*4;\
|
CFI_DEF_CFA esp, 3*4
|
||||||
/*CFI_OFFSET cs, -2*4;*/\
|
/*CFI_OFFSET cs, -2*4;*/
|
||||||
CFI_OFFSET eip, -3*4
|
CFI_OFFSET eip, -3*4
|
||||||
|
.endm
|
||||||
|
|
||||||
#define RING0_EC_FRAME \
|
.macro RING0_EC_FRAME
|
||||||
CFI_STARTPROC simple;\
|
CFI_STARTPROC simple
|
||||||
CFI_SIGNAL_FRAME;\
|
CFI_SIGNAL_FRAME
|
||||||
CFI_DEF_CFA esp, 4*4;\
|
CFI_DEF_CFA esp, 4*4
|
||||||
/*CFI_OFFSET cs, -2*4;*/\
|
/*CFI_OFFSET cs, -2*4;*/
|
||||||
CFI_OFFSET eip, -3*4
|
CFI_OFFSET eip, -3*4
|
||||||
|
.endm
|
||||||
|
|
||||||
#define RING0_PTREGS_FRAME \
|
.macro RING0_PTREGS_FRAME
|
||||||
CFI_STARTPROC simple;\
|
CFI_STARTPROC simple
|
||||||
CFI_SIGNAL_FRAME;\
|
CFI_SIGNAL_FRAME
|
||||||
CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\
|
CFI_DEF_CFA esp, PT_OLDESP-PT_EBX
|
||||||
/*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\
|
/*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/
|
||||||
CFI_OFFSET eip, PT_EIP-PT_OLDESP;\
|
CFI_OFFSET eip, PT_EIP-PT_OLDESP
|
||||||
/*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\
|
/*CFI_OFFSET es, PT_ES-PT_OLDESP;*/
|
||||||
/*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\
|
/*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/
|
||||||
CFI_OFFSET eax, PT_EAX-PT_OLDESP;\
|
CFI_OFFSET eax, PT_EAX-PT_OLDESP
|
||||||
CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\
|
CFI_OFFSET ebp, PT_EBP-PT_OLDESP
|
||||||
CFI_OFFSET edi, PT_EDI-PT_OLDESP;\
|
CFI_OFFSET edi, PT_EDI-PT_OLDESP
|
||||||
CFI_OFFSET esi, PT_ESI-PT_OLDESP;\
|
CFI_OFFSET esi, PT_ESI-PT_OLDESP
|
||||||
CFI_OFFSET edx, PT_EDX-PT_OLDESP;\
|
CFI_OFFSET edx, PT_EDX-PT_OLDESP
|
||||||
CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\
|
CFI_OFFSET ecx, PT_ECX-PT_OLDESP
|
||||||
CFI_OFFSET ebx, PT_EBX-PT_OLDESP
|
CFI_OFFSET ebx, PT_EBX-PT_OLDESP
|
||||||
|
.endm
|
||||||
|
|
||||||
ENTRY(ret_from_fork)
|
ENTRY(ret_from_fork)
|
||||||
CFI_STARTPROC
|
CFI_STARTPROC
|
||||||
|
@ -595,28 +601,30 @@ syscall_badsys:
|
||||||
END(syscall_badsys)
|
END(syscall_badsys)
|
||||||
CFI_ENDPROC
|
CFI_ENDPROC
|
||||||
|
|
||||||
#define FIXUP_ESPFIX_STACK \
|
.macro FIXUP_ESPFIX_STACK
|
||||||
/* since we are on a wrong stack, we cant make it a C code :( */ \
|
/* since we are on a wrong stack, we cant make it a C code :( */
|
||||||
PER_CPU(gdt_page, %ebx); \
|
PER_CPU(gdt_page, %ebx)
|
||||||
GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
|
GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
|
||||||
addl %esp, %eax; \
|
addl %esp, %eax
|
||||||
pushl $__KERNEL_DS; \
|
pushl $__KERNEL_DS
|
||||||
CFI_ADJUST_CFA_OFFSET 4; \
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
pushl %eax; \
|
pushl %eax
|
||||||
CFI_ADJUST_CFA_OFFSET 4; \
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
lss (%esp), %esp; \
|
lss (%esp), %esp
|
||||||
CFI_ADJUST_CFA_OFFSET -8;
|
CFI_ADJUST_CFA_OFFSET -8
|
||||||
#define UNWIND_ESPFIX_STACK \
|
.endm
|
||||||
movl %ss, %eax; \
|
.macro UNWIND_ESPFIX_STACK
|
||||||
/* see if on espfix stack */ \
|
movl %ss, %eax
|
||||||
cmpw $__ESPFIX_SS, %ax; \
|
/* see if on espfix stack */
|
||||||
jne 27f; \
|
cmpw $__ESPFIX_SS, %ax
|
||||||
movl $__KERNEL_DS, %eax; \
|
jne 27f
|
||||||
movl %eax, %ds; \
|
movl $__KERNEL_DS, %eax
|
||||||
movl %eax, %es; \
|
movl %eax, %ds
|
||||||
/* switch to normal stack */ \
|
movl %eax, %es
|
||||||
FIXUP_ESPFIX_STACK; \
|
/* switch to normal stack */
|
||||||
27:;
|
FIXUP_ESPFIX_STACK
|
||||||
|
27:
|
||||||
|
.endm
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build the entry stubs and pointer table with some assembler magic.
|
* Build the entry stubs and pointer table with some assembler magic.
|
||||||
|
@ -1136,26 +1144,27 @@ END(page_fault)
|
||||||
* by hand onto the new stack - while updating the return eip past
|
* by hand onto the new stack - while updating the return eip past
|
||||||
* the instruction that would have done it for sysenter.
|
* the instruction that would have done it for sysenter.
|
||||||
*/
|
*/
|
||||||
#define FIX_STACK(offset, ok, label) \
|
.macro FIX_STACK offset ok label
|
||||||
cmpw $__KERNEL_CS,4(%esp); \
|
cmpw $__KERNEL_CS, 4(%esp)
|
||||||
jne ok; \
|
jne \ok
|
||||||
label: \
|
\label:
|
||||||
movl TSS_sysenter_sp0+offset(%esp),%esp; \
|
movl TSS_sysenter_sp0 + \offset(%esp), %esp
|
||||||
CFI_DEF_CFA esp, 0; \
|
CFI_DEF_CFA esp, 0
|
||||||
CFI_UNDEFINED eip; \
|
CFI_UNDEFINED eip
|
||||||
pushfl; \
|
pushfl
|
||||||
CFI_ADJUST_CFA_OFFSET 4; \
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
pushl $__KERNEL_CS; \
|
pushl $__KERNEL_CS
|
||||||
CFI_ADJUST_CFA_OFFSET 4; \
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
pushl $sysenter_past_esp; \
|
pushl $sysenter_past_esp
|
||||||
CFI_ADJUST_CFA_OFFSET 4; \
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
CFI_REL_OFFSET eip, 0
|
CFI_REL_OFFSET eip, 0
|
||||||
|
.endm
|
||||||
|
|
||||||
ENTRY(debug)
|
ENTRY(debug)
|
||||||
RING0_INT_FRAME
|
RING0_INT_FRAME
|
||||||
cmpl $ia32_sysenter_target,(%esp)
|
cmpl $ia32_sysenter_target,(%esp)
|
||||||
jne debug_stack_correct
|
jne debug_stack_correct
|
||||||
FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
|
FIX_STACK 12, debug_stack_correct, debug_esp_fix_insn
|
||||||
debug_stack_correct:
|
debug_stack_correct:
|
||||||
pushl $-1 # mark this as an int
|
pushl $-1 # mark this as an int
|
||||||
CFI_ADJUST_CFA_OFFSET 4
|
CFI_ADJUST_CFA_OFFSET 4
|
||||||
|
@ -1213,7 +1222,7 @@ nmi_stack_correct:
|
||||||
|
|
||||||
nmi_stack_fixup:
|
nmi_stack_fixup:
|
||||||
RING0_INT_FRAME
|
RING0_INT_FRAME
|
||||||
FIX_STACK(12,nmi_stack_correct, 1)
|
FIX_STACK 12, nmi_stack_correct, 1
|
||||||
jmp nmi_stack_correct
|
jmp nmi_stack_correct
|
||||||
|
|
||||||
nmi_debug_stack_check:
|
nmi_debug_stack_check:
|
||||||
|
@ -1224,7 +1233,7 @@ nmi_debug_stack_check:
|
||||||
jb nmi_stack_correct
|
jb nmi_stack_correct
|
||||||
cmpl $debug_esp_fix_insn,(%esp)
|
cmpl $debug_esp_fix_insn,(%esp)
|
||||||
ja nmi_stack_correct
|
ja nmi_stack_correct
|
||||||
FIX_STACK(24,nmi_stack_correct, 1)
|
FIX_STACK 24, nmi_stack_correct, 1
|
||||||
jmp nmi_stack_correct
|
jmp nmi_stack_correct
|
||||||
|
|
||||||
nmi_espfix_stack:
|
nmi_espfix_stack:
|
||||||
|
|
Loading…
Reference in New Issue