From: Alexander van Heukelum <heukelum@mailshack.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Jan Beulich <jbeulich@novell.com>,
Glauber Costa <gcosta@redhat.com>, Matt Mackall <mpm@selenic.com>,
Thomas Gleixner <tglx@linutronix.de>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH] x86: Introduce save_rest and restructure the PTREGSCALL macro in entry_64.S
Date: Fri, 21 Nov 2008 16:41:55 +0100 [thread overview]
Message-ID: <20081121154155.GA12999@mailshack.com> (raw)
In-Reply-To: <20081120153954.GA22511@elte.hu>
The save_rest function completes a partial stack frame for use
by the PTREGSCALL macro. This also avoid the indirect call in
PTREGSCALLs.
This adds the macro movq_cfi_restore to hide the CFI_RESTORE
annotation when restoring a register from the stack frame.
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
arch/x86/kernel/entry_64.S | 91 +++++++++++++++++++++++++------------------
1 files changed, 53 insertions(+), 38 deletions(-)
Hello Ingo,
Here are three more patches cleaning up entry_64.S. They apply to
current tip/x86/irq. Thanks again for your help on the binutils
problems!
Greetings,
Alexander
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 92c5e18..ef95c45 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -78,6 +78,11 @@
CFI_REL_OFFSET \reg, \offset
.endm
+ .macro movq_cfi_restore offset reg
+ movq \offset(%rsp), %\reg
+ CFI_RESTORE \reg
+ .endm
+
#ifdef CONFIG_FUNCTION_TRACER
#ifdef CONFIG_DYNAMIC_FTRACE
ENTRY(mcount)
@@ -186,21 +191,21 @@ ENTRY(native_usergs_sysret64)
*/
/* %rsp:at FRAMEEND */
- .macro FIXUP_TOP_OF_STACK tmp
- movq %gs:pda_oldrsp,\tmp
- movq \tmp,RSP(%rsp)
- movq $__USER_DS,SS(%rsp)
- movq $__USER_CS,CS(%rsp)
- movq $-1,RCX(%rsp)
- movq R11(%rsp),\tmp /* get eflags */
- movq \tmp,EFLAGS(%rsp)
+ .macro FIXUP_TOP_OF_STACK tmp offset=0
+ movq %gs:pda_oldrsp,\tmp
+ movq \tmp,RSP+\offset(%rsp)
+ movq $__USER_DS,SS+\offset(%rsp)
+ movq $__USER_CS,CS+\offset(%rsp)
+ movq $-1,RCX+\offset(%rsp)
+ movq R11+\offset(%rsp),\tmp /* get eflags */
+ movq \tmp,EFLAGS+\offset(%rsp)
.endm
- .macro RESTORE_TOP_OF_STACK tmp,offset=0
- movq RSP-\offset(%rsp),\tmp
- movq \tmp,%gs:pda_oldrsp
- movq EFLAGS-\offset(%rsp),\tmp
- movq \tmp,R11-\offset(%rsp)
+ .macro RESTORE_TOP_OF_STACK tmp offset=0
+ movq RSP+\offset(%rsp),\tmp
+ movq \tmp,%gs:pda_oldrsp
+ movq EFLAGS+\offset(%rsp),\tmp
+ movq \tmp,R11+\offset(%rsp)
.endm
.macro FAKE_STACK_FRAME child_rip
@@ -333,6 +338,21 @@ ENTRY(save_args)
CFI_ENDPROC
END(save_args)
+ENTRY(save_rest)
+ PARTIAL_FRAME 1 REST_SKIP+8
+ movq 5*8+16(%rsp), %r11 /* save return address */
+ movq_cfi rbx, RBX+16
+ movq_cfi rbp, RBP+16
+ movq_cfi r12, R12+16
+ movq_cfi r13, R13+16
+ movq_cfi r14, R14+16
+ movq_cfi r15, R15+16
+ movq %r11, 8(%rsp) /* return address */
+ FIXUP_TOP_OF_STACK %r11, 16
+ ret
+ CFI_ENDPROC
+END(save_rest)
+
/*
* A newly forked process directly context switches into this.
*/
@@ -353,7 +373,7 @@ rff_action:
je int_ret_from_sys_call
testl $_TIF_IA32,TI_flags(%rcx)
jnz int_ret_from_sys_call
- RESTORE_TOP_OF_STACK %rdi,ARGOFFSET
+ RESTORE_TOP_OF_STACK %rdi, -ARGOFFSET
jmp ret_from_sys_call
rff_trace:
movq %rsp,%rdi
@@ -626,18 +646,20 @@ END(system_call)
/*
* Certain special system calls that need to save a complete full stack frame.
*/
-
.macro PTREGSCALL label,func,arg
- .globl \label
-\label:
- leaq \func(%rip),%rax
- leaq -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
- jmp ptregscall_common
+ENTRY(\label)
+ PARTIAL_FRAME 1 8 /* offset 8: return address */
+ subq $REST_SKIP, %rsp
+ CFI_ADJUST_CFA_OFFSET REST_SKIP
+ call save_rest
+ DEFAULT_FRAME 0 8 /* offset 8: return address */
+ leaq 8(%rsp), \arg /* pt_regs pointer */
+ call \func
+ jmp ptregscall_common
+ CFI_ENDPROC
END(\label)
.endm
- CFI_STARTPROC
-
PTREGSCALL stub_clone, sys_clone, %r8
PTREGSCALL stub_fork, sys_fork, %rdi
PTREGSCALL stub_vfork, sys_vfork, %rdi
@@ -645,22 +667,15 @@ END(\label)
PTREGSCALL stub_iopl, sys_iopl, %rsi
ENTRY(ptregscall_common)
- popq %r11
- CFI_ADJUST_CFA_OFFSET -8
- CFI_REGISTER rip, r11
- SAVE_REST
- movq %r11, %r15
- CFI_REGISTER rip, r15
- FIXUP_TOP_OF_STACK %r11
- call *%rax
- RESTORE_TOP_OF_STACK %r11
- movq %r15, %r11
- CFI_REGISTER rip, r11
- RESTORE_REST
- pushq %r11
- CFI_ADJUST_CFA_OFFSET 8
- CFI_REL_OFFSET rip, 0
- ret
+ DEFAULT_FRAME 1 8 /* offset 8: return address */
+ RESTORE_TOP_OF_STACK %r11, 8
+ movq_cfi_restore R15+8, r15
+ movq_cfi_restore R14+8, r14
+ movq_cfi_restore R13+8, r13
+ movq_cfi_restore R12+8, r12
+ movq_cfi_restore RBP+8, rbp
+ movq_cfi_restore RBX+8, rbx
+ ret $REST_SKIP /* pop extended registers */
CFI_ENDPROC
END(ptregscall_common)
--
1.5.4.3
next prev parent reply other threads:[~2008-11-21 15:47 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-16 14:29 [PATCH] trivial, entry_64: remove whitespace at end of lines Alexander van Heukelum
2008-11-16 14:29 ` [RFC] x86: save_args out of line Alexander van Heukelum
2008-11-17 12:14 ` Glauber Costa
2008-11-17 15:13 ` Alexander van Heukelum
2008-11-17 12:53 ` Andi Kleen
2008-11-17 15:37 ` Alexander van Heukelum
2008-11-17 18:23 ` Andi Kleen
2008-11-17 19:22 ` Cyrill Gorcunov
2008-11-17 19:29 ` Cyrill Gorcunov
2008-11-17 19:49 ` Alexander van Heukelum
2008-11-17 19:54 ` Cyrill Gorcunov
2008-11-17 19:43 ` Alexander van Heukelum
2008-11-17 19:49 ` Cyrill Gorcunov
2008-11-17 17:52 ` [RFC,v2] x86_64: " Alexander van Heukelum
2008-11-18 8:09 ` Jan Beulich
2008-11-18 11:16 ` Alexander van Heukelum
2008-11-18 12:51 ` Jan Beulich
2008-11-18 14:03 ` Ingo Molnar
2008-11-18 14:52 ` Jan Beulich
2008-11-18 15:00 ` Ingo Molnar
2008-11-18 22:53 ` Roland McGrath
2008-11-18 23:35 ` Andi Kleen
2008-11-18 23:36 ` Jeremy Fitzhardinge
2008-11-18 23:44 ` H. Peter Anvin
2008-11-19 0:08 ` Jeremy Fitzhardinge
2008-11-18 23:45 ` Roland McGrath
2008-11-19 0:06 ` Andi Kleen
2008-11-19 0:01 ` H. Peter Anvin
2008-11-19 10:34 ` Ingo Molnar
2008-11-19 20:09 ` Ingo Molnar
2008-11-19 0:18 ` [PATCH/RFC] Move entry_64.S register saving out of the macros Alexander van Heukelum
2008-11-19 17:54 ` H. Peter Anvin
2008-11-19 20:16 ` Ingo Molnar
2008-11-20 13:40 ` [PATCH] x86: clean up after: move " Alexander van Heukelum
2008-11-20 14:01 ` Andi Kleen
2008-11-20 15:04 ` Ingo Molnar
2008-11-20 15:26 ` Alexander van Heukelum
2008-11-20 15:39 ` Ingo Molnar
2008-11-20 15:50 ` [PATCH] x86: clean up after: move entry_64.S register savingout " Jan Beulich
2008-11-20 15:57 ` [PATCH] x86: clean up after: move entry_64.S register saving out " Alexander van Heukelum
2008-11-20 16:07 ` Cyrill Gorcunov
2008-11-20 16:29 ` Alexander van Heukelum
2008-11-20 17:24 ` Ingo Molnar
2008-11-21 15:41 ` Alexander van Heukelum [this message]
2008-11-21 15:43 ` [PATCH] x86: entry_64.S: Factor out save_paranoid and paranoid_exit Alexander van Heukelum
2008-11-21 15:44 ` [PATCH] Split out some macro's and move common code to paranoid_exit Alexander van Heukelum
2008-11-21 16:06 ` Ingo Molnar
2008-11-23 9:08 ` [PATCH] x86: include ENTRY/END in entry handlers in entry_64.S Alexander van Heukelum
2008-11-23 9:15 ` [PATCH] x86: KPROBE_ENTRY should be paired wth KPROBE_END Alexander van Heukelum
2008-11-23 13:27 ` Ingo Molnar
2008-11-23 13:51 ` Cyrill Gorcunov
2008-11-23 14:12 ` Cyrill Gorcunov
2008-11-23 14:55 ` Ingo Molnar
2008-11-23 15:04 ` Cyrill Gorcunov
2008-11-23 15:04 ` Alexander van Heukelum
2008-11-23 15:12 ` Cyrill Gorcunov
2008-11-23 15:31 ` Ingo Molnar
2008-11-23 15:41 ` Cyrill Gorcunov
2008-11-23 15:37 ` Cyrill Gorcunov
2008-11-23 16:29 ` Ingo Molnar
2008-11-24 9:17 ` Jan Beulich
2008-11-24 10:26 ` Alexander van Heukelum
2008-11-24 10:35 ` Jan Beulich
2008-11-24 12:24 ` [PATCH] x86_64: get rid of the use of KPROBE_ENTRY / KPROBE_END Alexander van Heukelum
2008-11-24 13:33 ` Jan Beulich
2008-11-24 14:38 ` [PATCH] i386: " Alexander van Heukelum
2008-11-23 9:21 ` [PATCH] x86: include ENTRY/END in entry handlers in entry_64.S Cyrill Gorcunov
2008-11-23 11:23 ` Alexander van Heukelum
2008-11-23 11:35 ` Cyrill Gorcunov
2008-11-23 20:13 ` H. Peter Anvin
2008-11-24 10:06 ` Alexander van Heukelum
2008-11-24 18:07 ` H. Peter Anvin
2008-11-23 13:23 ` Ingo Molnar
2008-11-17 9:47 ` [PATCH] trivial, entry_64: remove whitespace at end of lines Ingo Molnar
2008-11-17 15:14 ` Alexander van Heukelum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081121154155.GA12999@mailshack.com \
--to=heukelum@mailshack.com \
--cc=andi@firstfloor.org \
--cc=gcosta@redhat.com \
--cc=gorcunov@gmail.com \
--cc=hpa@zytor.com \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mpm@selenic.com \
--cc=nickpiggin@yahoo.com.au \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).