Skip to content

Commit c0aa533

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Will Deacon: "The two main things to note are: (1) The bulk of the diffstat is us reverting a horrible bodge we had in place to ease the merging of maple tree during the merge window (which turned out not to be needed, but anyway) (2) The TLB invalidation fix is done in core code, as suggested by (and Acked-by) Peter. Summary: - Revert temporary bodge in MTE coredumping to ease maple tree integration - Fix stack frame size warning reported with 64k pages - Fix stop_machine() race with instruction text patching - Ensure alternatives patching routines are not instrumented - Enable Spectre-BHB mitigation for Cortex-A78AE - Fix hugetlb TLB invalidation when contiguous hint is used - Minor perf driver fixes - Fix some typos" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: perf/imx_ddr: Fix undefined behavior due to shift overflowing the constant arm64: Add part number for Arm Cortex-A78AE arm64: patch_text: Fixup last cpu should be master tlb: hugetlb: Add more sizes to tlb_remove_huge_tlb_entry arm64: alternatives: mark patch_alternative() as `noinstr` perf: MARVELL_CN10K_DDR_PMU should depend on ARCH_THUNDER perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator arm64: Fix comments in macro __init_el2_gicv3 arm64: fix typos in comments arch/arm64: Fix topology initialization for core scheduling arm64: mte: Fix the stack frame size warning in mte_dump_tag_range() Revert "arm64: Change elfcore for_each_mte_vma() to use VMA iterator"
2 parents d66b698 + d02b4dd commit c0aa533

File tree

15 files changed

+53
-41
lines changed

15 files changed

+53
-41
lines changed

arch/arm64/include/asm/cputype.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define ARM_CPU_PART_CORTEX_A77 0xD0D
7676
#define ARM_CPU_PART_NEOVERSE_V1 0xD40
7777
#define ARM_CPU_PART_CORTEX_A78 0xD41
78+
#define ARM_CPU_PART_CORTEX_A78AE 0xD42
7879
#define ARM_CPU_PART_CORTEX_X1 0xD44
7980
#define ARM_CPU_PART_CORTEX_A510 0xD46
8081
#define ARM_CPU_PART_CORTEX_A710 0xD47
@@ -130,6 +131,7 @@
130131
#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77)
131132
#define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1)
132133
#define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78)
134+
#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE)
133135
#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)
134136
#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510)
135137
#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)

arch/arm64/include/asm/el2_setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
isb // Make sure SRE is now set
108108
mrs_s x0, SYS_ICC_SRE_EL2 // Read SRE back,
109109
tbz x0, #0, .Lskip_gicv3_\@ // and check that it sticks
110-
msr_s SYS_ICH_HCR_EL2, xzr // Reset ICC_HCR_EL2 to defaults
110+
msr_s SYS_ICH_HCR_EL2, xzr // Reset ICH_HCR_EL2 to defaults
111111
.Lskip_gicv3_\@:
112112
.endm
113113

arch/arm64/kernel/alternative.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ bool alternative_is_applied(u16 cpufeature)
4242
/*
4343
* Check if the target PC is within an alternative block.
4444
*/
45-
static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc)
45+
static __always_inline bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc)
4646
{
4747
unsigned long replptr = (unsigned long)ALT_REPL_PTR(alt);
4848
return !(pc >= replptr && pc <= (replptr + alt->alt_len));
4949
}
5050

5151
#define align_down(x, a) ((unsigned long)(x) & ~(((unsigned long)(a)) - 1))
5252

53-
static u32 get_alt_insn(struct alt_instr *alt, __le32 *insnptr, __le32 *altinsnptr)
53+
static __always_inline u32 get_alt_insn(struct alt_instr *alt, __le32 *insnptr, __le32 *altinsnptr)
5454
{
5555
u32 insn;
5656

@@ -95,7 +95,7 @@ static u32 get_alt_insn(struct alt_instr *alt, __le32 *insnptr, __le32 *altinsnp
9595
return insn;
9696
}
9797

98-
static void patch_alternative(struct alt_instr *alt,
98+
static noinstr void patch_alternative(struct alt_instr *alt,
9999
__le32 *origptr, __le32 *updptr, int nr_inst)
100100
{
101101
__le32 *replptr;

arch/arm64/kernel/elfcore.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@
88
#include <asm/cpufeature.h>
99
#include <asm/mte.h>
1010

11-
#ifndef VMA_ITERATOR
12-
#define VMA_ITERATOR(name, mm, addr) \
13-
struct mm_struct *name = mm
14-
#define for_each_vma(vmi, vma) \
15-
for (vma = vmi->mmap; vma; vma = vma->vm_next)
16-
#endif
17-
18-
#define for_each_mte_vma(vmi, vma) \
11+
#define for_each_mte_vma(tsk, vma) \
1912
if (system_supports_mte()) \
20-
for_each_vma(vmi, vma) \
13+
for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
2114
if (vma->vm_flags & VM_MTE)
2215

2316
static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -32,10 +25,11 @@ static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
3225
static int mte_dump_tag_range(struct coredump_params *cprm,
3326
unsigned long start, unsigned long end)
3427
{
28+
int ret = 1;
3529
unsigned long addr;
30+
void *tags = NULL;
3631

3732
for (addr = start; addr < end; addr += PAGE_SIZE) {
38-
char tags[MTE_PAGE_TAG_STORAGE];
3933
struct page *page = get_dump_page(addr);
4034

4135
/*
@@ -59,22 +53,36 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
5953
continue;
6054
}
6155

56+
if (!tags) {
57+
tags = mte_allocate_tag_storage();
58+
if (!tags) {
59+
put_page(page);
60+
ret = 0;
61+
break;
62+
}
63+
}
64+
6265
mte_save_page_tags(page_address(page), tags);
6366
put_page(page);
64-
if (!dump_emit(cprm, tags, MTE_PAGE_TAG_STORAGE))
65-
return 0;
67+
if (!dump_emit(cprm, tags, MTE_PAGE_TAG_STORAGE)) {
68+
mte_free_tag_storage(tags);
69+
ret = 0;
70+
break;
71+
}
6672
}
6773

68-
return 1;
74+
if (tags)
75+
mte_free_tag_storage(tags);
76+
77+
return ret;
6978
}
7079

7180
Elf_Half elf_core_extra_phdrs(void)
7281
{
7382
struct vm_area_struct *vma;
7483
int vma_count = 0;
75-
VMA_ITERATOR(vmi, current->mm, 0);
7684

77-
for_each_mte_vma(vmi, vma)
85+
for_each_mte_vma(current, vma)
7886
vma_count++;
7987

8088
return vma_count;
@@ -83,9 +91,8 @@ Elf_Half elf_core_extra_phdrs(void)
8391
int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
8492
{
8593
struct vm_area_struct *vma;
86-
VMA_ITERATOR(vmi, current->mm, 0);
8794

88-
for_each_mte_vma(vmi, vma) {
95+
for_each_mte_vma(current, vma) {
8996
struct elf_phdr phdr;
9097

9198
phdr.p_type = PT_ARM_MEMTAG_MTE;
@@ -109,9 +116,8 @@ size_t elf_core_extra_data_size(void)
109116
{
110117
struct vm_area_struct *vma;
111118
size_t data_size = 0;
112-
VMA_ITERATOR(vmi, current->mm, 0);
113119

114-
for_each_mte_vma(vmi, vma)
120+
for_each_mte_vma(current, vma)
115121
data_size += mte_vma_tag_dump_size(vma);
116122

117123
return data_size;
@@ -120,9 +126,8 @@ size_t elf_core_extra_data_size(void)
120126
int elf_core_write_extra_data(struct coredump_params *cprm)
121127
{
122128
struct vm_area_struct *vma;
123-
VMA_ITERATOR(vmi, current->mm, 0);
124129

125-
for_each_mte_vma(vmi, vma) {
130+
for_each_mte_vma(current, vma) {
126131
if (vma->vm_flags & VM_DONTDUMP)
127132
continue;
128133

arch/arm64/kernel/hw_breakpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ NOKPROBE_SYMBOL(breakpoint_handler);
701701
* addresses. There is no straight-forward way, short of disassembling the
702702
* offending instruction, to map that address back to the watchpoint. This
703703
* function computes the distance of the memory access from the watchpoint as a
704-
* heuristic for the likelyhood that a given access triggered the watchpoint.
704+
* heuristic for the likelihood that a given access triggered the watchpoint.
705705
*
706706
* See Section D2.10.5 "Determining the memory location that caused a Watchpoint
707707
* exception" of ARMv8 Architecture Reference Manual for details.

arch/arm64/kernel/module-plts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static unsigned int count_plts(Elf64_Sym *syms, Elf64_Rela *rela, int num,
220220
* increasing the section's alignment so that the
221221
* resulting address of this instruction is guaranteed
222222
* to equal the offset in that particular bit (as well
223-
* as all less signficant bits). This ensures that the
223+
* as all less significant bits). This ensures that the
224224
* address modulo 4 KB != 0xfff8 or 0xfffc (which would
225225
* have all ones in bits [11:3])
226226
*/

arch/arm64/kernel/patching.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ static int __kprobes aarch64_insn_patch_text_cb(void *arg)
117117
int i, ret = 0;
118118
struct aarch64_insn_patch *pp = arg;
119119

120-
/* The first CPU becomes master */
121-
if (atomic_inc_return(&pp->cpu_count) == 1) {
120+
/* The last CPU becomes master */
121+
if (atomic_inc_return(&pp->cpu_count) == num_online_cpus()) {
122122
for (i = 0; ret == 0 && i < pp->insn_cnt; i++)
123123
ret = aarch64_insn_patch_text_nosync(pp->text_addrs[i],
124124
pp->new_insns[i]);

arch/arm64/kernel/proton-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ u8 spectre_bhb_loop_affected(int scope)
853853
if (scope == SCOPE_LOCAL_CPU) {
854854
static const struct midr_range spectre_bhb_k32_list[] = {
855855
MIDR_ALL_VERSIONS(MIDR_CORTEX_A78),
856+
MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE),
856857
MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C),
857858
MIDR_ALL_VERSIONS(MIDR_CORTEX_X1),
858859
MIDR_ALL_VERSIONS(MIDR_CORTEX_A710),

arch/arm64/kernel/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ asmlinkage notrace void secondary_start_kernel(void)
234234
* Log the CPU info before it is marked online and might get read.
235235
*/
236236
cpuinfo_store_cpu();
237+
store_cpu_topology(cpu);
237238

238239
/*
239240
* Enable GIC and timers.
@@ -242,7 +243,6 @@ asmlinkage notrace void secondary_start_kernel(void)
242243

243244
ipi_setup(cpu);
244245

245-
store_cpu_topology(cpu);
246246
numa_add_cpu(cpu);
247247

248248
/*

arch/arm64/kernel/suspend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
140140
/*
141141
* Restore pstate flags. OS lock and mdscr have been already
142142
* restored, so from this point onwards, debugging is fully
143-
* renabled if it was enabled when core started shutdown.
143+
* reenabled if it was enabled when core started shutdown.
144144
*/
145145
local_daif_restore(flags);
146146

0 commit comments

Comments
 (0)