From nobody Sun Nov 24 15:05:19 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.55]) (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 1D0C22170CE for ; Tue, 5 Nov 2024 21:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843740; cv=fail; b=K8e2udT6AfWPhucRfUuxqxCS+8uG4KzSe+lEFWezM/MiC3DsSw13ni0oddJApZBrMOI9p7qLFVuuBw4M1HhdxoVkLlOPgWiwR9hfGFbdYbRmX1Z4xxFE5Uc9nJD5gnQJm1mCxG2Ia8Xp0rdBanZhqsGazEz7SG21rgkGV1VZFLc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730843740; c=relaxed/simple; bh=Q0TVtakTOeZNHp+Y5aZ7E7a+J6uQpARB2DRD9kidytQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EXYHKi3812AZeAodAAeF7BfjA5lrO0w2axmoufGox8vhW7gqebFJZXiqnsjWgUNib/4vnaKyVgNxi9yhR8jxMSGnpybxU2ojC14qAvwJsyBT91W2ENhf+2QSOfh4biZop6xIQ0fQEWyeJBzGq8YKpU0hoP9E2CqWgIwCpGFPgaE= 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=BmurYv3U; arc=fail smtp.client-ip=40.107.236.55 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="BmurYv3U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ho6t63QMZLmnITWJKehcEHxQukn3+meQtPHtb+VQwMapw4FZCTEZMhGJUqdaYR/eXzQYQ9L5UeDJS0nGsH95TIAKi74wZV9ZnPHx225tCz00XmI+vRM+i5D5EkvdKnS00cdBE1BmgowhkqLriAdgRA/z/Rn88Ix7FdNTs/ZIXTSpuBV6dt7MosYsSsnkw/ZzkK7H3kQJQv/UYeEzhsZPt4Xj3HyYGNkWI/+ywVZ1IpLyu7oyeUs+flIDsz+xz2r5bbRLUGhlqHSa44PLd9wpnbamZuzc7ddEdpTqFql5FhIGN5mxPOneJ69DUBwxcBs0cp8AjcF9lIfPE56U5U3e3w== 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=rKKNqIHpsxjZxJ3iuU7qBcRJ70trhqSv73qS24qwBUg=; b=OclMR7X8JbL86Dk7CNTIcorKgGQ47dehpEl7i618XG7h3dab0FaIvEWg1Qva0omUH6EfSB16+OFhxJlbzqchCrJbbE8Ry14VPcVGHv6O9NLnFtPF922x3066a6OfBrSnAGqVB+y3TF8/T3Ozw3E6GRbH3U2SSGRLR9mg3Jw6xdq0Or6POakWuyGlzYZ8Bz+WX1wFVQc3ryho/JrWBKB4VPQ+wuN1BP9Rnvd5Zud0Hj5AHmYHLpLpnwPVlG+IUnlJVaeEWz9SMstgUo3ABHsdXos/Dp08EthyKx6/M6FL9DPDqYDFP/oNmQqphha1Efd4NT1Zwl8oo2jxqFTYEcaF5Q== 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=rKKNqIHpsxjZxJ3iuU7qBcRJ70trhqSv73qS24qwBUg=; b=BmurYv3U/S9JQjxeAOQBPhqQ2C1csnNq6SiibEW1eM6elvn8T4y5CW/7kBCorBZ5n4ioPAvCNfMuM6rZ7VqQFcWwdaAeu9DU65kvb3ePRTxix7jRgOwnldWavahtIl/GCzpu+jsPadZsNz34jr/ZQBcuK7DAK/aOUjADfQZgfx8= Received: from MN2PR15CA0063.namprd15.prod.outlook.com (2603:10b6:208:237::32) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 21:55:28 +0000 Received: from BN3PEPF0000B374.namprd21.prod.outlook.com (2603:10b6:208:237:cafe::ce) by MN2PR15CA0063.outlook.office365.com (2603:10b6:208:237::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 21:55:28 +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 BN3PEPF0000B374.mail.protection.outlook.com (10.167.243.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 21:55:28 +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; Tue, 5 Nov 2024 15:55:26 -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 v2 10/35] x86/bugs: Restructure gds mitigation Date: Tue, 5 Nov 2024 15:54:30 -0600 Message-ID: <20241105215455.359471-11-david.kaplan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105215455.359471-1-david.kaplan@amd.com> References: <20241105215455.359471-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: BN3PEPF0000B374:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a0b8c4b-f3ba-418f-8c4b-08dcfde48fd6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R2XfvSXDOfDqc44gJheeVWVUuZVhWhRNtDBzwuyyuKT/Tk22kYLZI7la7do/?= =?us-ascii?Q?msT9JplnPbCF4qSnwxsmbbxkMCdNUw+lUPHYBkFfVx4BUwCVlBIBRuP7exaX?= =?us-ascii?Q?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P8Jh+s2COlDp?= =?us-ascii?Q?vIyXMktnmJ2y8nBUpXgWKT1ZVcOYBmCt3dPSc4JaH015NGlsp1hjRAq2h1df?= =?us-ascii?Q?wlQwKMICPCC0xLatYpRXZVyla5PDnuIAKS3dmxK4pEgpfdPD/fswQrXmqdud?= =?us-ascii?Q?JRQWE2TF6WfbeEk0vS+2GzVPbAwCqkcpxiTO65G09LB7p1Fgdr7uxL7laKMA?= =?us-ascii?Q?ICEdmyQUK6UV1x3T8vijQTQArxPiAUIRLGd6ZbGOTXTZuvKiIgOficpyQmFL?= =?us-ascii?Q?7rz+fDAtt0LejxAhXeiBONTK4+PuAnBJDxxY/19SrPl0gR49yIUPdVcAysnG?= =?us-ascii?Q?Sc5DGDNBuzql9PQdK/nC4hZ015keRFCgACuN1EW5t3ZTLLPAS1op0zFx2uzU?= =?us-ascii?Q?XU6NOPTZuUqClhx+XCFP9A+Lnd/sM9XHM+4lS6+xok3Tuebjdg=3D=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)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 21:55:28.6716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a0b8c4b-f3ba-418f-8c4b-08dcfde48fd6 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: BN3PEPF0000B374.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 Content-Type: text/plain; charset="utf-8" Restructure gds mitigation to use select/apply functions to create consistent vulnerability handling. Define new AUTO mitigation for gds. Signed-off-by: David Kaplan --- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 452aa5994aac..37056bdd3a9b 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -76,6 +76,7 @@ static void __init srbds_apply_mitigation(void); static void __init l1d_flush_select_mitigation(void); static void __init srso_select_mitigation(void); static void __init gds_select_mitigation(void); +static void __init gds_apply_mitigation(void); =20 /* The base value of the SPEC_CTRL MSR without task-specific bits set */ u64 x86_spec_ctrl_base; @@ -220,6 +221,7 @@ void __init cpu_select_mitigations(void) mmio_apply_mitigation(); rfds_apply_mitigation(); srbds_apply_mitigation(); + gds_apply_mitigation(); } =20 /* @@ -801,6 +803,7 @@ early_param("l1d_flush", l1d_flush_parse_cmdline); =20 enum gds_mitigations { GDS_MITIGATION_OFF, + GDS_MITIGATION_AUTO, GDS_MITIGATION_UCODE_NEEDED, GDS_MITIGATION_FORCE, GDS_MITIGATION_FULL, @@ -809,7 +812,7 @@ enum gds_mitigations { }; =20 static enum gds_mitigations gds_mitigation __ro_after_init =3D - IS_ENABLED(CONFIG_MITIGATION_GDS) ? GDS_MITIGATION_FULL : GDS_MITIGATION_= OFF; + IS_ENABLED(CONFIG_MITIGATION_GDS) ? GDS_MITIGATION_AUTO : GDS_MITIGATION_= OFF; =20 static const char * const gds_strings[] =3D { [GDS_MITIGATION_OFF] =3D "Vulnerable", @@ -850,6 +853,7 @@ void update_gds_msr(void) case GDS_MITIGATION_FORCE: case GDS_MITIGATION_UCODE_NEEDED: case GDS_MITIGATION_HYPERVISOR: + case GDS_MITIGATION_AUTO: return; } =20 @@ -873,13 +877,16 @@ static void __init gds_select_mitigation(void) =20 if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) { gds_mitigation =3D GDS_MITIGATION_HYPERVISOR; - goto out; + return; } =20 if (cpu_mitigations_off()) gds_mitigation =3D GDS_MITIGATION_OFF; /* Will verify below that mitigation _can_ be disabled */ =20 + if (gds_mitigation =3D=3D GDS_MITIGATION_AUTO) + gds_mitigation =3D GDS_MITIGATION_FULL; + /* No microcode */ if (!(x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)) { if (gds_mitigation =3D=3D GDS_MITIGATION_FORCE) { @@ -892,7 +899,7 @@ static void __init gds_select_mitigation(void) } else { gds_mitigation =3D GDS_MITIGATION_UCODE_NEEDED; } - goto out; + return; } =20 /* Microcode has mitigation, use it */ @@ -914,8 +921,14 @@ static void __init gds_select_mitigation(void) gds_mitigation =3D GDS_MITIGATION_FULL_LOCKED; } =20 +} + +static void __init gds_apply_mitigation(void) +{ + if (!boot_cpu_has_bug(X86_BUG_GDS)) + return; + update_gds_msr(); -out: pr_info("%s\n", gds_strings[gds_mitigation]); } =20 --=20 2.34.1