Received: by 10.192.165.156 with SMTP id m28csp62880imm; Tue, 10 Apr 2018 16:27:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ZeyyaEyuU1tv8Gzdzw7eij91S3HCJYwogDWlrVWsgmOOqJyp5ESPDPXbT9YCDPn3Lqaef X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr2512438plb.198.1523402836057; Tue, 10 Apr 2018 16:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402836; cv=none; d=google.com; s=arc-20160816; b=J+eFp0uDouOaGW/Dd3Jx8nyzQM1H1uCXdfu3wqPnq2uUE3Go0yCaBl0IP59oayczjX EBd4Ob2cd2lkAonBDU3kHNPIyWXAqUoU3UV5fzTKOEz5Ci7qOnBWjVqhVJAxxNqdqgVi eYcyfG9qczLjpBa+dKgA1JIgbpr7nL8cSKUh5aqUxd2DSB5IZK+lnk1CuPDRAyclefMU qYCwRPE3u3lbRZFL4aYQzW63AtVRLTgtGg06Nj3aXpdud85cZc0UIycounz6TXOEAaDF 7gnPR7wF9XGun98drc6Uj+dvZkWijmgD+7GGLhwtwYycVpmPS4333Dqh9pAyBcQRCjy5 dVtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0hBx04s4eaJRK/e9PiAsVdFcTxxmJD6IUwITVcTmZDw=; b=oay+qViaHVpljZv80C1iah2j0gjnpN2cwDP3DSWDdmGD47tfmWP8DGSnG3oLH2fpS9 2bgt5rV1434ANWaz6BYvbFyGPMtUAimfo5/V9I7DewOCWPWW2p3JXrJCIEMgqT7q2hp8 OR7yzu02X/hd5TQwRcgDc2Mx5WxkoPJtQUSZEhSmn9EK9P+AP9j6/VYLZW6jGktlqZ9I KpH5SpgBvKc639aRs+DzRmMiH2Gg/ed50EQRlK6+NTj4Os16wt13OWOHgFvd79RGNThx w8kALaFwnauDnXHkfOjW3IqpUN4f6TCRddCZ9QbXPd/dXPvtuzpfh4cvEyi/vnwsYEJN R06g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si2428873pgq.593.2018.04.10.16.26.39; Tue, 10 Apr 2018 16:27:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754675AbeDJWau (ORCPT + 99 others); Tue, 10 Apr 2018 18:30:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40126 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752775AbeDJWap (ORCPT ); Tue, 10 Apr 2018 18:30:45 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CC19BDE3; Tue, 10 Apr 2018 22:30:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashok Raj , Borislav Petkov , Andy Lutomirski , Arjan van de Ven , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.15 110/168] x86/CPU: Add a microcode loader callback Date: Wed, 11 Apr 2018 00:24:12 +0200 Message-Id: <20180410212804.937372528@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit 1008c52c09dcb23d93f8e0ea83a6246265d2cce0 upstream. Add a callback function which the microcode loader calls when microcode has been updated to a newer revision. Do the callback only when no error was encountered during loading. Tested-by: Ashok Raj Signed-off-by: Borislav Petkov Reviewed-by: Ashok Raj Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: Dave Hansen Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180216112640.11554-3-bp@alien8.de Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/processor.h | 1 + arch/x86/kernel/cpu/common.c | 10 ++++++++++ arch/x86/kernel/cpu/microcode/core.c | 8 ++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -969,4 +969,5 @@ bool xen_set_default_idle(void); void stop_this_cpu(void *dummy); void df_debug(struct pt_regs *regs, long error_code); +void microcode_check(void); #endif /* _ASM_X86_PROCESSOR_H */ --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1749,3 +1749,13 @@ static int __init init_cpu_syscore(void) return 0; } core_initcall(init_cpu_syscore); + +/* + * The microcode loader calls this upon late microcode load to recheck features, + * only when microcode has been updated. Caller holds microcode_mutex and CPU + * hotplug lock. + */ +void microcode_check(void) +{ + perf_check_microcode(); +} --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -509,6 +509,7 @@ static ssize_t reload_store(struct devic const char *buf, size_t size) { enum ucode_state tmp_ret = UCODE_OK; + bool do_callback = false; unsigned long val; ssize_t ret = 0; int cpu; @@ -531,10 +532,13 @@ static ssize_t reload_store(struct devic if (!ret) ret = -EINVAL; } + + if (tmp_ret == UCODE_UPDATED) + do_callback = true; } - if (!ret && tmp_ret == UCODE_UPDATED) - perf_check_microcode(); + if (!ret && do_callback) + microcode_check(); mutex_unlock(µcode_mutex); put_online_cpus();