From: tip-bot for Denys Vlasenko <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, hpa@zytor.com, peterz@infradead.org,
rostedt@goodmis.org, luto@amacapital.net,
torvalds@linux-foundation.org, oleg@redhat.com,
dvlasenk@redhat.com, wad@chromium.org,
linux-kernel@vger.kernel.org, ast@plumgrid.com,
akpm@linux-foundation.org, fweisbec@gmail.com,
keescook@chromium.org, tglx@linutronix.de, bp@alien8.de
Subject: [tip:x86/asm] x86/asm/entry/32: Explain reloading of registers after __audit_syscall_entry()
Date: Wed, 10 Jun 2015 00:09:52 -0700 [thread overview]
Message-ID: <tip-1536bb46fac7672ef04aaaa6a3b07848314263bc@git.kernel.org> (raw)
In-Reply-To: <1433876051-26604-2-git-send-email-dvlasenk@redhat.com>
Commit-ID: 1536bb46fac7672ef04aaaa6a3b07848314263bc
Gitweb: http://git.kernel.org/tip/1536bb46fac7672ef04aaaa6a3b07848314263bc
Author: Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Tue, 9 Jun 2015 20:54:08 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 10 Jun 2015 08:42:13 +0200
x86/asm/entry/32: Explain reloading of registers after __audit_syscall_entry()
Here it is not obvious why we load pt_regs->cx to %esi etc.
Lets improve comments.
Explain that here we combine two things: first, we reload
registers since some of them are clobbered by the C function we
just called; and we also convert 32-bit syscall params to 64-bit
C ABI, because we are going to jump back to syscall dispatch
code.
Move reloading of 6th argument into the macro instead of having
it after each of two macro invocations.
No actual code changes here.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
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: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1433876051-26604-2-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/entry/entry_64_compat.S | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 2c44180..0fa108c 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -185,12 +185,18 @@ sysexit_from_sys_call:
movl %ebx, %esi /* 2nd arg: 1st syscall arg */
movl %eax, %edi /* 1st arg: syscall number */
call __audit_syscall_entry
- movl ORIG_RAX(%rsp), %eax /* reload syscall number */
- movl %ebx, %edi /* reload 1st syscall arg */
- movl RCX(%rsp), %esi /* reload 2nd syscall arg */
- movl RDX(%rsp), %edx /* reload 3rd syscall arg */
- movl RSI(%rsp), %ecx /* reload 4th syscall arg */
- movl RDI(%rsp), %r8d /* reload 5th syscall arg */
+ /*
+ * We are going to jump back to syscall dispatch.
+ * Prepare syscall args as required by 64-bit C ABI.
+ * Clobbered registers are loaded from pt_regs on stack.
+ */
+ movl ORIG_RAX(%rsp), %eax /* syscall number */
+ movl %ebx, %edi /* arg1 */
+ movl RCX(%rsp), %esi /* arg2 */
+ movl RDX(%rsp), %edx /* arg3 */
+ movl RSI(%rsp), %ecx /* arg4 */
+ movl RDI(%rsp), %r8d /* arg5 */
+ movl %ebp, %r9d /* arg6 */
.endm
.macro auditsys_exit exit
@@ -221,7 +227,6 @@ sysexit_from_sys_call:
sysenter_auditsys:
auditsys_entry_common
- movl %ebp, %r9d /* reload 6th syscall arg */
jmp sysenter_dispatch
sysexit_audit:
@@ -379,7 +384,6 @@ sysretl_from_sys_call:
#ifdef CONFIG_AUDITSYSCALL
cstar_auditsys:
auditsys_entry_common
- movl %ebp, %r9d /* reload 6th syscall arg */
jmp cstar_dispatch
sysretl_audit:
next prev parent reply other threads:[~2015-06-10 7:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 18:54 [PATCH 1/5] x86/asm/entry/32: Fix fallout from r9 trick removal in SYSCALL code Denys Vlasenko
2015-06-09 18:54 ` [PATCH 2/5] x86/asm/entry/32: Explain reloading of registers after __audit_syscall_entry Denys Vlasenko
2015-06-10 7:09 ` tip-bot for Denys Vlasenko [this message]
2015-06-09 18:54 ` [PATCH 3/5] x86/asm/entry/32: Shorten __audit_syscall_entry args preparation Denys Vlasenko
2015-06-10 6:21 ` Ingo Molnar
2015-06-12 23:28 ` Andy Lutomirski
2015-06-10 7:10 ` [tip:x86/asm] x86/asm/entry/32: Shorten __audit_syscall_entry() " tip-bot for Denys Vlasenko
2015-06-09 18:54 ` [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with open-coded 32-bit reads Denys Vlasenko
2015-06-09 19:01 ` Andy Lutomirski
2015-06-09 19:03 ` Denys Vlasenko
2015-06-09 19:11 ` Andy Lutomirski
2015-06-09 19:18 ` Denys Vlasenko
2015-06-09 19:27 ` Andy Lutomirski
2015-06-14 8:40 ` Ingo Molnar
2015-06-14 15:21 ` Denys Vlasenko
2015-06-15 20:20 ` Ingo Molnar
2015-06-16 0:24 ` Denys Vlasenko
2015-06-18 9:31 ` Ingo Molnar
2015-06-18 10:59 ` Denys Vlasenko
2015-06-09 18:54 ` [PATCH 5/5] x86/asm/entry/32: Simplify ptrace register shuffling Denys Vlasenko
2015-06-09 18:59 ` Andy Lutomirski
2015-06-09 19:14 ` Denys Vlasenko
2015-06-18 9:33 ` Ingo Molnar
2015-06-10 7:09 ` [tip:x86/asm] x86/asm/entry/32: Fix fallout from the R9 trick removal in the SYSCALL code tip-bot for Denys Vlasenko
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=tip-1536bb46fac7672ef04aaaa6a3b07848314263bc@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=ast@plumgrid.com \
--cc=bp@alien8.de \
--cc=dvlasenk@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=wad@chromium.org \
/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