All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Denys Vlasenko <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: fweisbec@gmail.com, peterz@infradead.org, ast@plumgrid.com,
	linux-kernel@vger.kernel.org, oleg@redhat.com, brgerst@gmail.com,
	keescook@chromium.org, rostedt@goodmis.org, tglx@linutronix.de,
	wad@chromium.org, akpm@linux-foundation.org, mingo@kernel.org,
	luto@amacapital.net, torvalds@linux-foundation.org,
	hpa@zytor.com, bp@alien8.de, dvlasenk@redhat.com
Subject: [tip:x86/asm] x86/asm/entry/32: Open-code CLEAR_RREGS
Date: Sun, 7 Jun 2015 01:31:19 -0700	[thread overview]
Message-ID: <tip-ef0cd5dc25404594f832dad9133abae52e3b2fa3@git.kernel.org> (raw)
In-Reply-To: <1433271842-9139-1-git-send-email-dvlasenk@redhat.com>

Commit-ID:  ef0cd5dc25404594f832dad9133abae52e3b2fa3
Gitweb:     http://git.kernel.org/tip/ef0cd5dc25404594f832dad9133abae52e3b2fa3
Author:     Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Tue, 2 Jun 2015 21:04:01 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 5 Jun 2015 13:22:22 +0200

x86/asm/entry/32: Open-code CLEAR_RREGS

This macro is small, has only four callsites, and one of them is
slightly different using a conditional parameter.

A few saved lines aren't worth the resulting obfuscation.

Generated machine code is identical.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
[ Added comments. ]
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: Brian Gerst <brgerst@gmail.com>
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/1433271842-9139-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/ia32entry.S | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/arch/x86/entry/ia32entry.S b/arch/x86/entry/ia32entry.S
index f00a409..8a45d2c 100644
--- a/arch/x86/entry/ia32entry.S
+++ b/arch/x86/entry/ia32entry.S
@@ -29,15 +29,6 @@
 
 	.section .entry.text, "ax"
 
-	/* clobbers %rax */
-	.macro  CLEAR_RREGS _r9=rax
-	xorl 	%eax,%eax
-	movq	%rax,R11(%rsp)
-	movq	%rax,R10(%rsp)
-	movq	%\_r9,R9(%rsp)
-	movq	%rax,R8(%rsp)
-	.endm
-
 	/*
 	 * Reload arg registers from stack in case ptrace changed them.
 	 * We don't reload %eax because syscall_trace_enter() returned
@@ -243,7 +234,11 @@ sysexit_from_sys_call:
 	TRACE_IRQS_OFF
 	testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
 	jz \exit
-	CLEAR_RREGS
+	xorl	%eax, %eax	/* do not leak kernel information */
+	movq	%rax, R11(%rsp)
+	movq	%rax, R10(%rsp)
+	movq	%rax, R9(%rsp)
+	movq	%rax, R8(%rsp)
 	jmp int_with_check
 	.endm
 
@@ -267,7 +262,11 @@ sysenter_tracesys:
 	jz	sysenter_auditsys
 #endif
 	SAVE_EXTRA_REGS
-	CLEAR_RREGS
+	xorl	%eax, %eax	/* do not leak kernel information */
+	movq	%rax, R11(%rsp)
+	movq	%rax, R10(%rsp)
+	movq	%rax, R9(%rsp)
+	movq	%rax, R8(%rsp)
 	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
 	call	syscall_trace_enter
 	LOAD_ARGS32  /* reload args from stack in case ptrace changed it */
@@ -407,7 +406,11 @@ cstar_tracesys:
 #endif
 	xchgl %r9d,%ebp
 	SAVE_EXTRA_REGS
-	CLEAR_RREGS r9
+	xorl	%eax, %eax	/* do not leak kernel information */
+	movq	%rax, R11(%rsp)
+	movq	%rax, R10(%rsp)
+	movq	%r9,  R9(%rsp)
+	movq	%rax, R8(%rsp)
 	movq %rsp,%rdi        /* &pt_regs -> arg1 */
 	call syscall_trace_enter
 	LOAD_ARGS32 1	/* reload args from stack in case ptrace changed it */
@@ -422,7 +425,11 @@ ia32_badarg:
 	jmp ia32_sysret
 
 ia32_ret_from_sys_call:
-	CLEAR_RREGS
+	xorl	%eax, %eax	/* do not leak kernel information */
+	movq	%rax, R11(%rsp)
+	movq	%rax, R10(%rsp)
+	movq	%rax, R9(%rsp)
+	movq	%rax, R8(%rsp)
 	jmp int_ret_from_sys_call
 
 /*

      parent reply	other threads:[~2015-06-07  8:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 19:04 [PATCH 1/2] x86/asm/entry/32: Open-code CLEAR_RREGS. No code changes Denys Vlasenko
2015-06-02 19:04 ` [PATCH 2/2] x86/asm/entry/32: Open-code LOAD_ARGS32. " Denys Vlasenko
2015-06-02 19:27   ` Borislav Petkov
2015-06-07  8:31   ` [tip:x86/asm] x86/asm/entry/32: Open-code LOAD_ARGS32 tip-bot for Denys Vlasenko
2015-06-02 19:34 ` [PATCH 1/2] x86/asm/entry/32: Open-code CLEAR_RREGS. No code changes Steven Rostedt
2015-06-02 20:25   ` Denys Vlasenko
2015-06-03  7:04   ` Ingo Molnar
2015-06-07  8:31 ` tip-bot for Denys Vlasenko [this message]

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-ef0cd5dc25404594f832dad9133abae52e3b2fa3@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@plumgrid.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.