[PATCH 10/10] x86/head_64: Simplify kernel load address alignment check

From: Borislav Petkov
Date: Tue Jan 26 2016 - 16:14:05 EST

From: Alexander Kuleshov <kuleshovmail@xxxxxxxxx>

We are using %rax as temporary register to check the kernel address
alignment. We don't really have to since the TEST instruction does not
clobber the destination operand.

Suggested-by: Brian Gerst <brgerst@xxxxxxxxx>
Signed-off-by: Alexander Kuleshov <kuleshovmail@xxxxxxxxx>
Cc: Alexander Popov <alpopov@xxxxxxxxxxxxxx>
Cc: Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/1453531828-19291-1-git-send-email-kuleshovmail@xxxxxxxxx
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
arch/x86/kernel/head_64.S | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index ffdc0e860390..7c21029cb733 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -76,9 +76,7 @@ startup_64:
subq $_text - __START_KERNEL_map, %rbp

/* Is the address not 2M aligned? */
- movq %rbp, %rax
- andl $~PMD_PAGE_MASK, %eax
- testl %eax, %eax
+ testl $~PMD_PAGE_MASK, %ebp
jnz bad_address