News for hackers. Stuff that matters.
Re:Weird things I learned while writing an x86 emulator by trzy on Thursday February 02, 2023 @10:59PM (#34636970)
Very cool! Writing emulators for simple CPUs is challenging enough because it's extremely easy to overlook a quirk or implement a flag calculation incorrectly that is used infrequently and have it silently lurking like a mine waiting for the rare piece of code to trip it. x86 is very complex. Instruction decoding alone looks like a nightmare. I guess the one saving grace here is that since most of us still run on x86, side-by-side validation is a lot easier.
Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:31PM (#34645721)
Yes, that made it 100x easier, because I was able to write unit tests that literally did a single step over the instruction and compare the register context to the emulated register context. The single step approach didn't work for all instructions (and didn't work for undefined flags) but was extremely effective and let me brute force a whole lot of testing.
Re:Weird things I learned while writing an x86 emulator by convery on Thursday February 02, 2023 @11:14PM (#34637067)
> You can add quite a few until you get to 15 bytes. This length is a hard limit on current x86-compatible CPUs. Any instruction longer than 15 bytes is considered invalid and will generate an exception.

There's a few valid 16 byte instructions though.. Sandpile lists a few examples: https://www.sandpile.org/x86/opc_enc.htm

  36 67 8F EA 78 10 84 24 disp32 imm32 =  bextr eax,[ss:esp*1+disp32],imm32
  64 67 8F EA F8 10 84 18 disp32 imm32 =  bextr rax,[fs:eax+ebx+disp32],imm32
Re:Weird things I learned while writing an x86 emulator by rustybolt on Thursday February 02, 2023 @11:18PM (#34637093)
Valid meaning "valid according to spec" or "actually executable by processors in practice"?
Re:Weird things I learned while writing an x86 emulator by Sniffnoy on Thursday February 02, 2023 @11:51PM (#34637279)
Going by the linked webpage, the answer appears to be "valid if we ignore the limit, but in fact the limit is enforced and you'll get an exception".
Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @12:03AM (#34637350)
The longest structurally valid x86 instruction is 26 bytes, from some research I did a few years ago[1]. But as others have noted, structurally valid does not mean that any x86 CPU will accept them: they’ll all produce #UD or similar, including these 16 byte ones.

[1]: https://yossarian.net/res/pub/mishegos-langsec-2021.pdf

Re:Weird things I learned while writing an x86 emulator by Sniffnoy on Friday February 03, 2023 @01:50AM (#34637948)
What is it? I can't seem to find it in the paper.
Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @01:55AM (#34637979)
There are many structurally valid 26 byte productions; the diagram on page 2 shows the layout and page 5 has pseudocode for generating them.

(There may be even longer valid productions; my analysis was pretty naive. But 26 is already substantially longer than the limit!)

Re:Weird things I learned while writing an x86 emulator by Sniffnoy on Friday February 03, 2023 @04:11AM (#34638983)
Thanks, I saw that, but I was hoping for explicit examples.
Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @04:18AM (#34639039)
Figure 6 has examples (in the context of instruction generation). But note that those instructions are “nonsense,” in the sense that they’re guaranteed to either #UD at 15 bytes or well before then.
Re:Weird things I learned while writing an x86 emulator by Sniffnoy on Friday February 03, 2023 @04:30AM (#34639130)
Ah, thanks, I missed that! Kind of disappointing that it doesn't give the instructions' dissassembly (so to speak -- obviously as you point out in reality they are nonsense), but I suppose I can sit down and figure that out myself. :)
Re:Weird things I learned while writing an x86 emulator by saagarjha on Friday February 03, 2023 @07:53AM (#34640410)
You can just keep sticking prefixes on an instruction to get something longer, no? The processor will refuse to decode it but it's "legal" otherwise.
Re:Weird things I learned while writing an x86 emulator by jcranmer on Friday February 03, 2023 @09:24AM (#34641351)
Ostensibly, only one prefix from each group can matter. Although I did notice that XACQUIRE and LOCK are both group 1 prefixes, which makes that statement kind of a lie (but it's an intentional design to make XACQUIRE do nothing on processors that don't support it).

In any case, there's only a finite number of prefixes you can meaningfully stick onto an instruction, and repeating the same prefix will do absolutely nothing.

Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @01:28PM (#34645659)
Yep: in that sense the longest structurally valid x86 instruction is unbounded in length, so long as you conform to the group restrictions.
Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:30PM (#34645706)
That's really interesting. I had no idea there were structurally valid instructions that are longer than 15 bytes.
Re:Weird things I learned while writing an x86 emulator by dwattttt on Friday February 03, 2023 @04:19PM (#34647852)
Assuming this limit has even been the cause of a vulnerability before: https://lists.gnu.org/archive/html/qemu-devel/2017-03/msg038...
Re:Weird things I learned while writing an x86 emulator by schemescape on Thursday February 02, 2023 @11:33PM (#34637181)
I thought this was going to be about a toy emulator/hobby project, but it's apparently about an emulator used in Time Travel Debugging!
Re:Weird things I learned while writing an x86 emulator by mark_undoio on Friday February 03, 2023 @03:14AM (#34638592)
Ha, I was just reading some of the discussion and thinking it sounded quite similar to the JIT we use in our own (Linuxy) Time Travel Debugger.

It's similarly am x86-on-x86 JIT / emulator but (and I'm sure WinDbg's TTD is similar) most of what you want to do there is just code copying for any instructions that don't need special instrumentation.

And you want to run entirely in the cache of JITted code so you're close to native speed, rather than exit to C code and make decisions.

Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:27PM (#34645643)
Funny enough, we tried going down the road of doing a JIT, but for our use cases pure emulation was often fast enough and it wasn't worth the extra complexity to do JIT. Part of that is probably due to the architecture of how TTD works, but part of it is how efficient we were able to get with the emulation mode. Later, a different emulator was created for running x86 code on ARM64, and that one uses an extremely efficient JIT. (I didn't get to work on the x86-on-arm64 emulator though. Would have been fun)

Working on the JIT in TTD was a lot of fun though, and it's a shame it didn't make sense to keep it around.

Re:Weird things I learned while writing an x86 emulator by mark_undoio on Saturday February 04, 2023 @07:50AM (#34654063)
Very impressive you got such good performance out of straight emulation! And WinDbg TTD runs with truly parallel threaded execution within one process, which we do not (yet).

I'm surprised a JIT wasn't worth it but, from what I'm aware of, I can see a few reasons why the trade offs are different.

Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @12:00AM (#34637330)
This is a good list! Another fun quirk: because x86 is a register-memory architecture and allows all kinds of variants of reg/mem operand encodings, there are a handful of equivalent encodings with exactly the same lengths (and just slightly different ModR/M bytes). You can take advantage of this to do software fingerprinting or, in my case, steganography without changing an executable’s size or semantics[1].

[1]: https://github.com/woodruffw/steg86

Re:Weird things I learned while writing an x86 emulator by anon223345 on Friday February 03, 2023 @12:05AM (#34637360)
Would love to learn more and help with this project if you need extra work done
Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @12:13AM (#34637405)
It’s relatively feature complete, but there are some ideas for increasing the steganographic capacity listed in the README and issues! In particular, we could use the flexibility of the multi-byte NOP sequences to hide some more information.
Re:Weird things I learned while writing an x86 emulator by menaerus on Friday February 03, 2023 @09:19AM (#34641295)
What are some interesting use-cases for information hiding in the binaries?
Re:Weird things I learned while writing an x86 emulator by jrockway on Friday February 03, 2023 @10:59AM (#34642840)
Embed your customer's serial number in the binary at download time. When the file ends up on The Pirate Bay, send them a bill.
Re:Weird things I learned while writing an x86 emulator by anon223345 on Friday February 03, 2023 @11:59AM (#34643897)
This is a huge issue in the cloud computing space.

“Golden Images” are often used to try to counter exploits hidden in the binaries of cloud images used by containers, etc

Re:Weird things I learned while writing an x86 emulator by userbinator on Friday February 03, 2023 @01:11AM (#34637717)
The (in)famous A86/A386 assembler claimed to use this technique to identify code produced with it. As far as I know, it was just a simple inversion of reg-reg ModRMs depending on the register values being used, although I didn't test it too exhaustively.
Re:Weird things I learned while writing an x86 emulator by actionfromafar on Friday February 03, 2023 @04:47AM (#34639214)
Speaking of things with the same names, what happened to Linux a386 and what the heck was it even? I can't find a link nowadays, but it was something like User Mode Linux, but not really.
Re:Weird things I learned while writing an x86 emulator by messe on Friday February 03, 2023 @05:18AM (#34639416)
Re:Weird things I learned while writing an x86 emulator by kuroguro on Friday February 03, 2023 @06:41AM (#34639934)
Used the exact same trick when researching dumb ways to break AV signatures at uni :)
Re:Weird things I learned while writing an x86 emulator by wruza on Friday February 03, 2023 @06:59AM (#34640035)
This is the first time I learned about eiz. Cool trick!

What’s eiz: https://stackoverflow.com/a/2553556/3125367

Re:Weird things I learned while writing an x86 emulator by ginnungagap on Friday February 03, 2023 @09:27AM (#34641388)
If I remember correctly there are also tricks like

  lea rax, [eiz+rbx*4]
instead of

  lea rax, [rbx*4]
because the latter will produce an heavier binary by being interpreted as

  lea rax, [00000000h+rbx*4]
Re:Weird things I learned while writing an x86 emulator by rep_lodsb on Friday February 03, 2023 @12:32PM (#34644595)
You won't find "eiz" in any Intel manual, and NASM doesn't recognize it either. x86 has no zero register¹.

This appears to be some GNU-specific syntax meaning "encode SIB byte with no index register". The only case where this would be required by the hardware is when using ESP/RSP as a base register, and every assembler should produce the correct encoding for that if you simply write [ESP].

So using "eiz" on GAS lets you control what is put into the (unused) scale field. One might call that a feature, but it is a meaningless encoding detail similar to which variant of "register to register" opcodes is emitted, something that I don't think any assembler gives you control over.

¹ except maybe on the microarchitectural level, but that isn't visible to the programmer

Re:Weird things I learned while writing an x86 emulator by m3kw9 on Friday February 03, 2023 @09:54AM (#34641747)
Why would I want to hide a message beside a program?
Re:Weird things I learned while writing an x86 emulator by praptak on Friday February 03, 2023 @09:59AM (#34641843)
I think this has mostly curiosity/show off value. Encoding messages into executable binaries without changing their running behavior is kinda cool.
Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @10:35AM (#34642403)
It’s primarily a cute trick.
Re:Weird things I learned while writing an x86 emulator by Pet_Ant on Friday February 03, 2023 @11:52AM (#34643748)
It gives you room to try to cause a hash collision. Could be used as a vector if a broken checksum is used.
Re:Weird things I learned while writing an x86 emulator by boomlinde on Friday February 03, 2023 @02:47PM (#34646802)
Maybe to be able to trace individual copies of a piece of software back to a licensee.
Re:Weird things I learned while writing an x86 emulator by praptak on Friday February 03, 2023 @09:58AM (#34641821)
The article itself exposes some encoding redundancy too: "[...] the count is masked against 1FH, essentially using only the lowest five bits".

So each rotation instruction is 3 bits free for out-of-band information.

Re:Weird things I learned while writing an x86 emulator by jamesfinlayson on Friday February 03, 2023 @12:48AM (#34637589)
> Other instructions leave some of the flags in an undefined state, although in some cases they are conditionally undefined. > I’ve heard that the Atom line of CPUs used a cheaper/slower way of doing bit shifts in the ALU, which results in the undefined flags having different values, although I haven’t tested this myself.

That seems... problematic. Do compilers know this and just ignore the flags if/when they use these instructions?

Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @12:53AM (#34637611)
Yes. In general, compilers only test emit flag testing instructions after instructions that are explicitly defined as having flag-modifying semantics.

(This is a common feature of ISAs, and makes sense in terms of component reuse: it allows you to cheaply reuse the ALU, for example, without needing extra wires/control signals telling it not to update the flag state.)

Re:Weird things I learned while writing an x86 emulator by Someone on Friday February 03, 2023 @02:50AM (#34638383)
> compilers only emit flag testing instructions after instructions that are explicitly defined as having flag-modifying semantics.

I think compiler writers sometimes also have to know that instructions do not modify the flags.

Such instructions can be inserted between flag-setting ones and the test of that flag.

Re:Weird things I learned while writing an x86 emulator by woodruffw on Friday February 03, 2023 @03:07AM (#34638528)
Yes, good point! It would have been more accurate for me to say “the compiler should always have a model of the flags during lowering.”
Re:Weird things I learned while writing an x86 emulator by userbinator on Friday February 03, 2023 @01:09AM (#34637706)
An ADD instruction will update the carry flag but the INC instruction does not!

Neither does DEC, and I believe the original reason for this was multiple-precision arithmetic routines --- you need to propagate the carry flag, but also update loop counters and pointers.

It seems that the actual behavior of the undefined flags is related to the internal implementation of the shift operation, and is different between different architectures.

According to https://www.sandpile.org/x86/flags.htm which unfortunately hasn't been updated nor is exhaustive, all of the P6 family behave the same, but different from the P5 and the P4, and probably the earlier generations too. "Undefined" values are often used by anti-debugging/anti-emulation/VM detection code to determine if the CPU is real hardware or not, so it's actually quite important to emulate them correctly.

Re:Weird things I learned while writing an x86 emulator by flohofwoe on Friday February 03, 2023 @03:12AM (#34638578)
This behaviour goes all the way back to (at least) the Z80 and i8080, and I bet it was intentional for exactly the reason you describe (updating loop counters inbetween a sequence of ADC/SBC instructions without destroying the carry flag from the previous ADC/SBC).
Re:Weird things I learned while writing an x86 emulator by mark_undoio on Friday February 03, 2023 @03:18AM (#34638616)
IIRC from our similar code, the LEA (load effective address) instruction is useful for doing adds / subtracts of arbitrary integers without updating the flags.

Flags turn out to be quite the annoyance for the kind of in-process virtualization needed by Time Travel Debug. You need to instrument code with minimal overhead so, on the one hand, you don't want to save/restore flags all the time .... And on the other hand it still all has to work when flags get used.

Re:Weird things I learned while writing an x86 emulator by psychphysic on Friday February 03, 2023 @03:44AM (#34638796)
Multiplication even.
Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:39PM (#34645838)
Yes, saving and restoring flags is very expensive. I thought about talking about that in the article but figured that was too much of a detour.

Darek Mihocka wrote a really interesting article about how to optimize flag calculations in an x86 emulator:

http://emulators.com/docs/nx11_flags.htm

Although looking at your username I suspect you may have read this one before...

Re:Weird things I learned while writing an x86 emulator by mark_undoio on Saturday February 04, 2023 @07:51AM (#34654071)
I had not read it before! Thanks for the link. I don't get too involved with our JIT other than to occasionally peer into some code and go "ooooh"
Re:Weird things I learned while writing an x86 emulator by FartyMcFarter on Friday February 03, 2023 @03:39AM (#34638771)
> "Undefined" values are often used by anti-debugging/anti-emulation/VM detection code to determine if the CPU is real hardware or not, so it's actually quite important to emulate them correctly.

That seems quite brittle, unless all real CPUs implement them the same way. If they do, one has to wonder whether it's really undefined or an undocumented part of the x86 spec instead.

Re:Weird things I learned while writing an x86 emulator by flohofwoe on Friday February 03, 2023 @05:08AM (#34639340)
I'd guess it's "undocumented", not "undefined". Don't know how the situation is on x86, but on the Z80 there were indeed some slight differences in undocumented behaviour between CPU vendors, but those are so obscure that it hardly affected any real world code (they affected the undocumented flag bits 3 and 5, and their behaviour was only properly 'decoded' in the 2000's (https://github.com/floooh/emu-info/blob/master/z80/memptr_en...).

The only CPU I know with actual 'undefined' behaviour is the 6502 for some of the undocumented/illegal opcodes which can yield different results based on things like current CPU temperature (see the ANE/XAA instruction description: https://www.masswerk.at/nowgobang/2021/6502-illegal-opcodes)

Re:Weird things I learned while writing an x86 emulator by dataflow on Friday February 03, 2023 @10:47AM (#34642617)
> According to https://www.sandpile.org/x86/flags.htm which unfortunately hasn't been updated nor is exhaustive

Do you know if there's a more exhaustive source (besides the official manuals)?

Re:Weird things I learned while writing an x86 emulator by menaerus on Friday February 03, 2023 @03:15AM (#34638593)
Has anyone used TTD, or rr for that purpose in Linux world, to debug a complex multi-threaded application? What is the main use-case of these tools?

For example, limitations of rr seem to suggest that it is almost of no use for multi-threaded programs so I have never actually tried it. I don't know about the TTD though.

  > rr limitations

  > ...

  > emulates a single-core machine. So, parallel programs incur the slowdown of running on a single core. This is an inherent feature of the design.
Re:Weird things I learned while writing an x86 emulator by rcxdude on Friday February 03, 2023 @05:01AM (#34639302)
It can still debug multi-threaded programs, but if your bug relies on multi-core interactions it won't appear under rr (you can still catch a lot of race conditions though, and it has a 'chaos mode' which generate irregular scheduling intended to increase the likelyhood of such bugs appearing). It's been used to debug race conditions as well as other bugs in firefox, for example.
Re:Weird things I learned while writing an x86 emulator by menaerus on Friday February 03, 2023 @07:48AM (#34640369)
That's what I thought as well, limited to the single-core race conditions era. Thanks for the evidence.
Re:Weird things I learned while writing an x86 emulator by pm215 on Friday February 03, 2023 @10:52AM (#34642700)
It's still much better than the alternative, which is not having any kind of way to reproduce race conditions :-) QEMU's a pretty complex multithreaded program and my experience with chaos mode has been that it's quite good at tripping up the races (and you only need to catch the race once).
Re:Weird things I learned while writing an x86 emulator by ghusbands on Friday February 03, 2023 @02:18PM (#34646454)
It's not limited to any era - it's a general-purpose tool that can perfectly reproduce bugs, even most race conditions. The lack of multi-threading will mostly just slow things down. Being able to perfectly reproduce a bug is immensely valuable.
Re:Weird things I learned while writing an x86 emulator by menaerus on Saturday February 04, 2023 @03:30AM (#34652773)
I didn't say anything about the usefulness of rr other than in the context of concurrency bugs so I don't quite understand a defending attitude of yours.
Re:Weird things I learned while writing an x86 emulator by Liquid_Fire on Friday February 03, 2023 @09:36AM (#34641505)
> limitations of rr seem to suggest that it is almost of no use for multi-threaded programs

Only if your main use case is debugging race conditions only possible with multiple cores, which is a tiny subset of all bugs.

I use rr all the time for a complex multi-threaded (although not extremely parallel) application and it works wonders. It frequently saves me hours of debugging. Practically none of the issues I use it for are race conditions (not because it doesn't work well for those, but because I rarely get any).

Even if I had to suffer an 8x slowdown from running it on a single core, it would still be worth it nearly every time.

Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:42PM (#34645895)
TTD (the WinDbg one) works very well for complex multithreaded apps. (The caveat being the performance hit you get from emulation). It's one of the big advantages it has over rr.

The main use case I saw for TTD was debugging complex memory corruption issues. Certain types of issues like stack corruption became trivial to debug under TTD. It was also very useful for capturing a repro. If a customer complained about something and I couldn't immediately reproduce it or get a crash dump, I'd ask them to record a TTD trace. More than 75% of the time I'd say it was enough to root cause the bug, without spending tons of time figuring out the repro steps.

Re:Weird things I learned while writing an x86 emulator by roca on Tuesday February 07, 2023 @05:45AM (#34691099)
(Disclaimer: rr maintainer.)

As others have said here, in practice rr works very well for debugging a wide range of bugs in multithreaded programs, including race conditions.

Where it falls down:

* It can only use a single core, so highly parallel programs run very slowly when recorded by rr.

* Some race conditions may be difficult or impossible to reproduce under rr recording (but rr's chaos mode helps a lot with this).

* rr imposes sequential consistency on the recorded program, so bugs due to weak memory models do not show up under rr. Such bugs are pretty rare on x86 (because x86's memory model is pretty strong); this may be more of an issue on ARM.

Re:Weird things I learned while writing an x86 emulator by junon on Friday February 03, 2023 @05:21AM (#34639433)
Fascinating list, and really well presented and written! Lots of stuff I've never read about before.
Re:Weird things I learned while writing an x86 emulator by amelius on Friday February 03, 2023 @07:17AM (#34640126)
What resources did he use for this research?

I would expect at least a reference to an Intel reference manual, but perhaps there are better ways to learn about the ISA.

Re:Weird things I learned while writing an x86 emulator by a-priori on Friday February 03, 2023 @10:31AM (#34642354)
There are reference manuals with a lot of details. Specifically you'd want to read the "Intel® 64 and IA-32 Architectures Software Developer’s Manual", Volumes 2, which includes specifications of each instruction including pseudo-code of how the processor executes them. You can freely access a PDF of the entire manual here: https://www.intel.com/content/www/us/en/developer/articles/t...

But there's a lot of details there — that volume alone spans about 4000 printed pages in the manual — so you're bound to mess things up.

I've written emulators for simpler instruction sets (RISC-V and the 6502) and found that the best way to ensure they work correctly is to do instruction-by-instruction comparisons against a reference. The good news is that if you've got a PC computer, you've got easy access to a reference machine! So you can do side-by-side comparisons where you set up an initial state on both a real machine and an emulated machine, then execute some code on both, and compare the final states. By inserting break instructions (`int 3` = 0xcc) at each instruction you could extract the intermediate states after each instruction too, and ensure they match the emulated state.

So that's my guess about how he did his too. It's painstaking work, but also kind of fun when you get into it.

Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:44PM (#34645926)
Yes, that's exactly what I did. Most useful thing I did was setting up a unit test framework to test a single instruction, and then generating a huge number of variations of those instructions.
Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:43PM (#34645911)
I talked a bit about the Intel SDM in the last post I wrote (linked at the top). The SDM is great for getting the specific details, but isn't always approachable for high level overview things.
Re:Weird things I learned while writing an x86 emulator by troad on Friday February 03, 2023 @11:23AM (#34643255)
I wish this wasn't written largely using a gray font on a gray background, because it's a pain to read.
Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:45PM (#34645939)
Apologies. I'm just using a Hugo template and haven't spent a lot of time figuring out how to customize it. You're right though, the contrast isn't great.
Re:Weird things I learned while writing an x86 emulator by Akronymus on Friday February 03, 2023 @01:00PM (#34645152)
This reminds me a lot of the defcon 25 talk by xlogicx about assembly being too high level.

https://youtu.be/eunYrrcxXfw

Re:Weird things I learned while writing an x86 emulator by FullyFunctional on Friday February 03, 2023 @01:22PM (#34645539)
Nice article, but nothing really surprising when you follow the progression starting from 8080.

One correction though:

> EAX is called the “Accumulator register” is not just a convention, it actually makes a difference to the encoding (and potentially the performance, as a result)

No. As the decoder doesn't decode byte-by-bytes, but whole strings together and registers are all renamed meaning that %eax isn't really different from %ebx etc. the only difference is that it saves one byte of code space which is an extremely minor density improvement and you'd have to make a very contrived example to be able to measure the difference.

Re:Weird things I learned while writing an x86 emulator by timmisiak on Friday February 03, 2023 @01:36PM (#34645790)
My point is the smaller encoding is what gives you the performance benefit. When done across an entire function/module, you can get a measurable increase in hit rate for the instruction cache. Not that the instruction itself is faster. Apologies if that wasn't clear.
Re:Weird things I learned while writing an x86 emulator by FullyFunctional on Friday February 03, 2023 @07:17PM (#34649765)
No, I got that point and it's vanishingly small. It _only_ affects miss rate (ie. does nothing if you are hitting in the cache) and the effect on miss rate is minuscule.