aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2015-04-27 09:21:52 -0400
committerIngo Molnar <mingo@kernel.org>2015-05-08 05:07:32 -0400
commit03335e95e27fc1f2b17b05b27342ad76986b3cf0 (patch)
tree898f968c90a2db88bcbc82e7f972e9f0777b9e7c
parentdde74f2e4a4447ef838c57e407f7139de3df68cb (diff)
x86/asm/entry/64: Clean up usage of TEST insns
By the nature of TEST operation, it is often possible to test a narrower part of the operand: "testl $3, mem" -> "testb $3, mem" This results in shorter insns, because TEST insn has no sign-entending byte-immediate forms unlike other ALU ops. text data bss dec hex filename 11674 0 0 11674 2d9a entry_64.o.before 11658 0 0 11658 2d8a entry_64.o Changes in object code: - f7 84 24 88 00 00 00 03 00 00 00 testl $0x3,0x88(%rsp) + f6 84 24 88 00 00 00 03 testb $0x3,0x88(%rsp) - f7 44 24 68 03 00 00 00 testl $0x3,0x68(%rsp) + f6 44 24 68 03 testb $0x3,0x68(%rsp) - f7 84 24 90 00 00 00 03 00 00 00 testl $0x3,0x90(%rsp) + f6 84 24 90 00 00 00 03 testb $0x3,0x90(%rsp) Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com> Acked-by: Andy Lutomirski <luto@kernel.org> Cc: Alexei Starovoitov <ast@plumgrid.com> 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: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Drewry <wad@chromium.org> Link: http://lkml.kernel.org/r/1430140912-7960-2-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/entry_64.S11
1 files changed, 5 insertions, 6 deletions
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8f8b22a361df..60705b032521 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -601,7 +601,7 @@ ENTRY(ret_from_fork)
601 601
602 RESTORE_EXTRA_REGS 602 RESTORE_EXTRA_REGS
603 603
604 testl $3,CS(%rsp) # from kernel_thread? 604 testb $3, CS(%rsp) # from kernel_thread?
605 605
606 /* 606 /*
607 * By the time we get here, we have no idea whether our pt_regs, 607 * By the time we get here, we have no idea whether our pt_regs,
@@ -665,7 +665,7 @@ END(irq_entries_start)
665 665
666 leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */ 666 leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
667 667
668 testl $3, CS-RBP(%rsp) 668 testb $3, CS-RBP(%rsp)
669 jz 1f 669 jz 1f
670 SWAPGS 670 SWAPGS
6711: 6711:
@@ -720,7 +720,7 @@ ret_from_intr:
720 CFI_DEF_CFA_REGISTER rsp 720 CFI_DEF_CFA_REGISTER rsp
721 CFI_ADJUST_CFA_OFFSET RBP 721 CFI_ADJUST_CFA_OFFSET RBP
722 722
723 testl $3,CS(%rsp) 723 testb $3, CS(%rsp)
724 jz retint_kernel 724 jz retint_kernel
725 /* Interrupt came from user space */ 725 /* Interrupt came from user space */
726 726
@@ -968,7 +968,7 @@ ENTRY(\sym)
968 .if \paranoid 968 .if \paranoid
969 .if \paranoid == 1 969 .if \paranoid == 1
970 CFI_REMEMBER_STATE 970 CFI_REMEMBER_STATE
971 testl $3, CS(%rsp) /* If coming from userspace, switch */ 971 testb $3, CS(%rsp) /* If coming from userspace, switch */
972 jnz 1f /* stacks. */ 972 jnz 1f /* stacks. */
973 .endif 973 .endif
974 call paranoid_entry 974 call paranoid_entry
@@ -1309,7 +1309,7 @@ ENTRY(error_entry)
1309 SAVE_C_REGS 8 1309 SAVE_C_REGS 8
1310 SAVE_EXTRA_REGS 8 1310 SAVE_EXTRA_REGS 8
1311 xorl %ebx,%ebx 1311 xorl %ebx,%ebx
1312 testl $3,CS+8(%rsp) 1312 testb $3, CS+8(%rsp)
1313 jz error_kernelspace 1313 jz error_kernelspace
1314error_swapgs: 1314error_swapgs:
1315 SWAPGS 1315 SWAPGS
@@ -1606,7 +1606,6 @@ end_repeat_nmi:
1606 je 1f 1606 je 1f
1607 movq %r12, %cr2 1607 movq %r12, %cr2
16081: 16081:
1609
1610 testl %ebx,%ebx /* swapgs needed? */ 1609 testl %ebx,%ebx /* swapgs needed? */
1611 jnz nmi_restore 1610 jnz nmi_restore
1612nmi_swapgs: 1611nmi_swapgs: