News for hackers. Stuff that matters.
Re:PCI Express on the Raspberry Pi 4 by vardump on Wednesday July 10, 2019 @01:38PM (#20404312)
> On ARM we’d also run into alignment issues...

Just don't use ARMv5 or older. ARMv6+ supports unaligned access.

Re:PCI Express on the Raspberry Pi 4 by planteen on Thursday July 11, 2019 @09:04AM (#20411163)
At least on ARMv7, it's up to the MMU, not the CPU. I've worked with Cortex-A9s that trap the unaligned access. You can write a handler or crash.
Re:PCI Express on the Raspberry Pi 4 by vardump on Thursday July 11, 2019 @12:01PM (#20412585)
Interesting. I've kept my accesses aligned, but noticed that unaligned ones worked. Didn't know about the exception mechanism behind, but yeah, should have err... expected it.

By the way, you can also opt to crash on x86. Just need to enable bit AM (Alignment Mask) bit 18) in CR0 (kernel stuff) and AC (Alignment Check, also bit 18) in EFLAGS.

After that point, unaligned accesses trap. I use this in my CPU JIT/dynamic compiler to trap target unaligned accesses.

https://en.wikipedia.org/wiki/Control_register#CR0