Received: by 10.192.165.156 with SMTP id m28csp35770imm; Tue, 10 Apr 2018 15:52:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx48a2v34Fyf0ZXLG9go+5hmFQC71S2ejGZCw8Ai9muiz1uBWWEmjIBFtJOwpYK7el/C8s9nm X-Received: by 10.98.32.87 with SMTP id g84mr1893438pfg.28.1523400740355; Tue, 10 Apr 2018 15:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400740; cv=none; d=google.com; s=arc-20160816; b=DjMcblSxllbw5vDQ49KfQbTzdgUEpF/U7S6YJuxQA7z/xEe0wOSrQnGZZdEPjjo8Nh NCT5Hqk4H5STKNVGKQzYxb/89jxTpyQ3AHMedtDDfL3h/es9huySnv0aiVIvmlNj5IXm mV9V2YkZ8/9H5G4mg6g09RXBZcCCbl6Sgismm9ZLOS59nektqRwUiYiTszqe0CNJCZva kRHSD5B77un/ej6gRWFBr2Nh/z8xAmXjfMZIFjPW3K+du+hOMwXeUyq2Lbw4z0ih6bdz C/dAKnKt+kc7c4I83dR8BE42oJKbuzNnbxn1NpNl5s67vM3H2WP4jC98Yi4nlbfNg8qy h0Hw== 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=hHgNLKhOuZoD/bJUJAYmR2UJSTiq+ezT64iborSgtbY=; b=QS10IUHFkDaoxM9tTYEUf5EFsl46VJYcFTCRdisEa19POa5WUljDUxi2ziobucAUp9 bvhLa0JHXvo8tGyakBCNHGbD2wd1CC+6tixkrF8arppx8Km2O+ndu8EykPCoLo+3CnhW lbwKFfN640ID3KcbwPcalp6XxBQNwLwARwQgrbcrRnW9FmN6Lec43uajJP3gru0k8PdH t6pzc2CzeYUABLLjoJeg59qDu/mfoB4q43DBV8m2i7c3h0KO411kW0g8rfADZVdY15Po ffRmx7VGyq9cTbsnTsm0nhDepCpbxKvDG1Us5RTJt8Vai/urIyB85ZCVOzJes7C+LdU4 hdSw== 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 d6si2834111pfc.230.2018.04.10.15.51.39; Tue, 10 Apr 2018 15:52:20 -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 S1756181AbeDJWqv (ORCPT + 99 others); Tue, 10 Apr 2018 18:46:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44970 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755353AbeDJWit (ORCPT ); Tue, 10 Apr 2018 18:38:49 -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 052D6D0A; Tue, 10 Apr 2018 22:38:48 +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.14 086/138] x86/CPU: Add a microcode loader callback Date: Wed, 11 Apr 2018 00:24:36 +0200 Message-Id: <20180410212912.160225124@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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 @@ -968,4 +968,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 @@ -1724,3 +1724,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();