Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp263830rdb; Thu, 18 Jan 2024 02:58:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxP5mF6pERdgTmcGI8PKsgiLfOtMohEUPCqC/kVnC+Wz1ojJLSaaJ7+bOKXskZ+zjcR70v X-Received: by 2002:a17:903:268d:b0:1d0:6ffd:6e85 with SMTP id jf13-20020a170903268d00b001d06ffd6e85mr520608plb.125.1705575510876; Thu, 18 Jan 2024 02:58:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705575510; cv=pass; d=google.com; s=arc-20160816; b=Lm3Kqu7fV+WKg0fYnJqk138IO9/M20Zawe0QeNsiYlmNL85cY4bz5Kxk6m4y1rvSFo SxiiZMvyiUP5mv4YduZGE8RsKcUAhubBQSzkmdoBQGg8xwtspudPVk/Sr8WQzJafLbx1 hW/35VIBZO7kbKKmVL8ohn/QlUXIQTCw+qtyrtbXL81nksk7MJQSjh9dHPWYkXRjZhac owYLcCpe7yPa979i1U2MQVzLxc5BdaNGJ5vBi1TJz85tL1MFJi5V7SjVa/V+qe+1ibll gDIsZspxxih6teBdUiUkWorgOoXHZ7GnlQGda7sHjImUihRo1VoEuI8bgBUrUggjal8F 7zeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=cp5nhDFOrYLOrDiNAJCJkd1/qZRGJCTsa9b6BFrYarQ=; fh=QKMMQkASe20NVixbznLGr3PKaB2r7r6cNM3rrqiXtcY=; b=oy0GHXLvXtdSx0sMqB9SvH2/3Z6ps8/MSEtugBFMIIDNj7xilidd0iFqKaLgJrQQ8c DTQR2FCli3Ei/VabmDUmWpgGvHxO6T5McxdRq8VhhPiTz5HCgt2OpTrRcdiCCFmFk/lm rNAC2Uo1xa8784VxF5yPOmHnw/C1dbiLSKynKxBMFhTsCDuc4A8QQnER/gBdQ74pwDGi M+amVDACHW3bXSeWNWpEhUUHNdJ99ta+qUoqAP4kgPkexJjTIgMvDLzxqQRcplhNcKy8 2q8R/p0KHb46lzu4cfhkUmm8CmI/NLtRKcwJXV17Q3yMtNWuIGbg97IyBWioWUaGyceU riAA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MpFTAmnL; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-30016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k8-20020a170902694800b001d5457db81dsi1215842plt.649.2024.01.18.02.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 02:58:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MpFTAmnL; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-30016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2BBB9B2173D for ; Thu, 18 Jan 2024 10:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 329D623761; Thu, 18 Jan 2024 10:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MpFTAmnL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AA381774B; Thu, 18 Jan 2024 10:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575502; cv=none; b=Fq6FpT2MaCj68eAMri+DweoPJLdHK4o08UC+PnYB28lrFyZbalfFBhfzTGO7XjvaD3JziZ1y11wdlR2qi69CrFGrC9cQMbEC/kJpLrdlQ0O7faK6g01aG1ol4FPnSlecCg0pilbDbEOBTpO3Y9y+GivFGvhZ4J+BGknwAwY4sb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575502; c=relaxed/simple; bh=Rqt9d8H9b7ON2dY22pUE5JwX1GzNwB3+PYGDm4bKB/E=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:User-Agent:X-stable: X-Patchwork-Hint:MIME-Version:Content-Transfer-Encoding; b=KiUKZS35UA3nPOAVkzoyfObq9YON7qDkU8OCpCghqJ9bh2g7br3+Q+z/eqMIXfNuiv2jg+OlspWrNbUAVzQHNAbVHfgmpUZKH7ehxtlVCRZ89dc28C9EW93Kca8lHRlOtQr2et6fV7UW4XD8wTnRtCbu089XC6Mf0mGjFkw1EmU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MpFTAmnL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D18ECC433F1; Thu, 18 Jan 2024 10:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705575502; bh=Rqt9d8H9b7ON2dY22pUE5JwX1GzNwB3+PYGDm4bKB/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpFTAmnLYx+DzpKxhXO/jxzN+fklmEPLz8kgGOvq1f4y5DoLx2B+7aCJQuhBTQF0R aN3U9OiC/sCdVmPchK65S8ea/VGPpM6pOwRSPUPvmOvzEMWwjzHQNyBXS0KYeNWHVv jEdM3qSWbaJj2oDAXPkqgHLPgrwjfPDe0Dg3ktRU= From: Greg Kroah-Hartman To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Hansen , Paolo Bonzini , "Borislav Petkov (AMD)" , x86@kernel.org Subject: [PATCH 6.6 129/150] x86/microcode: do not cache microcode if it will not be used Date: Thu, 18 Jan 2024 11:49:11 +0100 Message-ID: <20240118104326.023345747@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118104320.029537060@linuxfoundation.org> References: <20240118104320.029537060@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ No relevant upstream kernel due to refactoring in 6.7 Builtin/initrd microcode will not be used the ucode loader is disabled. But currently, save_microcode_in_initrd is always performed and it accesses MSR_IA32_UCODE_REV even if dis_ucode_ldr is true, and in particular even if X86_FEATURE_HYPERVISOR is set; the TDX module does not implement the MSR and the result is a call trace at boot for TDX guests. Mainline Linux fixed this as part of a more complex rework of microcode caching that went into 6.7 (see in particular commits dd5e3e3ca6, "x86/microcode/intel: Simplify early loading"; and a7939f0167203, "x86/microcode/amd: Cache builtin/initrd microcode early"). Do the bare minimum in stable kernels, setting initrd_gone just like mainline Linux does in mark_initrd_gone(). Note that save_microcode_in_initrd() is not in the microcode application path, which runs with paging disabled on 32-bit systems, so it can (and has to) use dis_ucode_ldr instead of check_loader_disabled_ap(). Cc: stable@vger.kernel.org # v6.6+ Cc: x86@kernel.org # v6.6+ Cc: Dave Hansen Signed-off-by: Paolo Bonzini Acked-by: Borislav Petkov (AMD) Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/microcode/core.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -208,6 +208,11 @@ static int __init save_microcode_in_init struct cpuinfo_x86 *c = &boot_cpu_data; int ret = -EINVAL; + if (dis_ucode_ldr) { + ret = 0; + goto out; + } + switch (c->x86_vendor) { case X86_VENDOR_INTEL: if (c->x86 >= 6) @@ -221,6 +226,7 @@ static int __init save_microcode_in_init break; } +out: initrd_gone = true; return ret;