summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-13 13:44:27 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-13 13:44:27 -0800
commit97d73c8251226cf27cc6656b4c542869bb8c69fa (patch)
tree54035c76f6e4c330b72eb5c0140b46b5143e5b9f
parent2800868f63227c8237d70c41e70d441c919620d6 (diff)
parentad3fc05c7e65009355effeea06aa629a687acef2 (diff)
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: "Fix hugetlb write fault livelock, permission overlay and GCS state preservation across CPU suspend, cpuidle context tracking during system suspend, GCS mode handling on signal return, AMU counter errata workarounds, kexec loading of images with a non-zero text_offset and a spurious ptrace warning: - Fix hugetlb write fault livelocks caused by stale read-only TLB entries after another CPU makes the page writable and only performs a local invalidate. Unlike the generic fault path, hugetlb has no fix_spurious_fault() fallback - Save and restore POR_EL0, GCSPR_EL0 and GCSCRE0_EL1 across CPU suspend - Restrict cpuidle context tracking in cpu_suspend() to idle tasks, avoiding context tracking warnings during system suspend - Ignore attempts to change GCS mode through signal return, which updated the software state without updating the hardware. Changes made through prctl() in the signal handler are preserved. This changes the documented ABI but no known userspace relies on it. Allowing mode changes through both prctl() and signal return also creates confusing interactions, with signal return potentially undoing changes deliberately made by the handler - Extend the AMU constant counter workaround to additional CPUs and add a core cycle counter workaround for Cortex-A715/A720, treating the affected counters as unavailable - Avoid CMA allocations when loading a kexec Image with a non-zero text_offset, fixing an incorrect entry point and a memory leak when freeing the image - Remove a spurious ptrace warning when setting the syscall number of a task in a non-seized group-stop without siginfo" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: suspend: Only track cpuidle context for idle tasks arm64: ptrace: don't warn on missing siginfo in a group-stop arm64: kexec_file: Do not use CMA for images with a non-zero text_offset arm64: errata: Add Cortex-A715/A720 AMU core counter workaround arm64: errata: Extend the workaround for broken AMEVCNTR01 counter arm64/gcs: Ignore attempts to change GCS mode during signal return arm64: hugetlb: Prevent write fault livelocks on stale TLB entries arm64: suspend: Save GCS state over suspend arm64: suspend: Save POR_EL0 over suspend
-rw-r--r--Documentation/arch/arm64/gcs.rst13
-rw-r--r--Documentation/arch/arm64/silicon-errata.rst12
-rw-r--r--arch/arm64/Kconfig44
-rw-r--r--arch/arm64/include/asm/suspend.h2
-rw-r--r--arch/arm64/kernel/cpu_errata.c28
-rw-r--r--arch/arm64/kernel/cpufeature.c3
-rw-r--r--arch/arm64/kernel/kexec_image.c7
-rw-r--r--arch/arm64/kernel/ptrace.c8
-rw-r--r--arch/arm64/kernel/signal.c22
-rw-r--r--arch/arm64/kernel/suspend.c11
-rw-r--r--arch/arm64/kernel/topology.c3
-rw-r--r--arch/arm64/mm/hugetlbpage.c21
-rw-r--r--arch/arm64/mm/proc.S20
-rw-r--r--arch/arm64/tools/cpucaps1
14 files changed, 151 insertions, 44 deletions
diff --git a/Documentation/arch/arm64/gcs.rst b/Documentation/arch/arm64/gcs.rst
index 226c0b008456..1e0424f915dc 100644
--- a/Documentation/arch/arm64/gcs.rst
+++ b/Documentation/arch/arm64/gcs.rst
@@ -179,9 +179,8 @@ intended to be exhaustive.
When returning from a signal handler:
-* If there is a gcs_context record in the signal frame then the GCS flags
- and GCSPR_EL0 will be restored from that context prior to further
- validation.
+* If there is a gcs_context record in the signal frame then GCSPR_EL0
+ will be restored from that context prior to further validation.
* If there is no gcs_context record in the signal frame then the GCS
configuration will be unchanged.
@@ -190,12 +189,8 @@ When returning from a signal handler:
point to a valid GCS signal cap record, this will be popped from the
GCS prior to signal return.
-* If the GCS configuration is locked when returning from a signal then any
- attempt to change the GCS configuration will be treated as an error. This
- is true even if GCS was not enabled prior to signal entry.
-
-* GCS may be disabled via signal return but any attempt to enable GCS via
- signal return will be rejected.
+* The features_enabled in the signal return context will be ignored; any
+ changes made using the prctl() in the signal handler will be preserved.
6. ptrace extensions
diff --git a/Documentation/arch/arm64/silicon-errata.rst b/Documentation/arch/arm64/silicon-errata.rst
index afe109afe692..dc4144ac895b 100644
--- a/Documentation/arch/arm64/silicon-errata.rst
+++ b/Documentation/arch/arm64/silicon-errata.rst
@@ -171,10 +171,18 @@ stable kernels.
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-A715 | #2645198 | ARM64_ERRATUM_2645198 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Cortex-A715 | #2738462 | ARM64_ERRATUM_2738461 |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-A715 | #3456084 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Cortex-A720 | #2738461 | ARM64_ERRATUM_2738461 |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-A720 | #3456091 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Cortex-A720 | #4689339 | ARM64_ERRATUM_3821522 |
++----------------+-----------------+-----------------+-----------------------------+
+| ARM | Cortex-A720AE | #4689340 | ARM64_ERRATUM_3821522 |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-A725 | #3821522 | ARM64_ERRATUM_3821522 |
@@ -233,6 +241,8 @@ stable kernels.
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-N3 | #3456111 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Neoverse-N3 | #4689341 | ARM64_ERRATUM_3821522 |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V1 | #1619801 | N/A |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V1 | #3324341 | ARM64_ERRATUM_3194386 |
@@ -257,6 +267,8 @@ stable kernels.
+----------------+-----------------+-----------------+-----------------------------+
| ARM | C1-Pro | #4193714 | ARM64_ERRATUM_4193714 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | C1-Pro | #4689344 | ARM64_ERRATUM_3821522 |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | C1-Ultra | #3683289 | N/A |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | C1-Ultra | #4193780 | ARM64_ERRATUM_4118414 |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1075bc661833..9b08b2457a55 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1051,6 +1051,38 @@ config ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT
# making it unreliable. As a result, AMU users should treat it as
# unavailable rather than relying on misleading counter values.
+config ARM64_WORKAROUND_BROKEN_AMU_CORECNT
+ bool
+ # Targeting errata affecting AMEVCNTR00, the AMU core cycle counter.
+ # On affected CPUs the counter may continue incrementing while core
+ # remains in WFE with the clocks enabled.
+ # This may lead to readings of said counter being unreliable.
+ # How much though depends on the sampling intervals.
+
+config ARM64_ERRATUM_2738461
+ bool "Cortex-A715/Cortex-A720: workaround for AMEVCNTR00 incrementing incorrectly"
+ depends on ARM64_AMU_EXTN
+ select ARM64_WORKAROUND_BROKEN_AMU_CORECNT
+ default y
+ help
+ This option adds the workaround for the following errata:
+
+ * ARM Cortex-A715 erratum 2738462
+ * ARM Cortex-A720 erratum 2738461
+
+ On affected cores the AMEVCNTR00 counter (AMU core frequency cycles
+ counter) may continue incrementing while the core remains in WFE
+ with the clocks being enabled.
+ This may result in inaccurate counter readings, with the magnitude
+ of the discrepancy depending on the sampling interval.
+
+ With this workaround, reads of the affected counter return 0 in
+ the relevant paths. This causes users of the counter to treat it
+ as unavailable and is functionally equivalent to firmware disabling
+ the affected counter.
+
+ If unsure, say Y.
+
config ARM64_ERRATUM_2457168
bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly"
depends on ARM64_AMU_EXTN
@@ -1086,14 +1118,20 @@ config ARM64_ERRATUM_2645198
If unsure, say Y.
config ARM64_ERRATUM_3821522
- bool "Cortex-A725: 3821522: workaround for possible CNT_CYCLES increment error due to WFE/WFI"
+ bool "Cortex-*/Neoverse-*/C1-*: workaround for possible CNT_CYCLES increment error due to WFE/WFI"
depends on ARM64_AMU_EXTN
select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT
default y
help
- This option adds the workaround for ARM Cortex-A725 erratum 3821522.
+ This option adds the workaround for the following errata:
+
+ * ARM Cortex-A725 erratum 3821522
+ * ARM Cortex-A720 erratum 4689339
+ * ARM Cortex-A720AE erratum 4689340
+ * ARM Neoverse N3 erratum 4689341
+ * ARM C1-Pro erratum 4689344
- On affected A725 cores, the CNT_CYCLES event may incur a significant
+ On affected cores, the CNT_CYCLES event may incur a significant
increment error when entering and subsequently exiting WFx.
As a result, the CNT_CYCLES may diverge from the system counter
frequency at which it is expected to increment.
diff --git a/arch/arm64/include/asm/suspend.h b/arch/arm64/include/asm/suspend.h
index a5abf0615594..8e9c97aab15a 100644
--- a/arch/arm64/include/asm/suspend.h
+++ b/arch/arm64/include/asm/suspend.h
@@ -2,7 +2,7 @@
#ifndef __ASM_SUSPEND_H
#define __ASM_SUSPEND_H
-#define NR_CTX_REGS 15
+#define NR_CTX_REGS 18
#define NR_CALLEE_SAVED_REGS 12
/*
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 38abd123c740..ca31d33152e9 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -420,13 +420,33 @@ static const struct midr_range workaround_amu_constcnt_list[] = {
MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1),
#endif
#ifdef CONFIG_ARM64_ERRATUM_3821522
+ /* Cortex-A720 r0p0 - r0p2 */
+ MIDR_RANGE(MIDR_CORTEX_A720, 0, 0, 0, 2),
+ /* Cortex-A720AE r0p0 - r0p1 */
+ MIDR_RANGE(MIDR_CORTEX_A720AE, 0, 0, 0, 1),
/* Cortex-A725 r0p0 - r0p2 */
MIDR_RANGE(MIDR_CORTEX_A725, 0, 0, 0, 2),
+ /* Neoverse N3 r0p0 - r0p1 */
+ MIDR_RANGE(MIDR_NEOVERSE_N3, 0, 0, 0, 1),
+ /* C1-Pro r0p0 - r1p3 */
+ MIDR_RANGE(MIDR_C1_PRO, 0, 0, 1, 3),
#endif
{}
};
#endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT */
+#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CORECNT
+static const struct midr_range workaround_amu_corecnt_list[] = {
+#ifdef CONFIG_ARM64_ERRATUM_2738461
+ /* Cortex-A715 r0p0 - r1p3 */
+ MIDR_RANGE(MIDR_CORTEX_A715, 0, 0, 1, 3),
+ /* Cortex-A720 r0p0 - r0p1 */
+ MIDR_RANGE(MIDR_CORTEX_A720, 0, 0, 0, 1),
+#endif
+ {}
+};
+#endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CORECNT */
+
#ifdef CONFIG_CAVIUM_ERRATUM_23154
static const struct midr_range cavium_erratum_23154_cpus[] = {
MIDR_ALL_VERSIONS(MIDR_THUNDERX),
@@ -970,6 +990,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
CAP_MIDR_RANGE_LIST(workaround_amu_constcnt_list)
},
#endif
+#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CORECNT
+ {
+ .desc = "Broken AMU AMEVCNTR00 (core cycle counter)",
+ .capability = ARM64_WORKAROUND_BROKEN_AMU_CORECNT,
+ .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
+ CAP_MIDR_RANGE_LIST(workaround_amu_corecnt_list)
+ },
+#endif
#ifdef CONFIG_ARM64_ERRATUM_2038923
{
.desc = "ARM erratum 2038923",
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 34c5c03c0c9b..c9c9a6889455 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1938,7 +1938,8 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
cpumask_set_cpu(smp_processor_id(), &amu_cpus);
/* 0 reference values signal broken/disabled counters */
- if (!this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT))
+ if (!this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT) &&
+ !this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CORECNT))
update_freq_counters_refs();
}
}
diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c
index 78b1f956d8d7..f4ad22447259 100644
--- a/arch/arm64/kernel/kexec_image.c
+++ b/arch/arm64/kernel/kexec_image.c
@@ -81,6 +81,13 @@ static void *image_load(struct kimage *image,
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
kbuf.memsz = le64_to_cpu(h->image_size);
text_offset = le64_to_cpu(h->text_offset);
+ /*
+ * A CMA segment is loaded and mapped through page_address(cma), which
+ * is the CMA base and cannot represent the text_offset adjustment
+ * below. Load images with a non-zero text_offset from normal memory.
+ */
+ if (text_offset)
+ image->no_cma = true;
kbuf.buf_align = MIN_KIMG_ALIGN;
/* Adjust kernel segment with TEXT_OFFSET */
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 7405c76724bf..6a0b3a9b6125 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -573,8 +573,12 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
if (regs->syscallno == NO_SYSCALL)
return;
- /* We should only be called when target is in a ptrace stop */
- if (WARN_ON_ONCE(!info))
+ /*
+ * For exit-stops, info is always non-NULL, but that's not true for other
+ * stops such as non-seized group-stops. In those cases, just return early
+ * as there's no need to update orig_x0 anyway.
+ */
+ if (!info)
return;
/*
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 6a06a4e352b1..80398ac83c3b 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -741,36 +741,16 @@ static int preserve_gcs_context(struct gcs_context __user *ctx)
static int restore_gcs_context(struct user_ctxs *user)
{
- u64 gcspr, enabled;
+ u64 gcspr;
int err = 0;
if (user->gcs_size != sizeof(*user->gcs))
return -EINVAL;
__get_user_error(gcspr, &user->gcs->gcspr, err);
- __get_user_error(enabled, &user->gcs->features_enabled, err);
if (err)
return err;
- /* Don't allow unknown modes */
- if (enabled & ~PR_SHADOW_STACK_SUPPORTED_STATUS_MASK)
- return -EINVAL;
-
- err = gcs_check_locked(current, enabled);
- if (err != 0)
- return err;
-
- /* Don't allow enabling */
- if (!task_gcs_el0_enabled(current) &&
- (enabled & PR_SHADOW_STACK_ENABLE))
- return -EINVAL;
-
- /* If we are disabling disable everything */
- if (!(enabled & PR_SHADOW_STACK_ENABLE))
- enabled = 0;
-
- current->thread.gcs_el0_mode = enabled;
-
/*
* We let userspace set GCSPR_EL0 to anything here, we will
* validate later in gcs_restore_signal().
diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index 3691c4c32904..4c281ae6babe 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -5,6 +5,7 @@
#include <linux/uaccess.h>
#include <linux/pgtable.h>
#include <linux/cpuidle.h>
+#include <linux/sched.h>
#include <asm/alternative.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
@@ -99,6 +100,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
int ret = 0;
unsigned long flags;
struct sleep_stack_data state;
+ bool idle = is_idle_task(current);
/*
* Some portions of CPU state (e.g. PSTATE.{PAN,DIT}) are initialized
@@ -133,7 +135,8 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
*/
pause_graph_tracing();
- ct_cpuidle_enter();
+ if (idle)
+ ct_cpuidle_enter();
if (__cpu_suspend_enter(&state)) {
/* Call the suspend finisher */
@@ -149,9 +152,11 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
if (!ret)
ret = -EOPNOTSUPP;
- ct_cpuidle_exit();
+ if (idle)
+ ct_cpuidle_exit();
} else {
- ct_cpuidle_exit();
+ if (idle)
+ ct_cpuidle_exit();
__cpu_suspend_exit();
}
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 44305b997a02..30a52659f15c 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -389,7 +389,8 @@ static void cpu_read_corecnt(void *val)
* counter read is properly handled as an error case by the users of the
* counter.
*/
- *(u64 *)val = read_corecnt();
+ *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CORECNT) ?
+ 0UL : read_corecnt();
}
static void cpu_read_constcnt(void *val)
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 8e799c1fe0aa..ff1f53e435e1 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -429,9 +429,24 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
VM_WARN_ON(!pte_present(pte));
ncontig = num_contig_ptes(huge_page_size(hstate_vma(vma)), &pgsize);
- if (!pte_cont(pte))
- return __ptep_set_access_flags_anysz(vma, addr, ptep, pte,
- dirty, pgsize);
+ if (!pte_cont(pte)) {
+ if (__ptep_set_access_flags_anysz(vma, addr, ptep, pte,
+ dirty, pgsize))
+ return 1;
+
+ /*
+ * Another CPU may have made the entry writable without
+ * invalidating our stale read-only TLB entry. To avoid
+ * indefinitely faulting on this entry, flush it.
+ */
+ if (dirty)
+ __flush_hugetlb_tlb_range(vma, addr, addr + pgsize,
+ pgsize,
+ TLBF_NOWALKCACHE |
+ TLBF_NOBROADCAST |
+ TLBF_NONOTIFY);
+ return 0;
+ }
if (!__cont_access_flags_changed(ptep, pte, ncontig))
return 0;
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index b1516630904d..99aacf03367d 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -118,6 +118,16 @@ alternative_if ARM64_SME
mrs_s x2, SYS_TPIDR2_EL0
str x2, [x0, #112]
alternative_else_nop_endif
+alternative_if ARM64_HAS_S1POE
+ mrs x2, REG_POR_EL0
+ str x2, [x0, #120]
+alternative_else_nop_endif
+alternative_if ARM64_HAS_GCS
+ mrs x2, REG_GCSPR_EL0
+ str x2, [x0, #128]
+ mrs x2, REG_GCSCRE0_EL1
+ str x2, [x0, #136]
+alternative_else_nop_endif
ret
SYM_FUNC_END(cpu_do_suspend)
@@ -160,6 +170,16 @@ alternative_if ARM64_SME
ldr x2, [x0, #112]
msr_s SYS_TPIDR2_EL0, x2
alternative_else_nop_endif
+alternative_if ARM64_HAS_S1POE
+ ldr x2, [x0, #120]
+ msr REG_POR_EL0, x2
+alternative_else_nop_endif
+alternative_if ARM64_HAS_GCS
+ ldr x2, [x0, #128]
+ msr REG_GCSPR_EL0, x2
+ ldr x2, [x0, #136]
+ msr REG_GCSCRE0_EL1, x2
+alternative_else_nop_endif
msr sctlr_el1, x12
set_this_cpu_offset x13
diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
index 20cc185649f9..3125695122a0 100644
--- a/arch/arm64/tools/cpucaps
+++ b/arch/arm64/tools/cpucaps
@@ -133,3 +133,4 @@ WORKAROUND_SPECULATIVE_AT
WORKAROUND_SPECULATIVE_SSBS
WORKAROUND_SPECULATIVE_UNPRIV_LOAD
WORKAROUND_BROKEN_AMU_CONSTCNT
+WORKAROUND_BROKEN_AMU_CORECNT