Skip to contentSkip to conversation

x86-64/asm: use negative immediates for stack adjustments

PATCH New Jan Beulich 2 participants 2 messages Jun 1, 2015 – Jun 2, 2015 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64/asm: use negative immediates for stack adjustments

Doing so allows adjustments by 128 bytes (occurring for REMOVE_PT_GPREGS_FROM_STACK 8 uses) to be expressed with a single byte immediate.

---
 arch/x86/include/asm/calling.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/calling.h +2 -2
@@ -91,7 +91,7 @@ For 32-bit we have the following convent
 #define SIZEOF_PTREGS	21*8
 
 	.macro ALLOC_PT_GPREGS_ON_STACK addskip=0
-	subq	$15*8+\addskip, %rsp
+	addq	$-(15*8+\addskip), %rsp
 	CFI_ADJUST_CFA_OFFSET 15*8+\addskip
 	.endm
 
@@ -204,7 +204,7 @@ For 32-bit we have the following convent
 	.endm
 
 	.macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
-	addq $15*8+\addskip, %rsp
+	subq $-(15*8+\addskip), %rsp
 	CFI_ADJUST_CFA_OFFSET -(15*8+\addskip)
 	.endm
 
#1 lore raw

[tip:x86/asm] x86/asm/entry/64: Use negative immediates for stack adjustments

x86/asm/entry/64: Use negative immediates for stack adjustments
Commit-ID:  2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Gitweb:     http://git.kernel.org/tip/2bf557ea3f49576fabe24cd5daf1a34e9ee22c3c
Author:     Jan Beulich <[email protected]>
AuthorDate: Mon, 1 Jun 2015 13:02:55 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 2 Jun 2015 10:10:09 +0200

x86/asm/entry/64: Use negative immediates for stack adjustments

Doing so allows adjustments by 128 bytes (occurring for REMOVE_PT_GPREGS_FROM_STACK 8 uses) to be expressed with a single byte immediate.

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/include/asm/calling.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/calling.h +2 -2
index 0d76acc..f4e6308 100644
@@ -89,7 +89,7 @@ For 32-bit we have the following conventions - kernel is built with
 #define SIZEOF_PTREGS	21*8
 
 	.macro ALLOC_PT_GPREGS_ON_STACK addskip=0
-	subq	$15*8+\addskip, %rsp
+	addq	$-(15*8+\addskip), %rsp
 	.endm
 
 	.macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
@@ -201,7 +201,7 @@ For 32-bit we have the following conventions - kernel is built with
 	.endm
 
 	.macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
-	addq $15*8+\addskip, %rsp
+	subq $-(15*8+\addskip), %rsp
 	.endm
 
 	.macro icebp