Skip to content

Commit f4c8824

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: "An unfortunately large collection of arm64 fixes for -rc5. Some of this is absolutely trivial, but the alternatives, vDSO and CPU errata workaround fixes are significant. At least people are finding and fixing these things, I suppose. - Fix workaround for CPU erratum #1418040 to disable the compat vDSO - Fix Oops when single-stepping with KGDB - Fix memory attributes for hypervisor device mappings at EL2 - Fix memory leak in PSCI and remove useless variable assignment - Fix up some comments and asm labels in our entry code - Fix broken register table formatting in our generated html docs - Fix missing NULL sentinel in CPU errata workaround list - Fix patching of branches in alternative instruction sections" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64/alternatives: don't patch up internal branches arm64: Add missing sentinel to erratum_1463225 arm64: Documentation: Fix broken table in generated HTML arm64: kgdb: Fix single-step exception handling oops arm64: entry: Tidy up block comments and label numbers arm64: Rework ARM_ERRATUM_1414080 handling arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040 arm64: arch_timer: Allow an workaround descriptor to disable compat vdso arm64: Introduce a way to disable the 32bit vdso arm64: entry: Fix the typo in the comment of el1_dbg() drivers/firmware/psci: Assign @err directly in hotplug_tests() drivers/firmware/psci: Fix memory leakage in alloc_init_cpu_groups() KVM: arm64: Fix definition of PAGE_HYP_DEVICE
2 parents e8749d0 + 5679b28 commit f4c8824

File tree

12 files changed

+68
-44
lines changed

12 files changed

+68
-44
lines changed

Documentation/arm64/cpu-feature-registers.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ infrastructure:
171171

172172

173173
3) ID_AA64PFR1_EL1 - Processor Feature Register 1
174+
174175
+------------------------------+---------+---------+
175176
| Name | bits | visible |
176177
+------------------------------+---------+---------+
@@ -181,6 +182,7 @@ infrastructure:
181182

182183

183184
4) MIDR_EL1 - Main ID Register
185+
184186
+------------------------------+---------+---------+
185187
| Name | bits | visible |
186188
+------------------------------+---------+---------+

arch/arm64/include/asm/arch_timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct arch_timer_erratum_workaround {
5858
u64 (*read_cntvct_el0)(void);
5959
int (*set_next_event_phys)(unsigned long, struct clock_event_device *);
6060
int (*set_next_event_virt)(unsigned long, struct clock_event_device *);
61+
bool disable_compat_vdso;
6162
};
6263

6364
DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extern bool arm64_use_ng_mappings;
6767
#define PAGE_HYP __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_HYP_XN)
6868
#define PAGE_HYP_EXEC __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY)
6969
#define PAGE_HYP_RO __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY | PTE_HYP_XN)
70-
#define PAGE_HYP_DEVICE __pgprot(PROT_DEVICE_nGnRE | PTE_HYP)
70+
#define PAGE_HYP_DEVICE __pgprot(_PROT_DEFAULT | PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_HYP | PTE_HYP_XN)
7171

7272
#define PAGE_S2_MEMATTR(attr) \
7373
({ \

arch/arm64/include/asm/vdso/clocksource.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#ifndef __ASM_VDSOCLOCKSOURCE_H
33
#define __ASM_VDSOCLOCKSOURCE_H
44

5-
#define VDSO_ARCH_CLOCKMODES \
6-
VDSO_CLOCKMODE_ARCHTIMER
5+
#define VDSO_ARCH_CLOCKMODES \
6+
/* vdso clocksource for both 32 and 64bit tasks */ \
7+
VDSO_CLOCKMODE_ARCHTIMER, \
8+
/* vdso clocksource for 64bit tasks only */ \
9+
VDSO_CLOCKMODE_ARCHTIMER_NOCOMPAT
710

811
#endif

arch/arm64/include/asm/vdso/compat_gettimeofday.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
111111
* update. Return something. Core will do another round and then
112112
* see the mode change and fallback to the syscall.
113113
*/
114-
if (clock_mode == VDSO_CLOCKMODE_NONE)
114+
if (clock_mode != VDSO_CLOCKMODE_ARCHTIMER)
115115
return 0;
116116

117117
/*
@@ -152,6 +152,12 @@ static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
152152
return ret;
153153
}
154154

155+
static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
156+
{
157+
return vd->clock_mode == VDSO_CLOCKMODE_ARCHTIMER;
158+
}
159+
#define vdso_clocksource_ok vdso_clocksource_ok
160+
155161
#endif /* !__ASSEMBLY__ */
156162

157163
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */

arch/arm64/kernel/alternative.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,8 @@ bool alternative_is_applied(u16 cpufeature)
4343
*/
4444
static bool branch_insn_requires_update(struct alt_instr *alt, unsigned long pc)
4545
{
46-
unsigned long replptr;
47-
48-
if (kernel_text_address(pc))
49-
return true;
50-
51-
replptr = (unsigned long)ALT_REPL_PTR(alt);
52-
if (pc >= replptr && pc <= (replptr + alt->alt_len))
53-
return false;
54-
55-
/*
56-
* Branching into *another* alternate sequence is doomed, and
57-
* we're not even trying to fix it up.
58-
*/
59-
BUG();
46+
unsigned long replptr = (unsigned long)ALT_REPL_PTR(alt);
47+
return !(pc >= replptr && pc <= (replptr + alt->alt_len));
6048
}
6149

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

arch/arm64/kernel/cpu_errata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ static const struct midr_range erratum_1463225[] = {
782782
MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 3, 1),
783783
/* Kryo4xx Gold (rcpe to rfpf) => (r0p0 to r3p1) */
784784
MIDR_RANGE(MIDR_QCOM_KRYO_4XX_GOLD, 0xc, 0xe, 0xf, 0xf),
785+
{},
785786
};
786787
#endif
787788

arch/arm64/kernel/entry-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void notrace el1_dbg(struct pt_regs *regs, unsigned long esr)
5757
/*
5858
* The CPU masked interrupts, and we are leaving them masked during
5959
* do_debug_exception(). Update PMR as if we had called
60-
* local_mask_daif().
60+
* local_daif_mask().
6161
*/
6262
if (system_uses_irq_prio_masking())
6363
gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET);

arch/arm64/kernel/entry.S

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ alternative_else_nop_endif
126126
add \dst, \dst, #(\sym - .entry.tramp.text)
127127
.endm
128128

129-
// This macro corrupts x0-x3. It is the caller's duty
130-
// to save/restore them if required.
129+
/*
130+
* This macro corrupts x0-x3. It is the caller's duty to save/restore
131+
* them if required.
132+
*/
131133
.macro apply_ssbd, state, tmp1, tmp2
132134
#ifdef CONFIG_ARM64_SSBD
133135
alternative_cb arm64_enable_wa2_handling
@@ -167,13 +169,28 @@ alternative_cb_end
167169
stp x28, x29, [sp, #16 * 14]
168170

169171
.if \el == 0
172+
.if \regsize == 32
173+
/*
174+
* If we're returning from a 32-bit task on a system affected by
175+
* 1418040 then re-enable userspace access to the virtual counter.
176+
*/
177+
#ifdef CONFIG_ARM64_ERRATUM_1418040
178+
alternative_if ARM64_WORKAROUND_1418040
179+
mrs x0, cntkctl_el1
180+
orr x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
181+
msr cntkctl_el1, x0
182+
alternative_else_nop_endif
183+
#endif
184+
.endif
170185
clear_gp_regs
171186
mrs x21, sp_el0
172187
ldr_this_cpu tsk, __entry_task, x20
173188
msr sp_el0, tsk
174189

175-
// Ensure MDSCR_EL1.SS is clear, since we can unmask debug exceptions
176-
// when scheduling.
190+
/*
191+
* Ensure MDSCR_EL1.SS is clear, since we can unmask debug exceptions
192+
* when scheduling.
193+
*/
177194
ldr x19, [tsk, #TSK_TI_FLAGS]
178195
disable_step_tsk x19, x20
179196

@@ -320,6 +337,14 @@ alternative_else_nop_endif
320337
tst x22, #PSR_MODE32_BIT // native task?
321338
b.eq 3f
322339

340+
#ifdef CONFIG_ARM64_ERRATUM_1418040
341+
alternative_if ARM64_WORKAROUND_1418040
342+
mrs x0, cntkctl_el1
343+
bic x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
344+
msr cntkctl_el1, x0
345+
alternative_else_nop_endif
346+
#endif
347+
323348
#ifdef CONFIG_ARM64_ERRATUM_845719
324349
alternative_if ARM64_WORKAROUND_845719
325350
#ifdef CONFIG_PID_IN_CONTEXTIDR
@@ -331,21 +356,6 @@ alternative_if ARM64_WORKAROUND_845719
331356
alternative_else_nop_endif
332357
#endif
333358
3:
334-
#ifdef CONFIG_ARM64_ERRATUM_1418040
335-
alternative_if_not ARM64_WORKAROUND_1418040
336-
b 4f
337-
alternative_else_nop_endif
338-
/*
339-
* if (x22.mode32 == cntkctl_el1.el0vcten)
340-
* cntkctl_el1.el0vcten = ~cntkctl_el1.el0vcten
341-
*/
342-
mrs x1, cntkctl_el1
343-
eon x0, x1, x22, lsr #3
344-
tbz x0, #1, 4f
345-
eor x1, x1, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
346-
msr cntkctl_el1, x1
347-
4:
348-
#endif
349359
scs_save tsk, x0
350360

351361
/* No kernel C function calls after this as user keys are set. */
@@ -377,11 +387,11 @@ alternative_else_nop_endif
377387
.if \el == 0
378388
alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0
379389
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
380-
bne 5f
390+
bne 4f
381391
msr far_el1, x30
382392
tramp_alias x30, tramp_exit_native
383393
br x30
384-
5:
394+
4:
385395
tramp_alias x30, tramp_exit_compat
386396
br x30
387397
#endif

arch/arm64/kernel/kgdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
252252
if (!kgdb_single_step)
253253
return DBG_HOOK_ERROR;
254254

255-
kgdb_handle_exception(1, SIGTRAP, 0, regs);
255+
kgdb_handle_exception(0, SIGTRAP, 0, regs);
256256
return DBG_HOOK_HANDLED;
257257
}
258258
NOKPROBE_SYMBOL(kgdb_step_brk_fn);

0 commit comments

Comments
 (0)