From patchwork Fri Jan 26 04:11:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13532063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3A91C47DDB for ; Fri, 26 Jan 2024 04:46:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 680796B0074; Thu, 25 Jan 2024 23:46:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6087E6B0087; Thu, 25 Jan 2024 23:46:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 482566B00B5; Thu, 25 Jan 2024 23:46:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2C03D6B0074 for ; Thu, 25 Jan 2024 23:46:53 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 077921204E9 for ; Fri, 26 Jan 2024 04:46:53 +0000 (UTC) X-FDA: 81720227106.24.B9CC8B4 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by imf19.hostedemail.com (Postfix) with ESMTP id 169F01A0007 for ; Fri, 26 Jan 2024 04:46:49 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=eWPMk9It; spf=pass (imf19.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.86 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1706244410; a=rsa-sha256; cv=pass; b=v2AIf8rdyOYbwelCg/5YLtnnpIbNRxhxt83GUtqysg1GuPzsxsoZAL0Zz4ROuNPfm2NUEn wTCsKhVCH6Ji7FmLqzKZqkAQSZJ/PxkoQBp79EXjwg0q1VROSNC+S5ZPKA9P1iG595iZt+ FXRUKWww9G8mSla/c3WFzAdXP1x5d6Q= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=eWPMk9It; spf=pass (imf19.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.86 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706244410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aDeqv0Rd+NQEOVYZuoLg7AnInMZUEU9WR2h7GI/0rZw=; b=GP7oWXB/IsNFtR831EdAZzamL81m7ei9MLM8L9rS6iLZYrjNlxFRWHPAZL6KW16EhUFHgD yGAQrdnw4AoUdIR8Gq9aHS8Q1VYM3Dy9odzQbLOx3Plz97R0y/c6Koj4zf3vvQcNeEds0J OZ22oB1kNGDwKp1X5eSQ0XrgcTuiMxs= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C7TaOS+T6xv4IAh7SPObQbVcd9elXaUW7IQFoDXlEe+v9TBQARTepxRKpbsc+pndrcp3vvZEZtiT/9EykVbto/E8wamWzFmgZ/585snUMIXQ6iFgiBP0QUNT6B/8PcqpT0MU02fpuD5NI5PzqHKaFprqph8u5miqoMoa8GQBGjnMXT7dKRyN8dzSXX3tCP82eE+SPWtenB5IDY0Mjq5kDfG1htL3xLEVpUaqhTGxFtDoVF5ezrqmUOfcuMS+YXMdUxIyOcT8ywyngEzVt0QeNfXR3uDJcfDqR/aTukSk3XIRvEsPHMIr+VgsOWZmMPcgEzKRXYm0vNa2wExtm5SCLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=aDeqv0Rd+NQEOVYZuoLg7AnInMZUEU9WR2h7GI/0rZw=; b=eLkiNoctUIsw/hJPkI2fmS6mYF+G2UFx/O9oG4FBZOSeyAj2Re8pem/U1kn0bL9aHmGHiYTaQuI64b4G+JczHoC5RQcgMT/RItsPyTi3SOot2kBmb+7QHFJlUoytR9Lif3am10Cbeb+2IPlgsTqfyHjvGMUSsL/s2BNg8laxsbZw5Vql8BqMFjt1P3EnhaVxqeqyjT517516URug6g0WL+C0swA5AeAfq1OXuczDiClB8cfZjD3DvP4ehj+ZaWp7N4IF0AfPOBdLS+vkZ+3kT8/+wBh5hpGPqQ4+6r/qtst9BdSJOQWvro8lQ3Nq87VQnmnmQ3DdvpmOjUhSwRbUxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=aDeqv0Rd+NQEOVYZuoLg7AnInMZUEU9WR2h7GI/0rZw=; b=eWPMk9ItwDqFSwJb3jUb6+LgwVjQw3GJBqSzw7C37mQzf5cFfhT0BEOmVJTKxLFgRQQa3VF+ylzbSbThlrqUkTFZrdir1tIuyCB6Aim9/npxvF494ip/+yWsdHjFz3XiGzjej5V3/q87J2QvsTAO+rOXGM0YQ7h0jtVQfSsYQdg= Received: from CH5PR02CA0017.namprd02.prod.outlook.com (2603:10b6:610:1ed::19) by BY5PR12MB4869.namprd12.prod.outlook.com (2603:10b6:a03:1d9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 04:46:44 +0000 Received: from DS2PEPF00003440.namprd02.prod.outlook.com (2603:10b6:610:1ed:cafe::7a) by CH5PR02CA0017.outlook.office365.com (2603:10b6:610:1ed::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Fri, 26 Jan 2024 04:46:44 +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 DS2PEPF00003440.mail.protection.outlook.com (10.167.18.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 04:46:44 +0000 Received: from localhost (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.34; Thu, 25 Jan 2024 22:46:43 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh , Alexey Kardashevskiy , Dionna Glaze Subject: [PATCH v2 25/25] crypto: ccp: Add the SNP_SET_CONFIG command Date: Thu, 25 Jan 2024 22:11:25 -0600 Message-ID: <20240126041126.1927228-26-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240126041126.1927228-1-michael.roth@amd.com> References: <20240126041126.1927228-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: DS2PEPF00003440:EE_|BY5PR12MB4869:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f7e2305-fbb1-427c-3cff-08dc1e29cbe7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aqDsBcSb6NdQLynCq/UCIeCeSzRx6k0iglwucgxYu3q5U+ZjM/2IC9biXlr2W4l2hoxIn1+6GoNzOud2aritAeAmA9A/ZIp8Nf1oI7LKwlss3YvIkqls/+suAnc6nry4/9nc6NteXOcfMJRLFBVN9t/IlNPHZueu8UAOUdA2TpOy1Lll3ibu5rx3UdTZozYRrqJbr9t83Q6GSyRGNEIGdmx/M3qJB+TzNvE/Ff732vMkkdGb5WkwTK3gt10bIfKdiID7OpBSNFLWxqjw8lNrfdHo7aVuPsTCgc45BhBIAYrEIvSNpJyUxKv9yVjeoiJ6faOovaw0tjzO/B2XwAhyHXDY5KtxxnfKfhOlXp40NVcYI7SI0v6Q0nVuLOFtKWlxBQBJpWwPRQDg5f+KHLxoTmxDCmgam49qCzwuRWRJMK40guZgpmQ89aFPHGaETiCG6F9i1aQchJAi6tzOy05WfqznMha/a1XHVB5aahYF5Hitw9qj4vxAyA3Vzkm5vRqZ5EW6wVpQYJJaGIJBrWuqqdOCnmyTgwCUYqlbM3fA5TsJVshoj+1O9aOVrxt2OGhs72HcZP7j6/OmutAlUWQI7Q1o79vWghBOjpxbXB2EbxmgOt6/thTATIA93R4pUzmWNWr5iZv40h+vMDWWf0rzAbLofTAmLCs+4AGq1xNknEwxdJWI/X0yaWA8lPThLg6IvUaByyOWq2b644x69SO0QmXSwadGKO9t2nEy9kiHX8BqrMUE15lkerf5wGmYFbfoxsnFt0iH1Exs0wiUqUfg+A== 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:(13230031)(4636009)(376002)(136003)(39860400002)(396003)(346002)(230922051799003)(1800799012)(82310400011)(64100799003)(186009)(451199024)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(2906002)(36860700001)(5660300002)(44832011)(7406005)(36756003)(7416002)(356005)(86362001)(426003)(4326008)(2616005)(336012)(26005)(16526019)(478600001)(1076003)(6666004)(41300700001)(47076005)(8676002)(8936002)(70586007)(54906003)(83380400001)(70206006)(316002)(6916009)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 04:46:44.2252 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f7e2305-fbb1-427c-3cff-08dc1e29cbe7 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: DS2PEPF00003440.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4869 X-Rspamd-Server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6zdOqVvi0Mj711 znjlSpW6 RhPav6j9rMTI6F1rNfwk3fzhSNQd6duqOhuMPJH80B4TfNQUltPiD8xhAQkvW8dRtwtwfddICZqWe60mn815t44QOkgYobQEr6PgBy/UC2/YLuVo6CMwwyNYcTLY/2RcgD3vH5yeMIsOwxnbR6X2vxledgIgs08RyfWKTAYGWSKoIsCjCELI2ce3W8fZL4msW3rn9pCbBoAiqya5xRuJ2tWCVRkUt9S5l6GqYMRCUIPPSD0MRXxg/TRVGAd0hop7e/Nk2T2uKtFkYF0se7bxeT2UTkcsZxFNKP+yVyl7Y30SCU7uHVJjK/r24yKq7Kgq45q5qKGUeGdSv9JzTbN2/6Q0L+8AzYWxR0CdCGSnJaILNHs6lUcF1mZttT01xNgMGDwHd42LmJXm3m1+8+jFFEhzbcg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Brijesh Singh The SEV-SNP firmware provides the SNP_CONFIG command used to set various system-wide configuration values for SNP guests, such as the reported TCB version used when signing guest attestation reports. Add an interface to set this via userspace. Signed-off-by: Brijesh Singh Co-developed-by: Alexey Kardashevskiy Signed-off-by: Alexey Kardashevskiy Co-developed-by: Dionna Glaze Signed-off-by: Dionna Glaze Signed-off-by: Ashish Kalra [mdr: squash in doc patch from Dionna, drop extended request/certificate handling and simplify this to a simple wrapper around SNP_CONFIG fw cmd] Signed-off-by: Michael Roth Reviewed-by: Liam Merwick --- Documentation/virt/coco/sev-guest.rst | 13 +++++++++++++ drivers/crypto/ccp/sev-dev.c | 20 ++++++++++++++++++++ include/uapi/linux/psp-sev.h | 1 + 3 files changed, 34 insertions(+) diff --git a/Documentation/virt/coco/sev-guest.rst b/Documentation/virt/coco/sev-guest.rst index 007ae828aa2a..14c9de997b7d 100644 --- a/Documentation/virt/coco/sev-guest.rst +++ b/Documentation/virt/coco/sev-guest.rst @@ -162,6 +162,19 @@ SEV-SNP firmware SNP_COMMIT command. This prevents roll-back to a previously committed firmware version. This will also update the reported TCB to match that of the currently installed firmware. +2.6 SNP_SET_CONFIG +------------------ +:Technology: sev-snp +:Type: hypervisor ioctl cmd +:Parameters (in): struct sev_user_data_snp_config +:Returns (out): 0 on success, -negative on error + +SNP_SET_CONFIG is used to set the system-wide configuration such as +reported TCB version in the attestation report. The command is similar +to SNP_CONFIG command defined in the SEV-SNP spec. The current values of +the firmware parameters affected by this command can be queried via +SNP_PLATFORM_STATUS. + 3. SEV-SNP CPUID Enforcement ============================ diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 73ace4064e5a..398ae932aa0b 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1982,6 +1982,23 @@ static int sev_ioctl_do_snp_commit(struct sev_issue_cmd *argp) return __sev_do_cmd_locked(SEV_CMD_SNP_COMMIT, &buf, &argp->error); } +static int sev_ioctl_do_snp_set_config(struct sev_issue_cmd *argp, bool writable) +{ + struct sev_device *sev = psp_master->sev_data; + struct sev_user_data_snp_config config; + + if (!sev->snp_initialized || !argp->data) + return -EINVAL; + + if (!writable) + return -EPERM; + + if (copy_from_user(&config, (void __user *)argp->data, sizeof(config))) + return -EFAULT; + + return __sev_do_cmd_locked(SEV_CMD_SNP_CONFIG, &config, &argp->error); +} + static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -2039,6 +2056,9 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg) case SNP_COMMIT: ret = sev_ioctl_do_snp_commit(&input); break; + case SNP_SET_CONFIG: + ret = sev_ioctl_do_snp_set_config(&input, writable); + break; default: ret = -EINVAL; goto out; diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h index 35c207664e95..b7a2c2ee35b7 100644 --- a/include/uapi/linux/psp-sev.h +++ b/include/uapi/linux/psp-sev.h @@ -30,6 +30,7 @@ enum { SEV_GET_ID2, SNP_PLATFORM_STATUS, SNP_COMMIT, + SNP_SET_CONFIG, SEV_MAX, };