From nobody Fri Dec 19 19:04:29 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2069.outbound.protection.outlook.com [40.107.244.69]) (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 E8AA8203706 for ; Wed, 8 Jan 2025 20:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367964; cv=fail; b=sbOUPYtAc3e/KVLZZmSWkF7fuZgFL7BqY+z8gNmOPfcSKdzAWEabxhW8U05uJaGV1pykchVgAFQW8sNRUFbnBCUAXSisIInTsHasZsoEzqcD6lUoszMSSo38M56DVyaMvwu7JJ/BhJcgFL1xLe1epoY7Xp8H4/4evt4OqP+BbhY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367964; c=relaxed/simple; bh=Z14pnsNNXEwuY4L5hZGfhe4FysZ8WFqdanck2j973ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m/l+Sg+oB8TtZZY3aJvtE+mdDtE1mNcfpIcZ4bL6qeSI5bUWW6ok8+L1WAozFkG2fyxWkbyKsOkBjFyiJiR+4Whh6V6tmSkTcRsuIZoxgITNjmvnySNxJeq3adFSMzqx0lx20Vm9NRMHPyXDmWSFEfG/jGMru31ftzopjdPWKlE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=hDgV75de; arc=fail smtp.client-ip=40.107.244.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hDgV75de" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q2iqcMY2iGoRuXHANUrHdyDlQ+/gXQN84iW+e320xVmI359YJ66qA9UxpqT/aw6Sm95Z0uItCZybwi0MgCoBN/QD0nph/0rewHJ/RYS3tEoVgoeTNJfJbNj0ron+qdWcCEwHoIQwTAMMK+M4zji9AbVlwcex+uvLiWz4bagteCwz7gtEBAf6HLqldAWbI/TDa9PRhadz6+hWiUaIsjPbv42c6e3ekNcOIbvXn/ugkN/Pv1bgz7IWTyALHkyCd47Z3vmRvnIVKyuGABH6iBCUtWjQ57dFScaYoeOTtm8NEglWXwXyC8+AM0HQZTyNXm8SBeN28VztAlqg7QTfNECkqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U4fL8KiVcoAL7gX2YSk7vRuJto5Y+qUHGqg+FHxwYTs=; b=FFdjLsdpgeoMJ7ZVaB1gW0LeOTHq59VkQw+9jrKDiHYhszIoQQsIL8WKsBDvp7iYTKOvoOx7duyRpQYQncbwAeR5BsiJUtJl5IuPwfpWFE10ZyjPT1wQKhL1skolTFQZzHM4fTmIJphVx+XkZqnKHoim36oCb39exqac+IMxRNsbPmsrVTAXsayvLhePtDmWYazZ/iaIjfIoSgcvO8Pt7QfxhTrOEbZyJx5gCcpxeA9YMfymdGfwInMk3Qht4SjYvl4c9z5rkp6qbiyJPrrb+aSXXc1YSjpPHOmDD9P5NSc5oSFvCpTQBup0k6bXy8E0IO2zVC/VPtwrY9i76cMqGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U4fL8KiVcoAL7gX2YSk7vRuJto5Y+qUHGqg+FHxwYTs=; b=hDgV75deZTG2IMKMr0YivIER+Hfej/Mue8eMJHfXAFeG+dVCXxurhORMbgVxH/jtk5J116hbdHV0+DMeId/xumPam5vOypDDx/MWe5PjeGzcU9ikn2v7pU1JteomtnuvOPLOqZNHg45QRvJNFfNCpAE76ilffmv/tqUv7VngK7Y= Received: from SA9PR11CA0022.namprd11.prod.outlook.com (2603:10b6:806:6e::27) by SA1PR12MB7293.namprd12.prod.outlook.com (2603:10b6:806:2b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Wed, 8 Jan 2025 20:25:56 +0000 Received: from DS3PEPF000099E2.namprd04.prod.outlook.com (2603:10b6:806:6e:cafe::d) by SA9PR11CA0022.outlook.office365.com (2603:10b6:806:6e::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.11 via Frontend Transport; Wed, 8 Jan 2025 20:25:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099E2.mail.protection.outlook.com (10.167.17.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Wed, 8 Jan 2025 20:25:55 +0000 Received: from tiny.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 8 Jan 2025 14:25:51 -0600 From: David Kaplan To: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , , "H . Peter Anvin" CC: Subject: [PATCH v3 29/35] x86/bugs: Add attack vector controls for retbleed Date: Wed, 8 Jan 2025 14:25:09 -0600 Message-ID: <20250108202515.385902-30-david.kaplan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108202515.385902-1-david.kaplan@amd.com> References: <20250108202515.385902-1-david.kaplan@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E2:EE_|SA1PR12MB7293:EE_ X-MS-Office365-Filtering-Correlation-Id: a0c561a8-222a-4ecc-6ed1-08dd3022a7cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Mwf8J6UR+m3bbFXVl1ND2ZfFnLsnV1N5AIuidHLjv00iU6fuapumC3CP8aGB?= =?us-ascii?Q?5QANVyI2lBKwn83NnT4h73AEw1MKzZz/nTkpS2NK0TIJCNdaEI8iCaq2XgN0?= =?us-ascii?Q?C93ot84CArKkCfOkkEd7JMQXWxYFuNBK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q?w0gJiud41mI1DemY3H60tVRCY4ixJ4lQGPtca8r4oFRf+H5Fmfei9Qts6asa?= =?us-ascii?Q?4qW/e8hHLETEFIQwzakUk0w0otI9d+exiNbYFivDSfQNgT656+VJ8JUvdPix?= =?us-ascii?Q?NnDr7gSf8lR0ibttVMs15sD6M0tRbA24HQEALDMPsuO9QdPl2VpuG+NFgCBA?= =?us-ascii?Q?KQFcP3WUlIGujv1PiC+mrzf3Zwo54uaM1W62l/XMNPVfyIYu5pGUefT8lad6?= =?us-ascii?Q?rKG9x/6s9GCG9UShCtk0kz8+Z2NUt/WaD20GmFTpYEpNhuANw3R8RIVE328V?= =?us-ascii?Q?ikpxTlNw0Mva7U85Q0/1K17RDQsNlcljt4F5yh0LSI9HnGAxsXsKtaxy8Ie6?= =?us-ascii?Q?OYxMtTKo7SH+AhOlszZDkw3Xr9eMGVv3zuqGde2v3s3zbAOHvXk+L+VfISBF?= =?us-ascii?Q?yvvn+tuRS0mVLpauXbl81CVqpGMFQcKRuifGlFmsIM0ld+kxRaUMfIMH+aHe?= =?us-ascii?Q?t8J4lqOoYEDzzR0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2025 20:25:55.7664 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0c561a8-222a-4ecc-6ed1-08dd3022a7cd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7293 Content-Type: text/plain; charset="utf-8" Use attack vector controls to determine if retbleed mitigation is required. Disable SMT if cross-thread protection is desired and STIBP is not available. Signed-off-by: David Kaplan --- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 41c8a9dad411..430f89a5f66a 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1331,13 +1331,17 @@ static void __init retbleed_select_mitigation(void) } =20 if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_AUTO) { - if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD || - boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_HYGON) { - if (IS_ENABLED(CONFIG_MITIGATION_UNRET_ENTRY)) - retbleed_mitigation =3D RETBLEED_MITIGATION_UNRET; - else if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY) && - boot_cpu_has(X86_FEATURE_IBPB)) - retbleed_mitigation =3D RETBLEED_MITIGATION_IBPB; + if (should_mitigate_vuln(X86_BUG_RETBLEED)) { + if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD || + boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_HYGON) { + if (IS_ENABLED(CONFIG_MITIGATION_UNRET_ENTRY)) + retbleed_mitigation =3D RETBLEED_MITIGATION_UNRET; + else if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY) && + boot_cpu_has(X86_FEATURE_IBPB)) + retbleed_mitigation =3D RETBLEED_MITIGATION_IBPB; + } + } else { + retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } } } @@ -1438,7 +1442,8 @@ static void __init retbleed_apply_mitigation(void) } =20 if (mitigate_smt && !boot_cpu_has(X86_FEATURE_STIBP) && - (retbleed_nosmt || cpu_mitigations_auto_nosmt())) + (retbleed_nosmt || cpu_mitigations_auto_nosmt() || + cpu_mitigate_attack_vector(CPU_MITIGATE_CROSS_THREAD))) cpu_smt_disable(false); =20 } --=20 2.34.1