From mboxrd@z Thu Jan 1 00:00:00 1970 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 E108839FD6; Mon, 21 Oct 2024 10:30:40 +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=1729506641; cv=none; b=UKVStqAQvJss9HTRsDX+M9Xw/qTzizvgMvJfpGmgk7XjQZJAgJqpZqygyrnQ48B2Pj7kPlcxq1vFY0juPjECp7gcPm/jOPlTaaJhtedrZWttihJbnOxvVyl1LUo4mjKBXXcFIkPKEAfS7jJcPHo1gFub2BRvW4CFxskESOmuWG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729506641; c=relaxed/simple; bh=H5FQJ0iKqgNWH7EYHG1NiEYy5eJM1s/SlakF4B7LkmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DjX8SrHBDhLGNKMw6s2nhixe4382T7Ag2/OaP2G6htOhflTDzsUbxvq3QHRN0Yiefig+PqxyMrsjbfkhNhguJl5xdg4cWKDkce2+JLaLTfBkykfmNdELc69unNx3hBw7NejNUT+mGbrm/GMUj6hpRZ5l2M14JUhzuaAElqxPRqw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MjxGiRUG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MjxGiRUG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FA7FC4CEC3; Mon, 21 Oct 2024 10:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729506640; bh=H5FQJ0iKqgNWH7EYHG1NiEYy5eJM1s/SlakF4B7LkmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MjxGiRUGBvpOarKvy//4CDTSCBTdO9lwje9KnxAL2gATbVl7UUgy93lZc4iqpqwiD lZjQDnGkKRgaZ1LU4Umaj9inlMSyKtshapotw9nlgS87JVYorpXehDebgEZT5gWpzf btptepUkuqY+mlLNkmYLNU38L9VqUfIwv3a1NOFw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Wikner , "Borislav Petkov (AMD)" , stable@kernel.org Subject: [PATCH 6.11 042/135] x86/cpufeatures: Add a IBPB_NO_RET BUG flag Date: Mon, 21 Oct 2024 12:23:18 +0200 Message-ID: <20241021102300.977764795@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021102259.324175287@linuxfoundation.org> References: <20241021102259.324175287@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Wikner commit 3ea87dfa31a7b0bb0ff1675e67b9e54883013074 upstream. Set this flag if the CPU has an IBPB implementation that does not invalidate return target predictions. Zen generations < 4 do not flush the RSB when executing an IBPB and this bug flag denotes that. [ bp: Massage. ] Signed-off-by: Johannes Wikner Signed-off-by: Borislav Petkov (AMD) Cc: Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/common.c | 3 +++ 2 files changed, 4 insertions(+) --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -524,4 +524,5 @@ #define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */ #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */ #define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */ +#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */ #endif /* _ASM_X86_CPUFEATURES_H */ --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1443,6 +1443,9 @@ static void __init cpu_set_bug_bits(stru boot_cpu_has(X86_FEATURE_HYPERVISOR))) setup_force_cpu_bug(X86_BUG_BHI); + if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET)) + setup_force_cpu_bug(X86_BUG_IBPB_NO_RET); + if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN)) return;