Skip to content

Commit 6fb4443

Browse files
committed
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 updates from Catalin Marinas: "A quick summary: perf support for Branch Record Buffer Extensions (BRBE), typical PMU hardware updates, small additions to MTE for store-only tag checking and exposing non-address bits to signal handlers, HAVE_LIVEPATCH enabled on arm64, VMAP_STACK forced on. There is also a TLBI optimisation on hardware that does not require break-before-make when changing the user PTEs between contiguous and non-contiguous. More details: Perf and PMU updates: - Add support for new (v3) Hisilicon SLLC and DDRC PMUs - Add support for Arm-NI PMU integrations that share interrupts between clock domains within a given instance - Allow SPE to be configured with a lower sample period than the minimum recommendation advertised by PMSIDR_EL1.Interval - Add suppport for Arm's "Branch Record Buffer Extension" (BRBE) - Adjust the perf watchdog period according to cpu frequency changes - Minor driver fixes and cleanups Hardware features: - Support for MTE store-only checking (FEAT_MTE_STORE_ONLY) - Support for reporting the non-address bits during a synchronous MTE tag check fault (FEAT_MTE_TAGGED_FAR) - Optimise the TLBI when folding/unfolding contiguous PTEs on hardware with FEAT_BBM (break-before-make) level 2 and no TLB conflict aborts Software features: - Enable HAVE_LIVEPATCH after implementing arch_stack_walk_reliable() and using the text-poke API for late module relocations - Force VMAP_STACK always on and change arm64_efi_rt_init() to use arch_alloc_vmap_stack() in order to avoid KASAN false positives ACPI: - Improve SPCR handling and messaging on systems lacking an SPCR table Debug: - Simplify the debug exception entry path - Drop redundant DBG_MDSCR_* macros Kselftests: - Cleanups and improvements for SME, SVE and FPSIMD tests Miscellaneous: - Optimise loop to reduce redundant operations in contpte_ptep_get() - Remove ISB when resetting POR_EL0 during signal handling - Mark the kernel as tainted on SEA and SError panic - Remove redundant gcs_free() call" * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (93 commits) arm64/gcs: task_gcs_el0_enable() should use passed task arm64: Kconfig: Keep selects somewhat alphabetically ordered arm64: signal: Remove ISB when resetting POR_EL0 kselftest/arm64: Handle attempts to disable SM on SME only systems kselftest/arm64: Fix SVE write data generation for SME only systems kselftest/arm64: Test SME on SME only systems in fp-ptrace kselftest/arm64: Test FPSIMD format data writes via NT_ARM_SVE in fp-ptrace kselftest/arm64: Allow sve-ptrace to run on SME only systems arm64/mm: Drop redundant addr increment in set_huge_pte_at() kselftest/arm4: Provide local defines for AT_HWCAP3 arm64: Mark kernel as tainted on SAE and SError panic arm64/gcs: Don't call gcs_free() when releasing task_struct drivers/perf: hisi: Support PMUs with no interrupt drivers/perf: hisi: Relax the event number check of v2 PMUs drivers/perf: hisi: Add support for HiSilicon SLLC v3 PMU driver drivers/perf: hisi: Use ACPI driver_data to retrieve SLLC PMU information drivers/perf: hisi: Add support for HiSilicon DDRC v3 PMU driver drivers/perf: hisi: Simplify the probe process for each DDRC version perf/arm-ni: Support sharing IRQs within an NI instance perf/arm-ni: Consolidate CPU affinity handling ...
2 parents 3bb38c5 + 5b1ae9d commit 6fb4443

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3765
-1246
lines changed

Documentation/arch/arm64/booting.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,27 @@ Before jumping into the kernel, the following conditions must be met:
388388

389389
- SMCR_EL2.EZT0 (bit 30) must be initialised to 0b1.
390390

391+
For CPUs with the Branch Record Buffer Extension (FEAT_BRBE):
392+
393+
- If EL3 is present:
394+
395+
- MDCR_EL3.SBRBE (bits 33:32) must be initialised to 0b01 or 0b11.
396+
397+
- If the kernel is entered at EL1 and EL2 is present:
398+
399+
- BRBCR_EL2.CC (bit 3) must be initialised to 0b1.
400+
- BRBCR_EL2.MPRED (bit 4) must be initialised to 0b1.
401+
402+
- HDFGRTR_EL2.nBRBDATA (bit 61) must be initialised to 0b1.
403+
- HDFGRTR_EL2.nBRBCTL (bit 60) must be initialised to 0b1.
404+
- HDFGRTR_EL2.nBRBIDR (bit 59) must be initialised to 0b1.
405+
406+
- HDFGWTR_EL2.nBRBDATA (bit 61) must be initialised to 0b1.
407+
- HDFGWTR_EL2.nBRBCTL (bit 60) must be initialised to 0b1.
408+
409+
- HFGITR_EL2.nBRBIALL (bit 56) must be initialised to 0b1.
410+
- HFGITR_EL2.nBRBINJ (bit 55) must be initialised to 0b1.
411+
391412
For CPUs with the Performance Monitors Extension (FEAT_PMUv3p9):
392413

393414
- If EL3 is present:

Documentation/arch/arm64/elf_hwcaps.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ HWCAP2_SME_SF8DP4
435435
HWCAP2_POE
436436
Functionality implied by ID_AA64MMFR3_EL1.S1POE == 0b0001.
437437

438+
HWCAP3_MTE_FAR
439+
Functionality implied by ID_AA64PFR2_EL1.MTEFAR == 0b0001.
440+
441+
HWCAP3_MTE_STORE_ONLY
442+
Functionality implied by ID_AA64PFR2_EL1.MTESTOREONLY == 0b0001.
443+
438444
4. Unused AT_HWCAP bits
439445
-----------------------
440446

Documentation/arch/arm64/tagged-pointers.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ that signal handlers in applications making use of tags cannot rely
6060
on the tag information for user virtual addresses being maintained
6161
in these fields unless the flag was set.
6262

63-
Due to architecture limitations, bits 63:60 of the fault address
64-
are not preserved in response to synchronous tag check faults
65-
(SEGV_MTESERR) even if SA_EXPOSE_TAGBITS was set. Applications should
66-
treat the values of these bits as undefined in order to accommodate
67-
future architecture revisions which may preserve the bits.
63+
If FEAT_MTE_TAGGED_FAR (Armv8.9) is supported, bits 63:60 of the fault address
64+
are preserved in response to synchronous tag check faults (SEGV_MTESERR)
65+
otherwise not preserved even if SA_EXPOSE_TAGBITS was set.
66+
Applications should interpret the values of these bits based on
67+
the support for the HWCAP3_MTE_FAR. If the support is not present,
68+
the values of these bits should be considered as undefined otherwise valid.
6869

6970
For signals raised in response to watchpoint debug exceptions, the
7071
tag information will be preserved regardless of the SA_EXPOSE_TAGBITS

arch/arm64/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ config ARM64
232232
select HAVE_HW_BREAKPOINT if PERF_EVENTS
233233
select HAVE_IOREMAP_PROT
234234
select HAVE_IRQ_TIME_ACCOUNTING
235+
select HAVE_LIVEPATCH
235236
select HAVE_MOD_ARCH_SPECIFIC
236237
select HAVE_NMI
237238
select HAVE_PERF_EVENTS
@@ -240,6 +241,7 @@ config ARM64
240241
select HAVE_PERF_USER_STACK_DUMP
241242
select HAVE_PREEMPT_DYNAMIC_KEY
242243
select HAVE_REGS_AND_STACK_ACCESS_API
244+
select HAVE_RELIABLE_STACKTRACE
243245
select HAVE_POSIX_CPU_TIMERS_TASK_WORK
244246
select HAVE_FUNCTION_ARG_ACCESS_API
245247
select MMU_GATHER_RCU_TABLE_FREE
@@ -278,6 +280,7 @@ config ARM64
278280
select HAVE_SOFTIRQ_ON_OWN_STACK
279281
select USER_STACKTRACE_SUPPORT
280282
select VDSO_GETRANDOM
283+
select VMAP_STACK
281284
help
282285
ARM 64-bit (AArch64) Linux support.
283286

@@ -2498,3 +2501,4 @@ source "drivers/acpi/Kconfig"
24982501

24992502
source "arch/arm64/kvm/Kconfig"
25002503

2504+
source "kernel/livepatch/Kconfig"

arch/arm64/include/asm/assembler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
.macro disable_step_tsk, flgs, tmp
5959
tbz \flgs, #TIF_SINGLESTEP, 9990f
6060
mrs \tmp, mdscr_el1
61-
bic \tmp, \tmp, #DBG_MDSCR_SS
61+
bic \tmp, \tmp, #MDSCR_EL1_SS
6262
msr mdscr_el1, \tmp
6363
isb // Take effect before a subsequent clear of DAIF.D
6464
9990:
@@ -68,7 +68,7 @@
6868
.macro enable_step_tsk, flgs, tmp
6969
tbz \flgs, #TIF_SINGLESTEP, 9990f
7070
mrs \tmp, mdscr_el1
71-
orr \tmp, \tmp, #DBG_MDSCR_SS
71+
orr \tmp, \tmp, #MDSCR_EL1_SS
7272
msr mdscr_el1, \tmp
7373
9990:
7474
.endm

arch/arm64/include/asm/cpufeature.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
275275
#define ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU ((u16)BIT(5))
276276
/* Panic when a conflict is detected */
277277
#define ARM64_CPUCAP_PANIC_ON_CONFLICT ((u16)BIT(6))
278+
/*
279+
* When paired with SCOPE_LOCAL_CPU, all early CPUs must satisfy the
280+
* condition. This is different from SCOPE_SYSTEM where the check is performed
281+
* only once at the end of the SMP boot on the sanitised ID registers.
282+
* SCOPE_SYSTEM is not suitable for cases where the capability depends on
283+
* properties local to a CPU like MIDR_EL1.
284+
*/
285+
#define ARM64_CPUCAP_MATCH_ALL_EARLY_CPUS ((u16)BIT(7))
278286

279287
/*
280288
* CPU errata workarounds that need to be enabled at boot time if one or
@@ -304,6 +312,16 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
304312
(ARM64_CPUCAP_SCOPE_LOCAL_CPU | \
305313
ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU | \
306314
ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU)
315+
/*
316+
* CPU feature detected at boot time and present on all early CPUs. Late CPUs
317+
* are permitted to have the feature even if it hasn't been enabled, although
318+
* the feature will not be used by Linux in this case. If all early CPUs have
319+
* the feature, then every late CPU must have it.
320+
*/
321+
#define ARM64_CPUCAP_EARLY_LOCAL_CPU_FEATURE \
322+
(ARM64_CPUCAP_SCOPE_LOCAL_CPU | \
323+
ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU | \
324+
ARM64_CPUCAP_MATCH_ALL_EARLY_CPUS)
307325

308326
/*
309327
* CPU feature detected at boot time, on one or more CPUs. A late CPU
@@ -391,6 +409,11 @@ static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
391409
return cap->type & ARM64_CPUCAP_SCOPE_MASK;
392410
}
393411

412+
static inline bool cpucap_match_all_early_cpus(const struct arm64_cpu_capabilities *cap)
413+
{
414+
return cap->type & ARM64_CPUCAP_MATCH_ALL_EARLY_CPUS;
415+
}
416+
394417
/*
395418
* Generic helper for handling capabilities with multiple (match,enable) pairs
396419
* of call backs, sharing the same capability bit.
@@ -848,6 +871,11 @@ static inline bool system_supports_pmuv3(void)
848871
return cpus_have_final_cap(ARM64_HAS_PMUV3);
849872
}
850873

874+
static inline bool system_supports_bbml2_noabort(void)
875+
{
876+
return alternative_has_cap_unlikely(ARM64_HAS_BBML2_NOABORT);
877+
}
878+
851879
int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);
852880
bool try_emulate_mrs(struct pt_regs *regs, u32 isn);
853881

arch/arm64/include/asm/debug-monitors.h

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
#include <asm/ptrace.h>
1414

1515
/* Low-level stepping controls. */
16-
#define DBG_MDSCR_SS (1 << 0)
1716
#define DBG_SPSR_SS (1 << 21)
1817

19-
/* MDSCR_EL1 enabling bits */
20-
#define DBG_MDSCR_KDE (1 << 13)
21-
#define DBG_MDSCR_MDE (1 << 15)
22-
#define DBG_MDSCR_MASK ~(DBG_MDSCR_KDE | DBG_MDSCR_MDE)
23-
2418
#define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
2519

2620
/* AArch64 */
@@ -62,30 +56,6 @@ struct task_struct;
6256
#define DBG_HOOK_HANDLED 0
6357
#define DBG_HOOK_ERROR 1
6458

65-
struct step_hook {
66-
struct list_head node;
67-
int (*fn)(struct pt_regs *regs, unsigned long esr);
68-
};
69-
70-
void register_user_step_hook(struct step_hook *hook);
71-
void unregister_user_step_hook(struct step_hook *hook);
72-
73-
void register_kernel_step_hook(struct step_hook *hook);
74-
void unregister_kernel_step_hook(struct step_hook *hook);
75-
76-
struct break_hook {
77-
struct list_head node;
78-
int (*fn)(struct pt_regs *regs, unsigned long esr);
79-
u16 imm;
80-
u16 mask; /* These bits are ignored when comparing with imm */
81-
};
82-
83-
void register_user_break_hook(struct break_hook *hook);
84-
void unregister_user_break_hook(struct break_hook *hook);
85-
86-
void register_kernel_break_hook(struct break_hook *hook);
87-
void unregister_kernel_break_hook(struct break_hook *hook);
88-
8959
u8 debug_monitors_arch(void);
9060

9161
enum dbg_active_el {
@@ -108,17 +78,15 @@ void kernel_rewind_single_step(struct pt_regs *regs);
10878
void kernel_fastforward_single_step(struct pt_regs *regs);
10979

11080
#ifdef CONFIG_HAVE_HW_BREAKPOINT
111-
int reinstall_suspended_bps(struct pt_regs *regs);
81+
bool try_step_suspended_breakpoints(struct pt_regs *regs);
11282
#else
113-
static inline int reinstall_suspended_bps(struct pt_regs *regs)
83+
static inline bool try_step_suspended_breakpoints(struct pt_regs *regs)
11484
{
115-
return -ENODEV;
85+
return false;
11686
}
11787
#endif
11888

119-
int aarch32_break_handler(struct pt_regs *regs);
120-
121-
void debug_traps_init(void);
89+
bool try_handle_aarch32_break(struct pt_regs *regs);
12290

12391
#endif /* __ASSEMBLY */
12492
#endif /* __ASM_DEBUG_MONITORS_H */

arch/arm64/include/asm/el2_setup.h

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,27 +189,91 @@
189189
.Lskip_set_cptr_\@:
190190
.endm
191191

192+
/*
193+
* Configure BRBE to permit recording cycle counts and branch mispredicts.
194+
*
195+
* At any EL, to record cycle counts BRBE requires that both BRBCR_EL2.CC=1 and
196+
* BRBCR_EL1.CC=1.
197+
*
198+
* At any EL, to record branch mispredicts BRBE requires that both
199+
* BRBCR_EL2.MPRED=1 and BRBCR_EL1.MPRED=1.
200+
*
201+
* Set {CC,MPRED} in BRBCR_EL2 in case nVHE mode is used and we are
202+
* executing in EL1.
203+
*/
204+
.macro __init_el2_brbe
205+
mrs x1, id_aa64dfr0_el1
206+
ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4
207+
cbz x1, .Lskip_brbe_\@
208+
209+
mov_q x0, BRBCR_ELx_CC | BRBCR_ELx_MPRED
210+
msr_s SYS_BRBCR_EL2, x0
211+
.Lskip_brbe_\@:
212+
.endm
213+
192214
/* Disable any fine grained traps */
193215
.macro __init_el2_fgt
194216
mrs x1, id_aa64mmfr0_el1
195217
ubfx x1, x1, #ID_AA64MMFR0_EL1_FGT_SHIFT, #4
196218
cbz x1, .Lskip_fgt_\@
197219

198220
mov x0, xzr
221+
mov x2, xzr
199222
mrs x1, id_aa64dfr0_el1
200223
ubfx x1, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4
201224
cmp x1, #3
202225
b.lt .Lskip_spe_fgt_\@
203226
/* Disable PMSNEVFR_EL1 read and write traps */
204-
orr x0, x0, #(1 << 62)
227+
orr x0, x0, #HDFGRTR_EL2_nPMSNEVFR_EL1_MASK
228+
orr x2, x2, #HDFGWTR_EL2_nPMSNEVFR_EL1_MASK
205229

206230
.Lskip_spe_fgt_\@:
231+
mrs x1, id_aa64dfr0_el1
232+
ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4
233+
cbz x1, .Lskip_brbe_fgt_\@
234+
235+
/*
236+
* Disable read traps for the following registers
237+
*
238+
* [BRBSRC|BRBTGT|RBINF]_EL1
239+
* [BRBSRCINJ|BRBTGTINJ|BRBINFINJ|BRBTS]_EL1
240+
*/
241+
orr x0, x0, #HDFGRTR_EL2_nBRBDATA_MASK
242+
243+
/*
244+
* Disable write traps for the following registers
245+
*
246+
* [BRBSRCINJ|BRBTGTINJ|BRBINFINJ|BRBTS]_EL1
247+
*/
248+
orr x2, x2, #HDFGWTR_EL2_nBRBDATA_MASK
249+
250+
/* Disable read and write traps for [BRBCR|BRBFCR]_EL1 */
251+
orr x0, x0, #HDFGRTR_EL2_nBRBCTL_MASK
252+
orr x2, x2, #HDFGWTR_EL2_nBRBCTL_MASK
253+
254+
/* Disable read traps for BRBIDR_EL1 */
255+
orr x0, x0, #HDFGRTR_EL2_nBRBIDR_MASK
256+
257+
.Lskip_brbe_fgt_\@:
207258

208259
.Lset_debug_fgt_\@:
209260
msr_s SYS_HDFGRTR_EL2, x0
210-
msr_s SYS_HDFGWTR_EL2, x0
261+
msr_s SYS_HDFGWTR_EL2, x2
211262

212263
mov x0, xzr
264+
mov x2, xzr
265+
266+
mrs x1, id_aa64dfr0_el1
267+
ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4
268+
cbz x1, .Lskip_brbe_insn_fgt_\@
269+
270+
/* Disable traps for BRBIALL instruction */
271+
orr x2, x2, #HFGITR_EL2_nBRBIALL_MASK
272+
273+
/* Disable traps for BRBINJ instruction */
274+
orr x2, x2, #HFGITR_EL2_nBRBINJ_MASK
275+
276+
.Lskip_brbe_insn_fgt_\@:
213277
mrs x1, id_aa64pfr1_el1
214278
ubfx x1, x1, #ID_AA64PFR1_EL1_SME_SHIFT, #4
215279
cbz x1, .Lskip_sme_fgt_\@
@@ -250,7 +314,7 @@
250314
.Lset_fgt_\@:
251315
msr_s SYS_HFGRTR_EL2, x0
252316
msr_s SYS_HFGWTR_EL2, x0
253-
msr_s SYS_HFGITR_EL2, xzr
317+
msr_s SYS_HFGITR_EL2, x2
254318

255319
mrs x1, id_aa64pfr0_el1 // AMU traps UNDEF without AMU
256320
ubfx x1, x1, #ID_AA64PFR0_EL1_AMU_SHIFT, #4
@@ -300,6 +364,7 @@
300364
__init_el2_hcrx
301365
__init_el2_timers
302366
__init_el2_debug
367+
__init_el2_brbe
303368
__init_el2_lor
304369
__init_el2_stage2
305370
__init_el2_gicv3

arch/arm64/include/asm/exception.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ void do_el0_bti(struct pt_regs *regs);
5959
void do_el1_bti(struct pt_regs *regs, unsigned long esr);
6060
void do_el0_gcs(struct pt_regs *regs, unsigned long esr);
6161
void do_el1_gcs(struct pt_regs *regs, unsigned long esr);
62-
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
62+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
63+
void do_breakpoint(unsigned long esr, struct pt_regs *regs);
64+
void do_watchpoint(unsigned long addr, unsigned long esr,
6365
struct pt_regs *regs);
66+
#else
67+
static inline void do_breakpoint(unsigned long esr, struct pt_regs *regs) {}
68+
static inline void do_watchpoint(unsigned long addr, unsigned long esr,
69+
struct pt_regs *regs) {}
70+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
71+
void do_el0_softstep(unsigned long esr, struct pt_regs *regs);
72+
void do_el1_softstep(unsigned long esr, struct pt_regs *regs);
73+
void do_el0_brk64(unsigned long esr, struct pt_regs *regs);
74+
void do_el1_brk64(unsigned long esr, struct pt_regs *regs);
75+
void do_bkpt32(unsigned long esr, struct pt_regs *regs);
6476
void do_fpsimd_acc(unsigned long esr, struct pt_regs *regs);
6577
void do_sve_acc(unsigned long esr, struct pt_regs *regs);
6678
void do_sme_acc(unsigned long esr, struct pt_regs *regs);

arch/arm64/include/asm/gcs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static inline u64 gcsss2(void)
5858

5959
static inline bool task_gcs_el0_enabled(struct task_struct *task)
6060
{
61-
return current->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE;
61+
return task->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE;
6262
}
6363

6464
void gcs_set_el0_mode(struct task_struct *task);

0 commit comments

Comments
 (0)