From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from aserp2130.oracle.com ([141.146.126.79]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1f9Lln-0004AE-2b for speck@linutronix.de; Fri, 20 Apr 2018 04:27:27 +0200 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3K2QIxM034630 for ; Fri, 20 Apr 2018 02:27:20 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2hf7amr0e8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 20 Apr 2018 02:27:20 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3K2RJ0j009441 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 20 Apr 2018 02:27:19 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3K2RIEa019157 for ; Fri, 20 Apr 2018 02:27:18 GMT Message-Id: <20180420022613.270943302@localhost.localdomain> Date: Thu, 19 Apr 2018 22:25:47 -0400 From: konrad.wilk@oracle.com Subject: [MODERATED] [patch 07/11] [PATCH v2 07/10] Linux Patch #7 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: We do a lot of things in the check_bugs() - one of the first things we do is identify_boot_cpu() which calls identify_cpu() which calls this_cpu->init. Once identify_boot_cpu() is done _then_ it walks through the spectre_v2_select_mitigation() and alternative_assembler(). If there are some CPU fix ups _after_ spectre_v2 is done we can't activate those on the BSP as we have already called 'this_cpu->init'. Hence add a new function to fixup CPUs. Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/include/asm/processor.h | 1 + arch/x86/kernel/cpu/bugs.c | 1 + arch/x86/kernel/cpu/common.c | 8 ++++++++ arch/x86/kernel/cpu/cpu.h | 1 + 4 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index b0ccd4847a58..b22bc9be2385 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -195,6 +195,7 @@ extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); extern void detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); +extern void apply_cpu_fixes(void); #ifdef CONFIG_X86_32 extern int have_cpuid_p(void); diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index b8513a93f4b8..f02443b331f5 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -80,6 +80,7 @@ void __init check_bugs(void) if (!direct_gbpages) set_memory_4k((unsigned long)__va(0), 1); #endif + apply_cpu_fixes(); } /* The kernel command line selection */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index f7d80658cced..a59f7902a7fa 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -955,6 +955,12 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) setup_force_cpu_bug(X86_BUG_CPU_SSB); }; +void apply_cpu_fixes(void) +{ + if (this_cpu->c_bug_fix) + this_cpu->c_bug_fix(&boot_cpu_data); +} + /* * Do minimum CPU detection early. * Fields really needed: vendor, cpuid_level, family, model, mask, @@ -1311,6 +1317,8 @@ static void identify_cpu(struct cpuinfo_x86 *c) #ifdef CONFIG_NUMA numa_add_cpu(smp_processor_id()); #endif + if (this_cpu->c_bug_fix) + this_cpu->c_bug_fix(c); } /* diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h index e806b11a99af..7081634caac5 100644 --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -15,6 +15,7 @@ struct cpu_dev { void (*c_identify)(struct cpuinfo_x86 *); void (*c_detect_tlb)(struct cpuinfo_x86 *); void (*c_bsp_resume)(struct cpuinfo_x86 *); + void (*c_bug_fix)(struct cpuinfo_x86 *); int c_x86_vendor; #ifdef CONFIG_X86_32 /* Optional vendor specific routine to obtain the cache size. */ -- 2.14.3