Linus delivered again !
https://lkml.org/lkml/2025/10/1/1140
Many interesting points but let's focus on this one:
- only do aligned memory accesses Bonus point for not even faulting, and just loading and storing garbage instead.
It's 2025.
Why would anybody perform an unaligned access ?
I mean by that : mis-aligning a variable. It's slow and inconvenient, particularly for out-of-page access. It still exists for packed data (the BMP headers....) and that's why there is the insert/extract (IE) unit. But mostly you want to avoid that and keep your code lean.
There is the case of getting a bogus/random pointer that forces loading garbage, and indeed this is caught by an exception (just check x LSB). But a decent language shouldn't let unchecked pointers strive. That's why my architectures have two levels:
- Known good aligned pointers to full-length words are just like register access.
- Anything else goes through the LSU/Shifter/alignment unit. This can throw an exception.
A further mechanism can be added:
if a register read is performed on a data register where the address register has LSB set, it may trap.
This is quite easy to implement, though it might have to ripple through the pipeline...
However, in the case of #aStrA : Aligned Strings format with attributes , we want an unaligned pointer to work. Is it worth an additional opcode ?
Yann Guidon / YGDES
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.