Skip to content

Commit 622909e

Browse files
committed
Merge branches 'for-next/mte', 'for-next/misc' and 'for-next/kselftest', remote-tracking branch 'arm64/for-next/perf' into for-next/core
* arm64/for-next/perf: arm64/perf: Replace '0xf' instances with ID_AA64DFR0_PMUVER_IMP_DEF * for-next/mte: : Miscellaneous MTE improvements. arm64/cpufeature: Optionally disable MTE via command-line arm64: kasan: mte: remove redundant mte_report_once logic arm64: kasan: mte: use a constant kernel GCR_EL1 value arm64: avoid double ISB on kernel entry arm64: mte: optimize GCR_EL1 modification on kernel entry/exit Documentation: document the preferred tag checking mode feature arm64: mte: introduce a per-CPU tag checking mode preference arm64: move preemption disablement to prctl handlers arm64: mte: change ASYNC and SYNC TCF settings into bitfields arm64: mte: rename gcr_user_excl to mte_ctrl arm64: mte: avoid TFSRE0_EL1 related operations unless in async mode * for-next/misc: : Miscellaneous updates. arm64: Do not trap PMSNEVFR_EL1 arm64: mm: fix comment typo of pud_offset_phys() arm64: signal32: Drop pointless call to sigdelsetmask() arm64/sve: Better handle failure to allocate SVE register storage arm64: Document the requirement for SCR_EL3.HCE arm64: head: avoid over-mapping in map_memory arm64/sve: Add a comment documenting the binutils needed for SVE asm arm64/sve: Add some comments for sve_save/load_state() arm64: replace in_irq() with in_hardirq() arm64: mm: Fix TLBI vs ASID rollover arm64: entry: Add SYM_CODE annotation for __bad_stack arm64: fix typo in a comment arm64: move the (z)install rules to arch/arm64/Makefile arm64/sve: Make fpsimd_bind_task_to_cpu() static arm64: unnecessary end 'return;' in void functions arm64/sme: Document boot requirements for SME arm64: use __func__ to get function name in pr_err arm64: SSBS/DIT: print SSBS and DIT bit when printing PSTATE arm64: cpufeature: Use defined macro instead of magic numbers arm64/kexec: Test page size support with new TGRAN range values * for-next/kselftest: : Kselftest additions for arm64. kselftest/arm64: signal: Add a TODO list for signal handling tests kselftest/arm64: signal: Add test case for SVE register state in signals kselftest/arm64: signal: Verify that signals can't change the SVE vector length kselftest/arm64: signal: Check SVE signal frame shows expected vector length kselftest/arm64: signal: Support signal frames with SVE register data kselftest/arm64: signal: Add SVE to the set of features we can check for kselftest/arm64: pac: Fix skipping of tests on systems without PAC kselftest/arm64: mte: Fix misleading output when skipping tests kselftest/arm64: Add a TODO list for floating point tests kselftest/arm64: Add tests for SVE vector configuration kselftest/arm64: Validate vector lengths are set in sve-probe-vls kselftest/arm64: Provide a helper binary and "library" for SVE RDVL kselftest/arm64: Ignore check_gcr_el1_cswitch binary
4 parents fd264b3 + 7a062ce + 50cb99f + fa5ca80 commit 622909e

Some content is hidden

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

62 files changed

+1402
-307
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,3 +640,20 @@ Description: SPURR ticks for cpuX when it was idle.
640640

641641
This sysfs interface exposes the number of SPURR ticks
642642
for cpuX when it was idle.
643+
644+
What: /sys/devices/system/cpu/cpuX/mte_tcf_preferred
645+
Date: July 2021
646+
Contact: Linux ARM Kernel Mailing list <[email protected]>
647+
Description: Preferred MTE tag checking mode
648+
649+
When a user program specifies more than one MTE tag checking
650+
mode, this sysfs node is used to specify which mode should
651+
be preferred when scheduling a task on that CPU. Possible
652+
values:
653+
654+
================ ==============================================
655+
"sync" Prefer synchronous mode
656+
"async" Prefer asynchronous mode
657+
================ ==============================================
658+
659+
See also: Documentation/arm64/memory-tagging-extension.rst

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@
380380
arm64.nopauth [ARM64] Unconditionally disable Pointer Authentication
381381
support
382382

383+
arm64.nomte [ARM64] Unconditionally disable Memory Tagging Extension
384+
support
385+
383386
ataflop= [HW,M68k]
384387

385388
atarimouse= [HW,MOUSE] Atari Mouse

Documentation/arm64/booting.rst

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,17 @@ Before jumping into the kernel, the following conditions must be met:
207207
software at a higher exception level to prevent execution in an UNKNOWN
208208
state.
209209

210-
- SCR_EL3.FIQ must have the same value across all CPUs the kernel is
211-
executing on.
212-
- The value of SCR_EL3.FIQ must be the same as the one present at boot
213-
time whenever the kernel is executing.
210+
For all systems:
211+
- If EL3 is present:
212+
213+
- SCR_EL3.FIQ must have the same value across all CPUs the kernel is
214+
executing on.
215+
- The value of SCR_EL3.FIQ must be the same as the one present at boot
216+
time whenever the kernel is executing.
217+
218+
- If EL3 is present and the kernel is entered at EL2:
219+
220+
- SCR_EL3.HCE (bit 8) must be initialised to 0b1.
214221

215222
For systems with a GICv3 interrupt controller to be used in v3 mode:
216223
- If EL3 is present:
@@ -311,6 +318,28 @@ Before jumping into the kernel, the following conditions must be met:
311318
- ZCR_EL2.LEN must be initialised to the same value for all CPUs the
312319
kernel will execute on.
313320

321+
For CPUs with the Scalable Matrix Extension (FEAT_SME):
322+
323+
- If EL3 is present:
324+
325+
- CPTR_EL3.ESM (bit 12) must be initialised to 0b1.
326+
327+
- SCR_EL3.EnTP2 (bit 41) must be initialised to 0b1.
328+
329+
- SMCR_EL3.LEN must be initialised to the same value for all CPUs the
330+
kernel will execute on.
331+
332+
- If the kernel is entered at EL1 and EL2 is present:
333+
334+
- CPTR_EL2.TSM (bit 12) must be initialised to 0b0.
335+
336+
- CPTR_EL2.SMEN (bits 25:24) must be initialised to 0b11.
337+
338+
- SCTLR_EL2.EnTP2 (bit 60) must be initialised to 0b1.
339+
340+
- SMCR_EL2.LEN must be initialised to the same value for all CPUs the
341+
kernel will execute on.
342+
314343
The requirements described above for CPU mode, caches, MMUs, architected
315344
timers, coherency and system registers apply to all CPUs. All CPUs must
316345
enter the kernel in the same exception level. Where the values documented

Documentation/arm64/memory-tagging-extension.rst

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,20 @@ configurable behaviours:
7777
address is unknown).
7878

7979
The user can select the above modes, per thread, using the
80-
``prctl(PR_SET_TAGGED_ADDR_CTRL, flags, 0, 0, 0)`` system call where
81-
``flags`` contain one of the following values in the ``PR_MTE_TCF_MASK``
80+
``prctl(PR_SET_TAGGED_ADDR_CTRL, flags, 0, 0, 0)`` system call where ``flags``
81+
contains any number of the following values in the ``PR_MTE_TCF_MASK``
8282
bit-field:
8383

84-
- ``PR_MTE_TCF_NONE`` - *Ignore* tag check faults
84+
- ``PR_MTE_TCF_NONE``  - *Ignore* tag check faults
85+
(ignored if combined with other options)
8586
- ``PR_MTE_TCF_SYNC`` - *Synchronous* tag check fault mode
8687
- ``PR_MTE_TCF_ASYNC`` - *Asynchronous* tag check fault mode
8788

89+
If no modes are specified, tag check faults are ignored. If a single
90+
mode is specified, the program will run in that mode. If multiple
91+
modes are specified, the mode is selected as described in the "Per-CPU
92+
preferred tag checking modes" section below.
93+
8894
The current tag check fault mode can be read using the
8995
``prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0)`` system call.
9096

@@ -120,13 +126,39 @@ in the ``PR_MTE_TAG_MASK`` bit-field.
120126
interface provides an include mask. An include mask of ``0`` (exclusion
121127
mask ``0xffff``) results in the CPU always generating tag ``0``.
122128

129+
Per-CPU preferred tag checking mode
130+
-----------------------------------
131+
132+
On some CPUs the performance of MTE in stricter tag checking modes
133+
is similar to that of less strict tag checking modes. This makes it
134+
worthwhile to enable stricter checks on those CPUs when a less strict
135+
checking mode is requested, in order to gain the error detection
136+
benefits of the stricter checks without the performance downsides. To
137+
support this scenario, a privileged user may configure a stricter
138+
tag checking mode as the CPU's preferred tag checking mode.
139+
140+
The preferred tag checking mode for each CPU is controlled by
141+
``/sys/devices/system/cpu/cpu<N>/mte_tcf_preferred``, to which a
142+
privileged user may write the value ``async`` or ``sync``. The default
143+
preferred mode for each CPU is ``async``.
144+
145+
To allow a program to potentially run in the CPU's preferred tag
146+
checking mode, the user program may set multiple tag check fault mode
147+
bits in the ``flags`` argument to the ``prctl(PR_SET_TAGGED_ADDR_CTRL,
148+
flags, 0, 0, 0)`` system call. If the CPU's preferred tag checking
149+
mode is in the task's set of provided tag checking modes (this will
150+
always be the case at present because the kernel only supports two
151+
tag checking modes, but future kernels may support more modes), that
152+
mode will be selected. Otherwise, one of the modes in the task's mode
153+
set will be selected in a currently unspecified manner.
154+
123155
Initial process state
124156
---------------------
125157

126158
On ``execve()``, the new process has the following configuration:
127159

128160
- ``PR_TAGGED_ADDR_ENABLE`` set to 0 (disabled)
129-
- Tag checking mode set to ``PR_MTE_TCF_NONE``
161+
- No tag checking modes are selected (tag check faults ignored)
130162
- ``PR_MTE_TAG_MASK`` set to 0 (all tags excluded)
131163
- ``PSTATE.TCO`` set to 0
132164
- ``PROT_MTE`` not set on any of the initial memory maps
@@ -251,11 +283,13 @@ Example of correct usage
251283
return EXIT_FAILURE;
252284
253285
/*
254-
* Enable the tagged address ABI, synchronous MTE tag check faults and
255-
* allow all non-zero tags in the randomly generated set.
286+
* Enable the tagged address ABI, synchronous or asynchronous MTE
287+
* tag check faults (based on per-CPU preference) and allow all
288+
* non-zero tags in the randomly generated set.
256289
*/
257290
if (prctl(PR_SET_TAGGED_ADDR_CTRL,
258-
PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | (0xfffe << PR_MTE_TAG_SHIFT),
291+
PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC |
292+
(0xfffe << PR_MTE_TAG_SHIFT),
259293
0, 0, 0)) {
260294
perror("prctl() failed");
261295
return EXIT_FAILURE;

arch/arm64/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ Image: vmlinux
165165
Image.%: Image
166166
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
167167

168-
zinstall install:
169-
$(Q)$(MAKE) $(build)=$(boot) $@
168+
install: install-image := Image
169+
zinstall: install-image := Image.gz
170+
install zinstall:
171+
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \
172+
$(boot)/$(install-image) System.map "$(INSTALL_PATH)"
170173

171174
PHONY += vdso_install
172175
vdso_install:

arch/arm64/boot/Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,3 @@ $(obj)/Image.lzma: $(obj)/Image FORCE
3535

3636
$(obj)/Image.lzo: $(obj)/Image FORCE
3737
$(call if_changed,lzo)
38-
39-
install:
40-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
41-
$(obj)/Image System.map "$(INSTALL_PATH)"
42-
43-
zinstall:
44-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
45-
$(obj)/Image.gz System.map "$(INSTALL_PATH)"

arch/arm64/include/asm/cpufeature.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ static inline bool system_supports_4kb_granule(void)
657657
val = cpuid_feature_extract_unsigned_field(mmfr0,
658658
ID_AA64MMFR0_TGRAN4_SHIFT);
659659

660-
return val == ID_AA64MMFR0_TGRAN4_SUPPORTED;
660+
return (val >= ID_AA64MMFR0_TGRAN4_SUPPORTED_MIN) &&
661+
(val <= ID_AA64MMFR0_TGRAN4_SUPPORTED_MAX);
661662
}
662663

663664
static inline bool system_supports_64kb_granule(void)
@@ -669,7 +670,8 @@ static inline bool system_supports_64kb_granule(void)
669670
val = cpuid_feature_extract_unsigned_field(mmfr0,
670671
ID_AA64MMFR0_TGRAN64_SHIFT);
671672

672-
return val == ID_AA64MMFR0_TGRAN64_SUPPORTED;
673+
return (val >= ID_AA64MMFR0_TGRAN64_SUPPORTED_MIN) &&
674+
(val <= ID_AA64MMFR0_TGRAN64_SUPPORTED_MAX);
673675
}
674676

675677
static inline bool system_supports_16kb_granule(void)
@@ -681,7 +683,8 @@ static inline bool system_supports_16kb_granule(void)
681683
val = cpuid_feature_extract_unsigned_field(mmfr0,
682684
ID_AA64MMFR0_TGRAN16_SHIFT);
683685

684-
return val == ID_AA64MMFR0_TGRAN16_SUPPORTED;
686+
return (val >= ID_AA64MMFR0_TGRAN16_SUPPORTED_MIN) &&
687+
(val <= ID_AA64MMFR0_TGRAN16_SUPPORTED_MAX);
685688
}
686689

687690
static inline bool system_supports_mixed_endian_el0(void)

arch/arm64/include/asm/el2_setup.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,17 @@
150150
ubfx x1, x1, #ID_AA64MMFR0_FGT_SHIFT, #4
151151
cbz x1, .Lskip_fgt_\@
152152

153-
msr_s SYS_HDFGRTR_EL2, xzr
154-
msr_s SYS_HDFGWTR_EL2, xzr
153+
mov x0, xzr
154+
mrs x1, id_aa64dfr0_el1
155+
ubfx x1, x1, #ID_AA64DFR0_PMSVER_SHIFT, #4
156+
cmp x1, #3
157+
b.lt .Lset_fgt_\@
158+
/* Disable PMSNEVFR_EL1 read and write traps */
159+
orr x0, x0, #(1 << 62)
160+
161+
.Lset_fgt_\@:
162+
msr_s SYS_HDFGRTR_EL2, x0
163+
msr_s SYS_HDFGWTR_EL2, x0
155164
msr_s SYS_HFGRTR_EL2, xzr
156165
msr_s SYS_HFGWTR_EL2, xzr
157166
msr_s SYS_HFGITR_EL2, xzr

arch/arm64/include/asm/fpsimd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ extern void fpsimd_preserve_current_state(void);
4545
extern void fpsimd_restore_current_state(void);
4646
extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
4747

48-
extern void fpsimd_bind_task_to_cpu(void);
4948
extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state,
5049
void *sve_state, unsigned int sve_vl);
5150

arch/arm64/include/asm/fpsimdmacros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
.endm
9595

9696
/* SVE instruction encodings for non-SVE-capable assemblers */
97+
/* (pre binutils 2.28, all kernel capable clang versions support SVE) */
9798

9899
/* STR (vector): STR Z\nz, [X\nxbase, #\offset, MUL VL] */
99100
.macro _sve_str_v nz, nxbase, offset=0

0 commit comments

Comments
 (0)