[1/3] x86: verify_cpu: use 32-bit arithmetic
diff mbox series

Message ID 20180517213001.GA4047@avx2
State New, archived
Headers show
Series
  • [1/3] x86: verify_cpu: use 32-bit arithmetic
Related show

Commit Message

Alexey Dobriyan May 17, 2018, 9:30 p.m. UTC
32-bit instructions are 1 byte shorter than 16-bit instructions.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 arch/x86/kernel/verify_cpu.S |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

H. Peter Anvin May 17, 2018, 10:45 p.m. UTC | #1
On May 17, 2018 2:30:01 PM PDT, Alexey Dobriyan <adobriyan@gmail.com> wrote:
>32-bit instructions are 1 byte shorter than 16-bit instructions.
>
>Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>---
>
> arch/x86/kernel/verify_cpu.S |    8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>--- a/arch/x86/kernel/verify_cpu.S
>+++ b/arch/x86/kernel/verify_cpu.S
>@@ -56,14 +56,14 @@ ENTRY(verify_cpu)
> 	cmpl	$0x1,%eax
> 	jb	.Lverify_cpu_no_longmode	# no cpuid 1
> 
>-	xor	%di,%di
>+	xor	%edi, %edi
> 	cmpl	$0x68747541,%ebx	# AuthenticAMD
> 	jnz	.Lverify_cpu_noamd
> 	cmpl	$0x69746e65,%edx
> 	jnz	.Lverify_cpu_noamd
> 	cmpl	$0x444d4163,%ecx
> 	jnz	.Lverify_cpu_noamd
>-	mov	$1,%di			# cpu is from AMD
>+	mov	$1, %edi		# cpu is from AMD
> 	jmp	.Lverify_cpu_check
> 
> .Lverify_cpu_noamd:
>@@ -122,13 +122,13 @@ ENTRY(verify_cpu)
> 	andl	$SSE_MASK,%edx
> 	cmpl	$SSE_MASK,%edx
> 	je	.Lverify_cpu_sse_ok
>-	test	%di,%di
>+	test	%edi, %edi
> 	jz	.Lverify_cpu_no_longmode	# only try to force SSE on AMD
> 	movl	$MSR_K7_HWCR,%ecx
> 	rdmsr
> 	btr	$15,%eax		# enable SSE
> 	wrmsr
>-	xor	%di,%di			# don't loop
>+	xor	%edi, %edi		# don't loop
> 	jmp	.Lverify_cpu_sse_test	# try again
> 
> .Lverify_cpu_no_longmode:

Well, in 32/64-bit mode... this code is also assembled in 16-bit mode, and the 16-but code is more space sensitive.

Patch
diff mbox series

--- a/arch/x86/kernel/verify_cpu.S
+++ b/arch/x86/kernel/verify_cpu.S
@@ -56,14 +56,14 @@  ENTRY(verify_cpu)
 	cmpl	$0x1,%eax
 	jb	.Lverify_cpu_no_longmode	# no cpuid 1
 
-	xor	%di,%di
+	xor	%edi, %edi
 	cmpl	$0x68747541,%ebx	# AuthenticAMD
 	jnz	.Lverify_cpu_noamd
 	cmpl	$0x69746e65,%edx
 	jnz	.Lverify_cpu_noamd
 	cmpl	$0x444d4163,%ecx
 	jnz	.Lverify_cpu_noamd
-	mov	$1,%di			# cpu is from AMD
+	mov	$1, %edi		# cpu is from AMD
 	jmp	.Lverify_cpu_check
 
 .Lverify_cpu_noamd:
@@ -122,13 +122,13 @@  ENTRY(verify_cpu)
 	andl	$SSE_MASK,%edx
 	cmpl	$SSE_MASK,%edx
 	je	.Lverify_cpu_sse_ok
-	test	%di,%di
+	test	%edi, %edi
 	jz	.Lverify_cpu_no_longmode	# only try to force SSE on AMD
 	movl	$MSR_K7_HWCR,%ecx
 	rdmsr
 	btr	$15,%eax		# enable SSE
 	wrmsr
-	xor	%di,%di			# don't loop
+	xor	%edi, %edi		# don't loop
 	jmp	.Lverify_cpu_sse_test	# try again
 
 .Lverify_cpu_no_longmode: