From patchwork Mon Aug 12 19:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashish Kalra X-Patchwork-Id: 818941 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2087.outbound.protection.outlook.com [40.107.96.87]) (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 904CF1917C9; Mon, 12 Aug 2024 19:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723491744; cv=fail; b=HktSAPBG7WmYFDe2pQuALEhidTTNZ8CtxaQo6It2nlnCJCAM5aiRFU2LkMbu0s4HTb7ARCqz6VCk5fIIuI4TJF9UOCJapWxubfXho6dNefJ0SVFX+B14amH3EYYhoDTENZQBQBE2FzD9Vo2br4454qK9w3SvMMK5f4Ng4MR+cDc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723491744; c=relaxed/simple; bh=J39Dg6ZereYGELeBhrrW1Y+iPYA/6uB8kMMWhreD58M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fa+aSB8DOjEYVTcvCqM/L+nALYkLrEZaNdC4V0Ys7QJx0HcDE/HRwsYhwO2EJ2DYEyxRZIzGPvdNgvqFfgxICyxdYeVXwZeccrd+sHUVxB3TkwBYYLYQEszdZYdgKZZx9kCQUINHYFiVtDjsHqlF1hDMMb/lCQT5BMGhWPujLuc= 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=uewOCHWj; arc=fail smtp.client-ip=40.107.96.87 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="uewOCHWj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m8795OnnYRR6CjQKqSlWewpxyKTDhUIGxSLZIXYmK1z/RJBFPTdaBb8aJz2+C8LrnY5dLlfX3H80FwF6OIrHs0uAYMvEX1V3UfxzbKz14eGkI5DhGBeRuHP0recKV2D1Vut8o452YSUvJTND/WvJRMpmGIaRP2uK3AfFfroAk0FmHYIeXAhqrk44MVzXhGJUYT26IOB7wxnmjuR35YRZxwc07tSg4ucfN4J59VIHThnQGuiSe7wnPbHzn/oGdajpNUPgEbPPTjFbiN2YcFgwjLAGxR52afK4I1CVYBR48mP7XGRm7OFmKnkJBLJM3ZytFxZPS8/cW/JAfgN4SwZwPw== 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=jkgrVNwxYHqtZtCzMFeHoqEl+4+6oapQGju3xY/ZMQI=; b=oW8BTmos4/KJrI/6gwQFR4Lw3hkdE5tpazNfg/cDxjxtslNo1hl2gkGLoKFxcDJKsIEaZpFBHTGWU/cB///iqtAbhKOIRQQcuKU9Cd7xtKuChD+bICDOEGSrpvPXP14PNFVjgmmRfN61LUmS3C0A04VbU/AUtfXW07gNPUJR6ZKSomACnAeLum1e5auhQIqW4ZvCgJ13MqCw+eHpowwpLj5PpjIrqBM1UkJv/WBBRUSHzQZhWHbX5prwt0McfRalm1YL9M1Fg66AOFodbQyro4Lo7ccYmUu0WDtsEke344LU15ZND/6LzlsHwoPAi7MtEXRJE5ka7jblGb8UzYkvfQ== 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=jkgrVNwxYHqtZtCzMFeHoqEl+4+6oapQGju3xY/ZMQI=; b=uewOCHWjMsrSu+9JC4ubP4FqEzUfx25WcItp6hX0LirJJNgcO/3ZrCjX+I2xLVDsKGEIMLyFfDIQpD58QK2FIgbWePR2RQv8HVv4+3f/l5Tmj7R5KLJ4s7c/vFcjmVrRHPmc7Yn9tvOA4kosX+zxD6bzMBpousHOglB4UZ1RCyY= Received: from MN2PR10CA0036.namprd10.prod.outlook.com (2603:10b6:208:120::49) by DM4PR12MB6325.namprd12.prod.outlook.com (2603:10b6:8:a4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Mon, 12 Aug 2024 19:42:17 +0000 Received: from BL02EPF0001A0FF.namprd03.prod.outlook.com (2603:10b6:208:120:cafe::d2) by MN2PR10CA0036.outlook.office365.com (2603:10b6:208:120::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20 via Frontend Transport; Mon, 12 Aug 2024 19:42: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 BL02EPF0001A0FF.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.7828.19 via Frontend Transport; Mon, 12 Aug 2024 19:42:17 +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, 12 Aug 2024 14:42:15 -0500 From: Ashish Kalra To: , , , , , , , , CC: , , , , , , Subject: [PATCH 1/3] crypto: ccp: Extend SNP_PLATFORM_STATUS command Date: Mon, 12 Aug 2024 19:42:05 +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: 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: BL02EPF0001A0FF:EE_|DM4PR12MB6325:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c96e413-d696-4540-707e-08dcbb06df66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: dWL0WeG0rrdvz3btCAv+B0k2+8R+KlXATkxDqchdD0QS31iUtZ3KFknDipW+Mxj/DTaYxYpR52CZe55/rhrbjHkOVEY7XqeJPGr9dOwG5aVcAnjMoB9TulVjhirUVhDpKWrndSe279t03ltJCvC4+ZEbl/SZBO2R3nA+65GqA7H48ChA7opfFEljFS14cPf2WnaQJ3ZBsCnJj9grtZccDtS0DYVbLbTrj+3QGv32QNKxXI4txjtNRJQfaR2u3zHD0nouBkbVRypRzjyBrn++iYfvaTk3aeT51fheUwQnZat8XLpN09G0fPnY0HSv2cKeiL+Rm8VVvw9/a3huoR3IaXoLPDnotAPbISvFEYIba405TzugApAKUvNK3J4WQz/S4e/MA0W9FNBPlikP6d8SgF29F5fvUq+iy26pVBw82m8Ca1XNNQMM010Tt2iDXLTNBEmVFXgepbOuv4JSmAwDZCxv8/v/33tmBuemIWqtERM14FxRZ7eSXJsaWeSZGd9DZP1MqEcJi6VSiE8BDTK+rPMRJbJzDqWMeEIohy4FuRZoZJE/gkOC8FWWaYIJJHlY3ZSlFP3j0ao+j0+JQi0Vfu1ssmBbFh2zpOzL2mQV3yZ4S3tkB4KOy1htWyUvwyYw9hYdA9Ke552GP/hLfU6N8j0IF7g7jswRdkemuoGsGuPatvO3+G4AjqsE5vPfZvuBqDgt8dYiAuytSnamN6hAAlVXeLFcegM22M8m+8u2uF2mtl86mQDI0vhhuLm0a8PIWIuF1AWmmJBlBcNersX9RgJ6l3bqzNHcaR5s73xWTpX1Rp6HUE0ca1pAKkz9ZrntSihFmj7ZxySCukO3PD93O7fCro3YwYbtIxPHNjHdaQ4D2cgyc+9H+UDroIVTW4aXAC7m5IILiyEA1O+X2r16/UeJ+aGM7h0yDyblKzJxcHuNqt2ZW4PCVaGBZc7JkEat1q8lSazI4aq3UrPJDXBz6KfAP6SDQla0lEI85AK5fVXVEXHMUxHhuMSamKjvkcovwRRCW19ZoLiAsV0NRm08HOgH4x5Ls6mH/wxeszEiFgxI2NGAIgYvkukYhLVrYxAV9bSnRt94DRsR1qsXey2qmpa+wTP530TiumTicAFdi5M0Jj4aRpUjSYf7hG+f+GkJ4pMT8DvM27kK4jcdYWezAUbSArnbn5K+LLm77KZlasjmbNohGik3shhEkoLfI4LO9/CpXDJkUBH0OIkazYd7QWdpupC4MAbLY+SgUNBOb0I7HhCSmMY9ws3HfdtQUrnXJeu5JJyn9EYI/Uzg546/1F0FAK1oYGezs0+86RueLEN9cFiFZAi8ew4A5K4G1FvTfq4/Zy07NBVfpcIP8Fcixv9ojEJep+tCGuW5vl4h1nZl/o/JqKknHpkypGE0C2+G3rA4H0C6lxoBnGeSTtFgCyANq2rExwVB/JFpqF3uFd4ykAgiPTuDE3vSFfxy3kk5 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)(82310400026)(7416014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 19:42:17.1373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c96e413-d696-4540-707e-08dcbb06df66 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: BL02EPF0001A0FF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6325 From: Ashish Kalra Extend information returned about SNP platform's status and capabilities such as SNP_FEATURE_INFO command availability, ciphertext hiding enabled and ciphertext hiding 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 2289b7c76c59..19a0a284b798 100644 --- a/include/uapi/linux/psp-sev.h +++ b/include/uapi/linux/psp-sev.h @@ -177,6 +177,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 enabled + * @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 @@ -192,7 +196,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 Aug 12 19:42:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashish Kalra X-Patchwork-Id: 818940 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) (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 7D71B191F87; Mon, 12 Aug 2024 19:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723491781; cv=fail; b=Lhm0jnk3F36HU6ETip+JdEfV0n2JUU33fE4svi6I80p5LVeMVMYLBwRh4j16HAY7sN3l+9AYDDQObcbamiUMnMouCHXkhQpsOxaGFKRSjUHqN6Lxt/I1Mt1jq3n1QvD61DD4WFHdoHup4geuE8y3OAPGRk+upxI2UUeMWej85Zw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723491781; c=relaxed/simple; bh=8hzBBpcsKib8XlsvoqsB6iaEUqueXQuu0VIcQG3c1Ac=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rLwAMAKaElbFicyNAuhV2mjE5A54XsWSg3FV3ENFs1SFmm8CtBGpoj8SnTkau6B0uh5o4wjD65+4RcatuQdLrCsaBGUzanQ8+WHydmtZ49no9VHUV7TIf7rqrQOGz4Aokuc1d8RHsWesKt2GJSl96suR5jKjOkGOH99Zy5ihmRs= 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=uD7kJpmS; arc=fail smtp.client-ip=40.107.237.77 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="uD7kJpmS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GMNSUBIji/DWem5ciOW+DRi5W4vVbG8cqZfAXCXkHEg98Y33QKpG5E8Do34eCTUApl9kC00Nwmt8AyKSijfOgbdmQ2lcK67TssRaJR1mU0NJsoenWfGDbw777bWMdL8nxE0+RSmRUXxgndDEZaQWOZzTiR8eqgd1wZAkTimbBVt1AY+OytoXj1PuVdw9m9KjXPmhERV6+83XpQSOSmRAYZfqH56UVDaU9g2AhF9jl3XqF6SvPcyLac8MpAESFBS2XnmiQcYemjSh+dZZN8zIWIVJmkl2/JHkDSXJxdNTrYLz3SUAkq4TslcVRsIbz39lANGQ0ZmTAZ7gOJuHPriPkw== 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=cvUhsD5rDMhC9dzbEnOfdQPnUxiNmTcUaj+pau+k/dY=; b=ydSUorlD/3/XxJ/8e4qhh7lBbt49fi2Wz9yjamkdWPg7VobSuds211Ghi6ZcoN55Yz8GC+jltTE3xu+Vs4pklwu2TY/qvU3YXLCg3tDLHbxAjEkqBWxjF/a7EwXscbqXfe40O+EZICpe16MRY5yEZKnEiSkNctT2E0szOlAfpMpxd/Bd50N6nY1IqRNp0mJtv/oC2b18sgH4sKCbcD9vuaRE9BU05gYs/ZUTq2XzZwQcFbHM9AwY4VimHLbumr2qoIlTkDPj3BIrEimoBQGtFmyWa5IbHU/zC3pcQIpuUZ4U524SrlmDvHUYFOumiH+PqX8LCGQaV8Ow2u8GI6eO8g== 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=cvUhsD5rDMhC9dzbEnOfdQPnUxiNmTcUaj+pau+k/dY=; b=uD7kJpmSf6GSo4MnkgV9psoqBYoQLJncsRf8KOi3u4DIb179Fxq93iMfPcplhuj4j70zrdtlgRqI/N9S3jihH+4cGuTW5qw18tzj0BMKEqlqKDfTuANtnZSsPWZWg/rEd2FgCJ2IojAJflYy1w0M2vOItPXVbq7LshxT2rRl924= Received: from BN9P222CA0012.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::17) by DM3PR12MB9434.namprd12.prod.outlook.com (2603:10b6:0:4b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22; Mon, 12 Aug 2024 19:42:55 +0000 Received: from BL02EPF0001A0FC.namprd03.prod.outlook.com (2603:10b6:408:10c:cafe::be) by BN9P222CA0012.outlook.office365.com (2603:10b6:408:10c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22 via Frontend Transport; Mon, 12 Aug 2024 19:42:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A0FC.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Mon, 12 Aug 2024 19:42:55 +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, 12 Aug 2024 14:42:53 -0500 From: Ashish Kalra To: , , , , , , , , CC: , , , , , , Subject: [PATCH 3/3] x86/sev: Add SEV-SNP CipherTextHiding support Date: Mon, 12 Aug 2024 19:42:44 +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: 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: BL02EPF0001A0FC:EE_|DM3PR12MB9434:EE_ X-MS-Office365-Filtering-Correlation-Id: 52977baf-6829-4a0e-0827-08dcbb06f625 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: oiL62vhFoXGOqb2lt80deVNcDs2h6EymWymF52EAknwTiNpbp5XyJQTeblbrE8oOE2U9d6oj6BklAR4zYqfqGzm+tBUQ8DU8gMFwcP4kzT6e9vxyc3PEC6viOCZaY1kMX50K5I1POA8Z06ErLjVY36/PyZNWQn0KpKG+17OyVq+Wt8rQKV8DdsB9lfSm88P+TTJC+JMJz4UEGWaL74LnH9/LBzjsPoHEOCWb2dR3vLkXQF6zASGS3zryw4Ldyea+F9Fo/qR8x1hvRwuzzCWrA9AP7lWDyUmp+j7DGWzVIAO1M2T3MfgobXaCY8Zej/lDzOctpZu0aQQun6zsla5xuf34nU8rn69GAaPqIkf1Nm7LlYW/Y4mO8xGjtftIsy4o8f43mjb3gy1SM50wt4Ac77gDCa4cvKAkHOYFeWwiVy19EF3w64pT03R9HE+vKOwJgP5abMWUyx4wnYOH1e8oRNMrQ1Rv+cywbZxz0sWARnkWB1vGB9p9MqCXsAjAs63vIgEzKh8SsmhZNhq6OPDZY6iGQCo2630Gezhcms58PYYD57KpoyzaFJeLs4CTyvsDAkjHF38N3jvpnnTrUFHG+gpLK91nyP7Hso0VFffBknPHNQgZzkQyc7CrEr5ap6Y7KLARh0njRmpPdZN7Y2K/G+hzexWbuQnJ5Wt9FKh2LDsyKjUGd+ts3V2KGPaznHgQ63OhsAawWpGbFb7UAbw9eNLG6pG8AUcP/jxTyzxFld4NxoHVa9I+dJ2iO+yE1IRwAhhZfEUh6nsmyZIuu6vZ2Rg24kHhtqa6TgJUKX4Z8E8y6RNC+X+wcQ7SGsWZyRoLkeQ0rTGFKOXz1/2cNRE3+QRWrRGzRWemFI1jjUTQAwueGtR2WtlGjqFApg2WPjVctO39FqDvyNmN2vKuw3b7US+XZeRxcouwXRz2nYQ8bGwOXqq/RRxz99Pvj4rob9Kjy4feWJPoPepCsMLn+3Kie4it2BfzpqS5apUzyQrP4zl7wVLHLEeeOlpXNauhqFeg63hOKR2DnI25qqp5rM+IDjmN8UKuZ3J+/VR4xQ4BZT+PJNz8vVK9milya9gamyeork5Xe9E6DB9xbV0YfxfCS4d5E2l4gohxO6VdENiPLgN/e31zv9PGqRKgIxyveh/3Mcv2YtJqC2X4zKCCN5AjX3YBCA85ooTcOnRhDlLrH3r1Vp041u4rWXsNeRfiEk6b+zWklLggvh8KA1lVzc2hIGiWKbK8DSKRWB/kBN/95Vz+Pe+a4Tv0uYaG/iTUwJk0xLZiRyzqCNOGgwUONIbDnj9swkp/53CxFTNlcEsgjrRUZEApCC/pmDke8p2M4WmApq61CVJoCNG002XxZCnWOtKMjRwMB09HBfYbONdQBfYLEvTfx8PXWYnzCF9Te1jLHHez5jgVgGP4tskISyZA9lyPqBuqESpKlXL8xOoWuEXapW+TNys9Pks0Woy+35ip 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)(7416014)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 19:42:55.2962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52977baf-6829-4a0e-0827-08dcbb06f625 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: BL02EPF0001A0FC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9434 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 a new module parameter to the CCP driver defined as psp_max_snp_asid which is 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 | 24 ++++++++++++++--- drivers/crypto/ccp/sev-dev.c | 50 ++++++++++++++++++++++++++++++++++++ include/linux/psp-sev.h | 10 ++++++-- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 532df12b43c5..954ef99a1aa8 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -173,6 +173,9 @@ static void sev_misc_cg_uncharge(struct kvm_sev_info *sev) static int sev_asid_new(struct kvm_sev_info *sev) { + struct kvm_svm *svm = container_of(sev, struct kvm_svm, sev_info); + struct kvm *kvm = &svm->kvm; + /* * 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. @@ -199,6 +202,18 @@ static int sev_asid_new(struct kvm_sev_info *sev) mutex_lock(&sev_bitmap_lock); + /* + * 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_en && sev->es_active) { + if (kvm->arch.vm_type == KVM_X86_SNP_VM) + max_asid = max_snp_asid; + else + min_asid = max_snp_asid + 1; + } again: asid = find_next_zero_bit(sev_asid_bitmap, max_asid + 1, min_asid); if (asid > max_asid) { @@ -3058,14 +3073,17 @@ 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 (max_snp_asid >= (min_sev_asid - 1)) + sev_es_supported = false; pr_info("SEV-ES %s (ASIDs %u - %u)\n", sev_es_supported ? "enabled" : "disabled", - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); + min_sev_asid > 1 ? max_snp_asid ? 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", sev_snp_supported ? "enabled" : "disabled", - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); + min_sev_asid > 1 ? 1 : 0, max_snp_asid ? : min_sev_asid - 1); sev_enabled = sev_supported; sev_es_enabled = sev_es_supported; diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index eefb481db5af..9ee81a6defc5 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -73,11 +73,27 @@ static bool psp_init_on_probe = true; module_param(psp_init_on_probe, bool, 0444); MODULE_PARM_DESC(psp_init_on_probe, " if true, the PSP will be initialized on module init. Else the PSP will be initialized on the first command requiring it"); +static bool psp_cth_enabled = true; +module_param(psp_cth_enabled, bool, 0444); +MODULE_PARM_DESC(psp_cth_enabled, " if true, the PSP will enable Cipher Text Hiding"); + +static int psp_max_snp_asid; +module_param(psp_max_snp_asid, int, 0444); +MODULE_PARM_DESC(psp_max_snp_asid, " override MAX_SNP_ASID for Cipher Text Hiding"); + MODULE_FIRMWARE("amd/amd_sev_fam17h_model0xh.sbin"); /* 1st gen EPYC */ MODULE_FIRMWARE("amd/amd_sev_fam17h_model3xh.sbin"); /* 2nd gen EPYC */ MODULE_FIRMWARE("amd/amd_sev_fam19h_model0xh.sbin"); /* 3rd gen EPYC */ MODULE_FIRMWARE("amd/amd_sev_fam19h_model1xh.sbin"); /* 4th gen EPYC */ +/* Cipher Text Hiding Enabled */ +bool snp_cipher_text_hiding_en; +EXPORT_SYMBOL(snp_cipher_text_hiding_en); + +/* MAX_SNP_ASID */ +unsigned int max_snp_asid; +EXPORT_SYMBOL(max_snp_asid); + static bool psp_dead; static int psp_timeout; @@ -1053,6 +1069,36 @@ static void snp_set_hsave_pa(void *arg) wrmsrl(MSR_VM_HSAVE_PA, 0); } +static void sev_snp_enable_ciphertext_hiding(struct sev_data_snp_init_ex *data, int *error) +{ + struct psp_device *psp = psp_master; + struct sev_device *sev; + unsigned int edx; + + sev = psp->sev_data; + + /* + * Check if CipherTextHiding feature is supported and enabled + * in the Platform/BIOS. + */ + if (sev->feat_info.ecx & FEAT_CIPHERTEXTHIDING_SUPPORTED && + sev->snp_plat_status.ciphertext_hiding_cap) { + /* Retrieve SEV CPUID information */ + edx = cpuid_edx(0x8000001f); + /* Do sanity checks on user-defined MAX_SNP_ASID */ + if (psp_max_snp_asid > (edx - 1)) { + dev_info(sev->dev, "user-defined MAX_SNP_ASID invalid, limiting to %d\n", + edx - 1); + psp_max_snp_asid = edx - 1; + } + max_snp_asid = psp_max_snp_asid ? : (edx - 1) / 2; + snp_cipher_text_hiding_en = 1; + data->ciphertext_hiding_en = 1; + data->max_snp_asid = max_snp_asid; + dev_dbg(sev->dev, "SEV-SNP CipherTextHiding feature support enabled\n"); + } +} + static void sev_cache_snp_platform_status_and_discover_features(void) { struct sev_device *sev = psp_master->sev_data; @@ -1181,6 +1227,10 @@ static int __sev_snp_init_locked(int *error) } memset(&data, 0, sizeof(data)); + + if (psp_cth_enabled) + sev_snp_enable_ciphertext_hiding(&data, error); + data.init_rmp = 1; data.list_paddr_en = 1; data.list_paddr = __psp_pa(snp_range_list); diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index d46d73911a76..a26b43c2eab9 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -27,6 +27,9 @@ enum sev_state { SEV_STATE_MAX }; +extern bool snp_cipher_text_hiding_en; +extern unsigned int max_snp_asid; + /** * SEV platform and guest management commands */ @@ -746,10 +749,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; /**