mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 |
|
||||
|
||||
+41
-3
@@ -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:
|
||||
|
||||
On affected A725 cores, the CNT_CYCLES event may incur a significant
|
||||
* 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 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.
|
||||
|
||||
@@ -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
|
||||
|
||||
/*
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
/*
|
||||
|
||||
@@ -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().
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -117,6 +117,16 @@ alternative_else_nop_endif
|
||||
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
|
||||
|
||||
@@ -133,3 +133,4 @@ WORKAROUND_SPECULATIVE_AT
|
||||
WORKAROUND_SPECULATIVE_SSBS
|
||||
WORKAROUND_SPECULATIVE_UNPRIV_LOAD
|
||||
WORKAROUND_BROKEN_AMU_CONSTCNT
|
||||
WORKAROUND_BROKEN_AMU_CORECNT
|
||||
|
||||
Reference in New Issue
Block a user