News for hackers. Stuff that matters.
Re:Benchmarking division and libdivide on Apple M1 and Intel... by marcan_42 on Wednesday May 12, 2021 @09:45PM (#27137522)
Apple's CPUs are compatible at the userspace level with normal ARM. At the kernel level, I only know of one architectural violation so far (other than adding custom optional stuff): the M1 has the HCR_EL2.E2H bit forced to 1, which forces hypervisors to use VHE mode (non-VHE operation is not supported, which is a violation of the arch spec). This only matters for hypervisors, as regular OS operation doesn't care about this.

It is true that Apple implemented a bunch of custom optional features (some of which are, arguably, in violation of architectural expectations), and they definitely have some kind of deal with ARM to be able to do this, but from a developer perspective they are all optional and can be ignored. I don't think Apple exposes any of them directly to iOS/macOS developers. They only use them internally in their own software and libraries (some are for Rosetta, some are used in Accelerate.framework, some are used to implement MAP_JIT and pthread_jit_write_protect_np, some are only used by the kernel).

Re:Benchmarking division and libdivide on Apple M1 and Intel... by monocasa on Wednesday May 12, 2021 @10:26PM (#27137762)
Their AMX instructions, and those decompress instructions you found in user space are the exact kinds of things even regular architectural license holders aren't allowed to do, even hidden behind a library.

They very clearly have a special, Apple-only relationship with ARM.

Re:Benchmarking division and libdivide on Apple M1 and Intel... by marcan_42 on Thursday May 13, 2021 @12:26AM (#27138406)
AMX is available in userspace, but only used by their Accelerate.framework library. Apple does not document or expect them to be used by any apps, and I expect they'd reject any App Store submissions that use them, as I doubt they guarantee their continued existence in their current form in future CPUs.

FWIW, the compresssion instructions are used by the kernel, and I don't even know if they work from userspace. I've only ever tried them in EL2.

Re:Benchmarking division and libdivide on Apple M1 and Intel... by comex on Wednesday May 12, 2021 @11:07PM (#27137992)
Sure. But the M1 doesn't drop backwards compatibility with existing (userspace) code, which nine_k arguably suggested it did.
Re:Benchmarking division and libdivide on Apple M1 and Intel... by spacedcowboy on Thursday May 13, 2021 @01:26AM (#27138723)
They co-founded Arm. It’s not too surprising that they know the right people there...
Re:Benchmarking division and libdivide on Apple M1 and Intel... by floatingatoll on Thursday May 13, 2021 @01:10AM (#27138640)
I'm not sure if this is the right spec, but it repeatedly references a section "Behavior of HCR_EL2.E2H" that I can't find anywhere in the 4700-page PDF "Arm® Architecture Registers, Armv8, for Armv8-A architecture profile"

https://developer.arm.com/documentation/ddi0595/2021-03/AArc...

Re:Benchmarking division and libdivide on Apple M1 and Intel... by saagarjha on Thursday May 13, 2021 @03:40AM (#27139434)
Re:Benchmarking division and libdivide on Apple M1 and Intel... by mlindner on Thursday May 13, 2021 @07:17AM (#27140832)
This is a link to a pdf document from https://cpu.fyi/ with the link pointing to an entry labeled "ARMv8-A Architecture Reference Manual"
Re:Benchmarking division and libdivide on Apple M1 and Intel... by saagarjha on Friday May 14, 2021 @04:33AM (#27152078)
Gah, I copied that link wrong. I meant to reference https://cpu.fyi/d/98dfae#G23.11082057, which is that specific section about HCR_EL2.E2H's behavior.
Re:Benchmarking division and libdivide on Apple M1 and Intel... by floatingatoll on Friday May 14, 2021 @02:35PM (#27158038)
Ah. Thx!
Re:Benchmarking division and libdivide on Apple M1 and Intel... by floatingatoll on Thursday May 13, 2021 @02:58PM (#27145907)
Thanks, I appreciate the guidance!