Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FINAL DRAFT
- ========================================================================
- From: Michael Reeves <[email protected]>
- Date: Tue, 6 Oct 2026 12:15:25 +1100
- Subject: [PATCH 0/2] KVM: arm64: Work around Apple M3 LPI EOI hangs
- Hi,
- There's an erratum on Apple M3 CPUs where an LPI EOI after VM exit
- can leave the running priority unchanged. This can block later
- interrupts and therefore hang the guest.
- This series updates KVM to trap Group-1 accesses on affected
- CPUs, which resolves the issue and restores normal VM functioning.
- In the first patch, CPU IDs for Apple M3 CPUs are introduced.
- In the second patch, an erratum capability for this issue is added,
- and when present, Group-1 accesses are trapped. Therefore, KVM
- emulates the EOI in software, and the running priority is properly
- cleared.
- This can reduce guest interrupt performance, but is required in order
- for KVM to work correctly on these devices.
- The erratum was reproduced on M3, M3 Pro (by myself) and M3 Max (by
- Myria). On all devices, kvm-arm.vgic_v3_group1_trap=1 prevented the
- guest hang.
- This series was tested on J613 (MacBook Air M3, 2024, 13").
- Myria Sarvay (1):
- arm64: Add Apple M3 CPU part numbers
- Michael Reeves (1):
- KVM: arm64: vgic: Fix Apple M3 LPI EOI hangs
- Documentation/arch/arm64/silicon-errata.rst | 3 +++
- arch/arm64/Kconfig | 14 +++++++++++
- arch/arm64/include/asm/cpucaps.h | 2 ++
- arch/arm64/include/asm/cputype.h | 12 +++++++++
- arch/arm64/kernel/cpu_errata.c | 28 +++++++++++++++++++++
- arch/arm64/kvm/vgic/vgic-v3.c | 4 +++
- arch/arm64/tools/cpucaps | 1 +
- 7 files changed, 64 insertions(+)
- base-commit: 67f0943b394d920b6c142aad8c6af94340342ae7
- ========================================================================
- From: Myria Sarvay <[email protected]>
- Date: Tue, 6 Oct 2026 12:15:25 +1100
- Subject: [PATCH 1/2] arm64: Add Apple M3 CPU part numbers
- Add Sawtooth and Everest CPU IDs for M3, M3 Pro, and M3 Max. The LPI EOI
- workaround needs these IDs to find the affected CPUs.
- Signed-off-by: Myria Sarvay <[email protected]>
- Signed-off-by: Michael Reeves <[email protected]>
- ---
- arch/arm64/include/asm/cputype.h | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
- diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
- index 1fa2961..886294e 100644
- --- a/arch/arm64/include/asm/cputype.h
- +++ b/arch/arm64/include/asm/cputype.h
- @@ -155,6 +155,12 @@
- #define APPLE_CPU_PART_M2_AVALANCHE_PRO 0x035
- #define APPLE_CPU_PART_M2_BLIZZARD_MAX 0x038
- #define APPLE_CPU_PART_M2_AVALANCHE_MAX 0x039
- +#define APPLE_CPU_PART_M3_SAWTOOTH 0x042
- +#define APPLE_CPU_PART_M3_EVEREST 0x043
- +#define APPLE_CPU_PART_M3_SAWTOOTH_PRO 0x044
- +#define APPLE_CPU_PART_M3_EVEREST_PRO 0x045
- +#define APPLE_CPU_PART_M3_SAWTOOTH_MAX 0x048
- +#define APPLE_CPU_PART_M3_EVEREST_MAX 0x049
- #define AMPERE_CPU_PART_AMPERE1 0xAC3
- #define AMPERE_CPU_PART_AMPERE1A 0xAC4
- @@ -250,6 +256,12 @@
- #define MIDR_APPLE_M2_AVALANCHE_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO)
- #define MIDR_APPLE_M2_BLIZZARD_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX)
- #define MIDR_APPLE_M2_AVALANCHE_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX)
- +#define MIDR_APPLE_M3_SAWTOOTH MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_SAWTOOTH)
- +#define MIDR_APPLE_M3_EVEREST MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_EVEREST)
- +#define MIDR_APPLE_M3_SAWTOOTH_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_SAWTOOTH_PRO)
- +#define MIDR_APPLE_M3_EVEREST_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_EVEREST_PRO)
- +#define MIDR_APPLE_M3_SAWTOOTH_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_SAWTOOTH_MAX)
- +#define MIDR_APPLE_M3_EVEREST_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M3_EVEREST_MAX)
- #define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1)
- #define MIDR_AMPERE1A MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1A)
- #define MIDR_MICROSOFT_AZURE_COBALT_100 MIDR_CPU_MODEL(ARM_CPU_IMP_MICROSOFT, MICROSOFT_CPU_PART_AZURE_COBALT_100)
- ========================================================================
- From: Michael Reeves <[email protected]>
- Date: Tue, 6 Oct 2026 12:15:25 +1100
- Subject: [PATCH 2/2] KVM: arm64: vgic: Fix Apple M3 LPI EOI hangs
- On Apple M3, an LPI EOI after a VM exit can leave the running priority
- unchanged. This can block later interrupts and hang the guest.
- Introduce a new CPU erratum capability to represent this issue.
- When the erratum is present, trap Group-1 CPU interface accesses
- on M3, M3 Pro, and M3 Max at EL2. The existing EOI handler then
- drops the priority in software.
- Other Group-1 accesses also trap, which can reduce guest interrupt
- performance.
- Signed-off-by: Michael Reeves <[email protected]>
- ---
- Documentation/arch/arm64/silicon-errata.rst | 3 +++
- arch/arm64/Kconfig | 14 +++++++++++
- arch/arm64/include/asm/cpucaps.h | 2 ++
- arch/arm64/kernel/cpu_errata.c | 28 +++++++++++++++++++++
- arch/arm64/kvm/vgic/vgic-v3.c | 4 +++
- arch/arm64/tools/cpucaps | 1 +
- 6 files changed, 52 insertions(+)
- diff --git a/Documentation/arch/arm64/silicon-errata.rst b/Documentation/arch/arm64/silicon-errata.rst
- index 99a1eb4..d2995a0 100644
- --- a/Documentation/arch/arm64/silicon-errata.rst
- +++ b/Documentation/arch/arm64/silicon-errata.rst
- @@ -64,6 +64,9 @@ stable kernels.
- | Ampere | AmpereOne AC04 | AC04_CPU_29 | N/A |
- +----------------+-----------------+-----------------+-----------------------------+
- +----------------+-----------------+-----------------+-----------------------------+
- +| Apple | M3/M3 Pro/M3 Max| N/A | APPLE_M3_LPI_EOI_ERRATUM |
- ++----------------+-----------------+-----------------+-----------------------------+
- ++----------------+-----------------+-----------------+-----------------------------+
- | ARM | Cortex-A510 | #2457168 | ARM64_ERRATUM_2457168 |
- +----------------+-----------------+-----------------+-----------------------------+
- | ARM | Cortex-A510 | #2064142 | ARM64_ERRATUM_2064142 |
- diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
- index cab741a..0606c0d 100644
- --- a/arch/arm64/Kconfig
- +++ b/arch/arm64/Kconfig
- @@ -454,6 +454,20 @@ config AMPERE_ERRATUM_AC04_CPU_23
- If unsure, say Y.
- +config APPLE_M3_LPI_EOI_ERRATUM
- + bool "Apple M3: virtual GIC LPI EOI fails to drop priority"
- + depends on KVM
- + default y
- + help
- + On Apple M3, M3 Pro, and M3 Max, an LPI EOI after a VM exit can
- + leave the running priority unchanged. This can hang the guest.
- +
- + The workaround traps Group-1 CPU interface accesses at EL2.
- + KVM then handles EOI in software. These traps can reduce guest
- + interrupt performance.
- +
- + If unsure, say Y.
- +
- config ARM64_WORKAROUND_CLEAN_CACHE
- bool
- diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h
- index 76350b3..4f879eb 100644
- --- a/arch/arm64/include/asm/cpucaps.h
- +++ b/arch/arm64/include/asm/cpucaps.h
- @@ -56,6 +56,8 @@ cpucap_is_possible(const unsigned int cap)
- return IS_ENABLED(CONFIG_ARM64_ERRATUM_2645198);
- case ARM64_WORKAROUND_2658417:
- return IS_ENABLED(CONFIG_ARM64_ERRATUM_2658417);
- + case ARM64_WORKAROUND_APPLE_M3_LPI_EOI:
- + return IS_ENABLED(CONFIG_APPLE_M3_LPI_EOI_ERRATUM);
- case ARM64_WORKAROUND_CAVIUM_23154:
- return IS_ENABLED(CONFIG_CAVIUM_ERRATUM_23154);
- case ARM64_WORKAROUND_DISABLE_CNP:
- diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
- index e0c0940..ae982b3 100644
- --- a/arch/arm64/kernel/cpu_errata.c
- +++ b/arch/arm64/kernel/cpu_errata.c
- @@ -314,6 +314,25 @@ static bool has_broken_gic_v3_seis(const struct arm64_cpu_capabilities *entry, i
- (read_sysreg_s(SYS_ICH_VTR_EL2) & ICH_VTR_EL2_SEIS));
- }
- +#ifdef CONFIG_APPLE_M3_LPI_EOI_ERRATUM
- +static const struct midr_range apple_m3_lpi_eoi_cpus[] = {
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_SAWTOOTH),
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_EVEREST),
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_SAWTOOTH_PRO),
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_EVEREST_PRO),
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_SAWTOOTH_MAX),
- + MIDR_ALL_VERSIONS(MIDR_APPLE_M3_EVEREST_MAX),
- + {},
- +};
- +
- +static bool has_apple_m3_lpi_eoi(const struct arm64_cpu_capabilities *entry,
- + int scope)
- +{
- + return is_kernel_in_hyp_mode() &&
- + is_affected_midr_range_list(entry, scope);
- +}
- +#endif
- +
- static void cpu_enable_impdef_pmuv3_traps(const struct arm64_cpu_capabilities *__unused)
- {
- sysreg_clear_set_s(SYS_HACR_EL2, 0, BIT(56));
- @@ -1039,6 +1058,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
- .matches = has_impdef_pmuv3,
- .cpu_enable = cpu_enable_impdef_pmuv3_traps,
- },
- +#ifdef CONFIG_APPLE_M3_LPI_EOI_ERRATUM
- + {
- + .desc = "Apple M3 virtual GIC LPI EOI workaround",
- + .capability = ARM64_WORKAROUND_APPLE_M3_LPI_EOI,
- + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
- + .matches = has_apple_m3_lpi_eoi,
- + .midr_range_list = apple_m3_lpi_eoi_cpus,
- + },
- +#endif
- {
- .desc = "Known broken GICv3 SEIS implementation",
- .capability = ARM64_WORKAROUND_GICv3_BROKEN_SEIS,
- diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c
- index 346bacb..83fdd41 100644
- --- a/arch/arm64/kvm/vgic/vgic-v3.c
- +++ b/arch/arm64/kvm/vgic/vgic-v3.c
- @@ -847,6 +847,10 @@ void noinstr kvm_compute_ich_hcr_trap_bits(struct alt_instr *alt,
- dir_trap = true;
- }
- + /* Trap Group-1 accesses so software drops the LPI priority. */
- + if (cpus_have_cap(ARM64_WORKAROUND_APPLE_M3_LPI_EOI))
- + group1_trap = true;
- +
- if (!cpus_have_cap(ARM64_HAS_ICH_HCR_EL2_TDIR))
- common_trap = true;
- diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
- index 58b6c08..fd9c8bb 100644
- --- a/arch/arm64/tools/cpucaps
- +++ b/arch/arm64/tools/cpucaps
- @@ -111,6 +111,7 @@ WORKAROUND_4193714
- WORKAROUND_4311569
- WORKAROUND_AMPERE_AC03_CPU_38
- WORKAROUND_AMPERE_AC04_CPU_23
- +WORKAROUND_APPLE_M3_LPI_EOI
- WORKAROUND_TRBE_OVERWRITE_FILL_MODE
- WORKAROUND_TSB_FLUSH_FAILURE
- WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
Advertisement
Add Comment
Please, Sign In to add comment