linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Some x86, asm cleanups
@ 2011-05-31 20:21 Borislav Petkov
  2011-05-31 20:21 ` [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros Borislav Petkov
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-05-31 20:21 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

Hi,

here are a couple of asm cleanups. I hope I don't break some esoteric
gas version with them. They survived booting into kvm and on a couple of
different machines so I might get lucky.

Suggestions welcome, as always.

Thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
@ 2011-05-31 20:21 ` Borislav Petkov
  2011-06-03 23:28   ` [tip:x86/asm] " tip-bot for Borislav Petkov
  2011-05-31 20:21 ` [PATCH 2/4] x86, asm: Flip SAVE_ARGS arguments logic Borislav Petkov
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-05-31 20:21 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

Use dwarf2 cfi annotation macros, making SAVE/RESTORE_* marginally more
readable.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/include/asm/calling.h |  101 ++++++++++++++++------------------------
 1 files changed, 41 insertions(+), 60 deletions(-)

diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 30af5a8..b67e06c 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -46,6 +46,7 @@ For 32-bit we have the following conventions - kernel is built with
 
 */
 
+#include "dwarf2.h"
 
 /*
  * 64-bit system call stack frame layout defines and helpers, for
@@ -87,30 +88,25 @@ For 32-bit we have the following conventions - kernel is built with
 	.macro SAVE_ARGS addskip=0, norcx=0, nor891011=0
 	subq  $9*8+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
-	movq  %rdi, 8*8(%rsp)
-	CFI_REL_OFFSET	rdi, 8*8
-	movq  %rsi, 7*8(%rsp)
-	CFI_REL_OFFSET	rsi, 7*8
-	movq  %rdx, 6*8(%rsp)
-	CFI_REL_OFFSET	rdx, 6*8
+	movq_cfi rdi, 8*8
+	movq_cfi rsi, 7*8
+	movq_cfi rdx, 6*8
+
 	.if \norcx
 	.else
-	movq  %rcx, 5*8(%rsp)
-	CFI_REL_OFFSET	rcx, 5*8
+	movq_cfi rcx, 5*8
 	.endif
-	movq  %rax, 4*8(%rsp)
-	CFI_REL_OFFSET	rax, 4*8
+
+	movq_cfi rax, 4*8
+
 	.if \nor891011
 	.else
-	movq  %r8, 3*8(%rsp)
-	CFI_REL_OFFSET	r8,  3*8
-	movq  %r9, 2*8(%rsp)
-	CFI_REL_OFFSET	r9,  2*8
-	movq  %r10, 1*8(%rsp)
-	CFI_REL_OFFSET	r10, 1*8
-	movq  %r11, (%rsp)
-	CFI_REL_OFFSET	r11, 0*8
+	movq_cfi r8,  3*8
+	movq_cfi r9,  2*8
+	movq_cfi r10, 1*8
+	movq_cfi r11, 0*8
 	.endif
+
 	.endm
 
 #define ARG_SKIP	(9*8)
@@ -119,37 +115,34 @@ For 32-bit we have the following conventions - kernel is built with
 			    skipr8910=0, skiprdx=0
 	.if \skipr11
 	.else
-	movq (%rsp), %r11
-	CFI_RESTORE r11
+	movq_cfi_restore 0*8, r11
 	.endif
+
 	.if \skipr8910
 	.else
-	movq 1*8(%rsp), %r10
-	CFI_RESTORE r10
-	movq 2*8(%rsp), %r9
-	CFI_RESTORE r9
-	movq 3*8(%rsp), %r8
-	CFI_RESTORE r8
+	movq_cfi_restore 1*8, r10
+	movq_cfi_restore 2*8, r9
+	movq_cfi_restore 3*8, r8
 	.endif
+
 	.if \skiprax
 	.else
-	movq 4*8(%rsp), %rax
-	CFI_RESTORE rax
+	movq_cfi_restore 4*8, rax
 	.endif
+
 	.if \skiprcx
 	.else
-	movq 5*8(%rsp), %rcx
-	CFI_RESTORE rcx
+	movq_cfi_restore 5*8, rcx
 	.endif
+
 	.if \skiprdx
 	.else
-	movq 6*8(%rsp), %rdx
-	CFI_RESTORE rdx
+	movq_cfi_restore 6*8, rdx
 	.endif
-	movq 7*8(%rsp), %rsi
-	CFI_RESTORE rsi
-	movq 8*8(%rsp), %rdi
-	CFI_RESTORE rdi
+
+	movq_cfi_restore 7*8, rsi
+	movq_cfi_restore 8*8, rdi
+
 	.if ARG_SKIP+\addskip > 0
 	addq $ARG_SKIP+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	-(ARG_SKIP+\addskip)
@@ -176,33 +169,21 @@ For 32-bit we have the following conventions - kernel is built with
 	.macro SAVE_REST
 	subq $REST_SKIP, %rsp
 	CFI_ADJUST_CFA_OFFSET	REST_SKIP
-	movq %rbx, 5*8(%rsp)
-	CFI_REL_OFFSET	rbx, 5*8
-	movq %rbp, 4*8(%rsp)
-	CFI_REL_OFFSET	rbp, 4*8
-	movq %r12, 3*8(%rsp)
-	CFI_REL_OFFSET	r12, 3*8
-	movq %r13, 2*8(%rsp)
-	CFI_REL_OFFSET	r13, 2*8
-	movq %r14, 1*8(%rsp)
-	CFI_REL_OFFSET	r14, 1*8
-	movq %r15, (%rsp)
-	CFI_REL_OFFSET	r15, 0*8
+	movq_cfi rbx, 5*8
+	movq_cfi rbp, 4*8
+	movq_cfi r12, 3*8
+	movq_cfi r13, 2*8
+	movq_cfi r14, 1*8
+	movq_cfi r15, 0*8
 	.endm
 
 	.macro RESTORE_REST
-	movq (%rsp),     %r15
-	CFI_RESTORE r15
-	movq 1*8(%rsp),  %r14
-	CFI_RESTORE r14
-	movq 2*8(%rsp),  %r13
-	CFI_RESTORE r13
-	movq 3*8(%rsp),  %r12
-	CFI_RESTORE r12
-	movq 4*8(%rsp),  %rbp
-	CFI_RESTORE rbp
-	movq 5*8(%rsp),  %rbx
-	CFI_RESTORE rbx
+	movq_cfi_restore 0*8, r15
+	movq_cfi_restore 1*8, r14
+	movq_cfi_restore 2*8, r13
+	movq_cfi_restore 3*8, r12
+	movq_cfi_restore 4*8, rbp
+	movq_cfi_restore 5*8, rbx
 	addq $REST_SKIP, %rsp
 	CFI_ADJUST_CFA_OFFSET	-(REST_SKIP)
 	.endm
-- 
1.7.5.3.401.gfb674


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/4] x86, asm: Flip SAVE_ARGS arguments logic
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
  2011-05-31 20:21 ` [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros Borislav Petkov
@ 2011-05-31 20:21 ` Borislav Petkov
  2011-06-03 23:28   ` [tip:x86/asm] " tip-bot for Borislav Petkov
  2011-05-31 20:21 ` [PATCH 3/4] x86, asm: Flip RESTORE_ARGS " Borislav Petkov
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-05-31 20:21 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

This saves us the else part of the conditional statement in the macro.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/ia32/ia32entry.S      |    6 +++---
 arch/x86/include/asm/calling.h |    8 +++-----
 arch/x86/kernel/entry_64.S     |    2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index c1870dd..c5435dc 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -143,7 +143,7 @@ ENTRY(ia32_sysenter_target)
 	CFI_REL_OFFSET rip,0
 	pushq_cfi %rax
 	cld
-	SAVE_ARGS 0,0,1
+	SAVE_ARGS 0,1,0
  	/* no need to do an access_ok check here because rbp has been
  	   32bit zero extended */ 
 1:	movl	(%rbp),%ebp
@@ -289,7 +289,7 @@ ENTRY(ia32_cstar_target)
 	 * disabled irqs and here we enable it straight after entry:
 	 */
 	ENABLE_INTERRUPTS(CLBR_NONE)
-	SAVE_ARGS 8,1,1
+	SAVE_ARGS 8,0,0
 	movl 	%eax,%eax	/* zero extension */
 	movq	%rax,ORIG_RAX-ARGOFFSET(%rsp)
 	movq	%rcx,RIP-ARGOFFSET(%rsp)
@@ -419,7 +419,7 @@ ENTRY(ia32_syscall)
 	cld
 	/* note the registers are not zero extended to the sf.
 	   this could be a problem. */
-	SAVE_ARGS 0,0,1
+	SAVE_ARGS 0,1,0
 	GET_THREAD_INFO(%r10)
 	orl   $TS_COMPAT,TI_status(%r10)
 	testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index b67e06c..b0b7d90 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -85,22 +85,20 @@ For 32-bit we have the following conventions - kernel is built with
 #define ARGOFFSET	R11
 #define SWFRAME		ORIG_RAX
 
-	.macro SAVE_ARGS addskip=0, norcx=0, nor891011=0
+	.macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
 	subq  $9*8+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
 	movq_cfi rdi, 8*8
 	movq_cfi rsi, 7*8
 	movq_cfi rdx, 6*8
 
-	.if \norcx
-	.else
+	.if \save_rcx
 	movq_cfi rcx, 5*8
 	.endif
 
 	movq_cfi rax, 4*8
 
-	.if \nor891011
-	.else
+	.if \save_r891011
 	movq_cfi r8,  3*8
 	movq_cfi r9,  2*8
 	movq_cfi r10, 1*8
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8a445a0..e5ece6b 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -473,7 +473,7 @@ ENTRY(system_call_after_swapgs)
 	 * and short:
 	 */
 	ENABLE_INTERRUPTS(CLBR_NONE)
-	SAVE_ARGS 8,1
+	SAVE_ARGS 8,0
 	movq  %rax,ORIG_RAX-ARGOFFSET(%rsp)
 	movq  %rcx,RIP-ARGOFFSET(%rsp)
 	CFI_REL_OFFSET rip,RIP-ARGOFFSET
-- 
1.7.5.3.401.gfb674


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/4] x86, asm: Flip RESTORE_ARGS arguments logic
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
  2011-05-31 20:21 ` [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros Borislav Petkov
  2011-05-31 20:21 ` [PATCH 2/4] x86, asm: Flip SAVE_ARGS arguments logic Borislav Petkov
@ 2011-05-31 20:21 ` Borislav Petkov
  2011-06-03 23:29   ` [tip:x86/asm] " tip-bot for Borislav Petkov
  2011-05-31 20:21 ` [PATCH 4/4] x86, asm: Cleanup thunk_64.S Borislav Petkov
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-05-31 20:21 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

... thus getting rid of the "else" part of the conditional statement in
the macro.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/ia32/ia32entry.S      |    4 ++--
 arch/x86/include/asm/calling.h |   21 ++++++++-------------
 arch/x86/kernel/entry_64.S     |    4 ++--
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index c5435dc..a0e866d 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -173,7 +173,7 @@ sysexit_from_sys_call:
 	andl  $~0x200,EFLAGS-R11(%rsp) 
 	movl	RIP-R11(%rsp),%edx		/* User %eip */
 	CFI_REGISTER rip,rdx
-	RESTORE_ARGS 1,24,1,1,1,1
+	RESTORE_ARGS 0,24,0,0,0,0
 	xorq	%r8,%r8
 	xorq	%r9,%r9
 	xorq	%r10,%r10
@@ -328,7 +328,7 @@ cstar_dispatch:
 	jnz sysretl_audit
 sysretl_from_sys_call:
 	andl $~TS_COMPAT,TI_status(%r10)
-	RESTORE_ARGS 1,-ARG_SKIP,1,1,1
+	RESTORE_ARGS 0,-ARG_SKIP,0,0,0
 	movl RIP-ARGOFFSET(%rsp),%ecx
 	CFI_REGISTER rip,rcx
 	movl EFLAGS-ARGOFFSET(%rsp),%r11d	
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index b0b7d90..a9e3a74 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -109,32 +109,27 @@ For 32-bit we have the following conventions - kernel is built with
 
 #define ARG_SKIP	(9*8)
 
-	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
-			    skipr8910=0, skiprdx=0
-	.if \skipr11
-	.else
+	.macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
+			    rstor_r8910=1, rstor_rdx=1
+	.if \rstor_r11
 	movq_cfi_restore 0*8, r11
 	.endif
 
-	.if \skipr8910
-	.else
+	.if \rstor_r8910
 	movq_cfi_restore 1*8, r10
 	movq_cfi_restore 2*8, r9
 	movq_cfi_restore 3*8, r8
 	.endif
 
-	.if \skiprax
-	.else
+	.if \rstor_rax
 	movq_cfi_restore 4*8, rax
 	.endif
 
-	.if \skiprcx
-	.else
+	.if \rstor_rcx
 	movq_cfi_restore 5*8, rcx
 	.endif
 
-	.if \skiprdx
-	.else
+	.if \rstor_rdx
 	movq_cfi_restore 6*8, rdx
 	.endif
 
@@ -193,7 +188,7 @@ For 32-bit we have the following conventions - kernel is built with
 
 	.macro RESTORE_ALL addskip=0
 	RESTORE_REST
-	RESTORE_ARGS 0, \addskip
+	RESTORE_ARGS 1, \addskip
 	.endm
 
 	.macro icebp
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e5ece6b..0412bcb 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -508,7 +508,7 @@ sysret_check:
 	TRACE_IRQS_ON
 	movq RIP-ARGOFFSET(%rsp),%rcx
 	CFI_REGISTER	rip,rcx
-	RESTORE_ARGS 0,-ARG_SKIP,1
+	RESTORE_ARGS 1,-ARG_SKIP,0
 	/*CFI_REGISTER	rflags,r11*/
 	movq	PER_CPU_VAR(old_rsp), %rsp
 	USERGS_SYSRET64
@@ -858,7 +858,7 @@ retint_restore_args:	/* return to kernel space */
 	 */
 	TRACE_IRQS_IRETQ
 restore_args:
-	RESTORE_ARGS 0,8,0
+	RESTORE_ARGS 1,8,1
 
 irq_return:
 	INTERRUPT_RETURN
-- 
1.7.5.3.401.gfb674


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/4] x86, asm: Cleanup thunk_64.S
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
                   ` (2 preceding siblings ...)
  2011-05-31 20:21 ` [PATCH 3/4] x86, asm: Flip RESTORE_ARGS " Borislav Petkov
@ 2011-05-31 20:21 ` Borislav Petkov
  2011-06-03 23:29   ` [tip:x86/asm] " tip-bot for Borislav Petkov
  2011-06-01  2:06 ` [PATCH 0/4] Some x86, asm cleanups H. Peter Anvin
  2011-06-03 20:07 ` [PATCH 5/4] x86, asm: Fix another binutils 2.16 issue Borislav Petkov
  5 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-05-31 20:21 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

Drop thunk_ra macro in favor of an additional argument to the thunk
macro since their bodies are almost identical. Do a whitespace scrubbing
and use CFI-aware macros for full annotation.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/lib/thunk_64.S |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
index 782b082..d5b088b 100644
--- a/arch/x86/lib/thunk_64.S
+++ b/arch/x86/lib/thunk_64.S
@@ -5,50 +5,42 @@
  * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc.
  * Subject to the GNU public license, v.2. No warranty of any kind.
  */
+#include <linux/linkage.h>
+#include <asm/dwarf2.h>
+#include <asm/calling.h>
+#include <asm/rwlock.h>
 
-	#include <linux/linkage.h>
-	#include <asm/dwarf2.h>
-	#include <asm/calling.h>			
-	#include <asm/rwlock.h>
-		
-	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */ 	
-	.macro thunk name,func
-	.globl \name
-\name:	
-	CFI_STARTPROC
-	SAVE_ARGS
-	call \func
-	jmp  restore
-	CFI_ENDPROC
-	.endm
-
-#ifdef CONFIG_TRACE_IRQFLAGS
-	/* put return address in rdi (arg1) */
-	.macro thunk_ra name,func
+	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */
+	.macro THUNK name, func, put_ret_addr_in_rdi=0
 	.globl \name
 \name:
 	CFI_STARTPROC
+
+	/* this one pushes 9 elems, the next one would be %rIP */
 	SAVE_ARGS
-	/* SAVE_ARGS pushs 9 elements */
-	/* the next element would be the rip */
-	movq 9*8(%rsp), %rdi
+
+	.if \put_ret_addr_in_rdi
+	movq_cfi_restore 9*8, rdi
+	.endif
+
 	call \func
 	jmp  restore
 	CFI_ENDPROC
 	.endm
 
-	thunk_ra trace_hardirqs_on_thunk,trace_hardirqs_on_caller
-	thunk_ra trace_hardirqs_off_thunk,trace_hardirqs_off_caller
+#ifdef CONFIG_TRACE_IRQFLAGS
+	THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
+	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
 #endif
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-	thunk lockdep_sys_exit_thunk,lockdep_sys_exit
+	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
 #endif
-	
+
 	/* SAVE_ARGS below is used only for the .cfi directives it contains. */
 	CFI_STARTPROC
 	SAVE_ARGS
 restore:
 	RESTORE_ARGS
-	ret	
+	ret
 	CFI_ENDPROC
-- 
1.7.5.3.401.gfb674


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] Some x86, asm cleanups
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
                   ` (3 preceding siblings ...)
  2011-05-31 20:21 ` [PATCH 4/4] x86, asm: Cleanup thunk_64.S Borislav Petkov
@ 2011-06-01  2:06 ` H. Peter Anvin
  2011-06-01  6:48   ` Borislav Petkov
  2011-06-01 18:14   ` Borislav Petkov
  2011-06-03 20:07 ` [PATCH 5/4] x86, asm: Fix another binutils 2.16 issue Borislav Petkov
  5 siblings, 2 replies; 16+ messages in thread
From: H. Peter Anvin @ 2011-06-01  2:06 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Ingo Molnar, Thomas Gleixner, LKML

On 05/31/2011 01:21 PM, Borislav Petkov wrote:
> Hi,
> 
> here are a couple of asm cleanups. I hope I don't break some esoteric
> gas version with them. They survived booting into kvm and on a couple of
> different machines so I might get lucky.
> 
> Suggestions welcome, as always.
> 
> Thanks.

Any way you can try them out on the gas version from hell[TM], a.k.a. 2.16?

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] Some x86, asm cleanups
  2011-06-01  2:06 ` [PATCH 0/4] Some x86, asm cleanups H. Peter Anvin
@ 2011-06-01  6:48   ` Borislav Petkov
  2011-06-01 18:14   ` Borislav Petkov
  1 sibling, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-06-01  6:48 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Thomas Gleixner, LKML

On Tue, May 31, 2011 at 07:06:22PM -0700, H. Peter Anvin wrote:
> On 05/31/2011 01:21 PM, Borislav Petkov wrote:
> > Hi,
> > 
> > here are a couple of asm cleanups. I hope I don't break some esoteric
> > gas version with them. They survived booting into kvm and on a couple of
> > different machines so I might get lucky.
> > 
> > Suggestions welcome, as always.
> > 
> > Thanks.
> 
> Any way you can try them out on the gas version from hell[TM], a.k.a. 2.16?

Yeah, let me see what I can do. I remember vaguely that my colleague had
problems with some asm changes when building the kernel on suse and one
of their versions should have that bat from hell.

I'll let you know.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] Some x86, asm cleanups
  2011-06-01  2:06 ` [PATCH 0/4] Some x86, asm cleanups H. Peter Anvin
  2011-06-01  6:48   ` Borislav Petkov
@ 2011-06-01 18:14   ` Borislav Petkov
  2011-06-01 18:19     ` H. Peter Anvin
  1 sibling, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-06-01 18:14 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Borislav Petkov, Ingo Molnar, Thomas Gleixner, LKML

On Wed, 1 June, 2011 4:06 am, H. Peter Anvin wrote:
> On 05/31/2011 01:21 PM, Borislav Petkov wrote:
>> Hi,
>>
>> here are a couple of asm cleanups. I hope I don't break some esoteric
>> gas version with them. They survived booting into kvm and on a couple of
>> different machines so I might get lucky.
>>
>> Suggestions welcome, as always.
>>
>> Thanks.
>
> Any way you can try them out on the gas version from hell[TM], a.k.a.
> 2.16?

I think by that you mean this guy:

 as --version
GNU assembler 2.16.91.0.5 20051219 (SUSE Linux)
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-suse-linux'.

at least this is one incarnation of it. I had to install SLES10 SP3
with the unpatched binutils version in kvm to test. And yes, the kernel
builds fine. Let me know if I should run some randconfigs, in addition.

Btw, I'm keeping the kvm image for future testing with the bat from hell :).

-- 
Regards/Gruss,
Boris.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] Some x86, asm cleanups
  2011-06-01 18:14   ` Borislav Petkov
@ 2011-06-01 18:19     ` H. Peter Anvin
  2011-06-01 20:40       ` Borislav Petkov
  0 siblings, 1 reply; 16+ messages in thread
From: H. Peter Anvin @ 2011-06-01 18:19 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Ingo Molnar, Thomas Gleixner, LKML

On 06/01/2011 11:14 AM, Borislav Petkov wrote:
>>
>> Any way you can try them out on the gas version from hell[TM], a.k.a.
>> 2.16?
> 
> I think by that you mean this guy:
> 
>  as --version
> GNU assembler 2.16.91.0.5 20051219 (SUSE Linux)
> Copyright 2005 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License.  This program has absolutely no warranty.
> This assembler was configured for a target of `x86_64-suse-linux'.
> 
> at least this is one incarnation of it. I had to install SLES10 SP3
> with the unpatched binutils version in kvm to test. And yes, the kernel
> builds fine. Let me know if I should run some randconfigs, in addition.
> 
> Btw, I'm keeping the kvm image for future testing with the bat from hell :).
> 

I think 2.16.9x is really 2.17.

	-hpa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] Some x86, asm cleanups
  2011-06-01 18:19     ` H. Peter Anvin
@ 2011-06-01 20:40       ` Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-06-01 20:40 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Thomas Gleixner, LKML

On Wed, Jun 01, 2011 at 11:19:44AM -0700, H. Peter Anvin wrote:
> >  as --version
> > GNU assembler 2.16.91.0.5 20051219 (SUSE Linux)
> > Copyright 2005 Free Software Foundation, Inc.
> > This program is free software; you may redistribute it under the terms of
> > the GNU General Public License.  This program has absolutely no warranty.
> > This assembler was configured for a target of `x86_64-suse-linux'.
> > 
> > at least this is one incarnation of it. I had to install SLES10 SP3
> > with the unpatched binutils version in kvm to test. And yes, the kernel
> > builds fine. Let me know if I should run some randconfigs, in addition.
> > 
> > Btw, I'm keeping the kvm image for future testing with the bat from hell :).
> > 
> 
> I think 2.16.9x is really 2.17.

Well, this is the one we had problems last time:
http://marc.info/?l=linux-kernel&m=128568422205398&w=2

Do you know per chance a distro version that has the one gas from hell
you mean so I could test with it additionally?

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/4] x86, asm: Fix another binutils 2.16 issue
  2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
                   ` (4 preceding siblings ...)
  2011-06-01  2:06 ` [PATCH 0/4] Some x86, asm cleanups H. Peter Anvin
@ 2011-06-03 20:07 ` Borislav Petkov
  2011-06-03 23:30   ` [tip:x86/asm] x86, asm: Fix binutils 2.16 issue with __USER32_CS tip-bot for Borislav Petkov
  5 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-06-03 20:07 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: LKML, Borislav Petkov

While testing the patchset at

http://lkml.kernel.org/r/1306873314-32523-1-git-send-email-bp@alien8.de

with binutils 2.16.1 from hell, kernel build fails with the following
error:

arch/x86/ia32/ia32entry.S: Assembler messages:
arch/x86/ia32/ia32entry.S:139: Error: too many positional arguments
make[2]: *** [arch/x86/ia32/ia32entry.o] Error 1
make[1]: *** [arch/x86/ia32] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [arch/x86] Error 2
make: *** Waiting for unfinished jobs....

due to spaces between the operators of the __USER32_CS define. Fix it so
that gas 2.16 can swallow it too.

Signed-off-by: Borislav Petkov <bp@alien8.de>
---
 arch/x86/include/asm/segment.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index cd84f72..5e64171 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -162,7 +162,7 @@
 #define GDT_ENTRY_DEFAULT_USER32_CS 4
 #define GDT_ENTRY_DEFAULT_USER_DS 5
 #define GDT_ENTRY_DEFAULT_USER_CS 6
-#define __USER32_CS   (GDT_ENTRY_DEFAULT_USER32_CS * 8 + 3)
+#define __USER32_CS   (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
 #define __USER32_DS	__USER_DS
 
 #define GDT_ENTRY_TSS 8	/* needs two entries */
-- 
1.7.5.3.401.gfb674


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [tip:x86/asm] x86, asm: Thin down SAVE/RESTORE_* asm macros
  2011-05-31 20:21 ` [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros Borislav Petkov
@ 2011-06-03 23:28   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Borislav Petkov @ 2011-06-03 23:28 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp

Commit-ID:  a268fcfaa6ab2ef740fda5ecf947aca45ccd535d
Gitweb:     http://git.kernel.org/tip/a268fcfaa6ab2ef740fda5ecf947aca45ccd535d
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Tue, 31 May 2011 22:21:51 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 3 Jun 2011 14:38:49 -0700

x86, asm: Thin down SAVE/RESTORE_* asm macros

Use dwarf2 cfi annotation macros, making SAVE/RESTORE_* marginally more
readable.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1306873314-32523-2-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/calling.h |  101 ++++++++++++++++------------------------
 1 files changed, 41 insertions(+), 60 deletions(-)

diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 30af5a8..b67e06c 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -46,6 +46,7 @@ For 32-bit we have the following conventions - kernel is built with
 
 */
 
+#include "dwarf2.h"
 
 /*
  * 64-bit system call stack frame layout defines and helpers, for
@@ -87,30 +88,25 @@ For 32-bit we have the following conventions - kernel is built with
 	.macro SAVE_ARGS addskip=0, norcx=0, nor891011=0
 	subq  $9*8+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
-	movq  %rdi, 8*8(%rsp)
-	CFI_REL_OFFSET	rdi, 8*8
-	movq  %rsi, 7*8(%rsp)
-	CFI_REL_OFFSET	rsi, 7*8
-	movq  %rdx, 6*8(%rsp)
-	CFI_REL_OFFSET	rdx, 6*8
+	movq_cfi rdi, 8*8
+	movq_cfi rsi, 7*8
+	movq_cfi rdx, 6*8
+
 	.if \norcx
 	.else
-	movq  %rcx, 5*8(%rsp)
-	CFI_REL_OFFSET	rcx, 5*8
+	movq_cfi rcx, 5*8
 	.endif
-	movq  %rax, 4*8(%rsp)
-	CFI_REL_OFFSET	rax, 4*8
+
+	movq_cfi rax, 4*8
+
 	.if \nor891011
 	.else
-	movq  %r8, 3*8(%rsp)
-	CFI_REL_OFFSET	r8,  3*8
-	movq  %r9, 2*8(%rsp)
-	CFI_REL_OFFSET	r9,  2*8
-	movq  %r10, 1*8(%rsp)
-	CFI_REL_OFFSET	r10, 1*8
-	movq  %r11, (%rsp)
-	CFI_REL_OFFSET	r11, 0*8
+	movq_cfi r8,  3*8
+	movq_cfi r9,  2*8
+	movq_cfi r10, 1*8
+	movq_cfi r11, 0*8
 	.endif
+
 	.endm
 
 #define ARG_SKIP	(9*8)
@@ -119,37 +115,34 @@ For 32-bit we have the following conventions - kernel is built with
 			    skipr8910=0, skiprdx=0
 	.if \skipr11
 	.else
-	movq (%rsp), %r11
-	CFI_RESTORE r11
+	movq_cfi_restore 0*8, r11
 	.endif
+
 	.if \skipr8910
 	.else
-	movq 1*8(%rsp), %r10
-	CFI_RESTORE r10
-	movq 2*8(%rsp), %r9
-	CFI_RESTORE r9
-	movq 3*8(%rsp), %r8
-	CFI_RESTORE r8
+	movq_cfi_restore 1*8, r10
+	movq_cfi_restore 2*8, r9
+	movq_cfi_restore 3*8, r8
 	.endif
+
 	.if \skiprax
 	.else
-	movq 4*8(%rsp), %rax
-	CFI_RESTORE rax
+	movq_cfi_restore 4*8, rax
 	.endif
+
 	.if \skiprcx
 	.else
-	movq 5*8(%rsp), %rcx
-	CFI_RESTORE rcx
+	movq_cfi_restore 5*8, rcx
 	.endif
+
 	.if \skiprdx
 	.else
-	movq 6*8(%rsp), %rdx
-	CFI_RESTORE rdx
+	movq_cfi_restore 6*8, rdx
 	.endif
-	movq 7*8(%rsp), %rsi
-	CFI_RESTORE rsi
-	movq 8*8(%rsp), %rdi
-	CFI_RESTORE rdi
+
+	movq_cfi_restore 7*8, rsi
+	movq_cfi_restore 8*8, rdi
+
 	.if ARG_SKIP+\addskip > 0
 	addq $ARG_SKIP+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	-(ARG_SKIP+\addskip)
@@ -176,33 +169,21 @@ For 32-bit we have the following conventions - kernel is built with
 	.macro SAVE_REST
 	subq $REST_SKIP, %rsp
 	CFI_ADJUST_CFA_OFFSET	REST_SKIP
-	movq %rbx, 5*8(%rsp)
-	CFI_REL_OFFSET	rbx, 5*8
-	movq %rbp, 4*8(%rsp)
-	CFI_REL_OFFSET	rbp, 4*8
-	movq %r12, 3*8(%rsp)
-	CFI_REL_OFFSET	r12, 3*8
-	movq %r13, 2*8(%rsp)
-	CFI_REL_OFFSET	r13, 2*8
-	movq %r14, 1*8(%rsp)
-	CFI_REL_OFFSET	r14, 1*8
-	movq %r15, (%rsp)
-	CFI_REL_OFFSET	r15, 0*8
+	movq_cfi rbx, 5*8
+	movq_cfi rbp, 4*8
+	movq_cfi r12, 3*8
+	movq_cfi r13, 2*8
+	movq_cfi r14, 1*8
+	movq_cfi r15, 0*8
 	.endm
 
 	.macro RESTORE_REST
-	movq (%rsp),     %r15
-	CFI_RESTORE r15
-	movq 1*8(%rsp),  %r14
-	CFI_RESTORE r14
-	movq 2*8(%rsp),  %r13
-	CFI_RESTORE r13
-	movq 3*8(%rsp),  %r12
-	CFI_RESTORE r12
-	movq 4*8(%rsp),  %rbp
-	CFI_RESTORE rbp
-	movq 5*8(%rsp),  %rbx
-	CFI_RESTORE rbx
+	movq_cfi_restore 0*8, r15
+	movq_cfi_restore 1*8, r14
+	movq_cfi_restore 2*8, r13
+	movq_cfi_restore 3*8, r12
+	movq_cfi_restore 4*8, rbp
+	movq_cfi_restore 5*8, rbx
 	addq $REST_SKIP, %rsp
 	CFI_ADJUST_CFA_OFFSET	-(REST_SKIP)
 	.endm

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [tip:x86/asm] x86, asm: Flip SAVE_ARGS arguments logic
  2011-05-31 20:21 ` [PATCH 2/4] x86, asm: Flip SAVE_ARGS arguments logic Borislav Petkov
@ 2011-06-03 23:28   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Borislav Petkov @ 2011-06-03 23:28 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp

Commit-ID:  cac0e0a78f722abd85b7f8d614ee0820f7672f58
Gitweb:     http://git.kernel.org/tip/cac0e0a78f722abd85b7f8d614ee0820f7672f58
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Tue, 31 May 2011 22:21:52 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 3 Jun 2011 14:38:51 -0700

x86, asm: Flip SAVE_ARGS arguments logic

This saves us the else part of the conditional statement in the macro.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1306873314-32523-3-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/ia32/ia32entry.S      |    6 +++---
 arch/x86/include/asm/calling.h |    8 +++-----
 arch/x86/kernel/entry_64.S     |    2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index c1870dd..c5435dc 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -143,7 +143,7 @@ ENTRY(ia32_sysenter_target)
 	CFI_REL_OFFSET rip,0
 	pushq_cfi %rax
 	cld
-	SAVE_ARGS 0,0,1
+	SAVE_ARGS 0,1,0
  	/* no need to do an access_ok check here because rbp has been
  	   32bit zero extended */ 
 1:	movl	(%rbp),%ebp
@@ -289,7 +289,7 @@ ENTRY(ia32_cstar_target)
 	 * disabled irqs and here we enable it straight after entry:
 	 */
 	ENABLE_INTERRUPTS(CLBR_NONE)
-	SAVE_ARGS 8,1,1
+	SAVE_ARGS 8,0,0
 	movl 	%eax,%eax	/* zero extension */
 	movq	%rax,ORIG_RAX-ARGOFFSET(%rsp)
 	movq	%rcx,RIP-ARGOFFSET(%rsp)
@@ -419,7 +419,7 @@ ENTRY(ia32_syscall)
 	cld
 	/* note the registers are not zero extended to the sf.
 	   this could be a problem. */
-	SAVE_ARGS 0,0,1
+	SAVE_ARGS 0,1,0
 	GET_THREAD_INFO(%r10)
 	orl   $TS_COMPAT,TI_status(%r10)
 	testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index b67e06c..b0b7d90 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -85,22 +85,20 @@ For 32-bit we have the following conventions - kernel is built with
 #define ARGOFFSET	R11
 #define SWFRAME		ORIG_RAX
 
-	.macro SAVE_ARGS addskip=0, norcx=0, nor891011=0
+	.macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
 	subq  $9*8+\addskip, %rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
 	movq_cfi rdi, 8*8
 	movq_cfi rsi, 7*8
 	movq_cfi rdx, 6*8
 
-	.if \norcx
-	.else
+	.if \save_rcx
 	movq_cfi rcx, 5*8
 	.endif
 
 	movq_cfi rax, 4*8
 
-	.if \nor891011
-	.else
+	.if \save_r891011
 	movq_cfi r8,  3*8
 	movq_cfi r9,  2*8
 	movq_cfi r10, 1*8
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8a445a0..e5ece6b 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -473,7 +473,7 @@ ENTRY(system_call_after_swapgs)
 	 * and short:
 	 */
 	ENABLE_INTERRUPTS(CLBR_NONE)
-	SAVE_ARGS 8,1
+	SAVE_ARGS 8,0
 	movq  %rax,ORIG_RAX-ARGOFFSET(%rsp)
 	movq  %rcx,RIP-ARGOFFSET(%rsp)
 	CFI_REL_OFFSET rip,RIP-ARGOFFSET

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [tip:x86/asm] x86, asm: Flip RESTORE_ARGS arguments logic
  2011-05-31 20:21 ` [PATCH 3/4] x86, asm: Flip RESTORE_ARGS " Borislav Petkov
@ 2011-06-03 23:29   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Borislav Petkov @ 2011-06-03 23:29 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp

Commit-ID:  838feb47549a9b73534c6c1d7da4a9639a0750f4
Gitweb:     http://git.kernel.org/tip/838feb47549a9b73534c6c1d7da4a9639a0750f4
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Tue, 31 May 2011 22:21:53 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 3 Jun 2011 14:38:53 -0700

x86, asm: Flip RESTORE_ARGS arguments logic

... thus getting rid of the "else" part of the conditional statement in
the macro.

No functionality change.

Signed-off-by: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1306873314-32523-4-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/ia32/ia32entry.S      |    4 ++--
 arch/x86/include/asm/calling.h |   21 ++++++++-------------
 arch/x86/kernel/entry_64.S     |    4 ++--
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index c5435dc..a0e866d 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -173,7 +173,7 @@ sysexit_from_sys_call:
 	andl  $~0x200,EFLAGS-R11(%rsp) 
 	movl	RIP-R11(%rsp),%edx		/* User %eip */
 	CFI_REGISTER rip,rdx
-	RESTORE_ARGS 1,24,1,1,1,1
+	RESTORE_ARGS 0,24,0,0,0,0
 	xorq	%r8,%r8
 	xorq	%r9,%r9
 	xorq	%r10,%r10
@@ -328,7 +328,7 @@ cstar_dispatch:
 	jnz sysretl_audit
 sysretl_from_sys_call:
 	andl $~TS_COMPAT,TI_status(%r10)
-	RESTORE_ARGS 1,-ARG_SKIP,1,1,1
+	RESTORE_ARGS 0,-ARG_SKIP,0,0,0
 	movl RIP-ARGOFFSET(%rsp),%ecx
 	CFI_REGISTER rip,rcx
 	movl EFLAGS-ARGOFFSET(%rsp),%r11d	
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index b0b7d90..a9e3a74 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -109,32 +109,27 @@ For 32-bit we have the following conventions - kernel is built with
 
 #define ARG_SKIP	(9*8)
 
-	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
-			    skipr8910=0, skiprdx=0
-	.if \skipr11
-	.else
+	.macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
+			    rstor_r8910=1, rstor_rdx=1
+	.if \rstor_r11
 	movq_cfi_restore 0*8, r11
 	.endif
 
-	.if \skipr8910
-	.else
+	.if \rstor_r8910
 	movq_cfi_restore 1*8, r10
 	movq_cfi_restore 2*8, r9
 	movq_cfi_restore 3*8, r8
 	.endif
 
-	.if \skiprax
-	.else
+	.if \rstor_rax
 	movq_cfi_restore 4*8, rax
 	.endif
 
-	.if \skiprcx
-	.else
+	.if \rstor_rcx
 	movq_cfi_restore 5*8, rcx
 	.endif
 
-	.if \skiprdx
-	.else
+	.if \rstor_rdx
 	movq_cfi_restore 6*8, rdx
 	.endif
 
@@ -193,7 +188,7 @@ For 32-bit we have the following conventions - kernel is built with
 
 	.macro RESTORE_ALL addskip=0
 	RESTORE_REST
-	RESTORE_ARGS 0, \addskip
+	RESTORE_ARGS 1, \addskip
 	.endm
 
 	.macro icebp
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e5ece6b..0412bcb 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -508,7 +508,7 @@ sysret_check:
 	TRACE_IRQS_ON
 	movq RIP-ARGOFFSET(%rsp),%rcx
 	CFI_REGISTER	rip,rcx
-	RESTORE_ARGS 0,-ARG_SKIP,1
+	RESTORE_ARGS 1,-ARG_SKIP,0
 	/*CFI_REGISTER	rflags,r11*/
 	movq	PER_CPU_VAR(old_rsp), %rsp
 	USERGS_SYSRET64
@@ -858,7 +858,7 @@ retint_restore_args:	/* return to kernel space */
 	 */
 	TRACE_IRQS_IRETQ
 restore_args:
-	RESTORE_ARGS 0,8,0
+	RESTORE_ARGS 1,8,1
 
 irq_return:
 	INTERRUPT_RETURN

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [tip:x86/asm] x86, asm: Cleanup thunk_64.S
  2011-05-31 20:21 ` [PATCH 4/4] x86, asm: Cleanup thunk_64.S Borislav Petkov
@ 2011-06-03 23:29   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Borislav Petkov @ 2011-06-03 23:29 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp

Commit-ID:  38e6b75d3b6f4b9445eb6486e28fc716acda44ae
Gitweb:     http://git.kernel.org/tip/38e6b75d3b6f4b9445eb6486e28fc716acda44ae
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Tue, 31 May 2011 22:21:54 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 3 Jun 2011 14:38:55 -0700

x86, asm: Cleanup thunk_64.S

Drop thunk_ra macro in favor of an additional argument to the thunk
macro since their bodies are almost identical. Do a whitespace scrubbing
and use CFI-aware macros for full annotation.

Signed-off-by: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1306873314-32523-5-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/lib/thunk_64.S |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
index 782b082..d5b088b 100644
--- a/arch/x86/lib/thunk_64.S
+++ b/arch/x86/lib/thunk_64.S
@@ -5,50 +5,42 @@
  * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc.
  * Subject to the GNU public license, v.2. No warranty of any kind.
  */
+#include <linux/linkage.h>
+#include <asm/dwarf2.h>
+#include <asm/calling.h>
+#include <asm/rwlock.h>
 
-	#include <linux/linkage.h>
-	#include <asm/dwarf2.h>
-	#include <asm/calling.h>			
-	#include <asm/rwlock.h>
-		
-	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */ 	
-	.macro thunk name,func
-	.globl \name
-\name:	
-	CFI_STARTPROC
-	SAVE_ARGS
-	call \func
-	jmp  restore
-	CFI_ENDPROC
-	.endm
-
-#ifdef CONFIG_TRACE_IRQFLAGS
-	/* put return address in rdi (arg1) */
-	.macro thunk_ra name,func
+	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */
+	.macro THUNK name, func, put_ret_addr_in_rdi=0
 	.globl \name
 \name:
 	CFI_STARTPROC
+
+	/* this one pushes 9 elems, the next one would be %rIP */
 	SAVE_ARGS
-	/* SAVE_ARGS pushs 9 elements */
-	/* the next element would be the rip */
-	movq 9*8(%rsp), %rdi
+
+	.if \put_ret_addr_in_rdi
+	movq_cfi_restore 9*8, rdi
+	.endif
+
 	call \func
 	jmp  restore
 	CFI_ENDPROC
 	.endm
 
-	thunk_ra trace_hardirqs_on_thunk,trace_hardirqs_on_caller
-	thunk_ra trace_hardirqs_off_thunk,trace_hardirqs_off_caller
+#ifdef CONFIG_TRACE_IRQFLAGS
+	THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
+	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
 #endif
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-	thunk lockdep_sys_exit_thunk,lockdep_sys_exit
+	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
 #endif
-	
+
 	/* SAVE_ARGS below is used only for the .cfi directives it contains. */
 	CFI_STARTPROC
 	SAVE_ARGS
 restore:
 	RESTORE_ARGS
-	ret	
+	ret
 	CFI_ENDPROC

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [tip:x86/asm] x86, asm: Fix binutils 2.16 issue with __USER32_CS
  2011-06-03 20:07 ` [PATCH 5/4] x86, asm: Fix another binutils 2.16 issue Borislav Petkov
@ 2011-06-03 23:30   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: tip-bot for Borislav Petkov @ 2011-06-03 23:30 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, hpa, bp

Commit-ID:  dd2897bf0f4d523238e87dabb23e9634ea9ba73d
Gitweb:     http://git.kernel.org/tip/dd2897bf0f4d523238e87dabb23e9634ea9ba73d
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Fri, 3 Jun 2011 22:07:22 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 3 Jun 2011 14:39:14 -0700

x86, asm: Fix binutils 2.16 issue with __USER32_CS

While testing the patchset at

http://lkml.kernel.org/r/1306873314-32523-1-git-send-email-bp@alien8.de

with binutils 2.16.1 from hell, kernel build fails with the following
error:

arch/x86/ia32/ia32entry.S: Assembler messages:
arch/x86/ia32/ia32entry.S:139: Error: too many positional arguments
make[2]: *** [arch/x86/ia32/ia32entry.o] Error 1
make[1]: *** [arch/x86/ia32] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [arch/x86] Error 2
make: *** Waiting for unfinished jobs....

due to spaces between the operators of the __USER32_CS define. Fix it so
that gas 2.16 can swallow it too.

Signed-off-by: Borislav Petkov <bp@alien8.de>
Link: http://lkml.kernel.org/r/1307131642-32595-1-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/segment.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index cd84f72..5e64171 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -162,7 +162,7 @@
 #define GDT_ENTRY_DEFAULT_USER32_CS 4
 #define GDT_ENTRY_DEFAULT_USER_DS 5
 #define GDT_ENTRY_DEFAULT_USER_CS 6
-#define __USER32_CS   (GDT_ENTRY_DEFAULT_USER32_CS * 8 + 3)
+#define __USER32_CS   (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
 #define __USER32_DS	__USER_DS
 
 #define GDT_ENTRY_TSS 8	/* needs two entries */

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-06-03 23:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-31 20:21 [PATCH 0/4] Some x86, asm cleanups Borislav Petkov
2011-05-31 20:21 ` [PATCH 1/4] x86, asm: Thin down SAVE/RESTORE_* asm macros Borislav Petkov
2011-06-03 23:28   ` [tip:x86/asm] " tip-bot for Borislav Petkov
2011-05-31 20:21 ` [PATCH 2/4] x86, asm: Flip SAVE_ARGS arguments logic Borislav Petkov
2011-06-03 23:28   ` [tip:x86/asm] " tip-bot for Borislav Petkov
2011-05-31 20:21 ` [PATCH 3/4] x86, asm: Flip RESTORE_ARGS " Borislav Petkov
2011-06-03 23:29   ` [tip:x86/asm] " tip-bot for Borislav Petkov
2011-05-31 20:21 ` [PATCH 4/4] x86, asm: Cleanup thunk_64.S Borislav Petkov
2011-06-03 23:29   ` [tip:x86/asm] " tip-bot for Borislav Petkov
2011-06-01  2:06 ` [PATCH 0/4] Some x86, asm cleanups H. Peter Anvin
2011-06-01  6:48   ` Borislav Petkov
2011-06-01 18:14   ` Borislav Petkov
2011-06-01 18:19     ` H. Peter Anvin
2011-06-01 20:40       ` Borislav Petkov
2011-06-03 20:07 ` [PATCH 5/4] x86, asm: Fix another binutils 2.16 issue Borislav Petkov
2011-06-03 23:30   ` [tip:x86/asm] x86, asm: Fix binutils 2.16 issue with __USER32_CS tip-bot for Borislav Petkov

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).