* [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg
@ 2020-10-29 14:29 Uros Bizjak
2020-10-29 14:41 ` Andy Lutomirski
2020-10-29 15:55 ` Arvind Sankar
0 siblings, 2 replies; 3+ messages in thread
From: Uros Bizjak @ 2020-10-29 14:29 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
Use TEST %reg,%reg which sets the zero flag in the same way
as CMP $0,%reg, but the encoding uses one byte less.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
arch/x86/boot/compressed/head_64.S | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 017de6cc87dc..e94874f4bbc1 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -241,12 +241,12 @@ SYM_FUNC_START(startup_32)
leal rva(startup_64)(%ebp), %eax
#ifdef CONFIG_EFI_MIXED
movl rva(efi32_boot_args)(%ebp), %edi
- cmp $0, %edi
+ testl %edi, %edi
jz 1f
leal rva(efi64_stub_entry)(%ebp), %eax
movl rva(efi32_boot_args+4)(%ebp), %esi
movl rva(efi32_boot_args+8)(%ebp), %edx // saved bootparams pointer
- cmpl $0, %edx
+ testl %edx, %edx
jnz 1f
/*
* efi_pe_entry uses MS calling convention, which requires 32 bytes of
@@ -592,7 +592,7 @@ SYM_CODE_START(trampoline_32bit_src)
movl %eax, %cr0
/* Check what paging mode we want to be in after the trampoline */
- cmpl $0, %edx
+ testl %edx, %edx
jz 1f
/* We want 5-level paging: don't touch CR3 if it already points to 5-level page tables */
@@ -622,7 +622,7 @@ SYM_CODE_START(trampoline_32bit_src)
/* Enable PAE and LA57 (if required) paging modes */
movl $X86_CR4_PAE, %eax
- cmpl $0, %edx
+ testl %edx, %edx
jz 1f
orl $X86_CR4_LA57, %eax
1:
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg
2020-10-29 14:29 [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg Uros Bizjak
@ 2020-10-29 14:41 ` Andy Lutomirski
2020-10-29 15:55 ` Arvind Sankar
1 sibling, 0 replies; 3+ messages in thread
From: Andy Lutomirski @ 2020-10-29 14:41 UTC (permalink / raw)
To: Uros Bizjak
Cc: X86 ML, LKML, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
On Thu, Oct 29, 2020 at 7:29 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> Use TEST %reg,%reg which sets the zero flag in the same way
> as CMP $0,%reg, but the encoding uses one byte less.
This will make a Linux distro fit on an embedded device that
previously had four bytes too little flash :)
Reviewed-by: Andy Lutomirski <luto@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg
2020-10-29 14:29 [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg Uros Bizjak
2020-10-29 14:41 ` Andy Lutomirski
@ 2020-10-29 15:55 ` Arvind Sankar
1 sibling, 0 replies; 3+ messages in thread
From: Arvind Sankar @ 2020-10-29 15:55 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
On Thu, Oct 29, 2020 at 03:29:15PM +0100, Uros Bizjak wrote:
> Use TEST %reg,%reg which sets the zero flag in the same way
> as CMP $0,%reg, but the encoding uses one byte less.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Please use x86/boot/64 or x86/boot/compressed/64 for the commit subject.
x86/entry is used for syscall/exception handler entries in the main
kernel.
> ---
> arch/x86/boot/compressed/head_64.S | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
> index 017de6cc87dc..e94874f4bbc1 100644
> --- a/arch/x86/boot/compressed/head_64.S
> +++ b/arch/x86/boot/compressed/head_64.S
> @@ -241,12 +241,12 @@ SYM_FUNC_START(startup_32)
> leal rva(startup_64)(%ebp), %eax
> #ifdef CONFIG_EFI_MIXED
> movl rva(efi32_boot_args)(%ebp), %edi
> - cmp $0, %edi
> + testl %edi, %edi
> jz 1f
> leal rva(efi64_stub_entry)(%ebp), %eax
> movl rva(efi32_boot_args+4)(%ebp), %esi
> movl rva(efi32_boot_args+8)(%ebp), %edx // saved bootparams pointer
> - cmpl $0, %edx
> + testl %edx, %edx
> jnz 1f
> /*
> * efi_pe_entry uses MS calling convention, which requires 32 bytes of
> @@ -592,7 +592,7 @@ SYM_CODE_START(trampoline_32bit_src)
> movl %eax, %cr0
>
> /* Check what paging mode we want to be in after the trampoline */
> - cmpl $0, %edx
> + testl %edx, %edx
> jz 1f
>
> /* We want 5-level paging: don't touch CR3 if it already points to 5-level page tables */
> @@ -622,7 +622,7 @@ SYM_CODE_START(trampoline_32bit_src)
>
> /* Enable PAE and LA57 (if required) paging modes */
> movl $X86_CR4_PAE, %eax
> - cmpl $0, %edx
> + testl %edx, %edx
> jz 1f
> orl $X86_CR4_LA57, %eax
> 1:
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-29 15:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 14:29 [PATCH] x86/entry/64: Use TEST %reg,%reg instead of CMP $0,%reg Uros Bizjak
2020-10-29 14:41 ` Andy Lutomirski
2020-10-29 15:55 ` Arvind Sankar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).