From nobody Wed Oct 8 05:57:16 2025 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2072.outbound.protection.outlook.com [40.107.101.72]) (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 98B76283FD7; Tue, 1 Jul 2025 20:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400903; cv=fail; b=dTv35v6rWENRKq7N5IZfRCJBd9a99MZdEudJmFNCRTuJGeM2dXTIM2lffbqU9shk4S7PyD50p42y6bsRwIpuObuLP9GuVxWUmddnvDRuTC6ZfdQPLCyACWLunycv9b20qGbGZA7aXWiXB9BgVppIzrXBvvlq3uzkw3F8j/o4Qhg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400903; c=relaxed/simple; bh=SB1wYF+yx0cHIZHraE2D44TLNggMmV9xD/BmgNIDs1s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rDtiH+QIpaHLxfgAj+dCwX4jkyt3vrVH3ykMZlXIgT+wgKrf/5FfyLqSdPFUG5rj6ivRNCz6gXEYVW8pIuQe1/fcJELhHOJpyPD08npne2kn6RpF6qIN85HjRVuP08fDMRq1xKkgHt4pj/w9OeY5K8KDExlT7tRz48DS0wFlkfM= 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=leEbNGyQ; arc=fail smtp.client-ip=40.107.101.72 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="leEbNGyQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h4yVC5z0PYnA6vJG9gbENkbkOwXQNNQcDM9pIGwDyLrR/Au9blj6WFfI+0rOZYXyDW0JN5COsUt8rpoki4kcHDsRxakAsIQClajrls0U6kLS7s2cDito1i6OG/qS92OH1FBDFZQY870qHpF/fT2hf3fhQbcyCF+jXjOBz5qj38cD0BzRs7zeC9V0uA3Vg+FPUv4/AV4rsPfAr3WyVlZ+n6b/cz2EyfwCUyaEriGQGC0MXGDyCVREBimTt7quQNqZS+yIUU6njPMYa9qLXZhiIhkWUbv7lLmpXUrEN0dOnxX2HirZWQy9P6KqtKWkCsC3qOXdm1ImqB3psOOojs10XA== 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=xkKLJnlF/78OEYVfLA8TArPEL2ti8EssOb2Dwys1WIY=; b=NFt+/p64MiUHQa+SP5aqrc0tTmkvmxW4iQzz7yxutpadmYyfkfBMpnJrmNWBCqVTfG+0PeuKxUMDaVNasSbKLjM9wjkML+Vl7G5YucUA6BY4g4naJp7VnZpHQ9rvbcMg2a92HCyevGzhKl9UAxPR+rQrWSO9Dl67c3aGHl2g1R4DfNM0+2DcZ0yg3R4e1k+2ydzhnkz5Hqdjaw01G6Fnoi19Mopc3xIHElhrTXquijmvnHAdBpEpdUOaqDYKBvApDMkOfIH4Wy+6KQi3on1U3flPgUI6lOPf2ntOWFCu3uZmzFa+eW9e4kwj+MFEaFj7V6GYEc5eMC/dYg8pNTEvbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=xkKLJnlF/78OEYVfLA8TArPEL2ti8EssOb2Dwys1WIY=; b=leEbNGyQjDj0DIxZ58okuHcR3hNf3FD08JJMNeh+a5jEb/IkAN/9r4mz8RrLQJQzLZwDhJ16ByA+xLLDf362/aGOMg4VPn3zg8pG8HVY71z/shw538lH2LWIY491VqqhvF2ldTIDkz7L6zAiAxyCvtF0RcyWq7Aynb+4Ajhrxss= Received: from BYAPR04CA0007.namprd04.prod.outlook.com (2603:10b6:a03:40::20) by DS7PR12MB5742.namprd12.prod.outlook.com (2603:10b6:8:71::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.30; Tue, 1 Jul 2025 20:14:59 +0000 Received: from BY1PEPF0001AE1D.namprd04.prod.outlook.com (2603:10b6:a03:40:cafe::6) by BYAPR04CA0007.outlook.office365.com (2603:10b6:a03:40::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.20 via Frontend Transport; Tue, 1 Jul 2025 20:14:58 +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 BY1PEPF0001AE1D.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:14:58 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:14:56 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 1/7] crypto: ccp - New bit-field definitions for SNP_PLATFORM_STATUS command Date: Tue, 1 Jul 2025 20:14:46 +0000 Message-ID: <5ad6bebf6c530d214aeb9b3987cae6e31ad15579.1751397223.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: BY1PEPF0001AE1D:EE_|DS7PR12MB5742:EE_ X-MS-Office365-Filtering-Correlation-Id: 13fafa61-d558-4758-545e-08ddb8dbf3ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pYKS+ry/FdFU1Dan0zrZpPT9kyrNOxxItvinUUr+UlIZeqkq7L0qV5kvl251?= =?us-ascii?Q?NN1VAD5Z4a3JRMm5dwykJe5WAOxWNhZu5Vb5ROXwepmOdXy90HRpUpnYX/9F?= =?us-ascii?Q?uHKs7KktcayST18293rfgKqw5VS341UYVM0slDXnrfa5qK6bMSbw8IpLoT0n?= =?us-ascii?Q?BHgQ4aMmTSycoEqomP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= =?us-ascii?Q?VlemGMbGwXTfVYZler17bBgQmLGnZTyDAMZNvEYBS+hGsmSAZqwcg82SdZGD?= =?us-ascii?Q?CS7Nw5RCSniCuklm40xhUY4m/+oqn2sPUZSoIv1PK5ijKYZvmFWWqaRzmkl+?= =?us-ascii?Q?0gSVTuGxiNA7c5gLvsAnZfEvOs7l7RoFG8m49gBZtexMTmjNEoH4fEm2sV6r?= =?us-ascii?Q?r2WuZKjSLG3iXbpI7Q27VZ9krCBjY5GdgtoYqPJEmYZZSQ2vjsLoRj/ZKotC?= =?us-ascii?Q?qpIXkJhmt+QVD4rVpQv/BGbEqtGIxu0xeU6dzDOLyvipRr5glIj9DaX2iJs8?= =?us-ascii?Q?pvtmU7uGNGQrrMpq5ByJTwLPDXN2DSudyKJiD6MhSaqSYBwuDXtmQ44wIhDN?= =?us-ascii?Q?4TjYDIasvpWTm/TDW7zD8wSaFS8B9Xx4nJ8gudxoZGh+h6TqpAcnF6K3Paui?= =?us-ascii?Q?+c5MdOZkwAyYR/66etLn7ERzDn94z663R+erAL1hXLoOOnrI/Q0/f1WZuA?= =?us-ascii?Q?=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)(7416014)(376014)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:14:58.4903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13fafa61-d558-4758-545e-08ddb8dbf3ed 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: BY1PEPF0001AE1D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5742 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Define new bit-field definitions returned by SNP_PLATFORM_STATUS command such as new capabilities like SNP_FEATURE_INFO command availability, ciphertext hiding enabled and capability. Reviewed-by: Tom Lendacky Signed-off-by: Ashish Kalra --- include/uapi/linux/psp-sev.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h index eeb20dfb1fda..c2fd324623c4 100644 --- a/include/uapi/linux/psp-sev.h +++ b/include/uapi/linux/psp-sev.h @@ -185,6 +185,10 @@ struct sev_user_data_get_id2 { * @mask_chip_id: whether chip id is present in attestation reports or not * @mask_chip_key: whether attestation reports are signed or not * @vlek_en: VLEK (Version Loaded Endorsement Key) hashstick is loaded + * @feature_info: whether SNP_FEATURE_INFO command is available + * @rapl_dis: whether RAPL is disabled + * @ciphertext_hiding_cap: whether platform has ciphertext hiding capabili= ty + * @ciphertext_hiding_en: whether ciphertext hiding is enabled * @rsvd1: reserved * @guest_count: the number of guest currently managed by the firmware * @current_tcb_version: current TCB version @@ -200,7 +204,11 @@ struct sev_user_data_snp_status { __u32 mask_chip_id:1; /* Out */ __u32 mask_chip_key:1; /* Out */ __u32 vlek_en:1; /* Out */ - __u32 rsvd1:29; + __u32 feature_info:1; /* Out */ + __u32 rapl_dis:1; /* Out */ + __u32 ciphertext_hiding_cap:1; /* Out */ + __u32 ciphertext_hiding_en:1; /* Out */ + __u32 rsvd1:25; __u32 guest_count; /* Out */ __u64 current_tcb_version; /* Out */ __u64 reported_tcb_version; /* Out */ --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2088.outbound.protection.outlook.com [40.107.95.88]) (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 8BFC72441A6; Tue, 1 Jul 2025 20:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400922; cv=fail; b=VwXX/hvlS/aXeefRhpVwX7/OAh1A7SPTnKMH1miaCLH6UML+Nvb2ocWU8QEX5Pprag64/Pzt83uzUxVXzmVmCGAaQUGi/jrEki8U4H1k0fmkpBqtk1X5HydDrUn6oZkHfSBCkEsziOMFBlRyiXC3Cz8DpYl+7iwryp1Ta5F3ejU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400922; c=relaxed/simple; bh=PCSWw3bmU7pvydph+mpvwfkpbqNAPXS6X5MSxiIZiHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gtnjN152S+fCdIsxPZgJZaH+WTavqbiyiqGjECw2bzeAmceHGEFzQ3H1jfg3SuoZ01a70qPtpMqO4hlrCmdartNpKQ6GO3kP0P1zUJjB/turWr6rIaKmEdfdnAQ1sqKYAER9dd690wLmj64fGuvZ2W/jM/vqm5cxxI5n2WePM9g= 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=kIG0sElI; arc=fail smtp.client-ip=40.107.95.88 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="kIG0sElI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VsJpYwo6zm6jqTkofP+EQmmT1mKdY9s02A7LrxSbF2zCq4yQEZ3FP6e2fU8eeD3p3uuzmb/Yf9lXw5CwgQBP5Nb0NZsQ2TV8bO7bs1ogNiQmAr8/6ijkMTlmvfinlq/sfPNV2+mV8Fgxlbf5NyQvTJi6vSt3vHC+p8M2T23TvEKEnT1BQP1WIHzQnuNBDd0xsLtTGNnT2IOp3BNj7lH3saY6uiPUikWTLIVkfWM/VJpi5xJ5eEJ0qqJ/VzDi7eKyiu1IQvMy3rGBTXnhTmCIG82YglHKXZlYDV+jRg9/RlBJ79BnrsDzsnQWaDLpYeSbmbEj9/jAXhKTBf+9FFNY6Q== 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=W1aYCuvLvbn4gi9xjSJ0qUrfIQG+6/ESmXgAdmILFtM=; b=WWRbYMdLa6edvM2oeOyQdI04A1dka4mMaHU2oRKVkoYYJsroSLa+c7CKtpufoMoGn1QsasPXKepu46RmUP5RQeqL3siFtV1YOApTBfgtq29ii+ETijK/ib//ubSlQt/y9EXSA0PQK2FLLWlvyKR9HGL4lSoElYTxc0NrU9GenvEvKIvU35Wuj8cd3gtRIHHMR2OgXuqOPi1eWpUelhOXV+ZmGiMpIfTjirPPQ4t/qelw00xIHwADf56epeZfQE2Jle7hK2gWrIa/i9fWHr7wAx7csLj27plPiVGMYFkjt4+aEVEaJo1HsQFeyzM0aURaRdYECbDE08FcyUxVbbLG1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=W1aYCuvLvbn4gi9xjSJ0qUrfIQG+6/ESmXgAdmILFtM=; b=kIG0sElIP2vjKTForH6MF1RZDjvcSeBpZhuyV6kXmb6kuABfzzo+WEukzjPKPMmncgGZLGPm89pq7ghRiGjTYYqPInAL4G4N4LXKllBMjtR63sS671ZyC0KwZncHRaCOVoxG8meQxhJYCbVviJ5+vLg/CToTTLJUleNwe+QhOAo= Received: from CH0PR03CA0345.namprd03.prod.outlook.com (2603:10b6:610:11a::29) by DS7PR12MB6047.namprd12.prod.outlook.com (2603:10b6:8:84::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.33; Tue, 1 Jul 2025 20:15:17 +0000 Received: from DS2PEPF0000343F.namprd02.prod.outlook.com (2603:10b6:610:11a:cafe::b0) by CH0PR03CA0345.outlook.office365.com (2603:10b6:610:11a::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.32 via Frontend Transport; Tue, 1 Jul 2025 20:15:17 +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 DS2PEPF0000343F.mail.protection.outlook.com (10.167.18.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:15:16 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:15:13 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 2/7] crypto: ccp - Cache SEV platform status and platform state Date: Tue, 1 Jul 2025 20:15:03 +0000 Message-ID: <69f95a382a6b5a6fb568aeba39b7c937fe552ed4.1751397223.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF0000343F:EE_|DS7PR12MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: d950817c-bd0f-453c-0190-08ddb8dbfe5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4NyP5VdmFC+EjWmMkKwSO7ivUtxlA8PQ7bDvpblkGAokUgju/6TAH/WpTR2C?= =?us-ascii?Q?oB1D5LbJZ5HYV9yqFoTu+qWfZ97sGURDH7l5Ms2k5XYL0MHorWYqez9hXCye?= =?us-ascii?Q?rrtOIVQ2jnXN0dMuOSm1m2GyADJxRUczYHG/2PQwjq8fko4nauXCzjWVMuuF?= =?us-ascii?Q?Hbs/ZARI5VHAERhKdtIL4ea9t6aevkP+/RG/EZ6yxyNvWG4EXrQ/l0ZhhANo?= =?us-ascii?Q?bA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Zrg0gQIyxqfxAOozWlPPjn68zB?= =?us-ascii?Q?zB3URfHDHDlugE+f6NnuyIMPG8LUCu3UajvQbe1AlxucJo6We3dBAQeaQ7uc?= =?us-ascii?Q?ZSqSnOzTYcq/Jaw3uSFKL2mYdklPuWdCH4hKRkt3zEEI4pAigQhd1zRk/8EB?= =?us-ascii?Q?9vG9lvWdb+FGSv1fMBDKSFx0BPE4rDBQ9lY52KYQ2BvGy+mtHG1UEEv0kCrG?= =?us-ascii?Q?XtgJAwzkZCAzu1HDtGsLCGRDSUKAhsWfeP3dZ+oMRT++EXESeHzTnxP9Dkdp?= =?us-ascii?Q?ycAbJaoMmm0dWHU+JJvFXMfucoAqSOqc/DMf1C0Xkw5OWGIcFir3flRLQZjL?= =?us-ascii?Q?kkcvS6FXhXC+WH0Lzf/76fAVOv8/nqeqgPp4nqf9m9mQUOuXgU/gLObhIj+D?= =?us-ascii?Q?dTFDzJnAwSZnyRxQSRIjKiF5EyGC6oVoPh9XlVJXDndfr14YpEFOg8fv+g?= =?us-ascii?Q?=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)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:15:16.0342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d950817c-bd0f-453c-0190-08ddb8dbfe5a 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: DS2PEPF0000343F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6047 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Cache the SEV platform status into sev_device structure and use this cached SEV platform status for api_major/minor/build. The platform state is unique between SEV and SNP and hence needs to be tracked independently. Remove the state field from sev_device structure and instead track SEV state from the cached SEV platform status. Suggested-by: Tom Lendacky Signed-off-by: Ashish Kalra Reviewed-by: Tom Lendacky --- drivers/crypto/ccp/sev-dev.c | 22 ++++++++++++---------- drivers/crypto/ccp/sev-dev.h | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 17edc6bf5622..5a2e1651d171 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1286,7 +1286,7 @@ static int __sev_platform_init_locked(int *error) =20 sev =3D psp_master->sev_data; =20 - if (sev->state =3D=3D SEV_STATE_INIT) + if (sev->sev_plat_status.state =3D=3D SEV_STATE_INIT) return 0; =20 __sev_platform_init_handle_tmr(sev); @@ -1318,7 +1318,7 @@ static int __sev_platform_init_locked(int *error) return rc; } =20 - sev->state =3D SEV_STATE_INIT; + sev->sev_plat_status.state =3D SEV_STATE_INIT; =20 /* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus(); @@ -1347,7 +1347,7 @@ static int _sev_platform_init_locked(struct sev_platf= orm_init_args *args) =20 sev =3D psp_master->sev_data; =20 - if (sev->state =3D=3D SEV_STATE_INIT) + if (sev->sev_plat_status.state =3D=3D SEV_STATE_INIT) return 0; =20 rc =3D __sev_snp_init_locked(&args->error); @@ -1384,7 +1384,7 @@ static int __sev_platform_shutdown_locked(int *error) =20 sev =3D psp->sev_data; =20 - if (sev->state =3D=3D SEV_STATE_UNINIT) + if (sev->sev_plat_status.state =3D=3D SEV_STATE_UNINIT) return 0; =20 ret =3D __sev_do_cmd_locked(SEV_CMD_SHUTDOWN, NULL, error); @@ -1394,7 +1394,7 @@ static int __sev_platform_shutdown_locked(int *error) return ret; } =20 - sev->state =3D SEV_STATE_UNINIT; + sev->sev_plat_status.state =3D SEV_STATE_UNINIT; dev_dbg(sev->dev, "SEV firmware shutdown\n"); =20 return ret; @@ -1502,7 +1502,7 @@ static int sev_ioctl_do_pek_pdh_gen(int cmd, struct s= ev_issue_cmd *argp, bool wr if (!writable) return -EPERM; =20 - if (sev->state =3D=3D SEV_STATE_UNINIT) { + if (sev->sev_plat_status.state =3D=3D SEV_STATE_UNINIT) { rc =3D sev_move_to_init_state(argp, &shutdown_required); if (rc) return rc; @@ -1551,7 +1551,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd = *argp, bool writable) data.len =3D input.length; =20 cmd: - if (sev->state =3D=3D SEV_STATE_UNINIT) { + if (sev->sev_plat_status.state =3D=3D SEV_STATE_UNINIT) { ret =3D sev_move_to_init_state(argp, &shutdown_required); if (ret) goto e_free_blob; @@ -1606,10 +1606,12 @@ static int sev_get_api_version(void) return 1; } =20 + /* Cache SEV platform status */ + sev->sev_plat_status =3D status; + sev->api_major =3D status.api_major; sev->api_minor =3D status.api_minor; sev->build =3D status.build; - sev->state =3D status.state; =20 return 0; } @@ -1837,7 +1839,7 @@ static int sev_ioctl_do_pek_import(struct sev_issue_c= md *argp, bool writable) data.oca_cert_len =3D input.oca_cert_len; =20 /* If platform is not in INIT state then transition it to INIT */ - if (sev->state !=3D SEV_STATE_INIT) { + if (sev->sev_plat_status.state !=3D SEV_STATE_INIT) { ret =3D sev_move_to_init_state(argp, &shutdown_required); if (ret) goto e_free_oca; @@ -2008,7 +2010,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_c= md *argp, bool writable) =20 cmd: /* If platform is not in INIT state then transition it to INIT. */ - if (sev->state !=3D SEV_STATE_INIT) { + if (sev->sev_plat_status.state !=3D SEV_STATE_INIT) { if (!writable) { ret =3D -EPERM; goto e_free_cert; diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h index 3e4e5574e88a..24dd8ff8afaa 100644 --- a/drivers/crypto/ccp/sev-dev.h +++ b/drivers/crypto/ccp/sev-dev.h @@ -42,7 +42,6 @@ struct sev_device { =20 struct sev_vdata *vdata; =20 - int state; unsigned int int_rcvd; wait_queue_head_t int_queue; struct sev_misc_dev *misc; @@ -57,6 +56,8 @@ struct sev_device { bool cmd_buf_backup_active; =20 bool snp_initialized; + + struct sev_user_data_status sev_plat_status; }; =20 int sev_dev_init(struct psp_device *psp); --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) (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 A0215265296; Tue, 1 Jul 2025 20:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400941; cv=fail; b=MMp4R2mAXKJe2JeIXHmawb1vAV5BdWxKzIAeB/13IyaBZ2KQ0WFEzvuh8qHfC5g7nNDkdmpPnorbf8OhWCWgUK/qK9noNLo0xNcfvv8XxY7zoUhQFlS4DHF4jou1aKIXkUGKyaU4ZrG2WNJ+WqwALs6SuDUKMlLU1Dy2lut5jBU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400941; c=relaxed/simple; bh=pzDi2ixdXHvMOQ75IAaxTvZ8Oif5Tj+v9heTVJOt9UQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fN1YjbLBBCSlYY98SRxXDARModInHFPRXy3jDzCmHT91cswVNvs8Mfhzjn1sCK7CGa9/jguKMJuoptRJZhbnbS2xcIg01m5YVPhJ/6+QB0FHxtjUWfW68rxCRdmIWptD663Lj4q8YncP1aMiESxMEdztyfZvW6oAZmDNS3zROJ4= 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=ptgrBGN9; arc=fail smtp.client-ip=40.107.220.66 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="ptgrBGN9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V8Fnyx6ij2CZTag26fJW0QkgwXJxpDvIuT1GI/cssqQE2PKHDcaiE/cLx06vqhEnQ0arx9nxKBfUuP9NeC9fYItDlhazAzyF0Hb4CTgUZQO92CSjEL4gqNl75TjovcO5+8Bw1jn+TQknemkjIv/H8B2z+9M7MkufZ+KUC6JmiP72JvzJJVLd69fBLfA5n5MiGhwjQjCs9JDIFjkha+O9cq0d+CAzqIWJndxZSBhoZqTB0TN2u25Qqm1RiGdnHfggVInNNfEevMHMqo40KIas/wq0dOzdHYGQV3XipJb9uPYJRixlCz+TOJuSVGpPUUe9vK/GpNux3FVri/oaf56QUA== 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=0oWqI/fausB4ZH8cWR/XakSkviVBgx/hBGvQgPL7DN0=; b=Pb/Rxfn0QSlqHZe1OSj6V9IJN8eCzKJI1WO8vhQQYxzT8OaM3E5E8QnwPB1g0nKPvUhiz2XdFnHeb5LpyF0Mv0GFTChbWJBMIv+8HTsn+Kb14l7DsTsm+ppsFr9vtRRYL70srFd1WYvEKPAdNpWsdS6tsdM2lh+LCQEAXTXPmb4TjrYl6QItXGLCaS2Wkpu1DRY/lp1wPLpiNt9kaGm0lv3juxUvpDRNoKSTDyvYkH0nDjEtxVW56rAgLwOya4ib0TZ5kuwbHdPmQShZPhkbVPqPtOaGVKScW8KtBlJyFIHTiIlLov7RdWIZXPoG+m7chfUObKCO0i2rDl7HnIfr8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=0oWqI/fausB4ZH8cWR/XakSkviVBgx/hBGvQgPL7DN0=; b=ptgrBGN9YQ4Kj1pG2d9BsV5xAsz0EtPK343lK2U35JlBlfKQMuQiB+5HoMNwd356q5Ocpx2SrXE81GSLYj8GgAksUSl6837KQlf2WQTZjd3p4yCip6zEbzhQwUYn4E/sjkRlq06NyDCLzmGjNf3c6TMaVK6BK+Njg3EyRPWx/IQ= Received: from CH5P221CA0006.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::19) by SA1PR12MB8096.namprd12.prod.outlook.com (2603:10b6:806:326::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.19; Tue, 1 Jul 2025 20:15:35 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::b5) by CH5P221CA0006.outlook.office365.com (2603:10b6:610:1f2::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 20:15:35 +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 DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:15:34 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:15:30 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 3/7] crypto: ccp - Add support for SNP_FEATURE_INFO command Date: Tue, 1 Jul 2025 20:15:21 +0000 Message-ID: <5048d1bab32530214e7f3e4d73a4756cf374dee6.1751397223.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF00003439:EE_|SA1PR12MB8096:EE_ X-MS-Office365-Filtering-Correlation-Id: da25ddac-c94b-4de4-a401-08ddb8dc097b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BrLIZu/YwQYUgQ/3497C2jhB+w20DLyfXJcy2i+0l2zDLOMxWOnfi2wXJwuT?= =?us-ascii?Q?7aexeg3kCYEGluCGc3TPvwwD0HoAwm7D/bT1/aNpjGf/qezIpHWS2vPmp3RX?= =?us-ascii?Q?vdZZGyqkZ5UzQF0UrH+V4WYfkEeIDmpbL+kYUZlSKrk2AVyATAElhGO5C1fA?= =?us-ascii?Q?FhSNdo9DJosw54WetWHsrLMjC2xrx1CCYxMZT7pk4LEtzhB3ZVMoYwbfl+Kt?= =?us-ascii?Q?IQNpjgDlFFmJg5NTDX8OAxc71lQCR+4qxBwR2j9h4b30VIs0BNnbRvl/5dvS?= =?us-ascii?Q?JGax7bicCKyozoLU9xhACtsUIjBZDoZvegRylLVFExwcEGYQ/Fb8JgfJijES?= =?us-ascii?Q?xTKQNhZMkHZ1B/uyKeOjABF0xXwytDuJdPzo+fHu8Q0QnlnX+7+AJkp1Y/X0?= =?us-ascii?Q?TQv2+VTV4af8BGakPDZ2NvwsBBp0Pr6SMEBTWAVf4wNC/un1JHHrAuzeemth?= =?us-ascii?Q?4wwfGmWLrcY5UdNZ5f9rJrxzhbjffKQn6pTjgYZc+qWmD4w/qm8vDiLugomJ?= =?us-ascii?Q?8hvooVqqCmoP4kTy4z1j4vN8G3YfltRPfDnx/janWRq9wFobkTpzlcEXUE8f?= =?us-ascii?Q?GCrYBJsN1li5NE2MHLF5k46XJEtY/CC4DZeofj4FPdUxD0bX2o5DEfKcSvFW?= =?us-ascii?Q?1wucYzvOFdX95G0L77faU5qQtMeX/koKZlczHGGU3Y//xbvF3tx49FdVF+11?= =?us-ascii?Q?zKHeT10uxgCXGy+XShMcTtuUSmM4bA1Y9ssvM3UdcyE3CY1zDdeXqS+PV8pZ?= =?us-ascii?Q?qvhs1INeVq6wbsAV34J5kYBUfKZCTSuQ/+GVNVTA9ws/BI7DxrWactC2FhU6?= =?us-ascii?Q?dArc+zKX3hSILFNpefTA7iY1bxA3ItgIfr67c96L6DBskim7TcynXBGxZqQL?= =?us-ascii?Q?Sxh+rlGe9G2Pg/422jGBzkHQ5FGquFvP5qas5NeFtZfpQWbel7ytD+qV9r/V?= =?us-ascii?Q?Di739E8AZrsfBzMoByAajCcg8MheGGJenF+3c1l3wbdq9OLBzeVOLV82RvcU?= =?us-ascii?Q?kgktKV4kb9UMhCbu/ctOvpjp8FJlQAKyZ306uRxuwHQiSjDubfiP1w+Qcccm?= =?us-ascii?Q?x+2vJuonkGMRTORuWu0al3LaJle9HhDccQvdo7KvAm2/a5Yl3VX9M4NhKrPD?= =?us-ascii?Q?ivdvIx6aud5iEYrCscqOWb0H/Ma+V/dz+2RaDTOjUc2MsGXlfGCo+RvMDR62?= =?us-ascii?Q?6Zz21I0GU9P/+mMJM8jE1XC8z9TM7uKw7A6XrkOuq0hBSrMPw+sdy8tuze+r?= =?us-ascii?Q?SmpwP395wmni95M0u9xVDD6CHuCr6N+VbNvq3DqYovNr61oEE2LDw8cPixRp?= =?us-ascii?Q?hEqIUyhnEfGCwbz+BlXQu4g5PC80BuFMZwJdO7v3ireEk+Q4MX+CdwL7Hju3?= =?us-ascii?Q?L/CsFDdC8z7TIeuW6eOShTM0XRrO8sdTwEN/fDw7fV/wKu4Do/afyaxIVPc+?= =?us-ascii?Q?XuYJLGo1MihJFhh6KWzXuNCkLqH3QbGpd4+88w28cPf4t8awtNT+wemZ9Rxx?= =?us-ascii?Q?3c7mo7YYaX9j+b7py4A4CbmovJI19aCuGc0+KPy7poBuETG2Le1sV/eIOQ?= =?us-ascii?Q?=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)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:15:34.7130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da25ddac-c94b-4de4-a401-08ddb8dc097b 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: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8096 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra The FEATURE_INFO command provides hypervisors a programmatic means to learn about the supported features of the currently loaded firmware. FEATURE_INFO command leverages the same mechanism as the CPUID instruction. Instead of using the CPUID instruction to retrieve Fn8000_0024, software can use FEATURE_INFO. Switch to using SNP platform status instead of SEV platform status if SNP is enabled and cache SNP platform status and feature information from CPUID 0x7fff_0024, sub-function 0, in the sev_device structure. Suggested-by: Tom Lendacky Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 72 ++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/sev-dev.h | 3 ++ include/linux/psp-sev.h | 29 +++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 5a2e1651d171..d1517a91a27d 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -233,6 +233,7 @@ static int sev_cmd_buffer_len(int cmd) case SEV_CMD_SNP_GUEST_REQUEST: return sizeof(struct sev_data_snp_guest_= request); case SEV_CMD_SNP_CONFIG: return sizeof(struct sev_user_data_snp_config); case SEV_CMD_SNP_COMMIT: return sizeof(struct sev_data_snp_commit); + case SEV_CMD_SNP_FEATURE_INFO: return sizeof(struct sev_data_snp_feature= _info); default: return 0; } =20 @@ -1073,6 +1074,67 @@ static void snp_set_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } =20 +static int snp_get_platform_data(struct sev_device *sev, int *error) +{ + struct sev_data_snp_feature_info snp_feat_info; + struct snp_feature_info *feat_info; + struct sev_data_snp_addr buf; + struct page *page; + int rc; + + /* + * This function is expected to be called before SNP is not + * initialized. + */ + if (sev->snp_initialized) + return -EINVAL; + + buf.address =3D __psp_pa(&sev->snp_plat_status); + rc =3D sev_do_cmd(SEV_CMD_SNP_PLATFORM_STATUS, &buf, error); + if (rc) { + dev_err(sev->dev, "SNP PLATFORM_STATUS command failed, ret =3D %d, error= =3D %#x\n", + rc, *error); + return rc; + } + + sev->api_major =3D sev->snp_plat_status.api_major; + sev->api_minor =3D sev->snp_plat_status.api_minor; + sev->build =3D sev->snp_plat_status.build_id; + + /* + * Do feature discovery of the currently loaded firmware, + * and cache feature information from CPUID 0x8000_0024, + * sub-function 0. + */ + if (!sev->snp_plat_status.feature_info) + return 0; + + /* + * Use dynamically allocated structure for the SNP_FEATURE_INFO + * command to ensure structure is 8-byte aligned, and does not + * cross a page boundary. + */ + page =3D alloc_page(GFP_KERNEL); + if (!page) + return -ENOMEM; + + feat_info =3D page_address(page); + snp_feat_info.length =3D sizeof(snp_feat_info); + snp_feat_info.ecx_in =3D 0; + snp_feat_info.feature_info_paddr =3D __psp_pa(feat_info); + + rc =3D sev_do_cmd(SEV_CMD_SNP_FEATURE_INFO, &snp_feat_info, error); + if (!rc) + sev->snp_feat_info_0 =3D *feat_info; + else + dev_err(sev->dev, "SNP FEATURE_INFO command failed, ret =3D %d, error = =3D %#x\n", + rc, *error); + + __free_page(page); + + return rc; +} + static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg) { struct sev_data_range_list *range_list =3D arg; @@ -1599,6 +1661,16 @@ static int sev_get_api_version(void) struct sev_user_data_status status; int error =3D 0, ret; =20 + /* + * Cache SNP platform status and SNP feature information + * if SNP is available. + */ + if (cc_platform_has(CC_ATTR_HOST_SEV_SNP)) { + ret =3D snp_get_platform_data(sev, &error); + if (ret) + return 1; + } + ret =3D sev_platform_status(&status, &error); if (ret) { dev_err(sev->dev, diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h index 24dd8ff8afaa..5aed2595c9ae 100644 --- a/drivers/crypto/ccp/sev-dev.h +++ b/drivers/crypto/ccp/sev-dev.h @@ -58,6 +58,9 @@ struct sev_device { bool snp_initialized; =20 struct sev_user_data_status sev_plat_status; + + struct sev_user_data_snp_status snp_plat_status; + struct snp_feature_info snp_feat_info_0; }; =20 int sev_dev_init(struct psp_device *psp); diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 0f5f94137f6d..935547c26985 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -107,6 +107,7 @@ enum sev_cmd { SEV_CMD_SNP_DOWNLOAD_FIRMWARE_EX =3D 0x0CA, SEV_CMD_SNP_COMMIT =3D 0x0CB, SEV_CMD_SNP_VLEK_LOAD =3D 0x0CD, + SEV_CMD_SNP_FEATURE_INFO =3D 0x0CE, =20 SEV_CMD_MAX, }; @@ -814,6 +815,34 @@ struct sev_data_snp_commit { u32 len; } __packed; =20 +/** + * struct sev_data_snp_feature_info - SEV_SNP_FEATURE_INFO structure + * + * @length: len of the command buffer read by the PSP + * @ecx_in: subfunction index + * @feature_info_paddr : SPA of the FEATURE_INFO structure + */ +struct sev_data_snp_feature_info { + u32 length; + u32 ecx_in; + u64 feature_info_paddr; +} __packed; + +/** + * struct feature_info - FEATURE_INFO structure + * + * @eax: output of SNP_FEATURE_INFO command + * @ebx: output of SNP_FEATURE_INFO command + * @ecx: output of SNP_FEATURE_INFO command + * #edx: output of SNP_FEATURE_INFO command + */ +struct snp_feature_info { + u32 eax; + u32 ebx; + u32 ecx; + u32 edx; +} __packed; + #ifdef CONFIG_CRYPTO_DEV_SP_PSP =20 /** --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) (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 3AF05382; Tue, 1 Jul 2025 20:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400955; cv=fail; b=Nw2Mcxk16+Aw563klIVQxOKdsY3mhjeKdIBnq9JsQFFlxPx2nGqD+0dslGybLz2kHQnxtvsfb89Ju3kbHvFk/aemxFDGni0Fj1/ss3tFnrWXNVpGyXfm27F8V/ORekDOKPSR1Z9vEe8sitym1LRiBvDVD3ZzjGJwhUfXugZZ2cA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400955; c=relaxed/simple; bh=QfnCeRx3YhFPUoxdtNZ+4EdLwvUIz/+51QaIIvAg9U0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rtdek9aeRikT1UvJDanoN+Vjoh2rL0kZ8QIBoZSoX5Lb4kqz88OtSHi6txyRuePSRBD+IPdpMYT3eqneEhvdvmRD+jgh/ODsV0Wt+M3OKSuisOQcXBXIZLlB0QqwRze+iO/zLTRNieBiE30H9OhBh4MRRGVJrQr+tLfY+kCU6Sw= 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=ZFpe6kIz; arc=fail smtp.client-ip=40.107.220.66 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="ZFpe6kIz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AUu7DbNoR7LWzeamT0YB5oeXW5nftxZhA19Z946S7I7oNC/EUOzrax8xDh2tAM0mBJxDDjWkRiRhA3fhwBNp73+3FkG9cfx6hWTzwyONOcL87AeD3wysDYY4mFNMk7HrMXbL7bg3TQWnsPy0+bMnpnVGhvpRMdxJLnCMhdBeAxPNyAmsttQ+QgPoVYYvcrHON9KlJHFXUIfzjd5b7BSuBamg/hJ28W3JpJCqm+n2O2rmo6Dzhlc5ogtNLpi3lFilqZhapGefoW7C4ERjhb5c3/OVPN+e9+UPIxwdD7DNizY9vMIRnCPNa/96Ps0ni9dQltm1nhA2L2JCcdYlElc/3w== 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=18c0/hWJUO05qBkA1prdnwiZaT7lEK2XdUaU8LlkJlQ=; b=EPZ/HksBY5fJB5llZ6B3+L2otsCS5NCJ7kH2pi/u6rgZK0zihV+CtEbRevMPbKFfyIKrcJ95yto0i0v3fM3TaytH9pdtD9d6r4bj2LoxKOexZ+zDWxsozqBx72APURXVeSi82TnPKwnsNk2oQZMla64oyDrvfdiCAXggunCA00H8LzuvZKaFqRghLhRowd41zZO9+16pIhMMhBleFxCUNFcs4JIAxgGGLlBJi5MXy5v2iImDzNaw2GokYdUK15FbtVFk1g+pHvvr8ujH1pOlhGT6TRrAT4IAUmHD5F7cu7PWdflGgXBc/J46sD4tjLTjH9aLGh1CU7Pds5Xcl0eRoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=18c0/hWJUO05qBkA1prdnwiZaT7lEK2XdUaU8LlkJlQ=; b=ZFpe6kIz5Ps3DRA4ZLkdwvIndVYGyPeQ9AQ5LUM4gBz9vvQfkT1c5osUeYmUFl0fD3/pHlulczuAQ2/W0TVBgWkMoOt4Q0bjm/blXLEHvyQv9Dbade2bbLKDxY11OFYpVGbsZdBmASf1V9c2zSsTw0rPUm0DGl3TG+4AR1auu9Y= Received: from CH5P221CA0021.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::8) by MN6PR12MB8489.namprd12.prod.outlook.com (2603:10b6:208:474::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.32; Tue, 1 Jul 2025 20:15:50 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::ef) by CH5P221CA0021.outlook.office365.com (2603:10b6:610:1f2::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 20:15:50 +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 DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:15:50 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:15:48 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 4/7] crypto: ccp - Introduce new API interface to indicate SEV-SNP Ciphertext hiding feature Date: Tue, 1 Jul 2025 20:15:38 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF00003439:EE_|MN6PR12MB8489:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bf4516a-37a0-478c-02f4-08ddb8dc12dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RM0G8rwBmzpvR//Yj5I4/bNDBYjWFcJPrDJf4Ur9ZRFrJ79Jj3TksMspsCJ/?= =?us-ascii?Q?T2JaxH+HD+eDIU47tUDmKzk18xMo2q9i+PaCjTdBP3mBAyFTZTp8VbJX+res?= =?us-ascii?Q?a9NqvGQLt5DXk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G?= =?us-ascii?Q?dJGWlW65XIkBKDV1mkPKnuak7YKg1J4/j1yKr6273vSLe+LKVcEt7WEUxglE?= =?us-ascii?Q?D7K4pXMgIrl5UgQNlDTJ1quswEHPgraii1Hb0/EZMe3vN25VXRjPPdKHAzC/?= =?us-ascii?Q?KSGKY88G6a8cyywMtugkmb5Cx+EJW4tdNWHOBicytw4OGWApz60w7ZpyVohN?= =?us-ascii?Q?FlE9y0qVziFwA2pXYM7HpSoajitZkyjCUMmublaGq2wZN5xm+7YlJ9fXsd+9?= =?us-ascii?Q?oDmgtfnCgV8cXtXSD8g6rjz3E0LjlINAwxoXjnND0lp0MZrymb1J3cG6A+QY?= =?us-ascii?Q?MNjzXLzvO1nFkeCiADOsZk4cHC7L3fZXoaYLsNnO+Q2h7f3BEpr4a2zwc6k2?= =?us-ascii?Q?Cud5s4Ewd4ZZ23ETYDmgJx6subY+xkXTx5mAPhfQ9zeVrjdjz0gmj4+CGT+k?= =?us-ascii?Q?gq0weGMEjQytW5ybq37Oz0i/6w6Yc0UAlciG1wp3fIqFIBk+HdE714HSsPVR?= =?us-ascii?Q?TRHYidnkq4NhkROvNfZvL6nBluhs8/QsmL17NRTbI6ZqoanxGeNnyrgz1g?= =?us-ascii?Q?=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)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:15:50.4438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bf4516a-37a0-478c-02f4-08ddb8dc12dd 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: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8489 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Implement a new API interface that indicates both the support for the SEV-SNP Ciphertext Hiding feature by the SEV firmware and whether this feature is enabled in the platform BIOS. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 21 +++++++++++++++++++++ include/linux/psp-sev.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index d1517a91a27d..3f2bbba93617 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1074,6 +1074,27 @@ static void snp_set_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } =20 +bool sev_is_snp_ciphertext_hiding_supported(void) +{ + struct psp_device *psp =3D psp_master; + struct sev_device *sev; + + if (!psp || !psp->sev_data) + return false; + + sev =3D psp->sev_data; + + /* + * Feature information indicates if CipherTextHiding feature is + * supported by the SEV firmware and additionally platform status + * indicates if CipherTextHiding feature is enabled in the + * Platform BIOS. + */ + return ((sev->snp_feat_info_0.ecx & SNP_CIPHER_TEXT_HIDING_SUPPORTED) && + sev->snp_plat_status.ciphertext_hiding_cap); +} +EXPORT_SYMBOL_GPL(sev_is_snp_ciphertext_hiding_supported); + static int snp_get_platform_data(struct sev_device *sev, int *error) { struct sev_data_snp_feature_info snp_feat_info; diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 935547c26985..ca19fddfcd4d 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -843,6 +843,8 @@ struct snp_feature_info { u32 edx; } __packed; =20 +#define SNP_CIPHER_TEXT_HIDING_SUPPORTED BIT(3) + #ifdef CONFIG_CRYPTO_DEV_SP_PSP =20 /** @@ -986,6 +988,7 @@ void *psp_copy_user_blob(u64 uaddr, u32 len); void *snp_alloc_firmware_page(gfp_t mask); void snp_free_firmware_page(void *addr); void sev_platform_shutdown(void); +bool sev_is_snp_ciphertext_hiding_supported(void); =20 #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ =20 @@ -1022,6 +1025,8 @@ static inline void snp_free_firmware_page(void *addr)= { } =20 static inline void sev_platform_shutdown(void) { } =20 +static inline bool sev_is_snp_ciphertext_hiding_supported(void) { return f= alse; } + #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ =20 #endif /* __PSP_SEV_H__ */ --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2084.outbound.protection.outlook.com [40.107.93.84]) (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 2F433261573; Tue, 1 Jul 2025 20:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400973; cv=fail; b=upfIEm34e6nIcvfg3541QaVFmOUP5Euz3dv82jyPeJsE1VANgfW3JdO46qxMKbcz2mWvN263yHGDuSinN0/Sexf+Fsgq76wp+QsMq24XagngOzJeKNxNmi8B1tHnlRqS8No2+t8a8Gaoz7zKzRhhVA47gVkVlUO2IEHCGgtgEH4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400973; c=relaxed/simple; bh=5ljD1hrlAAxCS2KXYaphZ4aIMTOq2GD0/jlBVWRMimk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jc9Abj5VIgcN/EvlmiaA94GqoNlNekCrI95Jh4M2cQQub1rhohYkDP1ONOkGzby0zq2FreyYXRNUYKPA0lsXnMpb3rpjLOB3PJZWgiPtJ3DA9WRL33ZYm4GXBbCH/1moIJ5axziKU1PWk8/kk+WYTuVQrNUR9pOmQVqQjM0j5Gc= 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=MHjQThq/; arc=fail smtp.client-ip=40.107.93.84 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="MHjQThq/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rUGn6mg9ZBxgVYtMbD/QRQ8/dOmomA9Cbp15vubMadb7l4oaGvX/j74VqwC/qRasQv0DMspq1mccFIZA4XpDt24U52+KPT5oG38ikc4gxYt8/q7AoTyt8ltrb6PBf8R0r8XXOEqkIpoduFsi28D1j6RyLeD4301MngQTSmeWy8DA0IzpQDoTB/7Gtw67ADppI9xo3+B/CwHjx0yOM59Un7/wfNx6dqRGCGHf/1IdK+OCRVP5jxu4Z4eH493YYDodbjNDOyArcZ697tcD2LNTBYuCDue7L8Wn1j74c0grYHJfZLPekoEzeUi4Zm10ny2ane7TuZRRpbp+rppDKQX1qg== 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=QVxM/XUc1AbKN4AMuy6XADegUDEWQdz5NLxP+N5Dx8E=; b=jZ6xK/DNHZi8Z8LlBATcUGgbj5A+I0C7gmjRnTRSwsSNZIK5nEqDhiRtgYK+5/UT5BujPzdw7brTmvSF5jsuadTWQYjPTLiACfhqG91cIjzuPhKc6LF8vR7md9YlbYDMcN/R0mUU5tlCqbbed548UxJq+uhcLvy9JBOeOOclTiu6Jkw0LdS8k0OFifaiXQJgMt6clMkNHHhqGLgervB70imzSMsZzWYa+wlFaHNm/K/TCNq1w6SkuQegb8HzW+C5WbmfICv3mfsty6w4CbA4JirhBrFFK8O29Lob2DAoRs+O43pZdf9O8NOrFQNtz1xVSbpgM08E1Zskw3YBec1nLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=QVxM/XUc1AbKN4AMuy6XADegUDEWQdz5NLxP+N5Dx8E=; b=MHjQThq/erD4hxbe/kOPqfPf+mVe4NvfkeWE/sR19UBAHNwI2Qv+YMn+7ajWx5uQ4/2VnXTzEFpdPRgr9FIKh63Tfdw9iiS1LqFtO9+OkhCMdHbot9fDk86OS67iYfnFOX7FDlOKHM1/5pePU/N179KSzvDYmMjvhfroJS6Iang= Received: from DS7PR05CA0097.namprd05.prod.outlook.com (2603:10b6:8:56::26) by CYXPR12MB9387.namprd12.prod.outlook.com (2603:10b6:930:e6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.31; Tue, 1 Jul 2025 20:16:08 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:8:56:cafe::6b) by DS7PR05CA0097.outlook.office365.com (2603:10b6:8:56::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.18 via Frontend Transport; Tue, 1 Jul 2025 20:16:07 +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 DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:16:07 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:16:04 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 5/7] crypto: ccp - Add support to enable CipherTextHiding on SNP_INIT_EX Date: Tue, 1 Jul 2025 20:15:55 +0000 Message-ID: <68885411fddfdba2fe0c3ab023dc5d5eb108689b.1751397223.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF0000343A:EE_|CYXPR12MB9387:EE_ X-MS-Office365-Filtering-Correlation-Id: 418d09e2-6d74-4844-4c4b-08ddb8dc1d1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TJKPfYbHRQ1H5rmhBy0QjG5d6QP3QN5uPRCc76t4+HW+aRxFqVkzTeQ99uwC?= =?us-ascii?Q?VCtsMz538hHQBUNVqo3b3O34QyxJYkzpeB8356TuokbzvtFNqIqHJmO6U30h?= =?us-ascii?Q?m11wBc/h3xmfly7//WzrkRl7r7F5vr8OWZJKtOtpkneQq5Cmc1h4JYncKFau?= =?us-ascii?Q?WjdDO0QH197h+b2qstYN5zalbcuoXO5quOFzH0lXdtNG/oZDNo7MIqh0kevO?= =?us-ascii?Q?UOB5pmg+xNijtDBDZS9lZAUqUBAypqeCkTedRrt3a2ShiTGuD1dByKjGEf8z?= =?us-ascii?Q?7WyrKYgnS8cw6sE9lyn13KWaGQs40t5HtfbCTuooSNLZaFSge+DUFBHRoyML?= =?us-ascii?Q?2blpDG/WT0IVC9YB/w2gIjzujtrWzdcN5OTMtbq856YujqDVWRIElHsaGJ5Z?= =?us-ascii?Q?9mvXHyJnGm6gqrEjNoyGz9G5zDuOpHtlqvZhTuzeFCcig0M0Jj2USpqe4YYk?= =?us-ascii?Q?Aud5NVZ8905yzuXmPpPsktsf7BoVROLXOtxpW3JzrW1ELj0988HiDidwHyfT?= =?us-ascii?Q?de4ZcrYXJxDQMDsiEpG5PyQT8YXOmRcFaRxZdagf7jzVHzl/dmv62vYqmj53?= =?us-ascii?Q?dRoSSc83PYTc9C2P2yx6pODbLDx9mCtWwirFrqsx5YIUud5wajTawfdekhD1?= =?us-ascii?Q?b82qSW/QOn+KhNbZ4tiYT9HP0sbCIB1jzhKNMJ6mhIGzPhRhpwjcFUMA0ZZB?= =?us-ascii?Q?+eEbDETmp682OGjDe6CxgBfc8oqtaCgDj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PV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:16:07.6435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 418d09e2-6d74-4844-4c4b-08ddb8dc1d1d 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: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9387 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Ciphertext hiding needs to be enabled on SNP_INIT_EX. Enhance sev_platform_init_args by adding a new argument that enables the KVM module to specify whether the Ciphertext Hiding feature should be activated during SNP initialization. Additionally, this argument will allow for the definition of the maximum ASID that can be used for an SEV-SNP guest when Ciphertext Hiding is enabled. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 12 +++++++++--- include/linux/psp-sev.h | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 3f2bbba93617..c883ccf8c3ff 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1186,7 +1186,7 @@ static int snp_filter_reserved_mem_regions(struct res= ource *rs, void *arg) return 0; } =20 -static int __sev_snp_init_locked(int *error) +static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid) { struct psp_device *psp =3D psp_master; struct sev_data_snp_init_ex data; @@ -1247,6 +1247,12 @@ static int __sev_snp_init_locked(int *error) } =20 memset(&data, 0, sizeof(data)); + + if (max_snp_asid) { + data.ciphertext_hiding_en =3D 1; + data.max_snp_asid =3D max_snp_asid; + } + data.init_rmp =3D 1; data.list_paddr_en =3D 1; data.list_paddr =3D __psp_pa(snp_range_list); @@ -1433,7 +1439,7 @@ static int _sev_platform_init_locked(struct sev_platf= orm_init_args *args) if (sev->sev_plat_status.state =3D=3D SEV_STATE_INIT) return 0; =20 - rc =3D __sev_snp_init_locked(&args->error); + rc =3D __sev_snp_init_locked(&args->error, args->max_snp_asid); if (rc && rc !=3D -ENODEV) return rc; =20 @@ -1516,7 +1522,7 @@ static int snp_move_to_init_state(struct sev_issue_cm= d *argp, bool *shutdown_req { int error, rc; =20 - rc =3D __sev_snp_init_locked(&error); + rc =3D __sev_snp_init_locked(&error, 0); if (rc) { argp->error =3D SEV_RET_INVALID_PLATFORM_STATE; return rc; diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index ca19fddfcd4d..b6eda9c560ee 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -748,10 +748,13 @@ struct sev_data_snp_guest_request { struct sev_data_snp_init_ex { u32 init_rmp:1; u32 list_paddr_en:1; - u32 rsvd:30; + u32 rapl_dis:1; + u32 ciphertext_hiding_en:1; + u32 rsvd:28; u32 rsvd1; u64 list_paddr; - u8 rsvd2[48]; + u16 max_snp_asid; + u8 rsvd2[46]; } __packed; =20 /** @@ -800,10 +803,13 @@ struct sev_data_snp_shutdown_ex { * @probe: True if this is being called as part of CCP module probe, which * will defer SEV_INIT/SEV_INIT_EX firmware initialization until needed * unless psp_init_on_probe module param is set + * @max_snp_asid: maximum ASID usable for SEV-SNP guest if + * CipherTextHiding feature is to be enabled */ struct sev_platform_init_args { int error; bool probe; + unsigned int max_snp_asid; }; =20 /** --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2045.outbound.protection.outlook.com [40.107.95.45]) (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 DB6AB1E9B1C; Tue, 1 Jul 2025 20:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400988; cv=fail; b=YVMKfJMJ1/3uv0HhUcUx7l4zM9rrCcUQBNIV3TwgcxWbl8/k+zkbdEjXRES4lZMKGFneXtieILnbAqabTqoaOki779AYzsQFZZajWcP2X2EYhbeuGuufIlliXdgRmKAFXsMzdAZJXROAWZcb0Z/NGJzq6JPlP088KReOR0fYu1U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751400988; c=relaxed/simple; bh=5pCf4Gb8b6TzFM60kREt4yCseuNtIRvgYfF1P0fiKSs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ivVe8qLzcuel/EiBiiqdMUnxaMBc1kHIBm2Z98+AYbgsjKQBq260XcnE8e3qMLGv/WU7p6myqXDSbwr1+t2z8/VTjiZsV0LFlKIRZFMRmrCofxqzGg6AkbCl2LW/Fc6h+3n0taGhHUNy5C/2mj0WwxA7HBHwd6m1BT1ov80V6zI= 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=JverPyZ/; arc=fail smtp.client-ip=40.107.95.45 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="JverPyZ/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j14OeycT1peYap6o889xFFqRBwhpR218rOtuC5rSMmILi+FFrGq8E0fN6oJEi4G9RrILBQGZOWYDPeJfAO9hn4SQ4FCzzm+oV7eSmpHY5RZMWbcLoy/5VWuuAtyCmc3Nczfqww1UdJT88ufJ4lPYFqS7azo0gPWwh/Mw0BAi3tyvi6Ivzhw3atrePnqhoK3EfJYRn8DeLpGogdK3Tex3Dn745eUDqFKhPwpOC/C/6W8gpExbMJuKAlBQ3BWwcFt32rvRozb0VreUfcOhsqCEJM6oM9AZkPBcVKF+AXLa79m3HBVbaF7Lrifl3NeXnEiU0J/JPAJ8lk2zijVf0M309w== 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=IdWNoaFPCDX5THysnOoYVM7n9Bc1pkUPmtH3ARfPUPE=; b=SnWf4EqUilk9VKPiwZC/8MbWs8DGxwVxoHN2WVxh4YNLdi0R57Dwk83dPr1KhUOXxJH7Z4/E6FLM1wdhRSESSdUFzERIQSn/klMxGAbxSWj4EDehuiqBZQ8nUie7PDEmPtkhqsjQApryuvknRK+A6rMeyAw/Am/LEiK4+0L/pdQUEViMtxgin2ogz9dVg+sOL11nb1z+FGSxpA6OIK9TVRhZ+9K7EoZs+gLMoO/4HT5340Ifoq2MM+Ll6MBTOEyeMXtu0ywnn/8s9M190leIQk3wmCHqrT4fOR9VaJWRAE+E3qWCo2JRSEHmZyo+lHYL/9E6nQuPguvCBQlgcl4x8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=IdWNoaFPCDX5THysnOoYVM7n9Bc1pkUPmtH3ARfPUPE=; b=JverPyZ/JAcJE2A9itDIx6FyezvJvmqOUc8kC6518R2L5qWb1lQnuLhW6w7kd6zQuFjcLgC/KKn2aFYhtU6lP5sptKlMilTRxUA1lVObW3KnlXXhfFAGPZd0B4oYKgS8pih5H0iMggY1VsPgspAem7lSQRNS3qNZ5mgUIIRMxuc= Received: from DS0PR17CA0021.namprd17.prod.outlook.com (2603:10b6:8:191::16) by SA3PR12MB9130.namprd12.prod.outlook.com (2603:10b6:806:37f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.30; Tue, 1 Jul 2025 20:16:23 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:8:191:cafe::f8) by DS0PR17CA0021.outlook.office365.com (2603:10b6:8:191::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 20:16:23 +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 DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:16:23 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:16:21 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 6/7] KVM: SEV: Introduce new min,max sev_es and sev_snp asid variables Date: Tue, 1 Jul 2025 20:16:12 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF0000343E:EE_|SA3PR12MB9130:EE_ X-MS-Office365-Filtering-Correlation-Id: b99bef41-ae26-45ce-9596-08ddb8dc2673 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+QIlXYhA/TA/QC1EVGHr0RUqH10hPUvgrjL0Q9IzaSNs4pHYDYRjEXms4UTv?= =?us-ascii?Q?TIOs9EXIgauDa0sogeri6K+gdpLbRbXAZgAcNFIIRii2b3hsrgY1tNi9e80t?= =?us-ascii?Q?IAcGTqZzbsmtH8+G/nESiMtJDvU9+LazXMRNIJQ5WaIi/0udD/Ja+DWIjdRj?= =?us-ascii?Q?+JwQCTf+wKUBZIF6ofJR44af2hSUYE0aSvzUYQ+Ez8t1vK1iDLR/7fFCYWhh?= =?us-ascii?Q?ro+iU7MuVkzJUPD186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?us-ascii?Q?QnLymull7fbvgsjz6VhH6rewBYpDkM6gaC03EXr6XNJ+fjXhwSN3LMam2odx?= =?us-ascii?Q?9XEKYE5KrjP7EkLjg0p60vsrjxGypcMSBA/3oAXBQebWbOV8iTyVCTxIHYg5?= =?us-ascii?Q?sqZ5V4IanaDFSQpq+qAfoNvKdjRKo9APSRlYUZBv+bZpzaLihzbIrTdKYOY6?= =?us-ascii?Q?vs4b0LroARlNtvIXYKEWUXSXZ3AoWiW/9AEP0pV+wB6YYqr3zV9s98NsutlO?= =?us-ascii?Q?C3EObRNO57ScQWaw/GhBTPOQoo0r+5hXYXRm4uvZS2rSQ+UykMzady1bItTQ?= =?us-ascii?Q?cgWYyzB2C39eS2VD1VOxWqZpO7q7V8o/V4FGtRIfEvnCpcR0Rdy8PTFGZvHd?= =?us-ascii?Q?PZYbMqqp+08GAZ9N3ca0FY7G6v4JfvfwIRy/6sJqTUZsbvSxyEBVSH91Ag?= =?us-ascii?Q?=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)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:16:23.3113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b99bef41-ae26-45ce-9596-08ddb8dc2673 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: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9130 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Introduce new min, max sev_es_asid and sev_snp_asid variables. The new {min,max}_{sev_es,snp}_asid variables along with existing {min,max}_sev_asid variable simplifies partitioning of the SEV and SEV-ES+ ASID space. Suggested-by: Sean Christopherson Signed-off-by: Ashish Kalra Reviewed-by: Tom Lendacky --- arch/x86/kvm/svm/sev.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index fde328ed3f78..89ce9e298201 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -85,6 +85,10 @@ static DECLARE_RWSEM(sev_deactivate_lock); static DEFINE_MUTEX(sev_bitmap_lock); unsigned int max_sev_asid; static unsigned int min_sev_asid; +static unsigned int max_sev_es_asid; +static unsigned int min_sev_es_asid; +static unsigned int max_snp_asid; +static unsigned int min_snp_asid; static unsigned long sev_me_mask; static unsigned int nr_asids; static unsigned long *sev_asid_bitmap; @@ -172,20 +176,31 @@ static void sev_misc_cg_uncharge(struct kvm_sev_info = *sev) misc_cg_uncharge(type, sev->misc_cg, 1); } =20 -static int sev_asid_new(struct kvm_sev_info *sev) +static int sev_asid_new(struct kvm_sev_info *sev, unsigned long vm_type) { /* * SEV-enabled guests must use asid from min_sev_asid to max_sev_asid. * SEV-ES-enabled guest can use from 1 to min_sev_asid - 1. - * Note: min ASID can end up larger than the max if basic SEV support is - * effectively disabled by disallowing use of ASIDs for SEV guests. */ - unsigned int min_asid =3D sev->es_active ? 1 : min_sev_asid; - unsigned int max_asid =3D sev->es_active ? min_sev_asid - 1 : max_sev_asi= d; - unsigned int asid; + unsigned int min_asid, max_asid, asid; bool retry =3D true; int ret; =20 + if (vm_type =3D=3D KVM_X86_SNP_VM) { + min_asid =3D min_snp_asid; + max_asid =3D max_snp_asid; + } else if (sev->es_active) { + min_asid =3D min_sev_es_asid; + max_asid =3D max_sev_es_asid; + } else { + min_asid =3D min_sev_asid; + max_asid =3D max_sev_asid; + } + + /* + * The min ASID can end up larger than the max if basic SEV support is + * effectively disabled by disallowing use of ASIDs for SEV guests. + */ if (min_asid > max_asid) return -ENOTTY; =20 @@ -439,7 +454,7 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm= _sev_cmd *argp, if (vm_type =3D=3D KVM_X86_SNP_VM) sev->vmsa_features |=3D SVM_SEV_FEAT_SNP_ACTIVE; =20 - ret =3D sev_asid_new(sev); + ret =3D sev_asid_new(sev, vm_type); if (ret) goto e_no_asid; =20 @@ -2996,6 +3011,9 @@ void __init sev_hardware_setup(void) if (min_sev_asid =3D=3D 1) goto out; =20 + min_sev_es_asid =3D min_snp_asid =3D 1; + max_sev_es_asid =3D max_snp_asid =3D min_sev_asid - 1; + sev_es_asid_count =3D min_sev_asid - 1; WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count)); sev_es_supported =3D true; @@ -3019,11 +3037,11 @@ void __init sev_hardware_setup(void) if (boot_cpu_has(X86_FEATURE_SEV_ES)) pr_info("SEV-ES %s (ASIDs %u - %u)\n", str_enabled_disabled(sev_es_supported), - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); + min_sev_es_asid, max_sev_es_asid); if (boot_cpu_has(X86_FEATURE_SEV_SNP)) pr_info("SEV-SNP %s (ASIDs %u - %u)\n", str_enabled_disabled(sev_snp_supported), - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); + min_snp_asid, max_snp_asid); =20 sev_enabled =3D sev_supported; sev_es_enabled =3D sev_es_supported; --=20 2.34.1 From nobody Wed Oct 8 05:57:16 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) (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 33CAD26059B; Tue, 1 Jul 2025 20:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751401006; cv=fail; b=Cal1dme/3aa2Nyx6tASrq0z5kHkNQcftnGEAfGdkSN/JpUDrY5a7m2o6CBlHabY595nbLWYJFisTUcNom9jLX9mFua24kdZ/nJaWq7nQFI+612q+qRRlklJKZHzahwD90z5Em5BwKtlYsQz++pspGRCXi/Tg4YQUiVnNWkwEB5E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751401006; c=relaxed/simple; bh=UYojFtEOtmxQwBz7WlAr7/bT8rtwE65JPveIawE7+c0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VLez5g/ztcUYrVciHOGjDZ+ms+HXqmN2tWmujhDwoyRTV6svenzJ6FwLO7HoFfatAfw6yIggGVcPkj9Od4Z2cXtAjR29osyPz4dbTffYB5hCBeIzE8mPMjvODuCwAwrUD7td2KTcHOBxUtEixYBFpmbP1pP8HEeWcMzuoQAE26E= 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=376NTFN0; arc=fail smtp.client-ip=40.107.92.41 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="376NTFN0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QWRyhXqf3jAQ8m5gMRn4XQ5yT+4XgGKnG6ecLgnFUlrh7tqMukEIKm9GxDZMZv/VieOZDVasZbOD4+TrBP6K0Rc6/3c30/nT83NnEdJswU7WCrxUYh6TbeautGkoXZNvnLBxMTlFHPdmpoFsj+ESOiOiNnKmIATe5qm77eu00MUvlcaHLOOMYG1cCLu+auw3kYSXFR1KGC7AxC7V9DJaLC+1U9DxfsEPNdSakfsYcYKhlzn3kgzMKlQ4ulsDIGpQnX2ElNpkrOvVROfAmY7QkvfVvlm1m0Jg5cK58gx13dhPIA85ilX1zKz3vJKTJuZc1ekUffj1HSEK0mnn+EKgCA== 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=uofeaD9TnHqR0DtB5TqX01ogOiAswFC9S+oBe+UOC3I=; b=HHaGuYq1lH1uOf79/gPMINV70fZg0inInL2Q94Qpw/p3+crBg2UoZrqEVYWtgteN5DeihsIT8+OYJHpLQ6cFXWV9irUnHLL4XjqgF8SBDV1h03ESEjjsK+lSUKTdwNdDecUHgufbq9WXkwolcEydHxZU1xWoyWRTYetCKZqH8uAmMgGuXtqt/DRa518BRhS6GDVgrYSQmgq80SGd7mIGXk6hHtyMmesD0ftBSKst/nUuVVXTeM5ELL02uWScKjDqx24vLNNSc1NolRq8uLus0UjWz4SF2PU8OOcs1IWeJpBsfvC8odRza5VLurk7uV/+cO+NcN7nTF4dlGVj2PtyvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=uofeaD9TnHqR0DtB5TqX01ogOiAswFC9S+oBe+UOC3I=; b=376NTFN0vN2gEDQoq6GN0jqu6yezmAlGioU8oSan5thXyYHs+cDhygZy4Ro882h8/oGzdHCbFHFAIycyESA0c0KlgFx3PI+UgZCneVFnuG/8FkHivHR27SffgRFVCrBPKA8fN+NWplQoUvJmTeuNDN5x63tI5xMNm8UkxmDz7Ac= Received: from DM6PR05CA0054.namprd05.prod.outlook.com (2603:10b6:5:335::23) by DM4PR12MB6352.namprd12.prod.outlook.com (2603:10b6:8:a0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.19; Tue, 1 Jul 2025 20:16:41 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:335:cafe::cb) by DM6PR05CA0054.outlook.office365.com (2603:10b6:5:335::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 20:16:41 +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 DS2PEPF0000343D.mail.protection.outlook.com (10.167.18.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 20:16:40 +0000 Received: from purico-ed09host.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, 1 Jul 2025 15:16:37 -0500 From: Ashish Kalra To: , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 7/7] KVM: SEV: Add SEV-SNP CipherTextHiding support Date: Tue, 1 Jul 2025 20:16:28 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: DS2PEPF0000343D:EE_|DM4PR12MB6352:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b5e715e-13e7-4998-1ec2-08ddb8dc30eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dMLPVmJodqqgfkoZM0LewKXT/pBuwIuRk6tHfpAI6mw5oU3qbtnsD/7O6Kdj?= =?us-ascii?Q?L3r4SaqxBnYtVbTiAeTrs5NLa8iyA99yNZJzoFbrlT9oiGR2RwyBnzqO9yXq?= =?us-ascii?Q?ix36f5ayYXqla5YQVrxEdJy5qC1ZlWjkHGtRjwHHwKsK35nkK7pYjyZB9r9H?= =?us-ascii?Q?rb+vCAYxRnWEog4MAubiOOyAv+cgpFQTQ9lr2qY1OGDD/JJk8skjTSuwzSc/?= =?us-ascii?Q?U6WrcWQX2qIqovUxsD9I9t81VJGivO0OmgoXRtbPaBe/b7KnVTL7vp3nU1NS?= =?us-ascii?Q?ITmAzGM1jmrq7BHPGAT15gw7LIY63Lu6AETH505XbwSKsLMmUx41ZRbWB3Z3?= =?us-ascii?Q?B/nUsmC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= =?us-ascii?Q?d9dej8V8YoSC0aEC7lfhlXyE1Q9TkMsM11iMYl6uLWjY3Z5vwSMJYFAx96//?= =?us-ascii?Q?gVjrSZD6iMY1I/ykWYpA38Jywdto8AlygtpE4157x3CF1a8FSTkWZ9PeegRo?= =?us-ascii?Q?becVjxLopmsDjkNU9Ko2/ZRYmx5vIsfKnxCbH2+fSGH9j/AHm+hvfW7xHVcn?= =?us-ascii?Q?GstXMtYOnkZNfDt0J4jtPHAKbvc1ze6GtBtEV+FCAzgcdlcOgK8LxB2Lxv+S?= =?us-ascii?Q?Fza0BUCd5sqhQ01ZM0bc+JcqLlovJavxFin5oRSbQfDG5Ofi8/9i9fHhmw?= =?us-ascii?Q?=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)(82310400026)(1800799024)(7416014)(376014)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 20:16:40.8713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b5e715e-13e7-4998-1ec2-08ddb8dc30eb 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: DS2PEPF0000343D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6352 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Ciphertext hiding prevents host accesses from reading the ciphertext of SNP guest private memory. Instead of reading ciphertext, the host reads will see constant default values (0xff). The SEV ASID space is basically split into legacy SEV and SEV-ES+. Ciphertext hiding further partitions the SEV-ES+ ASID space into SEV-ES and SEV-SNP. Add new module parameter to the KVM module to enable Ciphertext hiding support and a user configurable system-wide maximum SNP ASID value. If the module parameter value is "max" then the complete SEV-ES+ ASID space is allocated to SEV-SNP guests. Suggested-by: Sean Christopherson Signed-off-by: Ashish Kalra --- .../admin-guide/kernel-parameters.txt | 19 ++++++ arch/x86/kvm/svm/sev.c | 58 ++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index ee0735c6b8e2..05e50c37969e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2942,6 +2942,25 @@ (enabled). Disable by KVM if hardware lacks support for NPT. =20 + kvm-amd.ciphertext_hiding_asids=3D + [KVM,AMD] Ciphertext hiding prevents host accesses from reading + the ciphertext of SNP guest private memory. Instead of reading + ciphertext, the host will see constant default values (0xff). + The SEV ASID space is split into legacy SEV and joint + SEV-ES and SEV-SNP ASID space. Ciphertext hiding further + partitions the joint SEV-ES/SEV-SNP ASID space into separate + SEV-ES and SEV-SNP ASID ranges with the SEV-SNP ASID range + starting at 1. For SEV-ES/SEV-SNP guests the maximum ASID + available is MIN_SEV_ASID - 1 and MIN_SEV_ASID value is + discovered by CPUID Fn8000_001F[EDX]. + + Format: { | "max" } + A non-zero value enables SEV-SNP CipherTextHiding feature and sets + how many ASIDs are available for SEV-SNP guests. + A Value of "max" assigns all ASIDs available in the joint SEV-ES + and SEV-SNP ASID range to SNP guests and also effectively disables + SEV-ES. + kvm-arm.mode=3D [KVM,ARM,EARLY] Select one of KVM/arm64's modes of operation. diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 89ce9e298201..16723b8e0e37 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -59,6 +59,11 @@ static bool sev_es_debug_swap_enabled =3D true; module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444); static u64 sev_supported_vmsa_features; =20 +static char ciphertext_hiding_asids[16]; +module_param_string(ciphertext_hiding_asids, ciphertext_hiding_asids, + sizeof(ciphertext_hiding_asids), 0444); +MODULE_PARM_DESC(ciphertext_hiding_asids, " Enable ciphertext hiding for = SEV-SNP guests and set the number of ASIDs to use ('max' to use all availab= le SEV-SNP ASIDs"); + #define AP_RESET_HOLD_NONE 0 #define AP_RESET_HOLD_NAE_EVENT 1 #define AP_RESET_HOLD_MSR_PROTO 2 @@ -200,6 +205,9 @@ static int sev_asid_new(struct kvm_sev_info *sev, unsig= ned long vm_type) /* * The min ASID can end up larger than the max if basic SEV support is * effectively disabled by disallowing use of ASIDs for SEV guests. + * Similarly for SEV-ES guests the min ASID can end up larger than the + * max when ciphertext hiding is enabled, effectively disabling SEV-ES + * support. */ if (min_asid > max_asid) return -ENOTTY; @@ -2913,10 +2921,46 @@ static bool is_sev_snp_initialized(void) return initialized; } =20 +static bool check_and_enable_sev_snp_ciphertext_hiding(void) +{ + unsigned int ciphertext_hiding_asid_nr =3D 0; + + if (!sev_is_snp_ciphertext_hiding_supported()) { + pr_warn("Module parameter ciphertext_hiding_asids specified but cipherte= xt hiding not supported or enabled\n"); + return false; + } + + if (isdigit(ciphertext_hiding_asids[0])) { + if (kstrtoint(ciphertext_hiding_asids, 10, &ciphertext_hiding_asid_nr)) { + pr_warn("Module parameter ciphertext_hiding_asids (%s) invalid\n", + ciphertext_hiding_asids); + return false; + } + /* Do sanity checks on user-defined ciphertext_hiding_asids */ + if (ciphertext_hiding_asid_nr >=3D min_sev_asid) { + pr_warn("Requested ciphertext hiding ASIDs (%u) exceeds or equals minim= um SEV ASID (%u)\n", + ciphertext_hiding_asid_nr, min_sev_asid); + return false; + } + } else if (!strcmp(ciphertext_hiding_asids, "max")) { + ciphertext_hiding_asid_nr =3D min_sev_asid - 1; + } else { + pr_warn("Module parameter ciphertext_hiding_asids (%s) invalid\n", + ciphertext_hiding_asids); + return false; + } + + max_snp_asid =3D ciphertext_hiding_asid_nr; + min_sev_es_asid =3D max_snp_asid + 1; + pr_info("SEV-SNP ciphertext hiding enabled\n"); + return true; +} + void __init sev_hardware_setup(void) { unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; struct sev_platform_init_args init_args =3D {0}; + bool snp_ciphertext_hiding_enabled =3D false; bool sev_snp_supported =3D false; bool sev_es_supported =3D false; bool sev_supported =3D false; @@ -3014,6 +3058,14 @@ void __init sev_hardware_setup(void) min_sev_es_asid =3D min_snp_asid =3D 1; max_sev_es_asid =3D max_snp_asid =3D min_sev_asid - 1; =20 + /* + * The ciphertext hiding feature partitions the joint SEV-ES/SEV-SNP + * ASID range into separate SEV-ES and SEV-SNP ASID ranges with + * the SEV-SNP ASID starting at 1. + */ + if (ciphertext_hiding_asids[0]) + snp_ciphertext_hiding_enabled =3D check_and_enable_sev_snp_ciphertext_hi= ding(); + sev_es_asid_count =3D min_sev_asid - 1; WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count)); sev_es_supported =3D true; @@ -3022,6 +3074,8 @@ void __init sev_hardware_setup(void) out: if (sev_enabled) { init_args.probe =3D true; + if (snp_ciphertext_hiding_enabled) + init_args.max_snp_asid =3D max_snp_asid; if (sev_platform_init(&init_args)) sev_supported =3D sev_es_supported =3D sev_snp_supported =3D false; else if (sev_snp_supported) @@ -3036,7 +3090,9 @@ void __init sev_hardware_setup(void) min_sev_asid, max_sev_asid); if (boot_cpu_has(X86_FEATURE_SEV_ES)) pr_info("SEV-ES %s (ASIDs %u - %u)\n", - str_enabled_disabled(sev_es_supported), + sev_es_supported ? min_sev_es_asid < min_sev_asid ? "enabled" : + "unusable" : + "disabled", min_sev_es_asid, max_sev_es_asid); if (boot_cpu_has(X86_FEATURE_SEV_SNP)) pr_info("SEV-SNP %s (ASIDs %u - %u)\n", --=20 2.34.1