Skip to content

Commit 721f791

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/boot: Use 32-bit XOR to clear registers
x86_64 zero extends 32-bit operations, so for 64-bit operands, XORL r32,r32 is functionally equal to XORQ r64,r64, but avoids a REX prefix byte when legacy registers are used. Slightly smaller code generated, no change in functionality. Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 891f889 commit 721f791

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

arch/x86/kernel/head_64.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
169169
ANNOTATE_NOENDBR
170170

171171
/* Clear %R15 which holds the boot_params pointer on the boot CPU */
172-
xorq %r15, %r15
172+
xorl %r15d, %r15d
173173

174174
/*
175175
* Retrieve the modifier (SME encryption mask if SME is active) to be
@@ -178,7 +178,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
178178
#ifdef CONFIG_AMD_MEM_ENCRYPT
179179
movq sme_me_mask, %rax
180180
#else
181-
xorq %rax, %rax
181+
xorl %eax, %eax
182182
#endif
183183

184184
/* Form the CR3 value being sure to include the CR3 modifier */
@@ -295,7 +295,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
295295

296296
.Llookup_AP:
297297
/* EAX contains the APIC ID of the current CPU */
298-
xorq %rcx, %rcx
298+
xorl %ecx, %ecx
299299
leaq cpuid_to_apicid(%rip), %rbx
300300

301301
.Lfind_cpunr:

arch/x86/kernel/sev_verify_cbit.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ SYM_FUNC_START(sev_verify_cbit)
7777
* The check failed, prevent any forward progress to prevent ROP
7878
* attacks, invalidate the stack and go into a hlt loop.
7979
*/
80-
xorq %rsp, %rsp
80+
xorl %esp, %esp
8181
subq $0x1000, %rsp
8282
2: hlt
8383
jmp 2b

0 commit comments

Comments
 (0)