Skip to contentSkip to conversation

x86/asm/entry/64: tidy up some instructions

PATCH Denys Vlasenko 1 participant 1 message Mar 31, 2015 x86

lore
Share & tools
lore
#0 lore raw

Tidy up TEST insns width to use shorter insn form,
Use logically correct JZ mnemonic instead of JE (this doesn't change code). Replace several BT insns with equivalent, but shorter TEST insns.

CC Linus Torvalds <[email protected]>
CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Borislav Petkov <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andy Lutomirski <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Alexei Starovoitov <[email protected]>
CC Will Drewry <[email protected]>
CC Kees Cook <[email protected]>
---
 arch/x86/kernel/entry_64.S | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
arch/x86/kernel/entry_64.S +17 -17
index 356266c..cc166ab 100644
@@ -67,8 +67,8 @@ ENDPROC(native_usergs_sysret64)
 
 .macro TRACE_IRQS_IRETQ
 #ifdef CONFIG_TRACE_IRQFLAGS
-	bt   $9,EFLAGS(%rsp)	/* interrupts off? */
-	jnc  1f
+	testb	$2, EFLAGS+1(%rsp)	/* interrupts off? */
+	jz	1f
 	TRACE_IRQS_ON
 1:
 #endif
@@ -100,8 +100,8 @@ ENDPROC(native_usergs_sysret64)
 .endm
 
 .macro TRACE_IRQS_IRETQ_DEBUG
-	bt   $9,EFLAGS(%rsp)	/* interrupts off? */
-	jnc  1f
+	testb	$2, EFLAGS+1(%rsp)	/* interrupts off? */
+	jz	1f
 	TRACE_IRQS_ON_DEBUG
 1:
 .endm
@@ -513,8 +513,8 @@ ENTRY(ret_from_fork)
 
 	RESTORE_EXTRA_REGS
 
-	testl $3,CS(%rsp)			# from kernel_thread?
-	jz   1f
+	testb	$3, CS(%rsp)			# from kernel_thread?
+	jz	1f
 
 	/*
 	 * By the time we get here, we have no idea whether our pt_regs,
@@ -598,8 +598,8 @@ END(interrupt)
 
 	leaq -RBP(%rsp),%rdi	/* arg1 for \func (pointer to pt_regs) */
 
-	testl $3, CS-RBP(%rsp)
-	je 1f
+	testb	$3, CS-RBP(%rsp)
+	jz	1f
 	SWAPGS
 1:
 	/*
@@ -653,8 +653,8 @@ ret_from_intr:
 	CFI_DEF_CFA_REGISTER	rsp
 	CFI_ADJUST_CFA_OFFSET	RBP
 
-	testl $3,CS(%rsp)
-	je retint_kernel
+	testb	$3, CS(%rsp)
+	jz	retint_kernel
 	/* Interrupt came from user space */
 
 	GET_THREAD_INFO(%rcx)
@@ -739,8 +739,8 @@ retint_kernel:
 #ifdef CONFIG_PREEMPT
 	/* Interrupts are off */
 	/* Check if we need preemption */
-	bt	$9,EFLAGS(%rsp)	/* interrupts were off? */
-	jnc	1f
+	testb	$2,EFLAGS+1(%rsp)	/* interrupts were off? */
+	jz	1f
 0:	cmpl	$0,PER_CPU_VAR(__preempt_count)
 	jnz	1f
 	call	preempt_schedule_irq
@@ -950,8 +950,8 @@ ENTRY(\sym)
 	.if \paranoid
 	.if \paranoid == 1
 	CFI_REMEMBER_STATE
-	testl $3, CS(%rsp)		/* If coming from userspace, switch */
-	jnz 1f				/* stacks. */
+	testb	$3, CS(%rsp)		/* If coming from userspace, switch */
+	jnz	1f			/* stacks. */
 	.endif
 	call paranoid_entry
 	.else
@@ -1291,8 +1291,8 @@ ENTRY(error_entry)
 	SAVE_C_REGS 8
 	SAVE_EXTRA_REGS 8
 	xorl %ebx,%ebx
-	testl $3,CS+8(%rsp)
-	je error_kernelspace
+	testb $3,CS+8(%rsp)
+	jz error_kernelspace
 error_swapgs:
 	SWAPGS
 error_sti:
@@ -1343,7 +1343,7 @@ ENTRY(error_exit)
 	TRACE_IRQS_OFF
 	GET_THREAD_INFO(%rcx)
 	testl %eax,%eax
-	jne retint_kernel
+	jnz retint_kernel
 	LOCKDEP_SYS_EXIT_IRQ
 	movl TI_flags(%rcx),%edx
 	movl $_TIF_WORK_MASK,%edi
Signature · 1 line
1.8.1.4