Skip to content

arm64: apple: Ask a hypervisor about IMPDEF registers only over HVC - #910

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:apple-impdef-el1
Nov 5, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:apple-impdef-el1

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

has_apple_apflg() and has_apple_afp() (#868, #869) ask the hypervisor whether it emulates ASPSR_EL1 / AFPCR_EL0 whenever the kernel isn't in hyp mode. That's right under KVM, which traps IMPDEF registers through HCR_EL2.TIDCP. But on M4 machines aura stays at EL2 as a monitor and enters Linux at EL1 with PSCI over SMC (monitor_required() in kboot.c, SMCCC 1.2), or with no PSCI and conduit NONE on older aura builds. The vendor services are only discovered from KVM, so kvm_arm_hyp_service_available() is always false, and APFLG is never detected, although nothing traps ASPSR_EL1 there.

This asks only over the HVC conduit, which is what KVM guests use. Anywhere else there's no hypervisor to answer, so the existing AIDR_EL1 and "enable bit sticks" checks decide. Guests with an HVC conduit (KVM) behave as before. AMX keeps its check: at EL1 it also needs EL2 to set AMX_CTL_EL2.EN_EL1.

Testing (J616C, M4 Max, EL1 under aura's monitor, kvm: HYP mode not available, no psci node)

The same check on our 7.2.10 J616C tree (the merged #868 plus the first version of this, which tested for conduit NONE). That boot used an older aura with no /psci, where both versions give the same answer:

  • CPU features: detected: x86 parity and adjust flags (Apple APFLG), apple_apflg on all 14 CPUs in /proc/cpuinfo, AT_HWCAP3: 0x8000000000000000. Without it the hypervisor check fails here (no vendor services are discovered), and HWCAP3 stays 0.
  • A test that turns APFLG on with PR_AURORA_SET_X86_FLAGS in 64 threads (14 CPUs), writes PF/AF through NZCV, then spins or makes a syscall and reads them back: 0 mismatches in 12.8M rounds. Threads that didn't turn it on read PF/AF as 0.

AFP isn't testable here: the ACTLR enable bit doesn't stick on this M4 Max, so it stays off either way.

Not booted: current aura main, with its PSCI over SMC. That case comes from reading psci.c and kboot.c in aura, and it's why the check is now != SMCCC_CONDUIT_HVC: the first version would have left APFLG off there.

On integration/aurora: builds with W=1 and no warnings with APFLG/AFP on and off, and checkpatch is clean.

has_apple_apflg() and has_apple_afp() require an Aurora vendor
hypervisor feature whenever the kernel runs below EL2, so that KVM,
which traps IMPLEMENTATION DEFINED registers through HCR_EL2.TIDCP,
does not give a guest an UNDEF at its first exception. On M4 machines
aura stays at EL2 as a monitor and enters Linux at EL1 with PSCI over
SMC, or with no PSCI and no SMCCC conduit on older builds. The vendor
hypervisor services are only discovered from KVM, so APFLG is never
detected there, although nothing traps ASPSR_EL1.

KVM guests call through HVC, so ask only over that conduit. AMX keeps
its check: at EL1 it also needs EL2 to set AMX_CTL_EL2.EN_EL1.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken AxxzyWasTaken changed the title arm64: apple: Ask a hypervisor about IMPDEF registers only when there is one arm64: apple: Ask a hypervisor about IMPDEF registers only over HVC Nov 3, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge train (MTL, 06/11). Gates passed on test tree 0412501d (integration/aurora 2661d71 + this batch):

  • Signed-off-by from the author on every commit. Adversarial review done.
  • W=1 on the touched objects: 0 new warnings. KUnit: drm/apple 112/113 (1 skip), hid 19/19, SEP 158/163 (the 4 known apple_sep_host_store failures, profile tests all pass). dt_binding_check clean. apple-dcp host selftests 86/86, run-host-tests at base parity (with Merge train: G17 hang confinement (#928) plus its host-test fixture #989's fixture).
  • Regression boots of 7.3.0-aurora-mtl1106a, compared with the fleet16/fleet17 rows: M2, M1 Pro, J700 and J616s all clean (0 err-level lines, 0 AVCs, displays, Wi-Fi, BT, Touch ID, camera, speakers at minimal volume with speakerguardd, s2idle, perf at parity).
  • arm64: apple: Ask a hypervisor about IMPDEF registers only over HVC #910: with it the J700, M2 and J616s now detect APFLG; all three run stable through s2idle. We have no J616C, so your own M4 Max testing is the proof there.

@RyanTheTide
RyanTheTide merged commit d6427fc into aurora-silicon:integration/aurora Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants