aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2015-02-26 17:40:36 -0500
committerIngo Molnar <mingo@kernel.org>2015-03-04 16:50:52 -0500
commit911d2bb5ccaab102abbab2bb58438c75bc342ca9 (patch)
tree7a2e7045c1a312e4ed2a22eacc7790c70f65309b /arch/x86
parent14f6e9532dda399a7b789f744dc045f8865a9e42 (diff)
x86/asm/entry/64: Use more readable constants
Constants such as SS+8 or SS+8-RIP are mysterious. In most cases, SS+8 is just meant to be SIZEOF_PTREGS, SS+8-RIP is RIP's offset in the iret frame. This patch changes some of these constants to be less mysterious. No code changes (verified with objdump). Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com> Signed-off-by: Andy Lutomirski <luto@amacapital.net> Cc: Alexei Starovoitov <ast@plumgrid.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Drewry <wad@chromium.org> Link: http://lkml.kernel.org/r/1d20491384773bd606e23a382fac23ddb49b5178.1424989793.git.luto@amacapital.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/calling.h2
-rw-r--r--arch/x86/kernel/entry_64.S28
2 files changed, 18 insertions, 12 deletions
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 4a7ceb9789a5..337423590b08 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -88,6 +88,8 @@ For 32-bit we have the following conventions - kernel is built with
88#define RSP 19*8 88#define RSP 19*8
89#define SS 20*8 89#define SS 20*8
90 90
91#define SIZEOF_PTREGS 21*8
92
91 .macro ALLOC_PT_GPREGS_ON_STACK addskip=0 93 .macro ALLOC_PT_GPREGS_ON_STACK addskip=0
92 subq $15*8+\addskip, %rsp 94 subq $15*8+\addskip, %rsp
93 CFI_ADJUST_CFA_OFFSET 15*8+\addskip 95 CFI_ADJUST_CFA_OFFSET 15*8+\addskip
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 466947770648..858e94e86f5e 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -164,12 +164,12 @@ ENDPROC(native_usergs_sysret64)
164 * initial frame state for interrupts (and exceptions without error code) 164 * initial frame state for interrupts (and exceptions without error code)
165 */ 165 */
166 .macro INTR_FRAME start=1 offset=0 166 .macro INTR_FRAME start=1 offset=0
167 EMPTY_FRAME \start, SS+8+\offset-RIP 167 EMPTY_FRAME \start, 5*8+\offset
168 /*CFI_REL_OFFSET ss, SS+\offset-RIP*/ 168 /*CFI_REL_OFFSET ss, 4*8+\offset*/
169 CFI_REL_OFFSET rsp, RSP+\offset-RIP 169 CFI_REL_OFFSET rsp, 3*8+\offset
170 /*CFI_REL_OFFSET rflags, EFLAGS+\offset-RIP*/ 170 /*CFI_REL_OFFSET rflags, 2*8+\offset*/
171 /*CFI_REL_OFFSET cs, CS+\offset-RIP*/ 171 /*CFI_REL_OFFSET cs, 1*8+\offset*/
172 CFI_REL_OFFSET rip, RIP+\offset-RIP 172 CFI_REL_OFFSET rip, 0*8+\offset
173 .endm 173 .endm
174 174
175/* 175/*
@@ -177,7 +177,7 @@ ENDPROC(native_usergs_sysret64)
177 * with vector already pushed) 177 * with vector already pushed)
178 */ 178 */
179 .macro XCPT_FRAME start=1 offset=0 179 .macro XCPT_FRAME start=1 offset=0
180 INTR_FRAME \start, RIP+\offset-ORIG_RAX 180 INTR_FRAME \start, 1*8+\offset
181 .endm 181 .endm
182 182
183/* 183/*
@@ -645,10 +645,14 @@ END(interrupt)
645 cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp 645 cmovzq PER_CPU_VAR(irq_stack_ptr),%rsp
646 CFI_DEF_CFA_REGISTER rsi 646 CFI_DEF_CFA_REGISTER rsi
647 pushq %rsi 647 pushq %rsi
648 /*
649 * For debugger:
650 * "CFA (Current Frame Address) is the value on stack + offset"
651 */
648 CFI_ESCAPE 0x0f /* DW_CFA_def_cfa_expression */, 6, \ 652 CFI_ESCAPE 0x0f /* DW_CFA_def_cfa_expression */, 6, \
649 0x77 /* DW_OP_breg7 */, 0, \ 653 0x77 /* DW_OP_breg7 (rsp) */, 0, \
650 0x06 /* DW_OP_deref */, \ 654 0x06 /* DW_OP_deref */, \
651 0x08 /* DW_OP_const1u */, SS+8-RBP, \ 655 0x08 /* DW_OP_const1u */, SIZEOF_PTREGS-RBP, \
652 0x22 /* DW_OP_plus */ 656 0x22 /* DW_OP_plus */
653 /* We entered an interrupt context - irqs are off: */ 657 /* We entered an interrupt context - irqs are off: */
654 TRACE_IRQS_OFF 658 TRACE_IRQS_OFF
@@ -674,7 +678,7 @@ ret_from_intr:
674 678
675 /* Restore saved previous stack */ 679 /* Restore saved previous stack */
676 popq %rsi 680 popq %rsi
677 CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */ 681 CFI_DEF_CFA rsi,SIZEOF_PTREGS-RBP /* reg/off reset after def_cfa_expr */
678 /* return code expects complete pt_regs - adjust rsp accordingly: */ 682 /* return code expects complete pt_regs - adjust rsp accordingly: */
679 leaq -RBP(%rsi),%rsp 683 leaq -RBP(%rsi),%rsp
680 CFI_DEF_CFA_REGISTER rsp 684 CFI_DEF_CFA_REGISTER rsp
@@ -1549,7 +1553,7 @@ first_nmi:
1549 .rept 5 1553 .rept 5
1550 pushq_cfi 11*8(%rsp) 1554 pushq_cfi 11*8(%rsp)
1551 .endr 1555 .endr
1552 CFI_DEF_CFA_OFFSET SS+8-RIP 1556 CFI_DEF_CFA_OFFSET 5*8
1553 1557
1554 /* Everything up to here is safe from nested NMIs */ 1558 /* Everything up to here is safe from nested NMIs */
1555 1559
@@ -1577,7 +1581,7 @@ repeat_nmi:
1577 pushq_cfi -6*8(%rsp) 1581 pushq_cfi -6*8(%rsp)
1578 .endr 1582 .endr
1579 subq $(5*8), %rsp 1583 subq $(5*8), %rsp
1580 CFI_DEF_CFA_OFFSET SS+8-RIP 1584 CFI_DEF_CFA_OFFSET 5*8
1581end_repeat_nmi: 1585end_repeat_nmi:
1582 1586
1583 /* 1587 /*