Skip to content

Commit

Permalink
Updated doc files
Browse files Browse the repository at this point in the history
  • Loading branch information
lelegard committed Mar 27, 2023
1 parent 24b3dd2 commit 3b0e975
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
27 changes: 20 additions & 7 deletions docs/apple-m1-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@

## Checking the presence of Arm features on a CPU

At a given level of Arm architecture, several features are mandatory or optional. A CPU core may or may not implement them. In the Arm architecture reference manual, they are usually named `FEAT_xxx`.
At a given level of Arm architecture, several features are mandatory or optional.
A CPU core may or may not implement them. In the Arm architecture reference manual,
they are usually named `FEAT_xxx`.

Using system registers (usually accessible at EL1 only), it is possible to check the presence of each feature. Consequently, the exact list of features is known to the kernel only. Userland applications cannot read these registers and cannot determine the exact list of features.
Using system registers (usually accessible at EL1 only), it is possible to check the
presence of each feature. Consequently, the exact list of features is known to the
kernel only. Userland applications cannot read these registers and cannot determine
the exact list of features.

Depending on the operating system, it is possible to query a limited subset of the supported Arm features from userland using various commands or system calls:
Depending on the operating system, it is possible to query a limited subset of the
supported Arm features from userland using various commands or system calls:

- On Linux: use `cat /proc/cpuinfo` on the command line or the `getauxval()` library function.
- On macOS: use `sysctl`, either the command line tool or the system call of the same name.

The C++ class `UserFeatures` and the program `demo-userfeatures` in this project demonstrate this.

To get the complete list of features from userland, we need a specialized kernel module (Linux) or kernel extension (macOS) to read all relevant system registers, such as done in this project. The command line `sysregs` calls the kernel module to fetch all relevant information and displays them.
To get the complete list of features from userland, we need a specialized kernel
module (Linux) or kernel extension (macOS) to read all relevant system registers,
such as done in this project. The command line `sysregs` calls the kernel module
to fetch all relevant information and displays them.

## Complete list of Arm features in the Apple M1

The following table lists all Arm features which are implemented - or not - in the Apple M1, based on the command `sysregs -s`.
The following table lists all Arm features which are implemented - or not - in the Apple M1,
based on the command `sysregs -s`.

~~~
FEAT_AA32BF16 ............ no FEAT_GICv4 ............... no FEAT_RAS ................. yes
Expand Down Expand Up @@ -101,9 +111,12 @@ FEAT_GICv3 ............... no FEAT_PRFMSLC ............. no FEAT_XS ......

## Features comparison between the M1 and the M2

The following table compares the features of the M1 and M2 based on the output of the command `sysctl hw.optional.arm`. Since the lists of features are not exactly the same, the two chips must use distinct types of cores.
The following table compares the features of the M1 and M2 based on the output of
the command `sysctl hw.optional.arm`. Since the lists of features are not exactly
the same, the two chips must use distinct types of cores.

Specifically, we can notice that the M2 implements all missing security features from the M1: BTI, PAuth2, FPAC.
Specifically, we can notice that the M2 implements all missing security features
from the M1: BTI, PAuth2, FPAC.

| Feature | Apple M1 | Apple M2
| :----------- | :------: | :------:
Expand Down
26 changes: 19 additions & 7 deletions docs/arm64e-on-macos.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Apple architectures `arm64` and `arm64e` on macOS

Recent Mac machines use so-called "Apple Silicon" chips, from the M1 or M2 families of chips. These chips are designed by Apple and use CPU cores implementing the 64-bit Arm Instruction Set Architecture (ISA), also called `arm64` in the Apple context and elsewhere.

The `arm64` ISA is described in details in the [Arm Architecture Reference Manual for A-profile architecture](https://developer.arm.com/documentation/ddi0487/latest). Be aware that this is a monstrous document of nearly 12,000 pages.

The name `arm64e` was recently introduced by Apple. This platform ABI is currently in "preview" on macOS. This note explores the differences between `arm64` and `arm64e`.

**Disclaimer:** I am not working for Apple or Arm. I have no internal information on the M1 or M2 chips, or macOS. Everything in this note is based on my observations and tests on a MacBook with an M1 chip. The explanations on how such or such feature is implemented in macOS are just **speculations**, based on a rational analysis of the technical possibilites. Moreover, all tests were performed on macOS 13 (Ventura). Future versions of macOS may behave differently. Specifically, the `arm64e` ABI, as defined by Apple, is still in preview mode and may evolve in the future.
Recent Mac machines use so-called "Apple Silicon" chips, from the M1 or M2 families
of chips. These chips are designed by Apple and use CPU cores implementing the 64-bit
Arm Instruction Set Architecture (ISA), also called `arm64` in the Apple context and
elsewhere.

The `arm64` ISA is described in details in the
[Arm Architecture Reference Manual for A-profile architecture](https://developer.arm.com/documentation/ddi0487/latest).
Be aware that this is a monstrous document of nearly 12,000 pages.

The name `arm64e` was recently introduced by Apple. This platform ABI is currently
in "preview" on macOS. This note explores the differences between `arm64` and `arm64e`.

**Disclaimer:** I am not working for Apple or Arm. I have no internal information on
the M1 or M2 chips, or macOS. Everything in this note is based on my observations and
tests on a MacBook with an M1 chip. The explanations on how such or such feature is
implemented in macOS are just **speculations**, based on a rational analysis of the
technical possibilites. Moreover, all tests were performed on macOS 13 (Ventura).
Future versions of macOS may behave differently. Specifically, the `arm64e` ABI,
as defined by Apple, is still in preview mode and may evolve in the future.

**Contents:**

Expand Down

0 comments on commit 3b0e975

Please sign in to comment.