From: Greg Kroah-Hartman Date: Fri, 30 Nov 2018 15:19:58 +0000 (+0100) Subject: drop arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch from 4.14 and 4.19 X-Git-Tag: v4.19.6~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac84aa395fd84b3d5e89c6a9a0e6244ae45b0341;p=thirdparty%2Fkernel%2Fstable-queue.git drop arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch from 4.14 and 4.19 --- diff --git a/queue-4.14/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch b/queue-4.14/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch deleted file mode 100644 index 31da9a4c489..00000000000 --- a/queue-4.14/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch +++ /dev/null @@ -1,210 +0,0 @@ -From f838ff9f7826b2e2228752fbb598cc29274c8d1c Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Thu, 19 Jul 2018 12:21:31 +0100 -Subject: ARM: spectre-v2: per-CPU vtables to work around big.Little systems - -[ Upstream commit 383fb3ee8024d596f488d2dbaf45e572897acbdb ] - -In big.Little systems, some CPUs require the Spectre workarounds in -paths such as the context switch, but other CPUs do not. In order -to handle these differences, we need per-CPU vtables. - -We are unable to use the kernel's per-CPU variables to support this -as per-CPU is not initialised at times when we need access to the -vtables, so we have to use an array indexed by logical CPU number. - -We use an array-of-pointers to avoid having function pointers in -the kernel's read/write .data section. - -Reviewed-by: Julien Thierry -Signed-off-by: Russell King -Signed-off-by: Sasha Levin ---- - arch/arm/include/asm/proc-fns.h | 23 +++++++++++++++++++++++ - arch/arm/kernel/setup.c | 5 +++++ - arch/arm/kernel/smp.c | 31 +++++++++++++++++++++++++++++++ - arch/arm/mm/proc-v7-bugs.c | 17 ++--------------- - 4 files changed, 61 insertions(+), 15 deletions(-) - -diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h -index c259cc49c641..e1b6f280ab08 100644 ---- a/arch/arm/include/asm/proc-fns.h -+++ b/arch/arm/include/asm/proc-fns.h -@@ -104,12 +104,35 @@ extern void cpu_do_resume(void *); - #else - - extern struct processor processor; -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+#include -+/* -+ * This can't be a per-cpu variable because we need to access it before -+ * per-cpu has been initialised. We have a couple of functions that are -+ * called in a pre-emptible context, and so can't use smp_processor_id() -+ * there, hence PROC_TABLE(). We insist in init_proc_vtable() that the -+ * function pointers for these are identical across all CPUs. -+ */ -+extern struct processor *cpu_vtable[]; -+#define PROC_VTABLE(f) cpu_vtable[smp_processor_id()]->f -+#define PROC_TABLE(f) cpu_vtable[0]->f -+static inline void init_proc_vtable(const struct processor *p) -+{ -+ unsigned int cpu = smp_processor_id(); -+ *cpu_vtable[cpu] = *p; -+ WARN_ON_ONCE(cpu_vtable[cpu]->dcache_clean_area != -+ cpu_vtable[0]->dcache_clean_area); -+ WARN_ON_ONCE(cpu_vtable[cpu]->set_pte_ext != -+ cpu_vtable[0]->set_pte_ext); -+} -+#else - #define PROC_VTABLE(f) processor.f - #define PROC_TABLE(f) processor.f - static inline void init_proc_vtable(const struct processor *p) - { - processor = *p; - } -+#endif - - #define cpu_proc_init PROC_VTABLE(_proc_init) - #define cpu_check_bugs PROC_VTABLE(check_bugs) -diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c -index 753e26960e6f..9f4c55b83b32 100644 ---- a/arch/arm/kernel/setup.c -+++ b/arch/arm/kernel/setup.c -@@ -115,6 +115,11 @@ EXPORT_SYMBOL(elf_hwcap2); - - #ifdef MULTI_CPU - struct processor processor __ro_after_init; -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+struct processor *cpu_vtable[NR_CPUS] = { -+ [0] = &processor, -+}; -+#endif - #endif - #ifdef MULTI_TLB - struct cpu_tlb_fns cpu_tlb __ro_after_init; -diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c -index e61af0600133..f6b1c9d2e178 100644 ---- a/arch/arm/kernel/smp.c -+++ b/arch/arm/kernel/smp.c -@@ -42,6 +42,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -102,6 +103,30 @@ static unsigned long get_arch_pgd(pgd_t *pgd) - #endif - } - -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+static int secondary_biglittle_prepare(unsigned int cpu) -+{ -+ if (!cpu_vtable[cpu]) -+ cpu_vtable[cpu] = kzalloc(sizeof(*cpu_vtable[cpu]), GFP_KERNEL); -+ -+ return cpu_vtable[cpu] ? 0 : -ENOMEM; -+} -+ -+static void secondary_biglittle_init(void) -+{ -+ init_proc_vtable(lookup_processor(read_cpuid_id())->proc); -+} -+#else -+static int secondary_biglittle_prepare(unsigned int cpu) -+{ -+ return 0; -+} -+ -+static void secondary_biglittle_init(void) -+{ -+} -+#endif -+ - int __cpu_up(unsigned int cpu, struct task_struct *idle) - { - int ret; -@@ -109,6 +134,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) - if (!smp_ops.smp_boot_secondary) - return -ENOSYS; - -+ ret = secondary_biglittle_prepare(cpu); -+ if (ret) -+ return ret; -+ - /* - * We need to tell the secondary core where to find - * its stack and the page tables. -@@ -360,6 +389,8 @@ asmlinkage void secondary_start_kernel(void) - struct mm_struct *mm = &init_mm; - unsigned int cpu; - -+ secondary_biglittle_init(); -+ - /* - * The identity mapping is uncached (strongly ordered), so - * switch away from it before attempting any exclusive accesses. -diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c -index 5544b82a2e7a..9a07916af8dd 100644 ---- a/arch/arm/mm/proc-v7-bugs.c -+++ b/arch/arm/mm/proc-v7-bugs.c -@@ -52,8 +52,6 @@ static void cpu_v7_spectre_init(void) - case ARM_CPU_PART_CORTEX_A17: - case ARM_CPU_PART_CORTEX_A73: - case ARM_CPU_PART_CORTEX_A75: -- if (processor.switch_mm != cpu_v7_bpiall_switch_mm) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - harden_branch_predictor_bpiall; - spectre_v2_method = "BPIALL"; -@@ -61,8 +59,6 @@ static void cpu_v7_spectre_init(void) - - case ARM_CPU_PART_CORTEX_A15: - case ARM_CPU_PART_BRAHMA_B15: -- if (processor.switch_mm != cpu_v7_iciallu_switch_mm) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - harden_branch_predictor_iciallu; - spectre_v2_method = "ICIALLU"; -@@ -88,11 +84,9 @@ static void cpu_v7_spectre_init(void) - ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 != 0) - break; -- if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - call_hvc_arch_workaround_1; -- processor.switch_mm = cpu_v7_hvc_switch_mm; -+ cpu_do_switch_mm = cpu_v7_hvc_switch_mm; - spectre_v2_method = "hypervisor"; - break; - -@@ -101,11 +95,9 @@ static void cpu_v7_spectre_init(void) - ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 != 0) - break; -- if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - call_smc_arch_workaround_1; -- processor.switch_mm = cpu_v7_smc_switch_mm; -+ cpu_do_switch_mm = cpu_v7_smc_switch_mm; - spectre_v2_method = "firmware"; - break; - -@@ -119,11 +111,6 @@ static void cpu_v7_spectre_init(void) - if (spectre_v2_method) - pr_info("CPU%u: Spectre v2: using %s workaround\n", - smp_processor_id(), spectre_v2_method); -- return; -- --bl_error: -- pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n", -- cpu); - } - #else - static void cpu_v7_spectre_init(void) --- -2.17.1 - diff --git a/queue-4.14/series b/queue-4.14/series index 9d0e06d12ea..363d2faa545 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -53,7 +53,6 @@ perf-x86-intel-uncore-add-more-imc-pci-ids-for-kabyl.patch arm-make-lookup_processor_type-non-__init.patch arm-clean-up-per-processor-check_bugs-method-call.patch arm-add-proc_vtable-and-proc_table-macros.patch -arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch sunrpc-fix-a-bogus-get-put-in-generic_key_to_expire.patch kdb-use-strscpy-with-destination-buffer-size.patch powerpc-numa-suppress-vphn-is-not-supported-messages.patch diff --git a/queue-4.19/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch b/queue-4.19/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch deleted file mode 100644 index 29d3d683372..00000000000 --- a/queue-4.19/arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch +++ /dev/null @@ -1,210 +0,0 @@ -From bf59fa8ce6a739b0d5c6e75bd7925785de232a9f Mon Sep 17 00:00:00 2001 -From: Russell King -Date: Thu, 19 Jul 2018 12:21:31 +0100 -Subject: ARM: spectre-v2: per-CPU vtables to work around big.Little systems - -[ Upstream commit 383fb3ee8024d596f488d2dbaf45e572897acbdb ] - -In big.Little systems, some CPUs require the Spectre workarounds in -paths such as the context switch, but other CPUs do not. In order -to handle these differences, we need per-CPU vtables. - -We are unable to use the kernel's per-CPU variables to support this -as per-CPU is not initialised at times when we need access to the -vtables, so we have to use an array indexed by logical CPU number. - -We use an array-of-pointers to avoid having function pointers in -the kernel's read/write .data section. - -Reviewed-by: Julien Thierry -Signed-off-by: Russell King -Signed-off-by: Sasha Levin ---- - arch/arm/include/asm/proc-fns.h | 23 +++++++++++++++++++++++ - arch/arm/kernel/setup.c | 5 +++++ - arch/arm/kernel/smp.c | 31 +++++++++++++++++++++++++++++++ - arch/arm/mm/proc-v7-bugs.c | 17 ++--------------- - 4 files changed, 61 insertions(+), 15 deletions(-) - -diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h -index c259cc49c641..e1b6f280ab08 100644 ---- a/arch/arm/include/asm/proc-fns.h -+++ b/arch/arm/include/asm/proc-fns.h -@@ -104,12 +104,35 @@ extern void cpu_do_resume(void *); - #else - - extern struct processor processor; -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+#include -+/* -+ * This can't be a per-cpu variable because we need to access it before -+ * per-cpu has been initialised. We have a couple of functions that are -+ * called in a pre-emptible context, and so can't use smp_processor_id() -+ * there, hence PROC_TABLE(). We insist in init_proc_vtable() that the -+ * function pointers for these are identical across all CPUs. -+ */ -+extern struct processor *cpu_vtable[]; -+#define PROC_VTABLE(f) cpu_vtable[smp_processor_id()]->f -+#define PROC_TABLE(f) cpu_vtable[0]->f -+static inline void init_proc_vtable(const struct processor *p) -+{ -+ unsigned int cpu = smp_processor_id(); -+ *cpu_vtable[cpu] = *p; -+ WARN_ON_ONCE(cpu_vtable[cpu]->dcache_clean_area != -+ cpu_vtable[0]->dcache_clean_area); -+ WARN_ON_ONCE(cpu_vtable[cpu]->set_pte_ext != -+ cpu_vtable[0]->set_pte_ext); -+} -+#else - #define PROC_VTABLE(f) processor.f - #define PROC_TABLE(f) processor.f - static inline void init_proc_vtable(const struct processor *p) - { - processor = *p; - } -+#endif - - #define cpu_proc_init PROC_VTABLE(_proc_init) - #define cpu_check_bugs PROC_VTABLE(check_bugs) -diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c -index 6b9d191da868..830d7b4ecb84 100644 ---- a/arch/arm/kernel/setup.c -+++ b/arch/arm/kernel/setup.c -@@ -115,6 +115,11 @@ EXPORT_SYMBOL(elf_hwcap2); - - #ifdef MULTI_CPU - struct processor processor __ro_after_init; -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+struct processor *cpu_vtable[NR_CPUS] = { -+ [0] = &processor, -+}; -+#endif - #endif - #ifdef MULTI_TLB - struct cpu_tlb_fns cpu_tlb __ro_after_init; -diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c -index 0978282d5fc2..12a6172263c0 100644 ---- a/arch/arm/kernel/smp.c -+++ b/arch/arm/kernel/smp.c -@@ -42,6 +42,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -102,6 +103,30 @@ static unsigned long get_arch_pgd(pgd_t *pgd) - #endif - } - -+#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR) -+static int secondary_biglittle_prepare(unsigned int cpu) -+{ -+ if (!cpu_vtable[cpu]) -+ cpu_vtable[cpu] = kzalloc(sizeof(*cpu_vtable[cpu]), GFP_KERNEL); -+ -+ return cpu_vtable[cpu] ? 0 : -ENOMEM; -+} -+ -+static void secondary_biglittle_init(void) -+{ -+ init_proc_vtable(lookup_processor(read_cpuid_id())->proc); -+} -+#else -+static int secondary_biglittle_prepare(unsigned int cpu) -+{ -+ return 0; -+} -+ -+static void secondary_biglittle_init(void) -+{ -+} -+#endif -+ - int __cpu_up(unsigned int cpu, struct task_struct *idle) - { - int ret; -@@ -109,6 +134,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) - if (!smp_ops.smp_boot_secondary) - return -ENOSYS; - -+ ret = secondary_biglittle_prepare(cpu); -+ if (ret) -+ return ret; -+ - /* - * We need to tell the secondary core where to find - * its stack and the page tables. -@@ -359,6 +388,8 @@ asmlinkage void secondary_start_kernel(void) - struct mm_struct *mm = &init_mm; - unsigned int cpu; - -+ secondary_biglittle_init(); -+ - /* - * The identity mapping is uncached (strongly ordered), so - * switch away from it before attempting any exclusive accesses. -diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c -index 5544b82a2e7a..9a07916af8dd 100644 ---- a/arch/arm/mm/proc-v7-bugs.c -+++ b/arch/arm/mm/proc-v7-bugs.c -@@ -52,8 +52,6 @@ static void cpu_v7_spectre_init(void) - case ARM_CPU_PART_CORTEX_A17: - case ARM_CPU_PART_CORTEX_A73: - case ARM_CPU_PART_CORTEX_A75: -- if (processor.switch_mm != cpu_v7_bpiall_switch_mm) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - harden_branch_predictor_bpiall; - spectre_v2_method = "BPIALL"; -@@ -61,8 +59,6 @@ static void cpu_v7_spectre_init(void) - - case ARM_CPU_PART_CORTEX_A15: - case ARM_CPU_PART_BRAHMA_B15: -- if (processor.switch_mm != cpu_v7_iciallu_switch_mm) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - harden_branch_predictor_iciallu; - spectre_v2_method = "ICIALLU"; -@@ -88,11 +84,9 @@ static void cpu_v7_spectre_init(void) - ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 != 0) - break; -- if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - call_hvc_arch_workaround_1; -- processor.switch_mm = cpu_v7_hvc_switch_mm; -+ cpu_do_switch_mm = cpu_v7_hvc_switch_mm; - spectre_v2_method = "hypervisor"; - break; - -@@ -101,11 +95,9 @@ static void cpu_v7_spectre_init(void) - ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 != 0) - break; -- if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu) -- goto bl_error; - per_cpu(harden_branch_predictor_fn, cpu) = - call_smc_arch_workaround_1; -- processor.switch_mm = cpu_v7_smc_switch_mm; -+ cpu_do_switch_mm = cpu_v7_smc_switch_mm; - spectre_v2_method = "firmware"; - break; - -@@ -119,11 +111,6 @@ static void cpu_v7_spectre_init(void) - if (spectre_v2_method) - pr_info("CPU%u: Spectre v2: using %s workaround\n", - smp_processor_id(), spectre_v2_method); -- return; -- --bl_error: -- pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n", -- cpu); - } - #else - static void cpu_v7_spectre_init(void) --- -2.17.1 - diff --git a/queue-4.19/series b/queue-4.19/series index 389291ddbd2..120d685b0b7 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -82,7 +82,6 @@ perf-x86-intel-uncore-add-more-imc-pci-ids-for-kabyl.patch arm-make-lookup_processor_type-non-__init.patch arm-clean-up-per-processor-check_bugs-method-call.patch arm-add-proc_vtable-and-proc_table-macros.patch -arm-spectre-v2-per-cpu-vtables-to-work-around-big.li.patch block-copy-ioprio-in-__bio_clone_fast-and-bounce.patch sunrpc-fix-a-bogus-get-put-in-generic_key_to_expire.patch riscv-add-missing-vdso_install-target.patch