From nobody Wed Dec 17 03:12:46 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) (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 64EED7BAEC; Tue, 22 Apr 2025 00:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281480; cv=fail; b=GEgKmzFlklGgNneXTNCL2UtrlZJhyGIY4QbzJLnfH0rjitro6FG+elUVEYjl9qC7K/C448ZmuzvH5e/KVoxJlq8zom8a+Ovh2tTtd5xG6ReW1TO79d8QUOXDOHF25q8+ikrcRzxDGdsT3/1HJNvKYc0xur/MQonbyoIre2gwdvU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281480; c=relaxed/simple; bh=iuvp7QQTCzbzbu2ifNUJ1n7IhP2Pi92rStx7EM4kNoU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tEGwlKmNQhKGNz4ODM1yybtjzzUrgL0jEb47IR0uvOs9+c60iWU7ySEU+ZilXee+OO1UD/j1ADoAPD8wZCc0BuTJPM0EDYkjDz/P3AJrBLfvTLtf4K6wGefo2EWQYw+DmuDubN4RNZVyzPpgndfCLbLEbEUKBPUhEHyDERb7OBI= 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=Nou5/P7A; arc=fail smtp.client-ip=40.107.93.63 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="Nou5/P7A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XHSJc7xJYlvNFMeVcJvrJR/EYyV7mnreWhXXo43DjHKorsUL/mxUMMKDe2+migf0TfjhM1iS3vo3/0CnX2uifUwnylR/AszUt6cWf905aD0n+aMEbtTzTGvIoAGM5vhcwMeyi7FzN+oHE+Zs5fYE4rViouWdtueyjWWfCRK11OSHUyx0a9WspmsTKr8OTmUqxnmScPe+YmWHNl1qWoEKsqPa4gCChJOoMIbgkE/3p7/pGR12bhMBaLdF6LETdmKlXwTyEb+ALMnQsxgwgErNd9At9d6lcXLOFGAg6KBeCv/tmJUb4g9+BSCMKmGrtK4/ekU3IGM/qh7RiMP/rT6r0w== 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=NYvwT5PreAuiHG1s1zbDu9qyWoPPUxadVhJp/06e0Vg=; b=UFTmVhP70ILqoYBtrJCtqlmrN+LUnEDAmKvBpO5cY+39+VqfRrbKJcwbQo9uKWFvtj5+wG3X4ogFCYYZbLWkbx6FLcSpigGscEo52rTyGgXqmtcOlKiQuaEMyh6rFZabB/Af4anC8eEONtAQsoEVvX3n+WyOAp+dpAtwzXzwFmRefaLsdHFFmkZdqzBRmhaGrTL92kwE7GO/jUCpPdtbtItQq9MEQOOrttfLCB0B9k+SSZNj+3Y4i4XZa+bCZY9QfIKrXZnoMW9MPNPt3OUX2xCIsI0xoy0bf+e2VfooiXj5R+SgSq0du88UQA+uaAEtRMnX14xebYdHQn6WbqjHAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=NYvwT5PreAuiHG1s1zbDu9qyWoPPUxadVhJp/06e0Vg=; b=Nou5/P7AUnsMHtvqCo/Fv9N/VW6ML9R+W8lsUKlsSG8NI2zEe8giy96f1irUgAD7dRjpj1KRPYg8QY8X9qiS/81qi6LVr+d2XdmGalSQ/CrxUmxeJ88uHQqDHu01uV2Cv1EoSFx61kiXTLM6RFQS8kKvFtyjtIL9inHt8to7S2Y= Received: from BN9PR03CA0183.namprd03.prod.outlook.com (2603:10b6:408:f9::8) by PH0PR12MB5648.namprd12.prod.outlook.com (2603:10b6:510:14b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.32; Tue, 22 Apr 2025 00:24:32 +0000 Received: from BN3PEPF0000B06D.namprd21.prod.outlook.com (2603:10b6:408:f9:cafe::c5) by BN9PR03CA0183.outlook.office365.com (2603:10b6:408:f9::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.36 via Frontend Transport; Tue, 22 Apr 2025 00:24:32 +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 BN3PEPF0000B06D.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8699.1 via Frontend Transport; Tue, 22 Apr 2025 00:24:32 +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; Mon, 21 Apr 2025 19:24:30 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 1/4] crypto: ccp: New bit-field definitions for SNP_PLATFORM_STATUS command Date: Tue, 22 Apr 2025 00:24:21 +0000 Message-ID: <0e0bda59404ab36c6bd7067ea13b8020e62dab11.1745279916.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: BN3PEPF0000B06D:EE_|PH0PR12MB5648:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b929943-1fab-43bf-fb75-08dd81340d9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?81ULuNjQ/PSeWGbkpdGOoo6ex0IwLkCX19MoF/rVdLb56kaEuD7hAU4tJGNV?= =?us-ascii?Q?Tse2gq0due1N9MW43Iynfb6308n8Tr2PzWDuXOOc7auzfgwSXsavC49RfsK1?= =?us-ascii?Q?zJSjIiuvuBDi09x02xUSpLH2u3JkVh2zxGc5hWczeRFSEiBPDs9TB8wqnOgL?= =?us-ascii?Q?L4NMVLiA7rF+EC61b4BUNbH02GJ9hFa3kEYNLAAGz+/vDao3ip16/H306xyw?= =?us-ascii?Q?RtWGKEhkSu6bjl1vbm6afFwONwDr0xPjjvk6URPcL9DC5fcf5raxY/tURHj9?= =?us-ascii?Q?rsDllq8LM3CUHGtjKKtSINfBd7J/RbbxsfpNraekLdQJnY0FPpha4yT2EVol?= =?us-ascii?Q?D9j2kMBt1GrlPiLlWlvvjRb4dZREUpTkmKaxFuAIG9m99KEaqsFgbbYW/geK?= =?us-ascii?Q?i4puO4bqAPptAseOjPgSDb5CsvH1KHu9XamuJYwFqLYS48zzmIkZd5OXisiI?= =?us-ascii?Q?yc7Rd1t891r00WU41CVjgd2UR44bTK4ZEFWFEAFD9I/97ahg1TrDRQuMCa4j?= =?us-ascii?Q?HiDi9JkyaxXa3Fls4dweX3cs9lrr9rxTv8ANpQJ3l0/WkgXIFSEPTNmgDdl8?= =?us-ascii?Q?jPg7aOfoMAwUM79I75Nn0+YuFZS871laC5g07v42sOnj+4I1dA6h/MATZ0hw?= =?us-ascii?Q?TWlzTGFRze9EGEN6CoHVxPzImX/W1YWF3pGIvMztyUC+cxiPVINamoAcZzH2?= =?us-ascii?Q?InLpRzmnq+luYYusMiaYMrpLUSveju7olGoi/DYZyofSKuu51ZYZeD0Czwxe?= =?us-ascii?Q?Ma+/u7nTqTOeo1dlv/SjmMVpIp/6IUqa4wYQW/AOpUuj3SvIZBAbmWc8icAd?= =?us-ascii?Q?04DFajbk5FGSeYI/f9NN/dwgsqZgJyVt71w2FixVN8HkU8fIOyy9o59g1+gj?= =?us-ascii?Q?I4qjklBKL6D298dsBY7MTBo0CkN9Apzjuv9E49SZNyShp0Us6cBHh2ZBtwUs?= =?us-ascii?Q?E/QIRm0Dk2X9Y5xhhaWiNJN8SuiNaQhOQ594SK4WVBSMX7clfryWS+j491So?= =?us-ascii?Q?6roYrfqzaxHj8m/T+Y7ammKZGOWJEqDCQuCSzz1nN8zJ7yalGbmmT7bm8K+l?= =?us-ascii?Q?rdBiapjgBpRZxFc76yunJAhNZt8547cfzjfiKIh5n3YSAnE+2+aKBLsnnQBC?= =?us-ascii?Q?+6Eg7HEjQriig7qp2/mT2dySnz4+uKiwAIpP9haJ43UpjfPaCdQ/1KZyUdHx?= =?us-ascii?Q?G9f139/AxxwUyLwIdUNG3VxuOYV1vtzWx1E72sfFiilDqu96mnY/J6ZS3FIn?= =?us-ascii?Q?PG8m6X4ylegAyMZ8cvbdVkXEfaTtlZGmdh1/aKdgYkDn5DkCP4mbnyF2GSoy?= =?us-ascii?Q?T7gEUTzSNABLyIODr1QySE9/LvcR+wK3F0IRvtavGZrlvExXsnbQ0cxeQBAA?= =?us-ascii?Q?o6ND0iO+GFGRIXVz9Ku7bmj4Obb7qK9djwz69dlvrzp8MVn6W2bdmrcS6VxJ?= =?us-ascii?Q?aNcv//vmsnRrkBXT4PQ9L0f25OPsnmYXMCHSO0/d9H190KWNn7hfsyhUT9KJ?= =?us-ascii?Q?pDp3XGhPnMeD71784n90LLwrTRURAhogOiee?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 00:24:32.2582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b929943-1fab-43bf-fb75-08dd81340d9a 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: BN3PEPF0000B06D.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5648 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. 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 Dec 17 03:12:46 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) (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 520F813AD1C; Tue, 22 Apr 2025 00:24:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281499; cv=fail; b=r1FXPZxRNoFE/+UDYFoiyb/0tVlMjg0yLhg5A68Ye329m8AiZvYXiUAGqxnLhN3Bw1J6RYFcKYlcYQ+86uYbXtdRCEPIKs2AYkgNXumsmegTQWvd0xzV5QcFkCLbFA9nwbyxweE1t+QCVCQt18jkTo0QApWra7QNkYSJXGMJpjE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281499; c=relaxed/simple; bh=5EoKTo0bswkf0QNkEbOjZ6qCP+9qcKB1BrSctwhXDvI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IOp+zkjR/uyq/R/FA4YlS6xzIuHDjgNm7mXFvx0h/dTAfkYGrhUrBwR9aaMn41FubuQ6C5ZlOYJbP71hpjCok1+yOqWTvFcMCUuvm5t/UYacWvyVjef/EdR+ulgKOskF/jrN+bKu2jrl34gueJecMgT2auSv7rfgAT3auG5NjZQ= 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=SWGUZw+0; arc=fail smtp.client-ip=40.107.223.54 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="SWGUZw+0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dRvR3k003QKe3OEUImQ6kA3ygerkQOCP+XGkvajwh4BBUoNlR+YW8+hFVKDO59GQesglozvj6p6jPpyXrizqAu9NzqFLS6T+Xu8dnsJt9pZjJMsrLW1VJnFs/vWyzV5LX6+ldThc2ley0dtXzJaDq8upyRK2E9sHGg82D65sdXMvbxBb4oiIpXFjQ++WrQslh/XX+6POM+NHM9+5k3tre2B2maLAqekkLJxE39/9PR2CJBeSIWmAH4SGM3UMug8D5Rfn8JQ0McMYep3EmzOkrn9y+1QXbXthG71mrkuAFcJrF6B+ST2rVJTR9kOlms90pUsRHhxCn84r6pWAuHUxag== 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=W/4Tc99I0VjnL+qa3veHlnKtnZFrRVXjP2j0N61Wabc=; b=cVzwrI2TeHlUkZoxnr4IZ5futa7NHdHzbgMe94Jafr7UNVuKVw8oyX44zryrN+g05ApU8dUO6077rMuZfa+zA7nSkw56OxDrhtDatQ3i3cBtb4r3bGLASlWMLBrRaedgB53OIfeGImVRMV/m4jPcQRR+ptKFu71pd83rW/naCuAT+3FvpzwAvF+iCF9helcTqSlk4/G2vDSDPNZKSFmWwiNFEZLSBcuFjSoJklI2r3dqALh8vo3wcV5kOz/nZFCSLkflJ0L0A/BbzxxxNPNjd/kq+DSlfytRCgOfv+GEEUZSmx7QagMnBgiI5GR7ZSQvShOT5EkJ4+a9TGx7/ZOmQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=W/4Tc99I0VjnL+qa3veHlnKtnZFrRVXjP2j0N61Wabc=; b=SWGUZw+071jwTQrY3p0y8GzUcgkhOPm+vT7/jqM7M0sZCSvDg0F0dcNuMxm34WL4fyzsDpYpH2sn8jwn+k+e0zt1BUhkmyY5Ss/wujG4Z5Aq+yrcdCIDpUFeqhSrxGgS0IK0rZUsQL4xtKJRaN5iYbkNpuR0e+ZsNoe5DU+WJak= Received: from BL0PR02CA0059.namprd02.prod.outlook.com (2603:10b6:207:3d::36) by CH3PR12MB7572.namprd12.prod.outlook.com (2603:10b6:610:144::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 00:24:53 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:207:3d:cafe::9e) by BL0PR02CA0059.outlook.office365.com (2603:10b6:207:3d::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Tue, 22 Apr 2025 00:24:53 +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 BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8699.1 via Frontend Transport; Tue, 22 Apr 2025 00:24:52 +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; Mon, 21 Apr 2025 19:24:51 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 2/4] crypto: ccp: Add support for SNP_FEATURE_INFO command Date: Tue, 22 Apr 2025 00:24:41 +0000 Message-ID: <0ec035a24116dce7c8b2a36a29cf5eed96e0eb52.1745279916.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: BN3PEPF0000B06B:EE_|CH3PR12MB7572:EE_ X-MS-Office365-Filtering-Correlation-Id: 132f3039-73ef-4b9a-d3a8-08dd813419e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Mi5MtHFLRuYNYxfCs6A0IlkBZxx/bpS91B4NXiwxm3btL5fQfXOhS33j6HP2?= =?us-ascii?Q?GPhghWTe5KHOxjnJn+1Av4dgMbam3t+RH+MnQ51/scZDilLwOIgqfdnLuPH5?= =?us-ascii?Q?oawYvTBjgTkcjXPdgaEXOimpqmqaGZBnSlPvqEIkTSFllapXhBukjgTV06Gt?= =?us-ascii?Q?SnFHYNBnZ9YPfi77z+/DqQ43l6eJEyHuiEEqhrv5jUocKIcjbJyov/1/1lrX?= =?us-ascii?Q?AI4iN05tZpYMEq1B9df9AczyUG5hDaO1pvKf+MPsxLsKj6dUJrFNxQIXE2vl?= =?us-ascii?Q?qOjZ3asVI6TodLeiQKL37afu3K9Ga9yNtsptdane6/RtjAkMl8Fn1apLCByK?= =?us-ascii?Q?uzn4Vb66EjJzlNQ4jbUIYjohdB4K3ecieJkzvli2HY3QVzdCvFLF5jMvBgvA?= =?us-ascii?Q?yVL3NqGBc/nrExlyBVur5CdTYEcr9cP+0n4wbdh68x6nosNFQHYKmbGmcwWX?= =?us-ascii?Q?OXCfsGWiKc/5go8Qn7zQLIdLrfbiAv+9lws+E0Alw33adJQb7yNfbON0BAt7?= =?us-ascii?Q?7f0eRuNY1PWpLmaqijD4NUARqZfdtoMbkDGm22iPyVSBi4f57zEqolUBnhOG?= =?us-ascii?Q?s4lhQDq3dTX2RnQaTrqW8jcz43gTySbJM9fXBN/YFyvaeRhLCji38Nv3w5bW?= =?us-ascii?Q?PJWsQX6g9Sve6sYN8psawuWr/XHM6okrniDrCYaqLCETds5Zmz4MVPtP18lK?= =?us-ascii?Q?FxhV5DfSKt4FijiU40C2vg6BxxRHDBFbr/wUgpCrzViW5gmgnnCHeZi43fLP?= =?us-ascii?Q?Wzio0GuM1Mk0EMKAI/hoZWFogTPlxH1Q5VSuacxm3Dzh4+WOuOAV0S2Mv+UX?= =?us-ascii?Q?ZOI0MXq2w4nqBZCPXdKSM2zfj4ZGgwt60tfMnv+G+Y1VlxXNz9P978M7IQpT?= =?us-ascii?Q?nG94VI32VyFVzJ7PFw49NlHW3rJ6ojgwl8NqQfdjjJnBjWxoBeaTXYtPeoq0?= =?us-ascii?Q?2C44MN2RzLMLFEBmZzoFm+pKhi108AHfCskp31aZoE18WBGMVkCYgh9+LkMi?= =?us-ascii?Q?/9DJlcKU412SUwJKULsrlfBn67qB9icPCv31XOOVPln/bzxid2w4s5k1GD74?= =?us-ascii?Q?VUmr3nQbJyPWN3pjrO57G3FKlDVbOcMcacgK5LgJuvoIWfeOv5WdZCpeBfX8?= =?us-ascii?Q?Vf763oRGxSqLYuuBRyGc2KxEYqt3vxNnac4tG870aA992o8WpBEC2niChRU5?= =?us-ascii?Q?Um5fhgT0pnKiry5n9sSVRVjKTvMxNFtvurAvaFMNDWJURytqOp7Z4dVF9Mqc?= =?us-ascii?Q?Tc+gKXR13qXivAiFbf5Y4BEe3FZlTA67tSdb4eZ5PH6zZ02Ow8UDPJBjapDg?= =?us-ascii?Q?xHguzyc9+ULucfEsAORKnQct7PnyNsBAxlsqIVvjWBw+gxK8sN3AbN1fkVHe?= =?us-ascii?Q?E9ypXGs+Jl82HfojB66B0zYNvk2YW09yMR/CCn9+HEXq8KbImp/xef6yssyF?= =?us-ascii?Q?aZBvk5Z8SB3eJn2D0jRWQzSMyY5vhaCJruLkpuHDkwMAbcgPI9U3Zu3KOzZG?= =?us-ascii?Q?O5z1wCE5n3JQeMa9i+myXWDBRIMUUyt13mDw?= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 00:24:52.8942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 132f3039-73ef-4b9a-d3a8-08dd813419e7 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: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7572 Content-Type: text/plain; charset="utf-8" From: Ashish Kalra The FEATURE_INFO command provides host and guests 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. Host/Hypervisor would use the FEATURE_INFO command, while guests would actually issue the CPUID instruction. The hypervisor can provide Fn8000_0024 values to the guest via the CPUID page in SNP_LAUNCH_UPDATE. As with all CPUID output recorded in that page, the hypervisor can filter Fn8000_0024. The firmware will examine Fn8000_0024 and apply its CPUID policy. During CCP module initialization, after firmware update, the SNP platform status and feature information from CPUID 0x8000_0024, sub-function 0, are cached in the sev_device structure. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 47 ++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/sev-dev.h | 3 +++ include/linux/psp-sev.h | 29 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index b08db412f752..f4f8a8905115 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -232,6 +232,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 snp_feature_info); default: return 0; } =20 @@ -1072,6 +1073,50 @@ static void snp_set_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } =20 +static void snp_get_platform_data(void) +{ + struct sev_device *sev =3D psp_master->sev_data; + struct sev_data_snp_feature_info snp_feat_info; + struct snp_feature_info *feat_info; + struct sev_data_snp_addr buf; + int error =3D 0, rc; + + if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP)) + return; + + /* + * The output buffer must be firmware page if SEV-SNP is + * initialized. + */ + if (sev->snp_initialized) + return; + + buf.address =3D __psp_pa(&sev->snp_plat_status); + rc =3D __sev_do_cmd_locked(SEV_CMD_SNP_PLATFORM_STATUS, &buf, &error); + + /* + * Do feature discovery of the currently loaded firmware, + * and cache feature information from CPUID 0x8000_0024, + * sub-function 0. + */ + if (!rc && sev->snp_plat_status.feature_info) { + /* + * Use dynamically allocated structure for the SNP_FEATURE_INFO + * command to handle any alignment and page boundary check + * requirements. + */ + feat_info =3D kzalloc(sizeof(*feat_info), GFP_KERNEL); + 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_locked(SEV_CMD_SNP_FEATURE_INFO, &snp_feat_info, &er= ror); + if (!rc) + sev->feat_info =3D *feat_info; + kfree(feat_info); + } +} + static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg) { struct sev_data_range_list *range_list =3D arg; @@ -2543,6 +2588,8 @@ void sev_pci_init(void) api_major, api_minor, build, sev->api_major, sev->api_minor, sev->build); =20 + snp_get_platform_data(); + return; =20 err: diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h index 3e4e5574e88a..1c1a51e52d2b 100644 --- a/drivers/crypto/ccp/sev-dev.h +++ b/drivers/crypto/ccp/sev-dev.h @@ -57,6 +57,9 @@ struct sev_device { bool cmd_buf_backup_active; =20 bool snp_initialized; + + struct sev_user_data_snp_status snp_plat_status; + struct snp_feature_info feat_info; }; =20 int sev_dev_init(struct psp_device *psp); diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 0b3a36bdaa90..0149d4a6aceb 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, }; @@ -812,6 +813,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 Dec 17 03:12:46 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2078.outbound.protection.outlook.com [40.107.94.78]) (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 94D6378C91; Tue, 22 Apr 2025 00:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281519; cv=fail; b=mVNzUSJV1fC99+1paTk/cNWui1gJljgbDdJTB/3RIXyDU7RgWF2x4JpxyPjHM6q4GkL7701QNpwg40S5blaFYgZlsF3NEueVnCLampPSTO3FEmbiCwyH2XI17d6eaeYJdf8GDvYj76jQ8uVLPyDioJI3g8alBAcS3RtJPppfH4g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281519; c=relaxed/simple; bh=Pxd7oieyZzcutl1SmkqtLfmm4aDRFfvCSTVgCABXEpA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XwT4/irvjF0vuXFuoUDPDez+BhCptwzxBARmX15OhgLf5A3RpjCseNv4OUzEC6I45p8r9x4nHZFOsTjLHNzf1gxCGLJ/YhTbRtKMl2/AcGjZZqj2iSM91f6GFS/qTxHDaBmzYZ+OPaBCMQ20rvd04UOXnFFR/ZZMbXTIqT5fmTY= 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=2oeaI34n; arc=fail smtp.client-ip=40.107.94.78 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="2oeaI34n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HbAqYSlEiH0dq33zSZj3iNwfkvOtYfv/ZLFCSPxIN08okiu1YwpSBke2Rqpnx1CTK1abpsiHIBLuP0FuVd3Bs68vMgsKJzGXE/MKAYMvgT9pq4Fe8ror78wZLOF0Oe1racIQ07JBxK1el921jYOgrcDAXZtHlhjwYUJlQQWJE7JFPhYAX2Kg3Ckd9Up480bTLqPhIgy/NvT6hxmdYM29i80IJbzbRGRAnhsRIznSZ44zFEaOuE7p6vyMiNKft4RcJGD1L2v83da9AcGrX2qySRsAQwrd44HdUDZKtTrnf8iTTMuNULn+68yzB2BgYSFDOrjh4qMqsk+yaEtmDkHqEA== 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=hEpTmj/MMhtiYoaekyNIEgDDO1u3tZjhDvLwRjmYlIc=; b=gZpKVrkbtf3u2oGCuZAcO+E3NOl0sRUNCKyWi7wGRDvzlG9wYc8fjaiI8jsfDlMltBxAbeF5ZT4ea2n9QmTRVXVpw18vodviZ21sM35JxBsvfH697F8PVAQ9pK7z05rM5qN7hIxQ+KL6UM1gptzmdCewKB4eS1E0DycFvpsHs10kHf3FogRHXc775QNqZWkjbz2znk+wLHlSgWILetfeAT1urXzXZ4AVhHAn80WUR5+IpikA+nUaQIBmLSh42Jk1XWgK7clXw3GBjI/9Q5WA8FCFfkq+K/bqCIBxV6GNH7u4FZvOw0MhFJHOuY6hmvNRP+8o40Nh6i0Fv4trq1oLqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=hEpTmj/MMhtiYoaekyNIEgDDO1u3tZjhDvLwRjmYlIc=; b=2oeaI34nHqNrS/HlTpG0s00win2K+ggbPxicoHirXbRV3aANrnLQXelUkcLY37OltjDkjh5zlGR7ngYteSj1vQxBQUChtzEGSOHjfcw6z10QoNpuAJB+9rC6QAK6Bdo72ZNSGWh3ZNsmLgoeVhv3Vfns+Jx7g4KnY5W4O4vSUf4= Received: from BN9PR03CA0396.namprd03.prod.outlook.com (2603:10b6:408:111::11) by CH1PPF68E8581EB.namprd12.prod.outlook.com (2603:10b6:61f:fc00::611) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.34; Tue, 22 Apr 2025 00:25:13 +0000 Received: from BN3PEPF0000B06C.namprd21.prod.outlook.com (2603:10b6:408:111:cafe::70) by BN9PR03CA0396.outlook.office365.com (2603:10b6:408:111::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Tue, 22 Apr 2025 00:25:12 +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 BN3PEPF0000B06C.mail.protection.outlook.com (10.167.243.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8699.1 via Frontend Transport; Tue, 22 Apr 2025 00:25:12 +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; Mon, 21 Apr 2025 19:25:10 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 3/4] crypto: ccp: Add support to enable CipherTextHiding on SNP_INIT_EX Date: Tue, 22 Apr 2025 00:25:00 +0000 Message-ID: <94ffa7595fca67cfdcd2352354791bdb6ac00499.1745279916.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: BN3PEPF0000B06C:EE_|CH1PPF68E8581EB:EE_ X-MS-Office365-Filtering-Correlation-Id: 5814acad-fa13-408d-00f5-08dd813425b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XzCwb789kLA7sl/qao3GVypeaCrSi+SYF5EVDc/u9DlaBNqMfR9yGCB7Cm/3?= =?us-ascii?Q?UZulAy/PpeEmXd4CzZ/1mYNNpxJ39DdkVISywL4EIds5/Zv36wwETBlfrF4j?= =?us-ascii?Q?kQfpVCmgt+LrIoTESahgPalVcCwMFODTBjcsM1mEWQe3jwpzh7JUdbn6MIPi?= =?us-ascii?Q?ORMo7h87vvAdmM+jh/Zx0yvVxCCYIqBnTman0k98IcidX5BGc62piLO1UvB3?= =?us-ascii?Q?7OeTJQJuSyrQXvUGUNuuUHBOPrxbCaLByYChh19UY/BtY7Dj7X7Bp93KGPtz?= =?us-ascii?Q?m1jupXqkbP+QMvlA12gik02F7KGY06v0fjFCnf6BFhKqcwzZyfVzrPxi8v7r?= =?us-ascii?Q?gxOwWpx5J1UgGHpu8O5yh9MFWBCQ/Qjio1vbsbIDSXGwEoPIV2fFJdSoJME4?= =?us-ascii?Q?eFR+8O32lo7mekEmaMF8+6LNzXtMUPHcQi1svMnrW3BtaIm6NgNSM9nx3/sf?= =?us-ascii?Q?AD+KkbDGQCuLPjrWrLOOc3ApPaaxasO4v7ypMpdWLwP6ae4RYp9lS73xK8qn?= =?us-ascii?Q?4Mtl7p+FkPhMUD9txmWt8RcwZ0DbUgMeD+MLiG1Q0JqADPqKNVxPkJh8V5iZ?= =?us-ascii?Q?rZPG6aaQRP1bQ3xadNy/sxC7EU0boGWz5+UIusoPPuINnRNWrLvCzxBMqta6?= =?us-ascii?Q?WH5vvtrP3B36hB0JOZwFgw88QRyLs5F0m9Y12i7Prb14LseD126ILub41yR9?= =?us-ascii?Q?BOBAg7BmQG6ovoEDudgYdNzgvMXABVzvoWYRlHxZnDcqBwCvZ5A6zdjI7TOE?= =?us-ascii?Q?1/OBad8Qr3vCLONgoqKWoVhtyYJcn5GQgn0xuT3wt4kIWTy+m9/bNv7CvW4S?= =?us-ascii?Q?lanmucqDhPvRF0QU2mNQPHRxcahg0Elqi1eo8eqs5Ttlremek5meuE0tCDB1?= =?us-ascii?Q?jLxOYLeckrfSTPjQ5SzDWVXjfHht5wW54rXUJwbVX1SJbL6CtaMAruBWH64Z?= =?us-ascii?Q?K/uT5mgSdkm5TraSUmOdwkiIPfC3SUWevE7ITCXheeGvyXV7Gg222RoAbIwY?= =?us-ascii?Q?tAge6BpwCPgmgF/0JONwSnivtjtI44/7WpLivhQUX1MktnLZsBU7hZBnY5oe?= =?us-ascii?Q?p/5KoC7kjIzhiSD0rPIKU+1K63Fc2zZUvQPTLVe11C0t/1ULMjK/rOmS1sZ+?= =?us-ascii?Q?VGT9BRcEQTn55V1FdwG4H1pLjwwKMPV4prxM5cicl3cqj4osm5unzurfsiYY?= =?us-ascii?Q?6zdFIFEPoyMru7VPVlY8GPTu+57MP9DZlJKRGd8g2sP3xzpX7WWJZJ8gFJ4C?= =?us-ascii?Q?e2jStKc6qbbdPDNjni63klFGA7CnBfz9vKjaAEC/be6LLlK/xM2L4Z17rkg2?= =?us-ascii?Q?6biB9cjdedBn8e3b96gLuNJJyHF+TZmcsi+xkjPpguQ9hmAXkuhmiMFfxhVX?= =?us-ascii?Q?Q9X3U2+9QbPZEzBRqmac5WSepBePYalbKmacNoWB4Ql14gfUI1zZkv2zo6eA?= =?us-ascii?Q?UmF2hKBT22cM42sDU0ZRIvMUtdYDr8lo0KrPNgAqLyNjDl2wgI7iedCWLOmp?= =?us-ascii?Q?t0laZjVKoksl7zxJEsa6zcv5RWIgNz9d6MnL?= 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)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 00:25:12.6992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5814acad-fa13-408d-00f5-08dd813425b8 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: BN3PEPF0000B06C.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PPF68E8581EB Content-Type: text/plain; charset="utf-8" From: Ashish Kalra Ciphertext hiding needs to be enabled on SNP_INIT_EX. Add two new arguments to sev_platform_init_args to allow KVM module to specify during SNP initialization if CipherTextHiding feature is to be enabled and the maximum ASID usable for an SEV-SNP guest when CipherTextHiding feature is enabled. Add new API interface to indicate if SEV-SNP CipherTextHiding feature is supported and enabled in the Platform/BIOS. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 31 ++++++++++++++++++++++++++++--- include/linux/psp-sev.h | 18 ++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index f4f8a8905115..ca4b156598de 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1073,6 +1073,25 @@ static void snp_set_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } =20 +bool is_sev_snp_ciphertext_hiding_supported(void) +{ + struct psp_device *psp =3D psp_master; + struct sev_device *sev; + + sev =3D psp->sev_data; + + /* + * Check if CipherTextHiding feature is supported and enabled + * in the Platform/BIOS. + */ + if ((sev->feat_info.ecx & SNP_CIPHER_TEXT_HIDING_SUPPORTED) && + sev->snp_plat_status.ciphertext_hiding_cap) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(is_sev_snp_ciphertext_hiding_supported); + static void snp_get_platform_data(void) { struct sev_device *sev =3D psp_master->sev_data; @@ -1147,7 +1166,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, bool cipher_text_hiding_en, u= nsigned int snp_max_snp_asid) { struct psp_device *psp =3D psp_master; struct sev_data_snp_init_ex data; @@ -1208,6 +1227,12 @@ static int __sev_snp_init_locked(int *error) } =20 memset(&data, 0, sizeof(data)); + + if (cipher_text_hiding_en) { + data.ciphertext_hiding_en =3D 1; + data.max_snp_asid =3D snp_max_snp_asid; + } + data.init_rmp =3D 1; data.list_paddr_en =3D 1; data.list_paddr =3D __psp_pa(snp_range_list); @@ -1392,7 +1417,7 @@ static int _sev_platform_init_locked(struct sev_platf= orm_init_args *args) if (sev->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->cipher_text_hiding_en, a= rgs->snp_max_snp_asid); if (rc && rc !=3D -ENODEV) return rc; =20 @@ -1475,7 +1500,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, false, 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 0149d4a6aceb..af45e3e372f5 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -746,10 +746,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 /** @@ -798,10 +801,16 @@ 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 + * @cipher_text_hiding_en: True if SEV-SNP CipherTextHiding support is + * enabled + * @snp_max_snp_asid: maximum ASID usable for SEV-SNP guest if + * CipherTextHiding is enabled */ struct sev_platform_init_args { int error; bool probe; + bool cipher_text_hiding_en; + unsigned int snp_max_snp_asid; }; =20 /** @@ -841,6 +850,8 @@ struct snp_feature_info { u32 edx; } __packed; =20 +#define SNP_CIPHER_TEXT_HIDING_SUPPORTED BIT(3) + #ifdef CONFIG_CRYPTO_DEV_SP_PSP =20 /** @@ -984,6 +995,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 is_sev_snp_ciphertext_hiding_supported(void); =20 #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ =20 @@ -1020,6 +1032,8 @@ static inline void snp_free_firmware_page(void *addr)= { } =20 static inline void sev_platform_shutdown(void) { } =20 +static inline bool is_sev_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 Dec 17 03:12:46 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) (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 D6FB078C91; Tue, 22 Apr 2025 00:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281536; cv=fail; b=CFq/3EoA2qFqml+LW1SHagWV7mI7SjSiUTd9pKJXvCmPNiEQ6tf3gY64fu0MW6m86IwFvqDQDM1e0sCsncn4uWZOH1N4SvOQpDGUKKAvwbB5IZIlRU32IpvE7XbxtJPxY9qXBkzhKtFpexBvVoE4Y6DURltQAujKzjjioK9mKJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745281536; c=relaxed/simple; bh=vh39ONNVYu1qA9fZZzaPVguXl5scdhzV99zQM8WWZYU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fV0x3RGwaL9DbmM3EATikSagW9IawjKgwkBtGZUTn5oi8HAW9A5m2Pyh4PoniAq0ojAZPBPk22KRyCVG8lzgbby3fOYYafL+SFoCO3tYi3xY7q+wIuo8On+/hoHort6kuB7OVoXQhWQqX7/Uegl+sBldFVcj8OClitbdLaFWqv4= 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=wpvzcx2Y; arc=fail smtp.client-ip=40.107.223.54 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="wpvzcx2Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WmuNW6vwgIyKB9YqNKRoo1KZyerR2IixK8bwmXxUFj6UYKE5d44otWx9dvu18/NM3XXYwBPdlgNz0ZbajqFYPmgwW+YqcxCc/2J13gk6ROVKRkS20J3f4XyY7RD1NTcKMqUZ1ILQPmb0iBMN/QWAwALZbcqQzyilJ1IKt2E44orMYxTOl3n/wy5yc/JZonwisTG4mBWWCXxOhDFPhCRU9Hl063JpeCW5Z429bipwxcNDVzrY56dqT4QawR2ziz1ZZ6vYyA5c5vnRhYo5DMrm7JgiCYD0BkHpo0lHh3NN+zwNFBNkYltkEiX2GRo2dm/1bv1pMbwa/PPNf3FzoiOffg== 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=HDEhbbL+pkSEqxULIZEOH/7Vt8ITkMTD40e0xID/3z8=; b=VHgy0Ebbm2eRVQELs8H7cLgIT6KXND7E4iBtVw2BbWXw99JmnF/GzBsuXHVAEWKFfQNmgWwANlTa+mI0daGY/A+TRVdbgUF4Xc2UpFdv7nC0mJGCJVYXRx3GUutrhuBLwX9UUPKf5T5PoMzNpd8IadIN8YCsZ9j1uzAKrE03DKB8SKH7oSoibjh0kphWUkf8kg+u0k/Hwp5UHXnOubS4K6UUtdtPMZ0RtsFTaV+qj4AGIeprJG7hgdkUWo0cmV+t2of3/u7k1URMtwK+zzBRgcRZ2qOqKUqpdvXrZeWSPF8F07ddvi7GGovVhSfZ+CNkHKmQgmRbLUYnwKGxuiVreQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=HDEhbbL+pkSEqxULIZEOH/7Vt8ITkMTD40e0xID/3z8=; b=wpvzcx2YrGwgAKUyhzHjJERwfNbf3p8xDchQ4eSBLieZipwAUUU3HCvEH0m33Su7zJYE++UQyvy6Z47tkVUEP4vXA48611pCFodXd9d9412DE9gVjaoKCdCmBLWGQif8aerQxPlkGOlEe2O9Lg+AuZPKQpRoqs59l3a2VNROOvI= Received: from BN9PR03CA0206.namprd03.prod.outlook.com (2603:10b6:408:f9::31) by CY5PR12MB6455.namprd12.prod.outlook.com (2603:10b6:930:35::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.35; Tue, 22 Apr 2025 00:25:31 +0000 Received: from BN3PEPF0000B06D.namprd21.prod.outlook.com (2603:10b6:408:f9:cafe::46) by BN9PR03CA0206.outlook.office365.com (2603:10b6:408:f9::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Tue, 22 Apr 2025 00:25:31 +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 BN3PEPF0000B06D.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8699.1 via Frontend Transport; Tue, 22 Apr 2025 00:25:31 +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; Mon, 21 Apr 2025 19:25:29 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 4/4] KVM: SVM: Add SEV-SNP CipherTextHiding support Date: Tue, 22 Apr 2025 00:25:17 +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: BN3PEPF0000B06D:EE_|CY5PR12MB6455:EE_ X-MS-Office365-Filtering-Correlation-Id: b3f1376c-1e44-4afe-d292-08dd813430cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?N0bP+22qWoxaLDCYiEr+I2tukj3AufkrEPKeOWycsgChIUDkwNRE2Tk8mebs?= =?us-ascii?Q?6/ioxxpT+C4QPSoJZNexIMwdMak6nnmbQ/PCD5ofe5buVfI2hqLBTRHKDqni?= =?us-ascii?Q?xXFf+nbcmG6nITkXUj+a62oWNhAExZj1lyaJ8YW8C4QjHAYqYZVbsdeVfd1R?= =?us-ascii?Q?RQcxUNAKi6E5A4b4GvPSJiya4/nmkYWvhZ44j5kx40psf/RRxWyIW8F0JG7R?= =?us-ascii?Q?SsexbbdNGqFUw9xxtoLDFSzl1TheX91tnFxULHZUHW7Ysl+Ti8RMWS/qHMmW?= =?us-ascii?Q?byrYUPp9qRIyFClBjDNkS1R7xUAXTh+83vb4n6DoUf7ahwn55xbu694zy34S?= =?us-ascii?Q?+mtxNd9ba/pphzAqFIPvDG8dOjfheD0FYVofNwy+dA7Nk727mGAJSt24mSJm?= =?us-ascii?Q?PiE/WNcAWAWnceMP0hTfeNOou8yI5zzfQWMa5cXm3bUAE0WS/8kuA+FWh+U1?= =?us-ascii?Q?tOdxJ6NZblmkYWXW8ZMBnK+bwfjw0b8BCm83zZAi603OMyP/lN0kACK64qPM?= =?us-ascii?Q?X5vNlIu9IILt1JkC0VhuZLg9w2jrffz0H/VFsByLq7hQVvgjmqoBrn0qhjGj?= =?us-ascii?Q?DkLgAu6TwpECd+1cSdOrkrfxwcZqrZXrauNPVjqoj7CtXfJ0ywyYzk2hj4MJ?= =?us-ascii?Q?jqeQ7/1aPrLItPCrmHYssumPGaBxBdFkbheS8HNURcIgXK8D4ZR2YuQNlO7S?= =?us-ascii?Q?m1yvKT+mHQFscFa48SLC93tPqJoVdx/phuBxoWxGAynJg5WRrz9b+Wu1XMkS?= =?us-ascii?Q?SYzJE07K9E94Sn24YPneXeVBqmL5GyhKilZJFv3C9JDNrR7DD6rOwRyo1PE4?= =?us-ascii?Q?Y1kcrLlHNSQGNprXIsm/zIy74ALdbNaSnUoCMPYJqjoURvamgwdK3/aLPfH+?= =?us-ascii?Q?rHu2IecGuMbJlkQnVRifsi6jm6YGU8gdruwgqtnerujC2aJ1OiAdvdi5AoGL?= =?us-ascii?Q?Tgl/zNr9zXKHzL7HVbpQRWNpZ0ePUkJXIyWS4y/lcusofKbjtounC+XW8Fpf?= =?us-ascii?Q?gIdjvkaQxoJ1U7OdBUTAmh3lQVa1fInbzkm9WmC3L9Pgh5g7V05Z4Q6/EjVx?= =?us-ascii?Q?778zrwFceZk6PsA/ys4YybCQcaFkGvHslTJPOWx0o1FZ+7tZl32e5eKsrEAh?= =?us-ascii?Q?9lPDbrcqtngiNB5qIv3BBQtDd5iWGw9qhayh/eqmUvADS837AQKKfOO/bj4u?= =?us-ascii?Q?sko9e5K4+bmL5hN2riSPTXUm0id4n07ydAR3gwdMw3tR3yIiTk4v8gylB0H+?= =?us-ascii?Q?d8aJvRTD6LT9U5NlEWHwnojbBJFfobRggDegUeLZOI3Gkj7QkmFEZd64jkNy?= =?us-ascii?Q?M3lj+NA9nROadhAvGHgd7xc838QmQhHygc6/2YO6xYufgoO4TOcaOmP2B7ku?= =?us-ascii?Q?PFK4xkJ9LzuWMBjBX+STJJ2eYuoMyVlySSJNFzx6e/w8SNmdz2ZCYlSx8ShF?= =?us-ascii?Q?+Zu5tTE3sxw8/63zKgbQ/mwACI/2xcFU+QEOulpVn/9srLVpDD/dxVdCRIx5?= =?us-ascii?Q?t3tDcZeP/jBcQTzOrzsPEJKUiVie1UIgzNaJ?= 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)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 00:25:31.3258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3f1376c-1e44-4afe-d292-08dd813430cf 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: BN3PEPF0000B06D.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6455 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). Ciphertext hiding separates the ASID space into SNP guest ASIDs and host ASIDs. All SNP active guests must have an ASID less than or equal to MAX_SNP_ASID provided to the SNP_INIT_EX command. All SEV-legacy guests (SEV and SEV-ES) must be greater than MAX_SNP_ASID. This patch-set adds two new module parameters to the KVM module, first to enable CipherTextHiding support and a user configurable MAX_SNP_ASID to define the system-wide maximum SNP ASID value. If this value is not set, then the ASID space is equally divided between SEV-SNP and SEV-ES guests. Signed-off-by: Ashish Kalra --- arch/x86/kvm/svm/sev.c | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 7a156ba07d1f..a905f755312a 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -58,6 +58,14 @@ 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 bool cipher_text_hiding; +module_param(cipher_text_hiding, bool, 0444); +MODULE_PARM_DESC(cipher_text_hiding, " if true, the PSP will enable Ciphe= r Text Hiding"); + +static int max_snp_asid; +module_param(max_snp_asid, int, 0444); +MODULE_PARM_DESC(max_snp_asid, " override MAX_SNP_ASID for Cipher Text Hi= ding"); + #define AP_RESET_HOLD_NONE 0 #define AP_RESET_HOLD_NAE_EVENT 1 #define AP_RESET_HOLD_MSR_PROTO 2 @@ -85,6 +93,8 @@ static DEFINE_MUTEX(sev_bitmap_lock); unsigned int max_sev_asid; static unsigned int min_sev_asid; static unsigned long sev_me_mask; +static unsigned int snp_max_snp_asid; +static bool snp_cipher_text_hiding; static unsigned int nr_asids; static unsigned long *sev_asid_bitmap; static unsigned long *sev_reclaim_asid_bitmap; @@ -171,7 +181,7 @@ static void sev_misc_cg_uncharge(struct kvm_sev_info *s= ev) 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. @@ -199,6 +209,18 @@ static int sev_asid_new(struct kvm_sev_info *sev) =20 mutex_lock(&sev_bitmap_lock); =20 + /* + * When CipherTextHiding is enabled, all SNP guests must have an + * ASID less than or equal to MAX_SNP_ASID provided on the + * SNP_INIT_EX command and all the SEV-ES guests must have + * an ASID greater than MAX_SNP_ASID. + */ + if (snp_cipher_text_hiding && sev->es_active) { + if (vm_type =3D=3D KVM_X86_SNP_VM) + max_asid =3D snp_max_snp_asid; + else + min_asid =3D snp_max_snp_asid + 1; + } again: asid =3D find_next_zero_bit(sev_asid_bitmap, max_asid + 1, min_asid); if (asid > max_asid) { @@ -438,7 +460,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 @@ -3005,6 +3027,18 @@ void __init sev_hardware_setup(void) if (!sev_es_enabled) goto out; =20 + if (cipher_text_hiding && is_sev_snp_ciphertext_hiding_supported()) { + /* Do sanity checks on user-defined MAX_SNP_ASID */ + if (max_snp_asid >=3D edx) { + pr_info("max_snp_asid module parameter is not valid, limiting to %d\n", + edx - 1); + max_snp_asid =3D edx - 1; + } + snp_max_snp_asid =3D max_snp_asid ? : (edx - 1) / 2; + snp_cipher_text_hiding =3D true; + pr_info("SEV-SNP CipherTextHiding feature support enabled\n"); + } + /* * SEV-ES requires MMIO caching as KVM doesn't have access to the guest * instruction stream, i.e. can't emulate in response to a #NPF and @@ -3040,14 +3074,18 @@ void __init sev_hardware_setup(void) "unusable" : "disabled", min_sev_asid, max_sev_asid); - if (boot_cpu_has(X86_FEATURE_SEV_ES)) + if (boot_cpu_has(X86_FEATURE_SEV_ES)) { + if (snp_max_snp_asid >=3D (min_sev_asid - 1)) + sev_es_supported =3D false; 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_asid > 1 ? snp_max_snp_asid ? snp_max_snp_asid + 1 : 1 : + 0, min_sev_asid - 1); + } 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_sev_asid > 1 ? 1 : 0, snp_max_snp_asid ? : min_sev_asid - 1); =20 sev_enabled =3D sev_supported; sev_es_enabled =3D sev_es_supported; @@ -3068,6 +3106,8 @@ void __init sev_hardware_setup(void) * Do both SNP and SEV initialization at KVM module load. */ init_args.probe =3D true; + init_args.cipher_text_hiding_en =3D snp_cipher_text_hiding; + init_args.snp_max_snp_asid =3D snp_max_snp_asid; sev_platform_init(&init_args); } =20 --=20 2.34.1