From patchwork Sat Dec 30 16:19:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13506894 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 D202BC4706F for ; Sat, 30 Dec 2023 16:28:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C27D8D001C; Sat, 30 Dec 2023 11:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 673858D0012; Sat, 30 Dec 2023 11:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5149B8D001C; Sat, 30 Dec 2023 11:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 42C768D0012 for ; Sat, 30 Dec 2023 11:28:11 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 23EB9C03CD for ; Sat, 30 Dec 2023 16:28:11 +0000 (UTC) X-FDA: 81624016782.04.E3A8B0E Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by imf03.hostedemail.com (Postfix) with ESMTP id 2C0CE20006 for ; Sat, 30 Dec 2023 16:28:08 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=e+TUBCNy; spf=pass (imf03.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.73 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=1703953688; 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=+HRK4QFVzuwysPEJ6g24TxyO83Z9D4pVegKGwtG3IRI=; b=BgxbDrEFqyLRqwBBBVNF18wULL8DPLpwMhgp999SItCni+0vzUWh1Gqpeg1N7g7sM4RrtF rleEBqbp6h7T48YV/mm8/EkYWOp5R1ownhqDIUaIThJivOfCUBOKRbsZ+pzbqyV7xKYyxF 1hfRn5oAM0MdREWw3xbO0nm+Tlm/z5Q= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=e+TUBCNy; spf=pass (imf03.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.73 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=1703953688; a=rsa-sha256; cv=pass; b=hXbhmX4EZ6It8HD37ren3LLUF1rSlDDKh3UArM7WmSM2V1jlHhma8WcjPia3eKUHyZg4Zd Tcviax3Om9M4m5wkpNzFQqcUpKfcxDPCPm29sIhSA0qraZPJ/MxAiheT5jg8CNaJuR5ES+ 8iiwZnEDBEMKXnfeYTnYhiMlJgpLHOk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EqxBW5KRjNmIwx6folFiFWBt4jAyC1sAi9EH5nJJRFAJTYQV2DyRTplcWpkZRP9GqUvIaqlJbMBISax4wb89qfgnrM9RxYpU/rVI5jTvne1Lnp2+sS7rS4voDtALJTVXBp1S+oK0CIwmyXVMoIGgSSsNw8A5AXW7/nN87SwF0AlZf9MQJdi2lra9/JEoxSukXtjuHDUokHJAJpbXY/L4csJ4M56A8Z+v881dHGVHzqfqyHE660BooP9bz0iMXtSZtWFhKqYYDCS1d5z+1UUkzAEoHELPa5UXq32BR7qb3CBY6k0St8RwZvj8U2S0T/ZqkOBAWEV6mkEywIzMLDU22g== 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=+HRK4QFVzuwysPEJ6g24TxyO83Z9D4pVegKGwtG3IRI=; b=lOhNXnXirKuRLFbHJhAUwyAnA6noJQDkznsqYDM1Rao366xsjjHFZlRa1HXtGjox60AueyQBivHVOYNKaFJryYsFb/jbDa0L8SyJet6xps7Sj17J5Tc+3QGU4IAvo6wJWlkZqbXacT53fb189EQspt+DInHQ6REq/oppXpZ1pulOWvBe5RucsiUYivLmDEOi1ZXTKdxAfnRpI+SCHk/nqLQ9m1SbqYtKFo7hY7e+W8EfNk3vdDwPrjaMQZqYIuZ8iQAcNwTDq4QNyLqG4sqreQ9x0oWc7utSdySH4/MmarzgzRxCAT7ARd7sijglDfr4IDhFtWdRCljnZOGGSgNX9g== 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=+HRK4QFVzuwysPEJ6g24TxyO83Z9D4pVegKGwtG3IRI=; b=e+TUBCNy2ZLJ5EtEdUdnA0TYh3Ke+tns3orq+8SuFdWt5orNpY2I/Yhor4FcPRt8wz4lR7TahQn337CVDhB7kWAlTUvoVRu4Ax8dmmldl9OeAHBNNvheIMnpqybTLfJUapNPtDhtgYRvagVx6yGVBsQICuQDxc8LQquWWaT21HY= Received: from DS7PR03CA0216.namprd03.prod.outlook.com (2603:10b6:5:3ba::11) by IA0PR12MB8227.namprd12.prod.outlook.com (2603:10b6:208:406::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.23; Sat, 30 Dec 2023 16:28:01 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:3ba:cafe::dd) by DS7PR03CA0216.outlook.office365.com (2603:10b6:5:3ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.22 via Frontend Transport; Sat, 30 Dec 2023 16:28:01 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7159.9 via Frontend Transport; Sat, 30 Dec 2023 16:28:01 +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; Sat, 30 Dec 2023 10:28:00 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh , Alexey Kardashevskiy , Dionna Glaze Subject: [PATCH v1 26/26] crypto: ccp: Add the SNP_SET_CONFIG command Date: Sat, 30 Dec 2023 10:19:54 -0600 Message-ID: <20231230161954.569267-27-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231230161954.569267-1-michael.roth@amd.com> References: <20231230161954.569267-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: DS1PEPF00017096:EE_|IA0PR12MB8227:EE_ X-MS-Office365-Filtering-Correlation-Id: 1636d343-8966-4580-b80d-08dc09544a92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dPhh2KRSw37/HaErMzCmJTsnzeUXr0kvWj1EuT+B/5kelbTimLSQIEfsjS/G4mkDbRZnnc9Qq2sjSFBn5qgCMvlhxbthL+WQrgW513k10E8qjEXJYwJ+Y2IznFOhD+q4bvp7FclaENDXHJedDaizBS5n1ti6Obr0gc6oym9DXWAcglXvVZVRblHnXiLsTC9/wOCid5twPWvkduxKyuAr+16YobVAGObsBt1sdwWPAGnM+6Om3k/62+TKmNSvvRsg+tHZBenKtKCaQ+reTqz22JCXjhXsOWhDz9NJ55sly8r0g9phfCLSePCjoinjmuW+/rzhngA4D1AfUy8e+1dsDUIEKAszz/TAxo8FWIUblYmnQozA49MQN2Vne5ceh76qf62X519VKIg0XQJWxl9frZtBTcpJiKEJTYIfj3DHbX/kQ3rwUrFvJvBiHiFp9CKQrEVLjb01V0mEgujyUF0+iBTp2QDliwQ8J/PaEa5/yRBDUdfsQJS9GbphtvGmWKCiGoBVT0kIlT9bMrXCQ+ZmWNy5o5sZIJSFeNc+SvlPMl3mWaq/eS7bLMuzHDmyqLYElPpYUkCzWIP2gGud5s0SHZ73L3gra3UsnnoeXqwDrakFi++d72nvGBHt1ZXx55O+sjMpcLhkb5rqsUIpadAUKeaYLWCCxmIOWVFB3u/yQSjYfYl4/3uZnEhlyTJ/paJDyWzcDTLmwtmFJEvJ7VbiFYv340HYqbziNAi94XXdPYVIPdQ9qIUda9+QhfQyCVo9sjjojcFtXg/+o4Q6Bnf0Tg== 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)(396003)(346002)(39860400002)(376002)(136003)(230922051799003)(451199024)(1800799012)(186009)(82310400011)(64100799003)(36840700001)(40470700004)(46966006)(2906002)(7406005)(7416002)(5660300002)(41300700001)(82740400003)(478600001)(36860700001)(2616005)(40460700003)(16526019)(426003)(336012)(40480700001)(83380400001)(26005)(1076003)(6666004)(47076005)(8936002)(8676002)(36756003)(4326008)(44832011)(6916009)(356005)(70586007)(70206006)(81166007)(316002)(86362001)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2023 16:28:01.2018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1636d343-8966-4580-b80d-08dc09544a92 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8227 X-Rspamd-Queue-Id: 2C0CE20006 X-Rspam-User: X-Stat-Signature: jxfpgeseb1jz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yMP/68qqnyKi/XRgHxkhEox11XhWUN2u7xWIGo7rrHLNvEp65q4TqSOMaqBFBhWTqmSQycrAAx1ubjQQtOFb41D8tQ3XdLfi1kywyL6ZqwFLFkJIPixypmx5xpwnebkySz9iOj+PoC4WnW5gzbp+ZF6hB4yc9bkASlEU288Z9wc1KIsQ4P6vvJt77O/qjWmu5oGEKwCqqAzqrZVzNh+/BNp/bKJPHBRWWjkQoqyP6ZpeEomz7alyNk0n/BEsQw7rI856KXg/z0WWjx8HzqUB4JtgvtyLrdEr1EFlwyXUSPb1Ud9tOip6VsjXD2Az4PaxpPVVe3qKS9jYoiaiyN2+do42emX71EJ7cfVgR+ad/zEfaabFqTZuyKZCt7gPQabZg== 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 TCB version to be reported in guest attestation reports. Add an interface to set this via userspace. Co-developed-by: Alexey Kardashevskiy Signed-off-by: Alexey Kardashevskiy Co-developed-by: Dionna Glaze Signed-off-by: Dionna Glaze Signed-off-by: Brijesh Singh 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 --- 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..4f696aacc866 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 + +The 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 9c051a9b43e2..c5b26b3fe7ff 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -2018,6 +2018,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; @@ -2075,6 +2092,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 01aab4b340f4..f28d4fb5bc21 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, };