Skip to content

Commit dd105d6

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: - Allow booting of late secondary CPUs affected by erratum 1418040 (currently they are parked if none of the early CPUs are affected by this erratum). - Add the 32-bit vdso Makefile to the vdso_install rule so that 'make vdso_install' installs the 32-bit compat vdso when it is compiled. - Print a warning that untrusted guests without a CPU erratum workaround (Cortex-A57 832075) may deadlock the affected system. * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: ARM64: vdso32: Install vdso32 from vdso_install KVM: arm64: Print warning when cpu erratum can cause guests to deadlock arm64: Allow booting of late CPUs affected by erratum 1418040 arm64: Move handling of erratum 1418040 into C code
2 parents d57ce84 + 8d75785 commit dd105d6

File tree

6 files changed

+42
-22
lines changed

6 files changed

+42
-22
lines changed

arch/arm64/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ zinstall install:
165165
PHONY += vdso_install
166166
vdso_install:
167167
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
168+
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@
168169

169170
# We use MRPROPER_FILES and CLEAN_FILES now
170171
archclean:

arch/arm64/kernel/cpu_errata.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
910910
.desc = "ARM erratum 1418040",
911911
.capability = ARM64_WORKAROUND_1418040,
912912
ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
913+
.type = (ARM64_CPUCAP_SCOPE_LOCAL_CPU |
914+
ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU),
913915
},
914916
#endif
915917
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT

arch/arm64/kernel/entry.S

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,6 @@ alternative_cb_end
170170
stp x28, x29, [sp, #16 * 14]
171171

172172
.if \el == 0
173-
.if \regsize == 32
174-
/*
175-
* If we're returning from a 32-bit task on a system affected by
176-
* 1418040 then re-enable userspace access to the virtual counter.
177-
*/
178-
#ifdef CONFIG_ARM64_ERRATUM_1418040
179-
alternative_if ARM64_WORKAROUND_1418040
180-
mrs x0, cntkctl_el1
181-
orr x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
182-
msr cntkctl_el1, x0
183-
alternative_else_nop_endif
184-
#endif
185-
.endif
186173
clear_gp_regs
187174
mrs x21, sp_el0
188175
ldr_this_cpu tsk, __entry_task, x20
@@ -294,14 +281,6 @@ alternative_else_nop_endif
294281
tst x22, #PSR_MODE32_BIT // native task?
295282
b.eq 3f
296283

297-
#ifdef CONFIG_ARM64_ERRATUM_1418040
298-
alternative_if ARM64_WORKAROUND_1418040
299-
mrs x0, cntkctl_el1
300-
bic x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
301-
msr cntkctl_el1, x0
302-
alternative_else_nop_endif
303-
#endif
304-
305284
#ifdef CONFIG_ARM64_ERRATUM_845719
306285
alternative_if ARM64_WORKAROUND_845719
307286
#ifdef CONFIG_PID_IN_CONTEXTIDR

arch/arm64/kernel/process.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,39 @@ static void entry_task_switch(struct task_struct *next)
515515
__this_cpu_write(__entry_task, next);
516516
}
517517

518+
/*
519+
* ARM erratum 1418040 handling, affecting the 32bit view of CNTVCT.
520+
* Assuming the virtual counter is enabled at the beginning of times:
521+
*
522+
* - disable access when switching from a 64bit task to a 32bit task
523+
* - enable access when switching from a 32bit task to a 64bit task
524+
*/
525+
static void erratum_1418040_thread_switch(struct task_struct *prev,
526+
struct task_struct *next)
527+
{
528+
bool prev32, next32;
529+
u64 val;
530+
531+
if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
532+
cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
533+
return;
534+
535+
prev32 = is_compat_thread(task_thread_info(prev));
536+
next32 = is_compat_thread(task_thread_info(next));
537+
538+
if (prev32 == next32)
539+
return;
540+
541+
val = read_sysreg(cntkctl_el1);
542+
543+
if (!next32)
544+
val |= ARCH_TIMER_USR_VCT_ACCESS_EN;
545+
else
546+
val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN;
547+
548+
write_sysreg(val, cntkctl_el1);
549+
}
550+
518551
/*
519552
* Thread switching.
520553
*/
@@ -530,6 +563,7 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
530563
entry_task_switch(next);
531564
uao_thread_switch(next);
532565
ssbs_thread_switch(next);
566+
erratum_1418040_thread_switch(prev, next);
533567

534568
/*
535569
* Complete any pending TLB or cache maintenance on this CPU in case

arch/arm64/kernel/vdso32/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ quiet_cmd_vdsosym = VDSOSYM $@
208208
cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
209209

210210
# Install commands for the unstripped file
211-
quiet_cmd_vdso_install = INSTALL $@
211+
quiet_cmd_vdso_install = INSTALL32 $@
212212
cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
213213

214214
vdso.so: $(obj)/vdso.so.dbg

arch/arm64/kvm/arm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,10 @@ int kvm_arch_init(void *opaque)
16401640
return -ENODEV;
16411641
}
16421642

1643+
if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE))
1644+
kvm_info("Guests without required CPU erratum workarounds can deadlock system!\n" \
1645+
"Only trusted guests should be used on this system.\n");
1646+
16431647
for_each_online_cpu(cpu) {
16441648
smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
16451649
if (ret < 0) {

0 commit comments

Comments
 (0)