flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > New instructions Goto page 1, 2 Next |
Author |
|
Jin X 27 Nov 2019, 12:57
Hello!
There're new instructions described in Intel SDM (October 2019): CLRSSBSY, ENDBR32, ENDBR64, INCSSPD/INCSSPQ RDSSPD/RDSSPQ, RSTORSSP, SAVEPREVSSP, SETSSBSY VPCOMPRESSB/VCOMPRESSW, VPDPBUSD, VPDPBUSDS, VPDPWSSD, VPDPWSSDS, VPEXPANDB/VPEXPANDW, VPOPCNT, VPSHLD, VPSHLDV, VPSHRD, VPSHRDV, VPSHUFBITQMB, VPDPWSSDS, WRSSD/WRSSQ, WRUSSD/WRUSSQ All of them are absent in fasm 1 now Last edited by Jin X on 27 Nov 2019, 13:11; edited 2 times in total |
|||
27 Nov 2019, 12:57 |
|
Tomasz Grysztar 27 Nov 2019, 16:31
You can get them for fasmg right now. But this should also pave the way for a future implementation in fasm 1.
|
|||
27 Nov 2019, 16:31 |
|
Jin X 27 Nov 2019, 18:04
I don't need it right now. I just wanted to let you know (just in case)
By the way, MOVSXD allows to use r16 and r32 as first operand but fasm 1 doesn't. This operation is meaningless but described in Intel SDM (and conflicting with ARPL in non-64-bit mode) |
|||
27 Nov 2019, 18:04 |
|
Tomasz Grysztar 27 Nov 2019, 18:44
Jin X wrote: By the way, MOVSXD allows to use r16 and r32 as first operand but fasm 1 doesn't. This operation is meaningless but described in Intel SDM (and conflicting with ARPL in non-64-bit mode) |
|||
27 Nov 2019, 18:44 |
|
Jin X 27 Nov 2019, 19:01
Some other comments:
1. PTWRITE is also absent in fasm 1. 2. It seems there's no way to specify operand size of XBEGIN instruction (rel16 or rel32). I don't know what reserved word should be used (maybe REL16 and REL32 as SHORT and NEAR for JMP: XBEGIN REL32 AbortProc). 3. SAL is encoded as SHL. |
|||
27 Nov 2019, 19:01 |
|
Tomasz Grysztar 27 Nov 2019, 19:23
Jin X wrote: 1. PTWRITE is also absent in fasm 1. Jin X wrote: 2. It seems there's no way to specify operand size of XBEGIN instruction (rel16 or rel32). I don't know what reserved word should be used (maybe REL16 and REL32 as SHORT and NEAR for JMP: XBEGIN REL32 AbortProc). Jin X wrote: 3. SAL is encoded as SHL. |
|||
27 Nov 2019, 19:23 |
|
Jin X 27 Nov 2019, 19:27
Tomasz Grysztar wrote: This has been discussed many years ago... 1. The manuals list MOVSX/MOVZX with forms of first operand being larger than the second one. MOVZX has no forms with the same operand size of 1st and 2nd operands but MOVSXD has. 2. The fact that it isn't really important for programmer which encoding the assembler chooses, allows even to make the "imprint" of the assembler on the code it generates. You limit the use of assembler to your personal vision of what is important to all programmers and what is not. However, this use can be much wider. For example, it can be sizecoding (for demoscene, where code can be part of data), obfuscation, or self-modifying code, where encoding or instruction length can be important. And many other cases that do not occur to us. |
|||
27 Nov 2019, 19:27 |
|
Jin X 27 Nov 2019, 19:34
Tomasz Grysztar wrote: It must have fallen through the cracks. Perhaps because it is not a part of any instruction set extension. Tomasz Grysztar wrote: Back when I was implementing it, I was not sure about this, so I decided to choose fasm's usual route and I just made it automatically optimized for size. |
|||
27 Nov 2019, 19:34 |
|
Tomasz Grysztar 27 Nov 2019, 19:36
Jin X wrote: MOVZX has no forms with the same operand size of 1st and 2nd operands but MOVSXD has. Jin X wrote: You limit the use of assembler to your personal vision of what is important to all programmers and what is not. However, this use can be much wider. For example, it can be sizecoding (for demoscene, where code can be part of data), obfuscation, or self-modifying code, where encoding or instruction length can be important. And many other cases that do not occur to us. Jin X wrote: I see but it can be important e.g. for self-modifying code |
|||
27 Nov 2019, 19:36 |
|
Tomasz Grysztar 27 Nov 2019, 20:53
OK, most of these new instruction sets were trivial to implement in fasm 1, the only ones left are AVX512_4VNNIW and CET_SS, because they need some specialized handlers. I could release a new version now, but there is no hurry, so I'm going to wait till I have the remaining instructions completed, too.
Having the (easier to make) fasmg macro implementations first is a great help in fasm 1 development as well. And it allows for additional cross-testing. |
|||
27 Nov 2019, 20:53 |
|
alphis01 05 Sep 2020, 20:04
Any idea when fasm 1 will support the new intel CET instructions? I'd like to begin testing by the end of the year if possible. I need my binaries to conform to CET when enabled and running on supported hardware. If anyone wants to see some of the hardware intel is releasing Tiger Lake soon. It will support it and Win10 already has support built in.
I believe the Linux kernel is also adding support as well. Thanks! |
|||
05 Sep 2020, 20:04 |
|
Tomasz Grysztar 05 Sep 2020, 20:34
The CET_SS and CET_IBT instruction sets were added in release 1.73.19, as noted in whatsnew.txt.
|
|||
05 Sep 2020, 20:34 |
|
alphis01 06 Sep 2020, 05:06
Ah I see! Thanks!
|
|||
06 Sep 2020, 05:06 |
|
alphis01 06 Sep 2020, 13:15
How do I enable use of IBT? I'm expecting to see function entries/jmp targets all prefixed with the new endbranch opcodes.
Do I need to do anything special to enable its use? Surely fasm's proc/jmp labels will automatically add them? Thanks. |
|||
06 Sep 2020, 13:15 |
|
Tomasz Grysztar 07 Sep 2020, 04:56
alphis01 wrote: Do I need to do anything special to enable its use? Surely fasm's proc/jmp labels will automatically add them? |
|||
07 Sep 2020, 04:56 |
|
alphis01 07 Sep 2020, 18:58
Quote: In general, if you need the new instructions in your code, you should just write them explicitly - this is an assembly language after all. While normally I'd agree, the intel CET functionality is something more akin to a "call" pushing the return address on the stack and less like doing something manually like pushing params on the stack/moving into regs (which you can still use invoke for). The entire point of ENDBRANCH is that its automatically inserted into call targets and jump targets. It would be a little silly to have to do this manually. Keep in mind that this instruction is also expected to be added to all jump targets which means jump tables as well. Perhaps even exception handlers |
|||
07 Sep 2020, 18:58 |
|
revolution 07 Sep 2020, 22:31
alphis01: You can write macros to insert the instructions for you if you want. But keep in mind that only newer CPUs can execute the new instructions so incompatibility may be an issue for others running your code.
|
|||
07 Sep 2020, 22:31 |
|
alphis01 09 Sep 2020, 04:13
Actually thats not true. I think there might be some misunderstanding of intel CET and its IBT functionality. The new opcodes are actually just NOPs on CPUs that don't have the new ISA. So its safe to have in current code.
The main issue that I see is that since its designed to work with calls (including virtual calls)/jumptables/etc these new endbr instructions need to automatically be inserted if "cet mode" is enabled. I'm not entirely sure macros can actually cover all the necessary ground going the more manual route. At least I can manually shove these bytes in for testing but prepare for AVs on HW that supports CET for cases you may forget to have them inserted. Or just not write CET code. |
|||
09 Sep 2020, 04:13 |
|
Tomasz Grysztar 09 Sep 2020, 09:24
alphis01 wrote: Actually thats not true. I think there might be some misunderstanding of intel CET and its IBT functionality. The new opcodes are actually just NOPs on CPUs that don't have the new ISA. So its safe to have in current code. alphis01 wrote: The main issue that I see is that since its designed to work with calls (including virtual calls)/jumptables/etc these new endbr instructions need to automatically be inserted if "cet mode" is enabled. I'm not entirely sure macros can actually cover all the necessary ground going the more manual route. This is analogous to "proc" macro, which requires additional syntax wrapped around the assembly instructions to provide semantic information about the scope of procedures, which would be impossible to derive from a pure assembly. By using such structuring layers, a programmer also imposes constraints on the code - adding HLL concepts like "function boundaries" to assembly language that in its basic form does not have to conform to anything like that. In a similar manner, to make the code conform to the rules of CET, you might also need to add new layers of structure to your code. For instance, normally assembler would not be able to reliably tell which points of your code could be targets of indirects jumps - you need to provide such information in one form or another. It could be done by adding more macros structuring the code, or at least making your code follow specific conventions. For example, in pure assembly you would prepare a target for an indirect jump this way: Code: option: endbr64 ; actual code after Code: ibt option ; actual code after Another option might be viable if your source code follows some specific conventions that would allow to derive information like "this label is going to be used as a target of indirect branch" from existing constructions. But this would be a specialized solution, dependent on following the conventions strictly. And it would probably be better to use fasmg in that case, as it has macro facilities that are more capable for such purposes. |
|||
09 Sep 2020, 09:24 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.