From patchwork Tue Apr 8 21:47:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 14043732 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 2E308256C85; Tue, 8 Apr 2025 21:48:05 +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=1744148887; cv=none; b=YNQdpS4dnsM96fZLLj4Sp1kwKsGsHd7mZRUXqwkn89Cx0zsKm4LxOKiGQkgtdLllFbCdl7yi78Nr10GLrNijXvVzUmscN8KtinEpAK9otQXUlcHHVjIcHXOjxYyT8juYO243CoaYP4BflnU1jJKa64GikPsOhVnUnDVrqh04WP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744148887; c=relaxed/simple; bh=QhfvR6gBCdpV2nBBPgso6jxGJZAibhAWKbj8KbjMsgk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XoGtoT0SHiiTtqipBclWkJAWndv6xss4D3A72rSUvq5WEWo847ABf/hoCOS/Heo+slzbSEl24b9cHQIdHltB1YBhre4BsPnzH+NMqT6cPMjLQibjNb3jds4HjS6dp03DprMO7HJsUZGc2YQQpVqoYNQpU97ABB1QpsbCkYzgyh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LPQJD1wB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LPQJD1wB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFB5FC4CEE7; Tue, 8 Apr 2025 21:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744148885; bh=QhfvR6gBCdpV2nBBPgso6jxGJZAibhAWKbj8KbjMsgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPQJD1wBhFMPk3X6nGFTBfvavMdMlgmoANWTfpbN61NLlJYBwBdq1lMAFrpBxJkfl 36FpDoRWgABY33XwEkdPwrp5pu5VMJCm162Gr4ZPKpA5qParNC2v7b5B2cDe1gQ2ey oXJCWusl0mG0nd+s/iI17pBjJzyOEc9dAuhjT5fuLgfPXdR8Kpyyv8NkY5B98tTF86 qa7X25QDBIJAARLAJL/rm0tyUY7MndP10iOGqw6XNdW6wp5+s3wE9+6Nu2Q5dubZVM Hf+qZ/BjwFKpGf0nnln1GAKd7Oz0hcSq+MM1+NrZ/nLCLUrEgwO3huPoZMVQEsFQFz W/61Ic5Z3HSUQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, amit@kernel.org, kvm@vger.kernel.org, amit.shah@amd.com, thomas.lendacky@amd.com, bp@alien8.de, tglx@linutronix.de, peterz@infradead.org, pawan.kumar.gupta@linux.intel.com, corbet@lwn.net, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, daniel.sneddon@linux.intel.com, kai.huang@intel.com, sandipan.das@amd.com, boris.ostrovsky@oracle.com, Babu.Moger@amd.com, david.kaplan@amd.com, dwmw@amazon.co.uk, andrew.cooper3@citrix.comm, nik.borisov@suse.com Subject: [PATCH v4 4/6] x86/bugs: Don't fill RSB on VMEXIT with eIBRS+retpoline Date: Tue, 8 Apr 2025 14:47:33 -0700 Message-ID: <84a1226e5c9e2698eae1b5ade861f1b8bf3677dc.1744148254.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 eIBRS protects against guest->host RSB underflow/poisoning attacks. Adding retpoline to the mix doesn't change that. Retpoline has a balanced CALL/RET anyway. So the current full RSB filling on VMEXIT with eIBRS+retpoline is overkill. Disable it or do the VMEXIT_LITE mitigation if needed. Suggested-by: Pawan Gupta Reviewed-by: Pawan Gupta Reviewed-by: Amit Shah Reviewed-by: Nikolay Borisov Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/cpu/bugs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 99265098d045..a10b37bb747e 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1617,20 +1617,20 @@ static void __init spectre_v2_determine_rsb_fill_type_at_vmexit(enum spectre_v2_ case SPECTRE_V2_NONE: return; - case SPECTRE_V2_EIBRS_LFENCE: case SPECTRE_V2_EIBRS: + case SPECTRE_V2_EIBRS_LFENCE: + case SPECTRE_V2_EIBRS_RETPOLINE: if (boot_cpu_has_bug(X86_BUG_EIBRS_PBRSB)) { - setup_force_cpu_cap(X86_FEATURE_RSB_VMEXIT_LITE); pr_info("Spectre v2 / PBRSB-eIBRS: Retire a single CALL on VMEXIT\n"); + setup_force_cpu_cap(X86_FEATURE_RSB_VMEXIT_LITE); } return; - case SPECTRE_V2_EIBRS_RETPOLINE: case SPECTRE_V2_RETPOLINE: case SPECTRE_V2_LFENCE: case SPECTRE_V2_IBRS: - setup_force_cpu_cap(X86_FEATURE_RSB_VMEXIT); pr_info("Spectre v2 / SpectreRSB : Filling RSB on VMEXIT\n"); + setup_force_cpu_cap(X86_FEATURE_RSB_VMEXIT); return; }