mirror of
https://github.com/torvalds/linux.git
synced 2024-12-11 05:33:09 +00:00
9dd0013824
- improve ARM implementation of pfn_valid() - various sparse fixes - spelling fixes - add further ARMv8 debug architecture versions - clang fix for decompressor - update to generic vDSO - remove Brahma-B53 from spectre hardening - initialise broadcast hrtimer device - use correct nm executable in decompressor - remove old mcount et.al. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEuNNh8scc2k/wOAE+9OeQG+StrGQFAl3frmsACgkQ9OeQG+St rGQbEQ//beELau57BFqbfV6FAo2nJ5S8t/w35VYPlOIwz6Y20ilJfAvHlBcX24N6 JSKGiQEQyoj7WBpypp6FnAOe161WxWl4tIS4saOxQjrCCFEZrY2ZeOl4tsFE4U7b abDiw7RmAk4sKW8JPSAhGcQkWvSdmk+SqQrKwgnLVvPv96DffF9U+W688yvEHyBN KnMG0JKXs6cZeq1jXpJLxrbX9jBU5ZNkaDy8U17MGpSrdhcFVpaDUtNVfmhxsFnr TuQWs9bRlDq77J7j//ojXU9IsvICTV3hedqJj3LmlhBlrbRFojROo2a/LSyfFT+u Hj1wV0OhaasLxKD0nqkn+kRMty0UZz+4mIgGfc+3xE9TaCRbDUbRt+czSqRvBNZR zh+ikwoBLTyKBRBmEBkCN66G+2dk5MC9MSsC/ZdW/8Y57mJ4DnjtCLfKOJEzFkgy zvlf3sWqcoRhLe4c6urB3LrWCoYqotdoV7zu3Obq8jccKCg802lfNtT2kGvaHiHj XFcm8mB26qAdhZAP3+D3C8CcY2LPJl7ERf51SQA6sowBw0BjDvJRd0ZU3pUQvGHY fribGwOVI51wGTCuBAMsvA3OwDTQUetk3bIItgIf+4PJ81MiDe72kMoG5M8uWjgG SUiKif8In5YNBgWwfD4S5shrmdCAaYGGRS15CY4rejwW9Eq/eLY= =67Db -----END PGP SIGNATURE----- Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm Pull ARM updates from Russell King: - improve ARM implementation of pfn_valid() - various sparse fixes - spelling fixes - add further ARMv8 debug architecture versions - clang fix for decompressor - update to generic vDSO - remove Brahma-B53 from spectre hardening - initialise broadcast hrtimer device - use correct nm executable in decompressor - remove old mcount et.al. * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: (26 commits) ARM: 8940/1: ftrace: remove mcount(),ftrace_caller_old() and ftrace_call_old() ARM: 8939/1: kbuild: use correct nm executable ARM: 8938/1: kernel: initialize broadcast hrtimer based clock event device ARM: 8937/1: spectre-v2: remove Brahma-B53 from hardening ARM: 8933/1: replace Sun/Solaris style flag on section directive ARM: 8932/1: Add clock_gettime64 entry point ARM: 8931/1: Add clock_getres entry point ARM: 8930/1: Add support for generic vDSO ARM: 8929/1: use APSR_nzcv instead of r15 as mrc operand ARM: 8927/1: ARM/hw_breakpoint: add more ARMv8 debug architecture versions support ARM: 8918/2: only build return_address() if needed ARM: 8928/1: ARM_ERRATA_775420: Spelling s/date/data/ ARM: 8925/1: tcm: include <asm/tcm.h> for missing declarations ARM: 8924/1: tcm: make dtcm_end and itcm_end static ARM: 8923/1: mm: include <asm/vga.h> for vga_base ARM: 8922/1: parse_dt_topology() rate is pointer to __be32 ARM: 8920/1: share get_signal_page from signal.c to process.c ARM: 8919/1: make unexported functions static ARM: 8917/1: mm: include <asm/set_memory.h> ARM: 8916/1: mm: make set_section_perms() static ...
158 lines
3.7 KiB
C
158 lines
3.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/arm-smccc.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/smp.h>
|
|
|
|
#include <asm/cp15.h>
|
|
#include <asm/cputype.h>
|
|
#include <asm/proc-fns.h>
|
|
#include <asm/system_misc.h>
|
|
|
|
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
|
|
DEFINE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn);
|
|
|
|
extern void cpu_v7_iciallu_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
|
|
extern void cpu_v7_bpiall_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
|
|
extern void cpu_v7_smc_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
|
|
extern void cpu_v7_hvc_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
|
|
|
|
static void harden_branch_predictor_bpiall(void)
|
|
{
|
|
write_sysreg(0, BPIALL);
|
|
}
|
|
|
|
static void harden_branch_predictor_iciallu(void)
|
|
{
|
|
write_sysreg(0, ICIALLU);
|
|
}
|
|
|
|
static void __maybe_unused call_smc_arch_workaround_1(void)
|
|
{
|
|
arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
|
|
}
|
|
|
|
static void __maybe_unused call_hvc_arch_workaround_1(void)
|
|
{
|
|
arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
|
|
}
|
|
|
|
static void cpu_v7_spectre_init(void)
|
|
{
|
|
const char *spectre_v2_method = NULL;
|
|
int cpu = smp_processor_id();
|
|
|
|
if (per_cpu(harden_branch_predictor_fn, cpu))
|
|
return;
|
|
|
|
switch (read_cpuid_part()) {
|
|
case ARM_CPU_PART_CORTEX_A8:
|
|
case ARM_CPU_PART_CORTEX_A9:
|
|
case ARM_CPU_PART_CORTEX_A12:
|
|
case ARM_CPU_PART_CORTEX_A17:
|
|
case ARM_CPU_PART_CORTEX_A73:
|
|
case ARM_CPU_PART_CORTEX_A75:
|
|
per_cpu(harden_branch_predictor_fn, cpu) =
|
|
harden_branch_predictor_bpiall;
|
|
spectre_v2_method = "BPIALL";
|
|
break;
|
|
|
|
case ARM_CPU_PART_CORTEX_A15:
|
|
case ARM_CPU_PART_BRAHMA_B15:
|
|
per_cpu(harden_branch_predictor_fn, cpu) =
|
|
harden_branch_predictor_iciallu;
|
|
spectre_v2_method = "ICIALLU";
|
|
break;
|
|
|
|
#ifdef CONFIG_ARM_PSCI
|
|
case ARM_CPU_PART_BRAHMA_B53:
|
|
/* Requires no workaround */
|
|
break;
|
|
default:
|
|
/* Other ARM CPUs require no workaround */
|
|
if (read_cpuid_implementor() == ARM_CPU_IMP_ARM)
|
|
break;
|
|
/* fallthrough */
|
|
/* Cortex A57/A72 require firmware workaround */
|
|
case ARM_CPU_PART_CORTEX_A57:
|
|
case ARM_CPU_PART_CORTEX_A72: {
|
|
struct arm_smccc_res res;
|
|
|
|
arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
|
|
ARM_SMCCC_ARCH_WORKAROUND_1, &res);
|
|
if ((int)res.a0 != 0)
|
|
return;
|
|
|
|
switch (arm_smccc_1_1_get_conduit()) {
|
|
case SMCCC_CONDUIT_HVC:
|
|
per_cpu(harden_branch_predictor_fn, cpu) =
|
|
call_hvc_arch_workaround_1;
|
|
cpu_do_switch_mm = cpu_v7_hvc_switch_mm;
|
|
spectre_v2_method = "hypervisor";
|
|
break;
|
|
|
|
case SMCCC_CONDUIT_SMC:
|
|
per_cpu(harden_branch_predictor_fn, cpu) =
|
|
call_smc_arch_workaround_1;
|
|
cpu_do_switch_mm = cpu_v7_smc_switch_mm;
|
|
spectre_v2_method = "firmware";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
if (spectre_v2_method)
|
|
pr_info("CPU%u: Spectre v2: using %s workaround\n",
|
|
smp_processor_id(), spectre_v2_method);
|
|
}
|
|
#else
|
|
static void cpu_v7_spectre_init(void)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
static __maybe_unused bool cpu_v7_check_auxcr_set(bool *warned,
|
|
u32 mask, const char *msg)
|
|
{
|
|
u32 aux_cr;
|
|
|
|
asm("mrc p15, 0, %0, c1, c0, 1" : "=r" (aux_cr));
|
|
|
|
if ((aux_cr & mask) != mask) {
|
|
if (!*warned)
|
|
pr_err("CPU%u: %s", smp_processor_id(), msg);
|
|
*warned = true;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static DEFINE_PER_CPU(bool, spectre_warned);
|
|
|
|
static bool check_spectre_auxcr(bool *warned, u32 bit)
|
|
{
|
|
return IS_ENABLED(CONFIG_HARDEN_BRANCH_PREDICTOR) &&
|
|
cpu_v7_check_auxcr_set(warned, bit,
|
|
"Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable\n");
|
|
}
|
|
|
|
void cpu_v7_ca8_ibe(void)
|
|
{
|
|
if (check_spectre_auxcr(this_cpu_ptr(&spectre_warned), BIT(6)))
|
|
cpu_v7_spectre_init();
|
|
}
|
|
|
|
void cpu_v7_ca15_ibe(void)
|
|
{
|
|
if (check_spectre_auxcr(this_cpu_ptr(&spectre_warned), BIT(0)))
|
|
cpu_v7_spectre_init();
|
|
}
|
|
|
|
void cpu_v7_bugs_init(void)
|
|
{
|
|
cpu_v7_spectre_init();
|
|
}
|