From patchwork Tue Nov 29 21:08:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp568996wrr; Tue, 29 Nov 2022 13:09:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5yv1IVArdtMpFLE7FzrTf60DpjA9KP8PeJnIryRvWMBHBoodYlN8VzyVUAOt7ygbKtGtdU X-Received: by 2002:a17:902:f707:b0:186:4f38:dd3f with SMTP id h7-20020a170902f70700b001864f38dd3fmr39895184plo.172.1669756197123; Tue, 29 Nov 2022 13:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756197; cv=none; d=google.com; s=arc-20160816; b=DmPncqrJbD6CZSUCsh2AZzMl2GBn5d4kzzQdGeaFERdZuQBp1y37tjkeoZt98M4Qu+ Gdyhnd6uNlY5e8TnQHRrI4utXeAGFzv+sJda+xHjHm/y36xUXy4xXNTLShmh2wML8FFd tSbO55CkWfxQomcY74gva9wQF5Y8bP1wvmGQjZUNO4dVIm9NjTWDijiy/z6aPBdBZfMq t1Y5TGU8h+OTfeZej3AqysICpmYCJtS1TW4BT++kvGucDGCgAsrpLUec6UFa7IiEdEPZ 1BR/i4Im1fBTcWExM/bKNp6hPLiz0yWImQEXMpxsSvbKAmMz896dONM9UFFZnW0AcLXg VrVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8njh6seRpxqxWctRPQ0//zdAf02osGgMvwEwaJ0G3ks=; b=d11QQJLcOgkO1PlLxBgj6n4D6VXPQsI23LjAUiiSDhrvv1la5FDKfyI5cCXBJlvWhY zRlCHC1U6kYmFuDFlp20sCTwdPnc2/EUhQk5Bb5V/mtZW+tgw3E4VIdYEkqpHbCpjXS+ KQVcFvUBZVNLVnKNnvNUCPxCXZvRJ0848uK+x0IKw8Y1w+bdRKu9ui+kxzXOcNTLxB97 AWSKI1t3wWML6+gaDinpa6YkI6cSOcSfGHbXpX/GmlUQY4bo8cDave6bN5DhrWVX5UIe qsKboLGjn4McGUo26Qpa5Mklj8pmpQ4ChNxKmY68YsToPET64ONifFHaGdaWa/zijsJy FCYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FNGLCYj4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om3-20020a17090b3a8300b001f31da6b2d2si2641136pjb.154.2022.11.29.13.09.43; Tue, 29 Nov 2022 13:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FNGLCYj4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236819AbiK2VJQ (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236761AbiK2VJF (ORCPT ); Tue, 29 Nov 2022 16:09:05 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04B8116E for ; Tue, 29 Nov 2022 13:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756143; x=1701292143; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=niny0WNbiHjtWmixHGOged4GvvPKSLIrCEDitMSqwFg=; b=FNGLCYj4i35hwjjS1y6iTxBpIlA1agriDPHy8G085RPdNfJAa+sjV3gJ P3r+dyqGc/ted7IUccgk4LpdFB9kFI8YvC0YtVuaR4L4elTVFBqZ8duLw g/49BmxDFks4QNYHKpwsuMHIGeu8ehaCTTLrFeV5Lo98qhM4d3SRWw4AX Xf9Yb/csGF50Xn0s+663RGV0dF6rQgg4+GTmji2RlpOwjJ3QdGcs7hQHs 0KxE55Inkp8NDjDaiyDQUIJTluZ6xqeXxly7GEoPeRVcwzmnV+om+eYPG t4VHr/JKKhH91EVI4CV9cHY7W+9Ftc3izQko18oNq+eJNLo3S6MqKfCi9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083127" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083127" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:03 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066201" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066201" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:03 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 1/7] x86/microcode/intel: Remove redundant microcode rev pr_info()s Date: Tue, 29 Nov 2022 13:08:26 -0800 Message-Id: <20221129210832.107850-2-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866274369331274?= X-GMAIL-MSGID: =?utf-8?q?1750866274369331274?= There is a pr_info() to dump information about newly loaded microcode. The code intends this pr_info() to be just once, but the check to ensure is racy. Unfortunately this happens quite often in with this new change resulting in multiple redundant prints on the console. microcode_init()->schedule_on_each_cpu(setup_online_cpu)->collect_cpu_info [ 33.688639] microcode: sig=0x50654, pf=0x80, revision=0x2006e05 [ 33.688659] microcode: sig=0x50654, pf=0x80, revision=0x2006e05 [ 33.688660] microcode: sig=0x50654, pf=0x80, revision=0x2006e05 There is already a pr_info() in microcode/core.c as shown below: microcode: Reload completed, microcode revision: 0x2b000041 -> 0x2b000070 The sig and pf aren't that useful to end user, they are available via /proc/cpuinfo and this never changes between microcode loads. Remove the redundant pr_info() and the racy single print checks. This removes the race entirely, zap the duplicated pr_info() spam and simplify the code. Fixes: b6f86689d5b7 ("x86/microcode: Rip out the subsys interface gunk") Reported-by: Tony Luck Signed-off-by: Ashok Raj --- arch/x86/kernel/cpu/microcode/intel.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index c4a00fb97f61..4f93875f57b4 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -554,7 +554,6 @@ void reload_ucode_intel(void) static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) { - static struct cpu_signature prev; struct cpuinfo_x86 *c = &cpu_data(cpu_num); unsigned int val[2]; @@ -570,13 +569,6 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) csig->rev = c->microcode; - /* No extra locking on prev, races are harmless. */ - if (csig->sig != prev.sig || csig->pf != prev.pf || csig->rev != prev.rev) { - pr_info("sig=0x%x, pf=0x%x, revision=0x%x\n", - csig->sig, csig->pf, csig->rev); - prev = *csig; - } - return 0; } From patchwork Tue Nov 29 21:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp569006wrr; Tue, 29 Nov 2022 13:09:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lzQFLmyQqiFpHoX2sn4M5bmaOxXjWPdPe7ceU8otqYcdq3ldbu3etBABlBxP12W/l1AaZ X-Received: by 2002:a17:902:a618:b0:189:72c2:67fe with SMTP id u24-20020a170902a61800b0018972c267femr19474499plq.135.1669756199257; Tue, 29 Nov 2022 13:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756199; cv=none; d=google.com; s=arc-20160816; b=ucXIMBGYIqOO33f0rVopbT36/sxzZWox7u/VB1MUY0IqLJ8Kodzas/9JuHsmqk61B0 dA/0Nm+yE+DsHvwsUq2hlFR33twV+Xl/2s/b0gjI95H1FsZpxSBBmLc8WSmh/oBl3TuG Ijyklls4nK5hj3cfZ6cwaQw+xFZC93wrdw0/np34kTPmCGbN11NJskqLx2XdOGtChNbt vufJMknls2BxLzdoOxw/rqWvI5UJaC5C1wINwRtfzw2mClItOvgIPJKteZ3TyVSUeOXv j3AdQ6W+CQzIUk+6DMWhD3FWACBqtv/f62dIibqpB++Cza0FQrKrvEdrSKTsYbYwJDkI QvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=voBW/s8OoYt5E6o5tabDbOkYItpw5zwBtuN4AXb7uUk=; b=0pYRdu2Ix6wfKasQxhpunyt+57uhg0W4z2Ptmhbq0IIWbCpLchsEsGmgRg4vsvN0j4 bo2x1/mvoYXXCi5wB7OYvtOVcMh6hggqHzrNzsm+kvQPZInnw7SsmsLXKgrmCs1Ldlxm vLivnIBf9hn3KHTLUbOhu+WzMBbpbptbnPTV9h9FL0gUO8+NSOSTzOcFAGhSnZ6sxcmj UaoVRG+sG9qluAyozS7M/p6t5hh2oRhfUNi9KjR+qLld7U1/jXKErRTEhY/QY7bm5Ths DVUzBtrCfyS0oLKIs6HndvUoVN1P7GxM6DOd/c5enD8EXLeB8szwLYJylWuszSsijNL8 s/GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TY4QdO1T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i63-20020a628742000000b0056ca60d51d6si14351628pfe.365.2022.11.29.13.09.46; Tue, 29 Nov 2022 13:09:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TY4QdO1T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235796AbiK2VJW (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236084AbiK2VJG (ORCPT ); Tue, 29 Nov 2022 16:09:06 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7919F55A0 for ; Tue, 29 Nov 2022 13:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756144; x=1701292144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CQp4qbII0DlxhRkqqCYEfCUWHdc6N9otPMAR1s7O/AM=; b=TY4QdO1TM6rxlpJvouVXEdRgnA/UyPI1zFZCbd17oChagrx9LnKEI4+E lJIvy7TrR0GpwxiMolddOJnTQ+Dhd/haAHRvG0jpqldFvtkLXZDSvSy4H LsrHNPpaRAFVN1Tn2Gud0+N+VGI9zxxLUVNrfuT1mwhSbIqFWb5/QwZe5 BKD2OmNKM7IoTVcu4fH+k2+rUb6NknL0tPZkpnfRb7wRABSnZ/aLVM/oj Y2SH1cmJBGNIa8HqwzTXDEjUt99mT6shePwY+4IeX9hDAOcOWD3tVG7DJ SMX9T3Ri7/XUfo+wUquFOL/40HjsFNsQjLPonNbfF/KbT3+YD/LF4MMfo w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083131" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083131" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066205" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066205" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:03 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 2/7] x86/microcode/intel: Remove retries on early microcode load Date: Tue, 29 Nov 2022 13:08:27 -0800 Message-Id: <20221129210832.107850-3-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866276436449397?= X-GMAIL-MSGID: =?utf-8?q?1750866276436449397?= Microcode loading can fail. This happens today when handling mixed steppings. But it can also happen for other reasons such as corrupted image, Security Version Number (SVN) preventing anti-rollback, dependencies on BIOS loaded microcode image for some capabilities. When the microcode loading fails, the kernel will quietly hang at boot. This has been observed by end users (Links below) who had to revert their microcode packages in order to boot again. The hang is due to an infinite retry loop. The retries were in place to support systems with mixed steppings. Now that mixed steppings are no longer supported, there is only one microcode image at a time. Any retries will simply reattempt to apply the same image over and over without making progress. Some possible past bugs that could be due to this bug are below. There is no direct evidence that these end user issues were caused by this retry loop. However, the early boot hangs along with reverting the microcode update workaround provide strong circumstantial evidence to support the theory that they are linked. Remove the retry loop and only attempt to apply microcode once. Link: https://bugs.launchpad.net/ubuntu/+source/intel-microcode/+bug/1911959 Link: https://forums.linuxmint.com/viewtopic.php?p=1827032#1827032 Link: https://askubuntu.com/questions/1291486/boot-crash-after-latest-update-of-intel-microcode-nov-11-2020 Fixes: 06b8534cb728 ("x86/microcode: Rework microcode loading") Cc: stable@vger.kernel.org Signed-off-by: Ashok Raj Reviewed-by: Thomas Gleixner Signed-off-by: Ashok Raj Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/intel.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 4f93875f57b4..d68b084a17e7 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -495,7 +495,6 @@ void load_ucode_intel_ap(void) else iup = &intel_ucode_patch; -reget: if (!*iup) { patch = __load_ucode_intel(&uci); if (!patch) @@ -505,13 +504,7 @@ void load_ucode_intel_ap(void) } uci.mc = *iup; - - if (apply_microcode_early(&uci, true)) { - /* Mixed-silicon system? Try to refetch the proper patch: */ - *iup = NULL; - - goto reget; - } + apply_microcode_early(&uci, true); } static struct microcode_intel *find_patch(struct ucode_cpu_info *uci) From patchwork Tue Nov 29 21:08:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp570145wrr; Tue, 29 Nov 2022 13:12:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6WXOMOciELOuGLto74l1HaytwBjrZnknYaHqvFc18Bv6IOmjsg7/KFGKNeZu+7fTN41N7m X-Received: by 2002:a17:902:a589:b0:189:7a0f:703b with SMTP id az9-20020a170902a58900b001897a0f703bmr17476019plb.103.1669756349919; Tue, 29 Nov 2022 13:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756349; cv=none; d=google.com; s=arc-20160816; b=j0o/ve/9CM9vVv8KQRLLbqYNK5nixLRjNEajpOsl8KwVO+r23Js95lJW4UWSuAoF6c pFJsoRfAjGc6AojUocLkvK0Vfg1m9ORlo0CD4kdO1i1qw7pvBdVz1/Wy2FL96SX1jteD L8qrSS6XAxHBA2Io0zNGnK/7oH4w/hdfbypvgKiUmGJVcsPlmVGhfQsaIR73547zdKSv WrD9H06T3WDKcxS2Vho/RG8VPUCVIL923F8nByZqatyXFzwPUFkgR7SpQIQ1LszJwBXc zzVknq6q7sfdmWi4jVZmCKv5y7w/z6G87zTB8xZdLFsYXTVy/lqf4bGNPUy8NAMVUHec 5G+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZOnOJ30AIqTMkc+smenuZpRSQaA9yxOwkimbP4jCbYo=; b=mgeaaCWvdivMsQfiaAuDRAXUqDrfbByFhKC6A971a2N4O58qEzwIU0OiaxOhMrmY1M bGc5juxLRBvj9PmpTRBRwWx1c0JKlkDXX9zsyxNVP/qtK3tBJvK/d9oY7pQ8scYzO5kS ix3izSUVBJcp5CwrOEGtAr5tWy6ltXUhkxaLcq7o/JnFB8tLnoL40hzB8I3T7fwll34R CCZY450UDsTAEORjXdlD9y4tEeieQUvxYWsZZtUTvM27OmzcldTc6rQVHrq0aNmYbia0 xsT4Bslp8OCEQiP0se3lKkI3THKhhykU7rdpY4BewE5TsFcZfkTjmfPuPfmdO8wPD/G6 0+sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cTLMGliB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g186-20020a636bc3000000b0047840ab4dc7si2498202pgc.250.2022.11.29.13.12.17; Tue, 29 Nov 2022 13:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cTLMGliB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236841AbiK2VJc (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236741AbiK2VJG (ORCPT ); Tue, 29 Nov 2022 16:09:06 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4233E63CE for ; Tue, 29 Nov 2022 13:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756145; x=1701292145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=70gwJLJLXs2AZIFAvJaft9GRLf9mjU7YlemJkv6J9xI=; b=cTLMGliBoVKRr8h8wPJMK6afJnp3psQ5cnPAQPqMHQmBEaxBBC0WVPQv +pf0UOsjJ4ARnfVsRstQDNwrszRIIGypF+5BrgTBdvvFZmcCf/yOkR8fv 0y23bo9a/j9pIcgjBRXLtI9NPM24QYhZd9srk+yUaiSld8b7tgISXR0z6 yH0nCBLebd6VzNA2dLR+uEZsaDHnDRNDa7d/dBfAzlTYaazpgHlxAmpqf YzZQ8gWiGQc7CignNfCrr8xGHKI5H4Qhwf0da39CU6ubUbjVOUFPLWg2E X3zmp/MirquVkEWg2cCj0l011bR2+8WKwd3NC58zgYDn9HyqDK4SzEJpr w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083136" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083136" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066208" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066208" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 3/7] x86/microcode/core: Move microcode_check() to cpu/microcode/core.c Date: Tue, 29 Nov 2022 13:08:28 -0800 Message-Id: <20221129210832.107850-4-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866434186856754?= X-GMAIL-MSGID: =?utf-8?q?1750866434186856754?= microcode_check() is only called from microcode/core.c. Move it and make it static to prepare for upcoming fix of false negative when checking CPU features after a microcode update. Also move get_cpu_cap() to processor.h for general use outside of kernel/cpu.h No functional change. Suggested-by: Alison Schofield Signed-off-by: Ashok Raj Reviewed-by: Thomas Gleixner --- Tony Add movement of get_cpu_cap() to commit log Reinette Avoid including ../cpu.h and move to more general header. Alison Split patch to just move the function before use inside microcode files. --- arch/x86/include/asm/processor.h | 3 +-- arch/x86/kernel/cpu/cpu.h | 1 - arch/x86/kernel/cpu/common.c | 32 ---------------------------- arch/x86/kernel/cpu/microcode/core.c | 31 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 67c9d73b31fa..f5380806f3fa 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -192,8 +192,8 @@ extern const struct seq_operations cpuinfo_op; #define cache_line_size() (boot_cpu_data.x86_cache_alignment) +extern void get_cpu_cap(struct cpuinfo_x86 *c); extern void cpu_detect(struct cpuinfo_x86 *c); - static inline unsigned long long l1tf_pfn_limit(void) { return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT); @@ -835,7 +835,6 @@ bool xen_set_default_idle(void); #endif void __noreturn stop_this_cpu(void *dummy); -void microcode_check(void); enum l1tf_mitigations { L1TF_MITIGATION_OFF, diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h index 7c9b5893c30a..a142b8d543a3 100644 --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -63,7 +63,6 @@ static inline void tsx_ap_init(void) { } extern void init_spectral_chicken(struct cpuinfo_x86 *c); -extern void get_cpu_cap(struct cpuinfo_x86 *c); extern void get_cpu_address_sizes(struct cpuinfo_x86 *c); extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c); extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 3e508f239098..bbd362ead043 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2305,38 +2305,6 @@ void cpu_init_secondary(void) } #endif -#ifdef CONFIG_MICROCODE_LATE_LOADING -/* - * 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) -{ - struct cpuinfo_x86 info; - - perf_check_microcode(); - - /* Reload CPUID max function as it might've changed. */ - info.cpuid_level = cpuid_eax(0); - - /* - * Copy all capability leafs to pick up the synthetic ones so that - * memcmp() below doesn't fail on that. The ones coming from CPUID will - * get overwritten in get_cpu_cap(). - */ - memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)); - - get_cpu_cap(&info); - - if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability))) - return; - - pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n"); - pr_warn("x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.\n"); -} -#endif - /* * Invoked from core CPU hotplug code after hotplug operations */ diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 712aafff96e0..ef24e1d228d0 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -431,6 +431,37 @@ static int __reload_late(void *info) return ret; } +/* + * 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. + */ +static void microcode_check(void) +{ + struct cpuinfo_x86 info; + + perf_check_microcode(); + + /* Reload CPUID max function as it might've changed. */ + info.cpuid_level = cpuid_eax(0); + + /* + * Copy all capability leafs to pick up the synthetic ones so that + * memcmp() below doesn't fail on that. The ones coming from CPUID will + * get overwritten in get_cpu_cap(). + */ + memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)); + + get_cpu_cap(&info); + + if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, + sizeof(info.x86_capability))) + return; + + pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n"); + pr_warn("x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.\n"); +} + /* * Reload microcode late on all CPUs. Wait for a sec until they * all gather together. From patchwork Tue Nov 29 21:08:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp569790wrr; Tue, 29 Nov 2022 13:11:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KF6L3IEKcN8gP/qDTRKH/LsLtMWbFocxZDsjA793zIg/3ujMXZTbGNFtP/GzoLGf/V0/i X-Received: by 2002:a17:902:f788:b0:189:5ff6:903c with SMTP id q8-20020a170902f78800b001895ff6903cmr25634491pln.147.1669756302441; Tue, 29 Nov 2022 13:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756302; cv=none; d=google.com; s=arc-20160816; b=CidmB9DIduQJDtSoGDU8xiegmWj3Le0XqKWgH0u10ut43Xj71Hg6jD1cB+yRd094NY BYiCvVqiNAZmk9WWH5DkF/VAc5CBQiESxcKihDI0GbPSqI+fcVGHIyZ5tWGIkmbH9+5F saRIt4oQBun8HATg/LrvADRPTJlVDmozEgdK6bktU1oDBnWOzuUit1iePN9Pq4kGjYAP 15fbHnqGrc1tLh8yC7crLkvl5ZnvwzJKbioVW+vI2MKL+m78RJIYRfxhSZdi86tsIGgf ys8caHNU+03cgdp3yBgS4cTihHJLCeORHLLMxClEY6oCHoMHInNVlD4AjslSr975fp+K OzlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZSfyXyzZyHfmPs2n6E76fH4nHw4UNxnmGeynljLHUCw=; b=ZTjJ3ZyNyptGMCy0e+MaFuJ3DPZJ4YtDJiN+R67qOYoP7ea7m1adlNptwvutgO+vpZ nn0LvVQ6SFdVnDaE2W+163i6c9gBhskERgNORLISopZWmqO8AsZFR91uF/5t5fS/FRFQ E1vprQgk1qCOHd/ceztxU4y6RswF5pJDudf/iB/d6R3z0593NN6IiK0alMh600myA/6W OkpxD0GCB9WdOISSd4O1756d+gLWpUXbosbYI9/XjGWkr3KEh32G0PWHntBHOhdC+9O0 G5ye+aCq9UvIu/lBuEKDF3SsqQ1cvF5FGixDilvTkLnboFmd4LvGzMV2NF20Rr5+Xtgn 7tGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iMSjoF5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l36-20020a635724000000b004779fb6a525si15210275pgb.559.2022.11.29.13.11.29; Tue, 29 Nov 2022 13:11:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iMSjoF5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236904AbiK2VJj (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233743AbiK2VJH (ORCPT ); Tue, 29 Nov 2022 16:09:07 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A631EE32 for ; Tue, 29 Nov 2022 13:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756145; x=1701292145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+c+idxLi34QmYjm2JNwF3yjYRC3bi0/GYB7hm+1xYXc=; b=iMSjoF5xPeqZPvkk5bmJPC5ioZnaWGMJrbWs0aE7KSglJw2rXcjz7VWA sFmUlpEvTYDEzYzpEByAftwRjKxEjIwjRVWwF1zrXDHKrEvoDhLvQng5y KwiTAt7JxI19NQpRqhefjZN0j1VJym7xSRDwjQ0GD94Fd45TuwuKIlzng svXp6theL+SkbbBH13Cnf7afNdtzuMwNcnUe2ttvuAzvbT8F+i0Yf15sA nmSashcbh+93ZOq1rICl+VtDh35lF9yU5UcyIH7DjbrcCtO/kmBjrsK+t RUfIRY4AphpGlWT9/GEboYVT+Pd2+ErxPHeMZrjPnQa6bXuMhgEmWua5/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083139" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083139" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066211" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066211" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 4/7] x86/microcode/core: Take a snapshot before and after applying microcode Date: Tue, 29 Nov 2022 13:08:29 -0800 Message-Id: <20221129210832.107850-5-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866384898227799?= X-GMAIL-MSGID: =?utf-8?q?1750866384898227799?= The kernel caches features about each CPU's features at boot in an x86_capability[] structure. The microcode update takes one snapshot and compares it with the saved copy at boot. However, the capabilities in the boot copy can be turned off as a result of certain command line parameters or configuration restrictions. This can cause a mismatch when comparing the values before and after the microcode update. microcode_check() is called after an update to report any previously cached CPUID bits might have changed due to the update. Ignore the capabilities recorded at boot. Take a new snapshot before the update and compare with a snapshot after the update to eliminate the false warning. Fixes: 1008c52c09dc ("x86/CPU: Add a microcode loader callback") Signed-off-by: Ashok Raj Reviewed-by: Tony Luck Signed-off-by: Ashok Raj --- arch/x86/kernel/cpu/microcode/core.c | 36 ++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index ef24e1d228d0..fab2010ff368 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -431,12 +431,28 @@ static int __reload_late(void *info) return ret; } +static void copy_cpu_caps(struct cpuinfo_x86 *info) +{ + /* Reload CPUID max function as it might've changed. */ + info->cpuid_level = cpuid_eax(0); + + /* + * Copy all capability leafs to pick up the synthetic ones so that + * memcmp() below doesn't fail on that. The ones coming from CPUID will + * get overwritten in get_cpu_cap(). + */ + memcpy(info->x86_capability, &boot_cpu_data.x86_capability, + sizeof(info->x86_capability)); + + get_cpu_cap(info); +} + /* * 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. */ -static void microcode_check(void) +static void microcode_check(struct cpuinfo_x86 *orig) { struct cpuinfo_x86 info; @@ -446,15 +462,13 @@ static void microcode_check(void) info.cpuid_level = cpuid_eax(0); /* - * Copy all capability leafs to pick up the synthetic ones so that - * memcmp() below doesn't fail on that. The ones coming from CPUID will - * get overwritten in get_cpu_cap(). - */ - memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)); + * Copy all capability leafs to pick up the synthetic ones so that + * memcmp() below doesn't fail on that. The ones coming from CPUID will + * get overwritten in get_cpu_cap(). + */ + copy_cpu_caps(&info); - get_cpu_cap(&info); - - if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, + if (!memcmp(&info.x86_capability, &orig->x86_capability, sizeof(info.x86_capability))) return; @@ -469,6 +483,7 @@ static void microcode_check(void) static int microcode_reload_late(void) { int old = boot_cpu_data.microcode, ret; + struct cpuinfo_x86 info; pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n"); pr_err("You should switch to early loading, if possible.\n"); @@ -476,9 +491,10 @@ static int microcode_reload_late(void) atomic_set(&late_cpus_in, 0); atomic_set(&late_cpus_out, 0); + copy_cpu_caps(&info); ret = stop_machine_cpuslocked(__reload_late, NULL, cpu_online_mask); if (ret == 0) - microcode_check(); + microcode_check(&info); pr_info("Reload completed, microcode revision: 0x%x -> 0x%x\n", old, boot_cpu_data.microcode); From patchwork Tue Nov 29 21:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp569791wrr; Tue, 29 Nov 2022 13:11:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6q3LjDFH5mqwolFJH8YxT4vRylCR9tI1KfM4rSMoaF/Gj2ZDV7nLF3xr5m4IbLpTPLHyp7 X-Received: by 2002:a63:2160:0:b0:46f:f26e:e8ba with SMTP id s32-20020a632160000000b0046ff26ee8bamr36098805pgm.250.1669756302447; Tue, 29 Nov 2022 13:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756302; cv=none; d=google.com; s=arc-20160816; b=sWQjb5ejtPRwTBG+ZZSg9ZLDmNCsFYPrBeBaf5YYWHjnomT1gY2fxXLfKLvAhN7Fdv hwrlkWGWQtmji+DSAVeBccf3UC5b7k1YBUKyYZw9UXPKNi47twPu4O1eBkIMe6LEFHjk Difcy+rSrrjKrj9jWdpFQySzkAUc9125Z7YZ8G7dorNWxQs5jIy0St3htFtkO6XqPUCl xQXN3YO/Nx+QJCBnDbTDqC/cse9CWNpjycu/R1yKKH4YD0CAvLJTeBlyCba1184G4omH MF16rd5mpltjRkzqjxM7ct+CKNmj0wJAxQeNcPU4L6/HWF+zVnIZ5AbEGLsHw9gv8mj0 ChcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pkzKDTqaBXOKLcFXO7KnzX/DjOJMptJTLrwEvMhth8w=; b=uBE1HHcogTRg6Lk1bMcCjAe0yRBvqzDpY9ajEJr0RpTawu/TLzFLFTz80JgXMdO2oD EFWONB2p9ou5wUswBCnurqKBGJp6Z4lhnEpbFrpj4T4850eHsAFME0Wba646qLhXPmkf wuIIuZ8PgwuRmfdeyZBw0jtDD9jCYlit5rtnVNwzwE5qbUuLdvuHR2vmDqT67n0hMHcs yS9GTFQiMSOAV++x63FZ4NGKuQ3jQhCB9JgCKX8q9IK6T8ivo9Hrm7lMVKO8DpiyCnkw eXcaqIMlqq7Re4oRxpQ9bqjTjDoXt0GU06AhxxEy4YFJv0CAgkgq87xZ7KCC+4ZM2Mqj cqSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kju5GOzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902c70200b001868277386dsi13341825plp.192.2022.11.29.13.11.28; Tue, 29 Nov 2022 13:11:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kju5GOzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236812AbiK2VJf (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236427AbiK2VJH (ORCPT ); Tue, 29 Nov 2022 16:09:07 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE94101F2 for ; Tue, 29 Nov 2022 13:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756146; x=1701292146; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aFHPQK+2Oph+JjnPWlBfQ8UflwxbR0mKWG54lIPAftU=; b=Kju5GOzbuX/5maJj+OH88jQB57hEY6ntKq0LAIyDBbn+Ui3z/fd+wvIo 00QKyzaeIrOdmHnRigR7B0nKqLxZo2CZ+6lxuspAABL2+rGvvoFuMa1Nl INTNwc9PIeWmEkI4WKDfKAQX16+ZZew/NSD+BYWujB4gzNXDNyRkkLyyi D+UynJ4oHL4NrSOTnyfGqMOaY63avWzi/zmGuu/EWTPYkTqwA45O5PmOJ p32dSoq6eg29mw5oXt9VsaoB1wvBrsfHUrFpYRCrJv4YnZQ28Xc1cjCAv GbfMxuTF3H5j++EVwazBR41TM20vXIrMm3iVPi9OSd9WJBvBeIxdClQ9L g==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083142" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083142" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:05 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066216" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066216" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:04 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 5/7] x86/microcode/intel: Prepare the print_ucode_rev to simply take a rev to print Date: Tue, 29 Nov 2022 13:08:30 -0800 Message-Id: <20221129210832.107850-6-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866384966049352?= X-GMAIL-MSGID: =?utf-8?q?1750866384966049352?= Instead of passing a struct ucode_cpu_info, just pass the rev to print. Next patch will permit printing old and new revisions after an early update. A subsequent patch will print a message when early loading fails. struct ucode_cpu_info is always the current version in the CPU. When loading fails this is the old rev, when its successfully applied its the new rev. That makes the code bit ugly to read. Remove the struct ucode_cpu_info parameter from print_ucode() and let the caller to pass in the revision number to print. No functional change. Signed-off-by: Ashok Raj Reviewed-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/intel.c | 28 +++++++++------------------ 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index d68b084a17e7..0a4f511e39ea 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -309,10 +309,10 @@ static bool load_builtin_intel_microcode(struct cpio_data *cp) * Print ucode update info. */ static void -print_ucode_info(struct ucode_cpu_info *uci, unsigned int date) +print_ucode_info(unsigned int new_rev, unsigned int date) { pr_info_once("microcode updated early to revision 0x%x, date = %04x-%02x-%02x\n", - uci->cpu_sig.rev, + new_rev, date & 0xffff, date >> 24, (date >> 16) & 0xff); @@ -332,7 +332,7 @@ void show_ucode_info_early(void) if (delay_ucode_info) { intel_cpu_collect_info(&uci); - print_ucode_info(&uci, current_mc_date); + print_ucode_info(uci.cpu_sig.rev. current_mc_date); delay_ucode_info = 0; } } @@ -341,33 +341,23 @@ void show_ucode_info_early(void) * At this point, we can not call printk() yet. Delay printing microcode info in * show_ucode_info_early() until printk() works. */ -static void print_ucode(struct ucode_cpu_info *uci) +static void print_ucode(int new_rev, int date) { struct microcode_intel *mc; int *delay_ucode_info_p; int *current_mc_date_p; - mc = uci->mc; - if (!mc) - return; - delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info); current_mc_date_p = (int *)__pa_nodebug(¤t_mc_date); *delay_ucode_info_p = 1; - *current_mc_date_p = mc->hdr.date; + *current_mc_date_p = date; } #else -static inline void print_ucode(struct ucode_cpu_info *uci) +static inline void print_ucode(int new_rev, int date) { - struct microcode_intel *mc; - - mc = uci->mc; - if (!mc) - return; - - print_ucode_info(uci, mc->hdr.date); + print_ucode_info(new_rev, date); } #endif @@ -407,9 +397,9 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) uci->cpu_sig.rev = rev; if (early) - print_ucode(uci); + print_ucode(uci->cpu_sig.rev, mc->hdr.date); else - print_ucode_info(uci, mc->hdr.date); + print_ucode_info(uci->cpu_sig.rev, mc->hdr.date); return 0; } From patchwork Tue Nov 29 21:08:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp569807wrr; Tue, 29 Nov 2022 13:11:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf5+8/mfy+ge4wDfh/icPoT3n+8VlSn1pUSAgL//nYr+cHkPEzot5RdX7QFMf5D4Ave2fIOO X-Received: by 2002:a05:6a00:1d21:b0:574:a486:cb with SMTP id a33-20020a056a001d2100b00574a48600cbmr25730892pfx.11.1669756303834; Tue, 29 Nov 2022 13:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756303; cv=none; d=google.com; s=arc-20160816; b=tMbeZ2SbemGikZ+f0bphDbYoS2SpoS0mozVONjRK+39vDdhuMe+T1mpre492KiUwA4 AYlgMev67RNY0RZZ4nmETp54y+vmzNdLtUpbCUbEMpnZ+m/CqVoGHS3aEa7pA4zGOmZu rlv9ktq77mOM7U3LGCIl7tfUsZiH5gAC4Q9Rlx+uiO9VghnOD8GOLtVDrJpDqCwVsqIE sPjnxOavNS8Z4hKD5lIU0zJSn8A8OapUReYozO1T5LHkucjsvbiXUHI3bfEB3TDDCBNo 9kdLZYFLTef+2QiVjliCNS6TmFSmFzFSRsFarU5DXy9U316SVkAImrHPhdLDwVwpv5T8 5mrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rzZJZw9Ny7F72piR/2BwinmEJcEqT4YDl/Vf5NKpIIw=; b=CBpbbKiU8bN9jsCjeVu5NBttI2AJwNdSbxguJHIQ558evei1+ttXztVSFk9J69Nrm9 PkEnY7X/SfE1gfLE3t5gk369/v3h8xBE7PI1qoCtWtorqy+/krKKkuB7CuxI4ZQVxh7P sjNPDA2Tjc69wLtw8UFK+wIRhVKlajdKqQ88rb4b8IYBJN8ri7PQZ3Fssl0xuctI3TR4 PoA6bTa7KTY19/bMOojoeWrSSTedf7yZAJpG+Z8f+nELk3/giIiGwO+esA/XoOH0Un/q Pamr7/0Ccj5BWENRrA+1aEZ+Io9SMO1U1yGZwPFxyqBcH1d21yvODRXyvhq/yRZjZz5B o80w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L1ZVpALi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090301d100b00189240585a8si9275650plh.292.2022.11.29.13.11.30; Tue, 29 Nov 2022 13:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L1ZVpALi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236871AbiK2VJo (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236770AbiK2VJH (ORCPT ); Tue, 29 Nov 2022 16:09:07 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5DD1275C for ; Tue, 29 Nov 2022 13:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756146; x=1701292146; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mNhSx3Rnv+AmLrb00ne/8ykmg4QVntYPSdnoX8ENEXo=; b=L1ZVpALiyIZ01wWHD/CvedubZSeHxDnirkWpr80wydZs/IHz3QJJQ59/ bkrezCihOAQokgGMDW5disB/YbnSqu9I1/17T18cE2Ddy5Y5TWECaZJDQ EC2K0kckbnWkWi99Ab9B99g+9Av8RnkcFW7n1oNWh90pjlWbZUhRoTzYu Dnkz85CuGHg1MUY6DawNmrI6xB58tl7UxiM/knpNdsQB+NIWLf4LG4oYU cl5hC70awS6xBTLpuXluy/oCLb92dZ5UNECLB1BcTjabFaoqG29qxmxWj 181IKXuEYvQwvd5I284451TEf23Jm4zMtZLUh769o38g6H5/SnJ67E/Yl g==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083145" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083145" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:05 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066219" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066219" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:05 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 6/7] x86/microcode/intel: Print old and new rev during early boot Date: Tue, 29 Nov 2022 13:08:31 -0800 Message-Id: <20221129210832.107850-7-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866385917263271?= X-GMAIL-MSGID: =?utf-8?q?1750866385917263271?= Make early loading message to match late loading messages. Print both old and new revisions. This is helpful to know what the BIOS loaded revision is before an early update. microcode: early update: 0x2b000041 -> 0x2b000070 date = 2000-01-01 Store the early BIOS revision and change the print format to match late loading message from microcode/core.c Signed-off-by: Ashok Raj --- arch/x86/kernel/cpu/microcode/intel.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 0a4f511e39ea..3dbcf457f45d 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -309,10 +309,10 @@ static bool load_builtin_intel_microcode(struct cpio_data *cp) * Print ucode update info. */ static void -print_ucode_info(unsigned int new_rev, unsigned int date) +print_ucode_info(int old_rev, int new_rev, unsigned int date) { - pr_info_once("microcode updated early to revision 0x%x, date = %04x-%02x-%02x\n", - new_rev, + pr_info_once("early update: 0x%x -> 0x%x, date = %04x-%02x-%02x\n", + old_rev, new_rev, date & 0xffff, date >> 24, (date >> 16) & 0xff); @@ -322,6 +322,7 @@ print_ucode_info(unsigned int new_rev, unsigned int date) static int delay_ucode_info; static int current_mc_date; +static int early_old_rev; /* * Print early updated ucode info after printk works. This is delayed info dump. @@ -332,7 +333,7 @@ void show_ucode_info_early(void) if (delay_ucode_info) { intel_cpu_collect_info(&uci); - print_ucode_info(uci.cpu_sig.rev. current_mc_date); + print_ucode_info(early_old_rev, uci.cpu_sig.rev, current_mc_date); delay_ucode_info = 0; } } @@ -341,30 +342,33 @@ void show_ucode_info_early(void) * At this point, we can not call printk() yet. Delay printing microcode info in * show_ucode_info_early() until printk() works. */ -static void print_ucode(int new_rev, int date) +static void print_ucode(int old_rev, int new_rev, int date) { struct microcode_intel *mc; int *delay_ucode_info_p; int *current_mc_date_p; + int *early_old_rev_p; delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info); current_mc_date_p = (int *)__pa_nodebug(¤t_mc_date); + early_old_rev_p = (int *)__pa_nodebug(&early_old_rev); *delay_ucode_info_p = 1; *current_mc_date_p = date; + *early_old_rev_p = old_rev; } #else -static inline void print_ucode(int new_rev, int date) +static inline void print_ucode(int old_rev, int new_rev, int date) { - print_ucode_info(new_rev, date); + print_ucode_info(old_rev, new_rev, date); } #endif static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) { struct microcode_intel *mc; - u32 rev; + u32 rev, old_rev; mc = uci->mc; if (!mc) @@ -390,6 +394,7 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) /* write microcode via MSR 0x79 */ native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); + old_rev = rev; rev = intel_get_microcode_revision(); if (rev != mc->hdr.rev) return -1; @@ -397,9 +402,9 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) uci->cpu_sig.rev = rev; if (early) - print_ucode(uci->cpu_sig.rev, mc->hdr.date); + print_ucode(old_rev, uci->cpu_sig.rev, mc->hdr.date); else - print_ucode_info(uci->cpu_sig.rev, mc->hdr.date); + print_ucode_info(old_rev, uci->cpu_sig.rev, mc->hdr.date); return 0; } From patchwork Tue Nov 29 21:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 27517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp569830wrr; Tue, 29 Nov 2022 13:11:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5aindHjm5KSVA4nFkF9X8JJNZmHxUEfKrK5pCq8yLhEvEBbIEUPXuWZefXVB4fUH6dAhdv X-Received: by 2002:a17:902:ced1:b0:179:ee31:1527 with SMTP id d17-20020a170902ced100b00179ee311527mr7378496plg.138.1669756306422; Tue, 29 Nov 2022 13:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669756306; cv=none; d=google.com; s=arc-20160816; b=a1a2L5ionBDn3TouNSXl0GVjWwCiwUUhJbDxSi5BtDla4Hgu7a8HcP99IPMG0Bwp/c h8BQ2ySwhlfuZKRQrs1VnzStHtmTiKzZTjxx5g/7NsWseVjOWmLB8D5VFdokAZVqIxZJ 46A7JcCTXB6FsYpquvH6pwuUEL3iSqMFsbAG+76HkN4rGeRRQ8LS/e/ckQfVdYIqU3pu YFPXOINGoVgSvHA4uaQv+iQbqZu9iFWKd3XgUqOm5cvu7kz1MDWig1RKhurBV3sndpKw fW+YHVoGbmfKJ0eT7AwzgrUC851JPCwm1yVlDhdmT4pTVwCOct84BEI214CluBZ7nmg5 pKLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RCHFMfB7pkqnZqvzK9ekQyoJIKeSvBtqDlwtyeoZLJE=; b=gUC5YBOxvqnUILa1cRORIJZXsQZA6nOlqmIw5quaTcyTsTXsH+ed2rhZkyi3Gen7Cu z14Dr1KvY4MJd0jRcmub7q0EhmtBp2kddiRFtKNz2zFm0beEKkV3RZ0APJ8Ic3L/i67z kHilN/2Cr8blsuehP77etzd9nTkQxX2DOltN6kvQBfCvimBsP3IUjzNESC1y3CIwmYqM RDVMhp+Qy/WK6uyjm3bXsnOPPqp51EqUpmUqrwi7/wwXENGJFcazXz7CK8rlPmZk2mkJ FiUzpL+YlVqq7fBeyuQkVt+eRaeiyOHGBE0qczY1LqNpQfUrkS+oKmADmw+GdLgbG/TZ 030Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hadAQMld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a654641000000b00477b29bb007si16435803pgr.854.2022.11.29.13.11.33; Tue, 29 Nov 2022 13:11:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hadAQMld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236464AbiK2VJt (ORCPT + 99 others); Tue, 29 Nov 2022 16:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236522AbiK2VJI (ORCPT ); Tue, 29 Nov 2022 16:09:08 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D8C413F41 for ; Tue, 29 Nov 2022 13:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669756147; x=1701292147; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=20JuXfzhAsVCbgdOdNtTvhg8467Iyas3sTDbl4soGRo=; b=hadAQMldluMt9tJL7ixJlQtcaB2uBl9ahcRVd0d8TnU/p9c091mXXKBU o4D6gOcvQlaYhskVKAimk6vkVRdpTz7g/VGUkPeD5pq5Ggq/S3q8yIaqv AAc7SzNXC2X8a2lkDH2hWTXSGvqliJpUL3egB5P4sV0XwspR2qS5cTczB ATHPMa7x1AxDADzsO1I2PPINqIukgxGsW1kkjAoaqJJhMs24ABp3/yAjS uHhXSawjR4ZHWnMXNsH+Kf0UBsWw+82DO+qutshC6f7PsY2/+aU+Hdqpf a4Y0Ys2CJv3NJ79TbpjdE2vsqcDBh5P+wPBjjfD477cm0wrQnNGh0R6B9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="317083148" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="317083148" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:05 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646066222" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="646066222" Received: from araj-ucode.jf.intel.com ([10.23.0.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 13:09:05 -0800 From: Ashok Raj To: Borislav Petkov Cc: X86-kernel , LKML Mailing List , Ashok Raj , Dave Hansen , Tony Luck , alison.schofield@intel.com, reinette.chatre@intel.com Subject: [Patch V1 7/7] x86/microcode/intel: Print when early microcode loading fails Date: Tue, 29 Nov 2022 13:08:32 -0800 Message-Id: <20221129210832.107850-8-ashok.raj@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129210832.107850-1-ashok.raj@intel.com> References: <20221129210832.107850-1-ashok.raj@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750866388409890570?= X-GMAIL-MSGID: =?utf-8?q?1750866388409890570?= Currently when early microcode loading fails there is no way for user to know that the update failed. Store the failed status and pass it to print_ucode_info() to let early loading failures to captured in console log. Signed-off-by: Ashok Raj --- arch/x86/kernel/cpu/microcode/intel.c | 29 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 3dbcf457f45d..3b299f437e35 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -309,13 +309,14 @@ static bool load_builtin_intel_microcode(struct cpio_data *cp) * Print ucode update info. */ static void -print_ucode_info(int old_rev, int new_rev, unsigned int date) +print_ucode_info(bool failed, int old_rev, int new_rev, unsigned int date) { - pr_info_once("early update: 0x%x -> 0x%x, date = %04x-%02x-%02x\n", + pr_info_once("early update: 0x%x -> 0x%x, date = %04x-%02x-%02x %s\n", old_rev, new_rev, date & 0xffff, date >> 24, - (date >> 16) & 0xff); + (date >> 16) & 0xff, + failed ? "FAILED" : ""); } #ifdef CONFIG_X86_32 @@ -323,6 +324,7 @@ print_ucode_info(int old_rev, int new_rev, unsigned int date) static int delay_ucode_info; static int current_mc_date; static int early_old_rev; +static bool early_failed; /* * Print early updated ucode info after printk works. This is delayed info dump. @@ -333,7 +335,7 @@ void show_ucode_info_early(void) if (delay_ucode_info) { intel_cpu_collect_info(&uci); - print_ucode_info(early_old_rev, uci.cpu_sig.rev, current_mc_date); + print_ucode_info(early_failed, early_old_rev, uci.cpu_sig.rev, current_mc_date); delay_ucode_info = 0; } } @@ -342,26 +344,28 @@ void show_ucode_info_early(void) * At this point, we can not call printk() yet. Delay printing microcode info in * show_ucode_info_early() until printk() works. */ -static void print_ucode(int old_rev, int new_rev, int date) +static void print_ucode(bool failed, int old_rev, int new_rev, int date) { - struct microcode_intel *mc; int *delay_ucode_info_p; int *current_mc_date_p; int *early_old_rev_p; + bool *early_failed_p; delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info); current_mc_date_p = (int *)__pa_nodebug(¤t_mc_date); early_old_rev_p = (int *)__pa_nodebug(&early_old_rev); + early_failed_p = (int *)__pa_nodebug(&early_failed); *delay_ucode_info_p = 1; *current_mc_date_p = date; *early_old_rev_p = old_rev; + *early_failed_p = failed; } #else -static inline void print_ucode(int old_rev, int new_rev, int date) +static inline void print_ucode(bool failed, int old_rev, int new_rev, int date) { - print_ucode_info(old_rev, new_rev, date); + print_ucode_info(failed, old_rev, new_rev, date); } #endif @@ -369,6 +373,7 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) { struct microcode_intel *mc; u32 rev, old_rev; + int retval = 0; mc = uci->mc; if (!mc) @@ -397,16 +402,16 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) old_rev = rev; rev = intel_get_microcode_revision(); if (rev != mc->hdr.rev) - return -1; + retval = -1; uci->cpu_sig.rev = rev; if (early) - print_ucode(old_rev, uci->cpu_sig.rev, mc->hdr.date); + print_ucode(retval, old_rev, mc->hdr.rev, mc->hdr.date); else - print_ucode_info(old_rev, uci->cpu_sig.rev, mc->hdr.date); + print_ucode_info(retval, old_rev, uci->cpu_sig.rev, mc->hdr.date); - return 0; + return retval; } int __init save_microcode_in_initrd_intel(void)