Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753072AbeAJBVs (ORCPT + 1 other); Tue, 9 Jan 2018 20:21:48 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:53916 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbeAJBVq (ORCPT ); Tue, 9 Jan 2018 20:21:46 -0500 Message-Id: <20180110011350.501418723@linutronix.de> User-Agent: quilt/0.63-1 Date: Wed, 10 Jan 2018 02:06:53 +0100 From: Thomas Gleixner To: LKML Cc: Linus Torvalds , x86@kernel.org, Peter Zijlstra , Borislav Petkov , David Woodhouse , Tim Chen , Andrea Arcangeli , Andi Kleen , Greg KH , Dave Hansen , Andy Lutomirski , Arjan Van De Ven , Borislav Petkov Subject: [patch RFC 1/5] x86/CPU: Sync CPU feature flags late References: <20180110010652.404145126@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=x86-CPU--Sync_CPU_feature_flags_late.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Borislav Petkov This is for the case where we need to set feature flags late, like, for example, after late microcode patch has been loaded which has enabled new CPUID bits. This has no effect on alternatives patching. Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra --- arch/x86/kernel/cpu/common.c | 17 +++++++++++++++++ arch/x86/kernel/cpu/cpu.h | 3 +++ 2 files changed, 20 insertions(+) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -724,6 +724,23 @@ static void apply_forced_caps(struct cpu } } +/* + * This late synchronization of CPU caps has no effect on alternatives patching + * but updates the visible feature bits per CPU. + */ +void cpu_caps_sync_late(void) +{ + int cpu; + + lockdep_assert_cpus_held(); + + for_each_online_cpu(cpu) { + struct cpuinfo_x86 *c = &cpu_data(cpu); + + apply_forced_caps(c); + } +} + void get_cpu_cap(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -46,5 +46,8 @@ extern const struct cpu_dev *const __x86 *const __x86_cpu_dev_end[]; extern void get_cpu_cap(struct cpuinfo_x86 *c); + +extern void cpu_caps_sync_late(void); + extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c); #endif /* ARCH_X86_CPU_H */