x86: Use xorl %0,%0 in __get_user_asm
PATCH v2 1/1 x86: 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. 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.
--- arch/x86/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/uaccess.h +1 -1
@@ -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 ) \
Signature · 1 line
2.26.2
Quoted 11 lines · Uros Bizjak
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.
Quoted 8 lines
Changes since v1:
- Rewrite commit message.Signed-off-by Uros Bizjak <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc "H. Peter Anvin" <[email protected]>
Quoted 8 lines · Uros Bizjak
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...
Quoted 11 lines · Al Viro
Quoted 8 lines · Uros Bizjak
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.
Quoted 5 lines
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.
[tip: x86/asm] x86/uaccess: Use XORL %0,%0 in __get_user_asm()
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
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 <[email protected]> AuthorDate: Thu, 27 Aug 2020 20:09:04 +02:00 Committer: Borislav Petkov <[email protected]> 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. ]
--- arch/x86/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/uaccess.h +1 -1
@@ -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 ) \