* [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm
@ 2020-08-27 18:09 Uros Bizjak
2020-08-27 18:55 ` H. Peter Anvin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Uros Bizjak @ 2020-08-27 18:09 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
xorl %0,%0 is equivalent to xorq %0,%0 as both will zero the
entire register. Use xorl %0,%0 for all operand sizes to avoid
REX prefix byte when legacy registers are used and to avoid size
prefix byte when 16bit registers are used.
Zeroing the full register is OK in this use case. xorl %0,%0 also
breaks register dependency chains, avoiding potential partial
register stalls with 8 and 16bit operands.
The patch lowers the size of .fixup section by 20 bytes.
Changes since v1:
- Rewrite commit message.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
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>
---
arch/x86/include/asm/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index ecefaffd15d4..2bffba2a1b23 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -343,7 +343,7 @@ do { \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3: mov %[efault],%[errout]\n" \
- " xor"itype" %[output],%[output]\n" \
+ " xorl %k[output],%k[output]\n" \
" jmp 2b\n" \
".previous\n" \
_ASM_EXTABLE_UA(1b, 3b) \
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm
2020-08-27 18:09 [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm Uros Bizjak
@ 2020-08-27 18:55 ` H. Peter Anvin
2020-08-27 20:14 ` Al Viro
2020-09-03 20:57 ` [tip: x86/asm] x86/uaccess: Use XORL %0,%0 in __get_user_asm() tip-bot2 for Uros Bizjak
2 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2020-08-27 18:55 UTC (permalink / raw)
To: Uros Bizjak, x86, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov
On 2020-08-27 11:09, Uros Bizjak wrote:
> xorl %0,%0 is equivalent to xorq %0,%0 as both will zero the
> entire register. Use xorl %0,%0 for all operand sizes to avoid
> REX prefix byte when legacy registers are used and to avoid size
> prefix byte when 16bit registers are used.
>
> Zeroing the full register is OK in this use case. xorl %0,%0 also
> breaks register dependency chains, avoiding potential partial
> register stalls with 8 and 16bit operands.
>
> The patch lowers the size of .fixup section by 20 bytes.
>
> Changes since v1:
> - Rewrite commit message.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> 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>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm
2020-08-27 18:09 [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm Uros Bizjak
2020-08-27 18:55 ` H. Peter Anvin
@ 2020-08-27 20:14 ` Al Viro
2020-08-28 6:41 ` Uros Bizjak
2020-09-03 20:57 ` [tip: x86/asm] x86/uaccess: Use XORL %0,%0 in __get_user_asm() tip-bot2 for Uros Bizjak
2 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2020-08-27 20:14 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
On Thu, Aug 27, 2020 at 08:09:04PM +0200, Uros Bizjak wrote:
> xorl %0,%0 is equivalent to xorq %0,%0 as both will zero the
> entire register. Use xorl %0,%0 for all operand sizes to avoid
> REX prefix byte when legacy registers are used and to avoid size
> prefix byte when 16bit registers are used.
>
> Zeroing the full register is OK in this use case. xorl %0,%0 also
> breaks register dependency chains, avoiding potential partial
> register stalls with 8 and 16bit operands.
No objections, but talking about stalls is more than slightly
ridiculous - we'd just taken a #PF, failed there, flipped
pt_regs %rip to fixup section, returned from fault and are
about to fail whatever syscall that had been; a stall here
is really not an issue...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm
2020-08-27 20:14 ` Al Viro
@ 2020-08-28 6:41 ` Uros Bizjak
0 siblings, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2020-08-28 6:41 UTC (permalink / raw)
To: Al Viro
Cc: X86 ML, LKML, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H. Peter Anvin
On Thu, Aug 27, 2020 at 10:14 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Thu, Aug 27, 2020 at 08:09:04PM +0200, Uros Bizjak wrote:
> > xorl %0,%0 is equivalent to xorq %0,%0 as both will zero the
> > entire register. Use xorl %0,%0 for all operand sizes to avoid
> > REX prefix byte when legacy registers are used and to avoid size
> > prefix byte when 16bit registers are used.
> >
> > Zeroing the full register is OK in this use case. xorl %0,%0 also
> > breaks register dependency chains, avoiding potential partial
> > register stalls with 8 and 16bit operands.
>
> No objections, but talking about stalls is more than slightly
> ridiculous - we'd just taken a #PF, failed there, flipped
> pt_regs %rip to fixup section, returned from fault and are
> about to fail whatever syscall that had been; a stall here
> is really not an issue...
Should I submit a v3 with the offending sentence removed, or could I
just ask a committer to remove it on the fly?
Uros.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: x86/asm] x86/uaccess: Use XORL %0,%0 in __get_user_asm()
2020-08-27 18:09 [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm Uros Bizjak
2020-08-27 18:55 ` H. Peter Anvin
2020-08-27 20:14 ` Al Viro
@ 2020-09-03 20:57 ` tip-bot2 for Uros Bizjak
2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2020-09-03 20:57 UTC (permalink / raw)
To: linux-tip-commits
Cc: Uros Bizjak, Borislav Petkov, H. Peter Anvin (Intel), x86, LKML
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 767ec7289e83721fee205a13b459f12fb2cf922f
Gitweb: https://git.kernel.org/tip/767ec7289e83721fee205a13b459f12fb2cf922f
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Thu, 27 Aug 2020 20:09:04 +02:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Thu, 03 Sep 2020 22:49:03 +02:00
x86/uaccess: Use XORL %0,%0 in __get_user_asm()
XORL %0,%0 is equivalent to XORQ %0,%0 as both will zero the entire
register. Use XORL %0,%0 for all operand sizes to avoid REX prefix byte
when legacy registers are used and to avoid size prefix byte when 16bit
registers are used.
Zeroing the full register is OK in this use case.
As a result, the size of the .fixup section decreases by 20 bytes.
[ bp: Massage commit message. ]
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Link: https://lkml.kernel.org/r/20200827180904.96399-1-ubizjak@gmail.com
---
arch/x86/include/asm/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index ecefaff..2bffba2 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -343,7 +343,7 @@ do { \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3: mov %[efault],%[errout]\n" \
- " xor"itype" %[output],%[output]\n" \
+ " xorl %k[output],%k[output]\n" \
" jmp 2b\n" \
".previous\n" \
_ASM_EXTABLE_UA(1b, 3b) \
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-03 20:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-27 18:09 [PATCH v2] x86: Use xorl %0,%0 in __get_user_asm Uros Bizjak
2020-08-27 18:55 ` H. Peter Anvin
2020-08-27 20:14 ` Al Viro
2020-08-28 6:41 ` Uros Bizjak
2020-09-03 20:57 ` [tip: x86/asm] x86/uaccess: Use XORL %0,%0 in __get_user_asm() tip-bot2 for Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox