New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang's integrated assembler does not support the movzxw instruction mnemonic #1010
Comments
based on
|
The gcc support of movzxw seems to be a hack as it does not support the other suffixes of movzx, $ cat bad.s $ gcc -c good.s -o good.o good.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <.text>: $ cat bad.s Maybe we should fix this in the kernel instead of the integrated assembler. Also, may I know which config I should use to reproduce? Thanks. |
In bad.s, you have |
Yes, that was my point. GCC supports movzx with 'w' suffix, but not other suffix such as 'q'. Is that intentional? |
@jcai19 maybe I'm wrong but doesn't |
That's precisely how this psuedo behaves. ➜ /tmp gcc -m64 foo.S -o foo.o -c
➜ /tmp objdump -d foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 48 0f b7 34 47 movzwq (%rdi,%rax,2),%rsi
➜ /tmp gcc -m32 foo.S -o foo.o -c
➜ /tmp objdump -d foo.o
foo.o: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: 0f b7 34 47 movzwl (%edi,%eax,2),%esi
➜ /tmp cat foo.S
#ifdef __x86_64__
movzxw (%rdi, %rax, 2), %rsi
#else
movzxw (%edi, %eax, 2), %esi
#endif |
I have a possible patch ZestProjects/linux@0648fc8. |
Thanks @lazerl0rd and @nickdesaulniers for the clarification and example. I guess my confusion came from the fact gnu as supported different suffixes of instructions like mov (e.g. movw and movl) and generated consistent opcodes, but for movzw it only supported its 'w' form but not the others, and treated it as a pseudo instruction and lowered it into different opcodes, depending on the target architecture and the type of operands -- on x64, gnu as assembles movzxw into movzxl if the registers used are 32-bit, or movzxq for 64-bit. $ cat foo32.s $ gcc -m32 -c foo32.s -o foo32.o foo32.o: file format elf32-i386 Disassembly of section .text: 00000000 <.text>: $ cat foo64.s $ gcc -m64 -c foo64.s -o foo64.o foo64.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <.text>: IMO it is clearer to change this in the kernel to explicitly use an instruction instead of a pseudo one, as suggested in the last comment. Also, not sure if this is the right source but it seems movzxw is not explicitly supported by x86 assembly. |
After multiple formatting tries, I seem to sit comfortably at ZestProjects/linux@65d285a. |
Thanks for the update! FWIW, gnu as assembles movzxw into either movzxl or movzxq if the operands are 32-bit or 64-bit respectively, as in the example. |
nice @lazerl0rd , please send it. |
Arnd independently sent a patch: https://lore.kernel.org/lkml/20200527141754.1850968-1-arnd@arndb.de/ |
No worries, I've been having email issues and will be for a week or two so I'm kinda MIA. |
Hmm, with clang-10 and @arndb patch I do not get this fixed... diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
@@ -170,7 +170,7 @@ continue_block:
## branch into array
lea jump_table(%rip), %bufp
- movzxw (%bufp, %rax, 2), len
+ movzxq (%bufp, %rax, 2), len
lea crc_array(%rip), %bufp
lea (%bufp, len, 1), %bufp
JMP_NOSPEC bufp ...and I see now:
|
Can you look at this please? |
I build with
|
Hmm, when using
|
OK, with
Objdump:
|
Hmm, I have respinned my LLVM_IAS=1 patches and see this again:
UPDATE: Aaargh forget to throw out |
NO, still seeing the Error. |
More coffee. Everything OK. |
What is the status of this patch? I do not see it in any crypto Git tree or latest Linux-next. [1] https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git/log/arch/x86/crypto/crc32c-pcl-intel-asm_64.S |
@dileks go chase it upstream ;) it was sent to our mailing list if, you're subscribed. |
@arndb
|
Patch accepted in |
Sorry if I have ignored your patch and of course this should have your S-o-b. |
No worries, it's just great to see this bug resolved :). |
Now in Linus Git. [1] https://git.kernel.org/linus/44623b2818f4a442726639572f44fd9b6d0ef68c |
@dileks thanks for noticing, commenting, and tagging. Don't forget to close out the bug once a FIXED tag is applied! |
No I did not forget. I thought when I close you will not notice. But on "closed" you get a message via GitHub, so next time I close myself. |
The text was updated successfully, but these errors were encountered: