From patchwork Mon May 19 23:56:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 891164 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2076.outbound.protection.outlook.com [40.107.243.76]) (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 847B323BD04; Mon, 19 May 2025 23:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699007; cv=fail; b=Dz6K06N7trz2ogdhZYUw40srZhzx4h+t/mpSQDKzkUD+N13h5Ptt7efE5rng4QGnVvjkAsdLRlQBam3JHhoZ1fJmssjfUne0UkBspJW0VJCSJMoXvPVr4boNxO7Iel8/kD1xIYQ6QqHdvaotV6x5IAOObH8wfnVaU6FUONksP+U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699007; c=relaxed/simple; bh=iuvp7QQTCzbzbu2ifNUJ1n7IhP2Pi92rStx7EM4kNoU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ODuhGs4T2/ZkhkqdIKbdq0KER8GaPoUA7URG61VxDYGpVI3/sH42g3dG+4FONt3p18JO93RjksSkXZgJeKhFfMGajsRehqFlpv7GIm54Z0I1r5itreho/cp4/4GPF6yFiO9rmqxJ8KrJ8iLaLfJ9O7Eau9A4XDF75jgMR6lcEv0= 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=bnqwg33t; arc=fail smtp.client-ip=40.107.243.76 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="bnqwg33t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eLvqtapEp84PoH4EoKFRRDz9/5dWbXY+gBBU/7VNxx5bJUGdRtVScoGtS5mzkef3OAvmcSgD0owop7ntFZ/mOqGbdOVZiPnHUxkQmOYh4JUU6dEfjBL7KKSX3urP+5YM1pZ7nGS1QrX5b5Qw8W2NBZqBK2ka81FEFro+N4ufKqfMHcJVWv43H9LBiTYNu0MAmss3rZx8Adv6KVvbrFI5DaeCbP1+hF6xAVLQe9spFd7YcSXXIXsfAJBHu3EkoWG/Q52sND6ImyZgVdbCCXTTh0jTAGXAsI4CJ4T5dRQJ8r+20Qaf3gxhIqLsH1ngMNixBTzp/12hgv0yiLKVnjU88g== 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=TEjqOp2ydRX3EzP8B7QITYuc63AKCKWMY1nA85yMoEW6zm/OdkkWsqUSgYykDPlNbsqmE+92xLOsKjl5hQAzD5O+gVJP8WPi3Dxx6g+T1k+egm4LLsDEZkPGVtaoJdwWPgr1A+YljFdiwJOYtSm7wjanwzFXipwd3G2/rnebnuHfe/3LVcwwHFZjcpg4x4YFKcON2s6wQQ5d3W+SuZ8fIGjB36pQjdsIjTbKh7r7mXMu0NW9ShB2w+Eb9v8aMteWiLeor5Qoqbmglzho73uhMnlW5zYzYu0yQszQYJffEiFnV2XtGlTSpw9UjdH44oWyJhmzFJHt/7xIsMFPYSjGIw== 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=bnqwg33tAdx7DXbLwVx3af7dmVBjVDSEydeVgspmc8XoakOOEN00+SIOCKyO3zoIfBiHD4LEs2yMj7/QNFSkIIxGHxw/UOk1Qj6OrTeff162htRZXwe5OvIQExE/1eQJQDIgt9bwPF03er3vIC9nXhp/RhgZbpSVDer68cva5e4= Received: from BYAPR06CA0018.namprd06.prod.outlook.com (2603:10b6:a03:d4::31) by IA0PR12MB8325.namprd12.prod.outlook.com (2603:10b6:208:407::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.30; Mon, 19 May 2025 23:56:38 +0000 Received: from SJ5PEPF000001F1.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::f6) by BYAPR06CA0018.outlook.office365.com (2603:10b6:a03:d4::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.25 via Frontend Transport; Mon, 19 May 2025 23:56:38 +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 SJ5PEPF000001F1.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8769.18 via Frontend Transport; Mon, 19 May 2025 23:56:38 +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, 19 May 2025 18:56:36 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v4 1/5] crypto: ccp: New bit-field definitions for SNP_PLATFORM_STATUS command Date: Mon, 19 May 2025 23:56:27 +0000 Message-ID: <5f4bb8f321c57cddd06f4205ee3cbf6bde0b3915.1747696092.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ5PEPF000001F1:EE_|IA0PR12MB8325:EE_ X-MS-Office365-Filtering-Correlation-Id: f9c34f7e-76dd-4d96-1912-08dd9730cb4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: psOTe2qaud0GqXPdD2EBA6ZXjNCHV2u3YhD9Apmqxmb5V/SNC2GZ/nJNPtKwH+sWu3mB+rw93+IK/ZM04Li+rR9uWrnfForeKL25ebbPtT1MI5XkWgwJGgBy56uHyJkQMzLikRTgOt6k+nvM5wnMvrQnsNJB3joOMvMy4TjqpdDRYPVCdvyxi8hQWOlEH0h9iWYPcZ5ygwCf5S8gMhQGQdaIs4YllDrejeg8jFH7fwlfXf51cIBnmbly2QhGXbGdGCdr5L8FvGZ0RCrkBHU18OmtsLH0mrMLHJrlYDLltqSFekVFfdYJXkzieBsuJ0Uk6HSh1Pio/YXO7oUHGBK7Ks50EqY20mhUk2EAnQT3nuGF9mgbXBY9/pqZSjbkiWbkfTdV/o9SuRbTZbbBk94xfVAQtoYpOpssNrvxrQtAVPcoL6OobAKfVaYzn0oPfqmuoIhQF94fwDsqvVdcqfJlRYnjusyMtt1IJTMnfVt+qsdmd/RNbXR1BBVykcTAnLs4gZDyEIcqdl+iP4eXdHrtAnFDAATlQHBJXWQogz0Jw6fvtCVU01XawsNpUPQeB//kPZkjaUaXzVlZanQN5mAftYmMhvFJuB9CuFrXPNb0XMkfwb2kQ2BsFUGnmKL3RNtIB71rZpCQK5XlZnRDeNsrm9TZB5YPnLsC2mNBUhN6hgri6CUSCCY/XxWK72o/bkMO515h4ke2sZa08tSjBw1GmomBHT8/FCmzh9OHp8vg5MotB3dku2NXkkd8zxtZf54siM0fHExkGpXzBlcnm5FU+wSCYC2eG/ytqY+21TosOtwnJGgXGDlXL8q9JZuWwSrTohWqmhCgmCPhgj2egyr3K8CRS918RqXs0r7ZOzuc23xWh9vjJ826FgFCJdYYLTfVhBn9J4VSCSXadN+BC5iWJ6g/C0ZfMKUsGq2aE+ey7dgyHeZ7uqRIfbDqToqRZrtqliAbQWjcQzyCOYu0y+ji9tPKmN4MGaADDd/KU3qn7/WyCp+AnJDZtkTaiPLYzhhiT1tHWmh2T4gfnbKveMuRKIEIAemGGaC0pTq0ltMVc/sH36739ogTPWkKe/eNLOCe+PYsldsOcfCrnl0HiICkoNnj0g9FrgGD5c/hOdPov4+RysHRjZ8wxPnVmlp4FSOlBgtQvTXXE5rdBAeyansDDsx2K2mFwQQKi77HLackZg28HVQTYbyLt2QvSLtiXVdfhrf4Fh/9W4seq6CxzfNIvQ9OQezIDqP1jNBTUuIxUf61lkvLivu00QBOYV3xk39pFaatc5DmlUIvbPPdPLIfkQACIo0zJYhz7ExbJ9gXeVvWBsbid2Xu0nSOUHkNyoBtJ0NGc439kBfxOGo33ftJcMDhZYW8DWMni1XsmiEzT13f1AQOu/Wqd0vxfKDHntcPRytTLgPCYkTXEkl4Y5n2t0C03mAyXvORABtKRcllLDUK3bHkXzKMLwmJNw2IsDz9tb1JGZrDxmPKgcru24a5c3JleOBtcdGmnTPacuUhxj5Jj8Ud4ir5xmi5RzM3m05Y X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2025 23:56:38.0073 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9c34f7e-76dd-4d96-1912-08dd9730cb4a 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: SJ5PEPF000001F1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8325 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 capability + * @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 */ From patchwork Mon May 19 23:57:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 891163 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2084.outbound.protection.outlook.com [40.107.102.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 6D67023BCFF; Mon, 19 May 2025 23:57:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699039; cv=fail; b=ZZjJEqD/CbVy4iz6y3nxvnJiy0kMp10ZwXPRJ1ZQn7uOd1ceXrN2Un9hdqknE0CBcyOVO8P4wWirOO/Exwo+Qf0PUvZV0WHCQ/3220boevNiW62LNuwT8psq6p3WZIMguj4FLLM1Wcg9vmTVBERoEenJvnxayR9wAgx0gZuaeyk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699039; c=relaxed/simple; bh=XwIJVAvkdGi+5qSqFvEpVYYGaUCzLZyDbzzimVbXsgo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KyV2NH+jbvfziVbzvD3kYye7kcCRb2lWan9i81l176GBcuu8u7Pu+IMhl+o5btVkwGjIf2RAapgVTjTfQmUhCWP92TTa83Mn3sMlSQQLLOTNa9/aupGXq9v7MHIErBCuy22SzesE9V8XlQPpP2HzXacwhCt65dWLXjGjCpthAQk= 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=pIEMzLc5; arc=fail smtp.client-ip=40.107.102.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="pIEMzLc5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QiIYuaNah5Q3/0xF6kP+dGAsuO6gzfJ0Kxj8wu90j6WgSqeFrITsFXYLZ2nh+3LGorVz/3JRzIWI4yn1WTwLmxfquXDo2Z3UdTM916uGkvYeXppWD2543oaFPSSCYMR0MyeK1QkhUOBcSM/hKtbIka6mtNPeEHUB5XSUwyDGlYN3RNU/o3tfllXhXnISZFnDNlUNHpUQzXlYy9hbJ8MjVYffUIYWEBMfUHgb7Bsup92NIGGET+X8FGATe0y9Usta2sHOBE8iyrkjGiV/360N5TY7T62Nm3/Nbr39xTo9FazLUNBIR/RK8K/Oov8X10CwQa0MV9l5C8ww5d/KPM9wwQ== 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=vNkjPS6nn7fxafRRCVEVr+xBTMw0ai5qm0iRQjKl8jo=; b=poZstmKnhZodlCqiUHIBq6k+Tk0T54IAw9BFpotqla2gmC2qf46XAfKUjqqrFittHAI8VZFE/1OwX9yIPiMOELf9lKCS1dwJBJhLcHBJdAP5qHfe3fTXiOxY/bWo5uGqg8BtHq5RiEPnEJ39KF7YEf8Q7ok592sW1QlPrORDbKakwJ/3E6nCbhp1cYzmEUg0f86aePccHUtz8ScSEnhQ/sFEiWx4zDTjBGvTy1/6ICRU0VrEbMp41Tib408lYZk+0cWvSKVnz7vEGPMHvoh3GDFarWROx4LMFh/UBSWNcjr0HDt9f51V/OUQD+Zwa/oEhxRGxz9CUAYPmLxPbb0t+A== 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=vNkjPS6nn7fxafRRCVEVr+xBTMw0ai5qm0iRQjKl8jo=; b=pIEMzLc52Mv8EnANBFclkkFizday1uF3kInNJEjW/Ujt5umTXBOdxdvEE8dPbqKPF2BrBm+R3a4I6rJ7e+kG4b625YShMZupBnS71Hf+1sHybYDRrdg/HOssmlGJo5djvfoMLJAdjZINS9VZe1VoNbXThFHnD5G/YG81mnqBJRg= Received: from BYAPR06CA0029.namprd06.prod.outlook.com (2603:10b6:a03:d4::42) by DM4PR12MB8498.namprd12.prod.outlook.com (2603:10b6:8:183::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.31; Mon, 19 May 2025 23:57:13 +0000 Received: from SJ5PEPF000001F1.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::7f) by BYAPR06CA0029.outlook.office365.com (2603:10b6:a03:d4::42) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8746.25 via Frontend Transport; Mon, 19 May 2025 23:57:13 +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 SJ5PEPF000001F1.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8769.18 via Frontend Transport; Mon, 19 May 2025 23:57:13 +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, 19 May 2025 18:57:11 -0500 From: Ashish Kalra To: , , , , , , , CC: , , , , , , , Subject: [PATCH v4 3/5] crypto: ccp: Add support to enable CipherTextHiding on SNP_INIT_EX Date: Mon, 19 May 2025 23:57:02 +0000 Message-ID: <0952165821cbf2d8fb69c85f2ccbf7f4290518e5.1747696092.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ5PEPF000001F1:EE_|DM4PR12MB8498:EE_ X-MS-Office365-Filtering-Correlation-Id: bb5ec418-ed13-4727-ab2a-08dd9730e070 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: gY68x1yJIqlkefc7Ltfd4As0r/4wYKjHyxTPjRgc4k4wRSHfU68aWKoOHmIpKal2xTavnmwwgl2qhR5Of9zaMA4d17f2oSIX0hhd6ZhFt8i1yd7tHj+3V13IGv8GbhhvyqTnyjFnq42VB0Ue3rXMqkfBE9gQldvsfbOifOTeg0HsjDgVIld2/MJIscsej/Ug18klzpMqXr57CbvT/hIbe0SKLRHYNte18jGayDyrbDNfDS9eRIU59jflGEQ2GFahqGMCvhQFeACL1FAOIQFqvFpCGgjvhnuc8KuGZY0+BSp/4R2idWRJJ0nVIFW3w+GXl43wRQiEHdPbeGJP+9tz5clP9dgd2N90G0Xa1zlgJUuqHOr14eEjzn7bX64t09LyVUR62w/kF+dJSo5F2juK8VP65qBI7nrmsm1EVllRpY/cRfQbJcNqw64oG40XPmAWLbwuAt5UMOio0rd7CfMRwxXD4JpbocjwBNIp1M9D09SbckosN4SerP/4HPgPJeLVAPi2sEvM7hmORy+dHggxqxrWLEI5BsGDl6LpzLUp7Ug5nAD24qgLu/ZFBmqs/Rphzzq55/jm9opeLYejugNd14xzeb51AcBrtxv6zgKyvCoEGIavW4L3Rp2mxWmvhR8zZySw/LW8uh/BjMQCkmLyRHNZbfu89NhnhjLpl5MxxCuC91/2toQIT2I1zSYczA81WqwiY6h5PFgNiDE4NRktwXuS8etO9FN1c7Pxi3zazvGO+3srM2F7e6ru3KJncfouPhBO94Y8jT/4IbgLsUs8gZked4NgIxdbNgRFWnmTEfbI8+OQ3c0Jh1f/q/5tH+shWG0yxLoDhanM3q6N8BeNoplEM6T+eczVEPHnbDjAE71Nfpo+Luh+zi3rpirDZ8rFQmtBcEfOW7hedYjjDLngVtq1SNxxdJ7qxwnjj4uTA0kO6eAYtpob7kiaD0sUQ0U7qVEHRlK0veJ0qE0XjbgpGzbLG42H8rgQh9afTytATxJiknRmSHWcJBswHqUQn5i7Ybsxwt8q2Yn1BVj1H4NCjUjCOb08kcRns7U/vhnZ/oNWLkChqSFcgU8QOmwkuo2QC7Xe/DjFnkZvVdQJRdMh5sLRW5i+yGyJutMWRg8+fIQsk9asidUQ7efm+tVAaZ2TGs8+qXDLTtFRm1RnU2CCJafHKvE2BXqBso12/83do9Kf+SqmAXq20hzqvU5VzLcUtOyrlCW98w+vKnc86C3C6DpO7C0LZ2UwEaOLoJSmRO463aqFTBKsDN4KE3VYdgqN7midfBxcjmUYxmYx5CWxcTGopF420eS9dRQBJkjzfBY8vHf2CTvH4ULNiAYXBKsXSK8laZIYYZAy8odTvXdHKNq9HwA88ruFRjhpSviKwBGgzQwSvh5MVry36srLw3tCkrqCCZKrTDncXmOIfn9VmCNZq6S2e3/vwU6OKst0zI6rE19wm0HmYg+OPR11hH9WoW/jN0U10PzEFOcCrCSZMnXg6+gbDwFbLwBgKANaS3Uj7TD+dIoDetdSI6OlNMUF 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)(82310400026)(36860700013)(7416014)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2025 23:57:13.4916 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb5ec418-ed13-4727-ab2a-08dd9730e070 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: SJ5PEPF000001F1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8498 From: Ashish Kalra Ciphertext hiding needs to be enabled on SNP_INIT_EX. Add new argument 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 by SEV firmware and additionally if CipherTextHiding feature is enabled in the Platform BIOS. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 30 +++++++++++++++++++++++++++--- include/linux/psp-sev.h | 15 +++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index b642f1183b8b..185668477182 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1074,6 +1074,24 @@ static void snp_set_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } +bool sev_is_snp_ciphertext_hiding_supported(void) +{ + struct psp_device *psp = psp_master; + struct sev_device *sev; + + sev = 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->feat_info.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_user_data_status *status, int *error) { struct sev_data_snp_feature_info snp_feat_info; @@ -1167,7 +1185,7 @@ static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg) return 0; } -static int __sev_snp_init_locked(int *error) +static int __sev_snp_init_locked(int *error, unsigned int snp_max_snp_asid) { struct psp_device *psp = psp_master; struct sev_data_snp_init_ex data; @@ -1228,6 +1246,12 @@ static int __sev_snp_init_locked(int *error) } memset(&data, 0, sizeof(data)); + + if (snp_max_snp_asid) { + data.ciphertext_hiding_en = 1; + data.max_snp_asid = snp_max_snp_asid; + } + data.init_rmp = 1; data.list_paddr_en = 1; data.list_paddr = __psp_pa(snp_range_list); @@ -1412,7 +1436,7 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args) if (sev->state == SEV_STATE_INIT) return 0; - rc = __sev_snp_init_locked(&args->error); + rc = __sev_snp_init_locked(&args->error, args->snp_max_snp_asid); if (rc && rc != -ENODEV) return rc; @@ -1495,7 +1519,7 @@ static int snp_move_to_init_state(struct sev_issue_cmd *argp, bool *shutdown_req { int error, rc; - rc = __sev_snp_init_locked(&error); + rc = __sev_snp_init_locked(&error, 0); if (rc) { argp->error = SEV_RET_INVALID_PLATFORM_STATE; return rc; diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 0149d4a6aceb..66fecd0c0f88 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; /** @@ -798,10 +801,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 + * @snp_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 snp_max_snp_asid; }; /** @@ -841,6 +847,8 @@ struct snp_feature_info { u32 edx; } __packed; +#define SNP_CIPHER_TEXT_HIDING_SUPPORTED BIT(3) + #ifdef CONFIG_CRYPTO_DEV_SP_PSP /** @@ -984,6 +992,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); #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ @@ -1020,6 +1029,8 @@ static inline void snp_free_firmware_page(void *addr) { } static inline void sev_platform_shutdown(void) { } +static inline bool sev_is_snp_ciphertext_hiding_supported(void) { return false; } + #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ #endif /* __PSP_SEV_H__ */ From patchwork Tue May 20 00:02:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 891162 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.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 7CFB3335C7; Tue, 20 May 2025 00:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699389; cv=fail; b=GIfnG3lcDJuREBymv4BNoJS8fbokNhKmxWZRfXxhXc1QoVa+QWVgOAGAxAN/iLsTVDRkl0yPjUTt2adreO2YhUvANf6W7+xDmdIjNdtjalQFgBO0US8flQu0MGIjvwsXYGbgoI6LI3TWHLSf8YvZ4y10Nbus+3NrAwwJQXbFiOs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747699389; c=relaxed/simple; bh=BaNzUTImRzdPjBturwi/5uz0NwWkgavQbTPx2vz7VqY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RVcg5JeaW2mwk/DblkoAPxcayWezGbV4sTw/d8wg3CpF/o/meUWFjoV/a4inh9ZpNYXbYls7lL6T/3Bu6cwbMmeRyS3JL6gg2mu6M93La5LgXhWxALh4CwEKUK5iX7ylGwUbyeKjc7+wEYqeWNLiHcwlyH+t3ln1CrHkEPwkdUs= 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=uzqgLw31; arc=fail smtp.client-ip=40.107.94.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="uzqgLw31" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hDn9Yy7IMH8qpl5ausOGJlWfI6NpeGwAtqXCA1I9sv4U4dnsVmNCzsqBpA1ts61sr60LHAxZnm+T3QekyoQQhgmxr7kkdZdIpWev0oAemjwW99HTqxEi3fzhjDbE183ZqeFIImPXWedQbLkNmQ39xr2IKd0DzhDRT2d8PzlWAel1kSate1OhvoyB2nCtYAgdkygs7WgtoWiy6ODi44hiPir5bTCmiem/9E8CIiJq/Smx257+m6IyxC9pMmsQcNJFv4IIncsMsYXb7oXRk8YlHIvAPhaBCY7xcOiwQv4Q+DUdqKJH66bFHxOixyIHLGM5OD2MuVc9FFMy9g+9DvX7gQ== 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=fqqNuGg2xxDWvpxqCX9OYUfVnJDf8MFJJeN4KOt7hLQ=; b=Mp9K89cwKa478ITEcbOQMMyFEI9KkQCTTKodxVR0USA36evuVD27/UBDUw9AaHM4EwNsd7fbD+S7g6RYjWhrh5Wn7A1DgA55+IdrqkQXq3zZSvRvh56IVKW50nWBZKnt623puyERNnr9ibERcmoeqc24CSlOi9z7JlNOdfImSfeAJFD2ktstX+vu9sJpj+1UXahiU/DbVW+lggQtSBy2OtwHoftmVfn0zY9oafPB0LkVO6DUVve23RQ7xM7XYXl25xdxxIfLAJQF3sPwyaWb7eeO1cA8KbgaEhjbS4pSM4Or+pPGZ0NvVeeyoBLISQflI9L7eZY0kn0aLf/UXn0RcA== 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=fqqNuGg2xxDWvpxqCX9OYUfVnJDf8MFJJeN4KOt7hLQ=; b=uzqgLw31fAhBX+Dp0CjQn5DRZ92Y1qwhiPRlaDxIPH1+Dgf2TP4gnPef0yQJ3PD2/5ert8I1MfaXHewub/3BFUJupqzRrwAGXzCZP9oVAfgW6zA3EewfMqgM5ZGBZQFBQpOg7kUsghcyAsJdk1ud1nZStQQUAm21MGF6ka87D4c= Received: from SJ0PR05CA0085.namprd05.prod.outlook.com (2603:10b6:a03:332::30) by SJ5PPF1C7838BF6.namprd12.prod.outlook.com (2603:10b6:a0f:fc02::98d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.24; Tue, 20 May 2025 00:02:59 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2603:10b6:a03:332:cafe::66) by SJ0PR05CA0085.outlook.office365.com (2603:10b6:a03:332::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8769.10 via Frontend Transport; Tue, 20 May 2025 00:02:59 +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 MWH0EPF000989E7.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8769.18 via Frontend Transport; Tue, 20 May 2025 00:02:59 +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, 19 May 2025 19:02:56 -0500 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , , , , , , , Subject: [PATCH v4 5/5] KVM: SEV: Add SEV-SNP CipherTextHiding support Date: Tue, 20 May 2025 00:02:47 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E7:EE_|SJ5PPF1C7838BF6:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d912732-340d-4839-01bb-08dd9731ae64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|36860700013|1800799024|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: Zea+Md+zU0PAs6p4UQtqODtQXMdEMqmdiG6zmeyJC6/YChR6gwo8i9xukO09TtV3HTm44yiYLl9e7zcqsoe3CUopC1B4kalNL/rKFyTgGhEH119oxcBvkmXqd2utlNl3bKv/1AU/0NJ7jUoV1FeJuItntKvFnn55+rdUnuJZiHhCHuuy20IXG9MKKQ+qvXWlIfQ0+c3B7IpA2hzVa6oAiwFN0uLgf7InHBwudgPWnUsE3Taz+2aSuu8UxvjPECSoXXN9Bu1FnL5bOJrRBnA8/JaIK/tLCq/aAOtp5WLzrOGHja3uNIQ/TJwW0Muy87FunnO8NvhAfmiiYoI/XHKCTQxMpfBtM640Oi1U5K0xvz5BLRl61XEBaZRilRfwWC/ck4aIrfvDF9cSBMerQQelZ7Wkth84ROCVCJxZdliUa2IrbT2MS029SnFwCxTYANliQ/Mz5fMr4DvjWuJ8yH1O5ZdzL2b+LZtr5bfq64s3IMHLxqmm0AsAvaExkc0q2sOapN7TA4QBQ0hSKMrlavNBetMSUyMNpf9Z01ISnm68Qeru5eVYOMLey/WyauGDsGy5JUDGmETc20240BY9naZoZQNnTxueJHTx2v/uc8nto+J5ziQhg8CCiVeLJq+GUqHNtqA1Jepy5Yi9cbswkv9jwJW7jjIZnRawJGqqwYQMqscvii5pFBLk/6/WO0ECouQ6MdkxFd7SG7Ksc8239byrS1+rK1kGFHneBoVQRjQOo/DZwCFupc5o2CaJAo2ZmKRW0bipg5McJOVvWWouQvKawwJ7/MIMvkgaaAc6/eDRciphQ+kqoKGOhfSTxe3zdtBWlU4OpybbDEoWteLJ0QW85jJYP7pOmn6TWTfgp7E6uQGBGPGYixTsVTEP1ZcwZBVX/XT2g/TOZMUrziuqeEvCHP2FBN0asJQ6WGkmKcKOpkx003HlEQEiKUhGE/Ez6Szd2buAeBEHYIRceoo5nRUXWt2gta5T/dV36kTk31EjfF/XBVd61UxxBjRFCzyn8gHh7ld84mHXndK6Vd6fbJbRGvhvEACooxhpG/OWK84YpmrOu6kk/BZTDMm+0Ni8CdsYauO2JTb6kKBdEuqiR6KFur+EDRlVlr25qbSRbZcaII/+GFPDey3dv4wCQVcZQdjen73nIQOPq1Qu2+m8cczEwqtYkHMT036Ekg1vLdDeH0ToELqnSyzkJB1bThRjXQsB4zVIvg9Y+Jpog3fUbJf/VNhvriSpCbNHPh5jq72H3MOENUySE5YjBN+p1LnX76yB0ia0aEoHF6AFg2vhG93lr7TA/Bq1kly2T4Kf6S1M8yesJMjH7sWnPfTbR70byEgKcA+URAE+ihCN96jNi4aNhze61EgteWvAO4uWjjklc1E5Hd/fHZ4zcx9vIFknRCROwgFhnCDZ6DkqjfFXUE0/BvUYKuCDlLo9pW1pYdvTWpGcXAheRUrwr2zSoiQSmDWq0FUf0r4GBsHcxpDCWUQg09wVEO7ha49VglfD9Lkt4JN6zUUPm3glcKWUWzN/9GDpolgMpFlRfBCpq9HA6zKzNQ== 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)(36860700013)(1800799024)(376014)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 00:02:59.0076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d912732-340d-4839-01bb-08dd9731ae64 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: MWH0EPF000989E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPF1C7838BF6 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+. CipherTextHiding further partitions the SEV-ES+ ASID space into SEV-ES and SEV-SNP. Add new module parameter to the KVM module to enable CipherTextHiding support and a user configurable system-wide maximum SNP ASID value. If the module parameter value is -1 then the ASID space is equally divided between SEV-SNP and SEV-ES guests. Suggested-by: Sean Christopherson Signed-off-by: Ashish Kalra --- .../admin-guide/kernel-parameters.txt | 10 ++++++ arch/x86/kvm/svm/sev.c | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 1e5e76bba9da..2cddb2b5c59d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2891,6 +2891,16 @@ (enabled). Disable by KVM if hardware lacks support for NPT. + kvm-amd.ciphertext_hiding_nr_asids= + [KVM,AMD] Enables SEV-SNP CipherTextHiding feature and + controls show many ASIDs are available for SEV-SNP guests. + The ASID space is basically split into legacy SEV and + SEV-ES+. CipherTextHiding feature further splits the + SEV-ES+ ASID space into SEV-ES and SEV-SNP. + If the value is -1, then it is used as an auto flag + and splits the ASID space equally between SEV-ES and + SEV-SNP ASIDs. + kvm-arm.mode= [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 383db1da8699..68dcb13d98f2 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -59,6 +59,10 @@ static bool sev_es_debug_swap_enabled = true; module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444); static u64 sev_supported_vmsa_features; +static int ciphertext_hiding_nr_asids; +module_param(ciphertext_hiding_nr_asids, int, 0444); +MODULE_PARM_DESC(max_snp_asid, " Number of ASIDs available for SEV-SNP guests when CipherTextHiding is enabled"); + #define AP_RESET_HOLD_NONE 0 #define AP_RESET_HOLD_NAE_EVENT 1 #define AP_RESET_HOLD_MSR_PROTO 2 @@ -200,6 +204,9 @@ static int sev_asid_new(struct kvm_sev_info *sev, unsigned 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 CipherTextHiding is enabled, effectively disabling SEV-ES + * support. */ if (min_asid > max_asid) @@ -2955,6 +2962,7 @@ 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 = {0}; + bool snp_cipher_text_hiding = false; bool sev_snp_supported = false; bool sev_es_supported = false; bool sev_supported = false; @@ -3052,6 +3060,27 @@ void __init sev_hardware_setup(void) if (min_sev_asid == 1) goto out; + /* + * The ASID space is basically split into legacy SEV and SEV-ES+. + * CipherTextHiding feature further partitions the SEV-ES+ ASID space + * into ASIDs for SEV-ES and SEV-SNP guests. + */ + if (ciphertext_hiding_nr_asids && sev_is_snp_ciphertext_hiding_supported()) { + /* Do sanity checks on user-defined ciphertext_hiding_nr_asids */ + if (ciphertext_hiding_nr_asids != -1 && + ciphertext_hiding_nr_asids >= min_sev_asid) { + pr_info("ciphertext_hiding_nr_asids module parameter invalid, limiting SEV-SNP ASIDs to %d\n", + min_sev_asid); + ciphertext_hiding_nr_asids = min_sev_asid - 1; + } + + min_sev_es_asid = ciphertext_hiding_nr_asids == -1 ? (min_sev_asid - 1) / 2 : + ciphertext_hiding_nr_asids + 1; + max_snp_asid = min_sev_es_asid - 1; + snp_cipher_text_hiding = true; + pr_info("SEV-SNP CipherTextHiding feature support enabled\n"); + } + sev_es_asid_count = min_sev_asid - 1; WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count)); sev_es_supported = true; @@ -3092,6 +3121,8 @@ void __init sev_hardware_setup(void) * Do both SNP and SEV initialization at KVM module load. */ init_args.probe = true; + if (snp_cipher_text_hiding) + init_args.snp_max_snp_asid = max_snp_asid; sev_platform_init(&init_args); }