Skip to content

Commit a82e4ef

Browse files
committed
Merge branch 'for-next/late-arrivals' into for-next/core
Late patches for 5.10: MTE selftests, minor KCSAN preparation and removal of some unused prototypes. (Amit Daniel Kachhap and others) * for-next/late-arrivals: arm64: random: Remove no longer needed prototypes arm64: initialize per-cpu offsets earlier kselftest/arm64: Check mte tagged user address in kernel kselftest/arm64: Verify KSM page merge for MTE pages kselftest/arm64: Verify all different mmap MTE options kselftest/arm64: Check forked child mte memory accessibility kselftest/arm64: Verify mte tag inclusion via prctl kselftest/arm64: Add utilities and a test to validate mte memory
2 parents baab853 + d433ab4 commit a82e4ef

18 files changed

Lines changed: 2089 additions & 17 deletions

arch/arm64/include/asm/archrandom.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,5 @@ arch_get_random_seed_long_early(unsigned long *v)
7979
}
8080
#define arch_get_random_seed_long_early arch_get_random_seed_long_early
8181

82-
#else
83-
84-
static inline bool __arm64_rndr(unsigned long *v) { return false; }
85-
static inline bool __init __early_cpu_has_rndr(void) { return false; }
86-
8782
#endif /* CONFIG_ARCH_RANDOM */
8883
#endif /* _ASM_ARCHRANDOM_H */

arch/arm64/include/asm/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info);
6868
void update_cpu_features(int cpu, struct cpuinfo_arm64 *info,
6969
struct cpuinfo_arm64 *boot);
7070

71+
void init_this_cpu_offset(void);
72+
7173
#endif /* __ASM_CPU_H */

arch/arm64/kernel/head.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ SYM_FUNC_START_LOCAL(__primary_switched)
448448
bl __pi_memset
449449
dsb ishst // Make zero page visible to PTW
450450

451+
bl init_this_cpu_offset
452+
451453
#ifdef CONFIG_KASAN
452454
bl kasan_early_init
453455
#endif
@@ -754,6 +756,7 @@ SYM_FUNC_START_LOCAL(__secondary_switched)
754756
ptrauth_keys_init_cpu x2, x3, x4, x5
755757
#endif
756758

759+
bl init_this_cpu_offset
757760
b secondary_start_kernel
758761
SYM_FUNC_END(__secondary_switched)
759762

arch/arm64/kernel/setup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ void __init smp_setup_processor_id(void)
8787
u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
8888
set_cpu_logical_map(0, mpidr);
8989

90-
/*
91-
* clear __my_cpu_offset on boot CPU to avoid hang caused by
92-
* using percpu variable early, for example, lockdep will
93-
* access percpu variable inside lock_release
94-
*/
95-
set_my_cpu_offset(0);
9690
pr_info("Booting Linux on physical CPU 0x%010lx [0x%08x]\n",
9791
(unsigned long)mpidr, read_cpuid_id());
9892
}
@@ -282,6 +276,12 @@ u64 cpu_logical_map(int cpu)
282276
}
283277
EXPORT_SYMBOL_GPL(cpu_logical_map);
284278

279+
void noinstr init_this_cpu_offset(void)
280+
{
281+
unsigned int cpu = task_cpu(current);
282+
set_my_cpu_offset(per_cpu_offset(cpu));
283+
}
284+
285285
void __init __no_sanitize_address setup_arch(char **cmdline_p)
286286
{
287287
init_mm.start_code = (unsigned long) _text;

arch/arm64/kernel/smp.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ asmlinkage notrace void secondary_start_kernel(void)
192192
u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
193193
struct mm_struct *mm = &init_mm;
194194
const struct cpu_operations *ops;
195-
unsigned int cpu;
196-
197-
cpu = task_cpu(current);
198-
set_my_cpu_offset(per_cpu_offset(cpu));
195+
unsigned int cpu = smp_processor_id();
199196

200197
/*
201198
* All kernel threads share the same mm context; grab a
@@ -435,7 +432,13 @@ void __init smp_cpus_done(unsigned int max_cpus)
435432

436433
void __init smp_prepare_boot_cpu(void)
437434
{
438-
set_my_cpu_offset(per_cpu_offset(smp_processor_id()));
435+
/*
436+
* Now that setup_per_cpu_areas() has allocated the runtime per-cpu
437+
* areas it is only safe to read the CPU0 boot-time area, and we must
438+
* reinitialize the offset to point to the runtime area.
439+
*/
440+
init_this_cpu_offset();
441+
439442
cpuinfo_store_boot_cpu();
440443

441444
/*

tools/testing/selftests/arm64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ARCH ?= $(shell uname -m 2>/dev/null || echo not)
55

66
ifneq (,$(filter $(ARCH),aarch64 arm64))
7-
ARM64_SUBTARGETS ?= tags signal pauth fp
7+
ARM64_SUBTARGETS ?= tags signal pauth fp mte
88
else
99
ARM64_SUBTARGETS :=
1010
endif
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
check_buffer_fill
2+
check_tags_inclusion
3+
check_child_memory
4+
check_mmap_options
5+
check_ksm_options
6+
check_user_mem
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (C) 2020 ARM Limited
3+
4+
CFLAGS += -std=gnu99 -I.
5+
SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
6+
PROGS := $(patsubst %.c,%,$(SRCS))
7+
8+
#Add mte compiler option
9+
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep gcc),)
10+
CFLAGS += -march=armv8.5-a+memtag
11+
endif
12+
13+
#check if the compiler works well
14+
mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
15+
16+
ifeq ($(mte_cc_support),1)
17+
# Generated binaries to be installed by top KSFT script
18+
TEST_GEN_PROGS := $(PROGS)
19+
20+
# Get Kernel headers installed and use them.
21+
KSFT_KHDR_INSTALL := 1
22+
endif
23+
24+
# Include KSFT lib.mk.
25+
include ../../lib.mk
26+
27+
ifeq ($(mte_cc_support),1)
28+
$(TEST_GEN_PROGS): mte_common_util.c mte_common_util.h mte_helper.S
29+
endif

0 commit comments

Comments
 (0)