From patchwork Fri Jan 26 04:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13532027 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 D2DE3C47DDB for ; Fri, 26 Jan 2024 04:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A4726B009D; Thu, 25 Jan 2024 23:42:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 653576B009F; Thu, 25 Jan 2024 23:42:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51BAF6B00A0; Thu, 25 Jan 2024 23:42:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 41EFA6B009D for ; Thu, 25 Jan 2024 23:42:41 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E4C241C1180 for ; Fri, 26 Jan 2024 04:42:40 +0000 (UTC) X-FDA: 81720216480.19.E07D41E Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2080.outbound.protection.outlook.com [40.107.102.80]) by imf27.hostedemail.com (Postfix) with ESMTP id 1EDF940005 for ; Fri, 26 Jan 2024 04:42:37 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=KhZVpj0s; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706244158; 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=gIRT4X+BHmhFMwKgtoHtLtgItgyKgjXL4IM1rRR5oe0=; b=RPqo/j4mcCbHd+GQnNcY/dVJFd4y91qxPmIPH9m/B39lYYJFpCwt+vvzV2gXeKZsrxG59/ HbgctkF99Y4b9Pmd2N/qbWu++N0+4yxstV0fare4Go81UDOpb4Pzl4Zzs2hVR1MGZ3L71/ 9nELGc7A+7c95UcDziu2cfsjz6qSYo4= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=KhZVpj0s; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1706244158; a=rsa-sha256; cv=pass; b=maYUbZkuYTx5v7AVsLcv3rRt3t42Ec1vpbKNzv359z4WSti6WI+C40mjcfgIEyYv+Vl/qc wWxGGpIZ5DSlOWVB4V3C9B0ZgTExcLtluOXjTxu3RG5DbdBG5PgkEsUUp85ZPMnQDQHX3+ HG81kURpXidkJYYK2D7I1h3gKmgmGBo= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWiyBsvkaStF8zJ0Kh+IHwLKdq7Gre2oAlu9F1h8h0d8FQNP5hF8M5qyDtO8sOZ5Mo+cxzZYyeWVBwASWx3qdu7sJYmxD3TK0d/xSKzNtXuEc9KSNw7Aj+qA1gQA+0Bn6mVzXBV1NhUB1kXC27PTI41kTgUfxgTsJ3CA4Tl8dijdxUOQ/taDC3m4Ri/ws8OAGQC4MLhsf8Ipw7ru3XKTzFord9vSc/O2E0wIkRJdAKdXAkRTodviF9pDWSr63JugDIiyslQMXyE4Vhtm/tQehNhAj5CDurH42S1sO3WmjTz2Mkb8OWSMtc3pAax1BvZHsjAgcdqVu80oquKf4JOaKQ== 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=gIRT4X+BHmhFMwKgtoHtLtgItgyKgjXL4IM1rRR5oe0=; b=CjG3dUY/lL8i21jrBBNVB9SaURWGdeCSEU/Lw13UFclVDuKZGtEFzDC+PXcmtyDt+UaDN9lRabC5ZY4HpPcr2Dt+zgio5ILjkRe+CuGl3wqkkwkDTGU1wF40HLqAxdUOItiiiiG5ibmIafjBIMO0C8L5Z8Z4ZA/T4J5usp1wnKymlAZpyhVykEksVFYy4I+Ybki5ePWbh01K5Hb9ZvowPFNXbZ4E1dTuzk4wz+R7EPNY50dvBcN+HWP8LCUCTcJ6F7/4chfPRIaROatug92My27NZoivN563/bXYAMwHPIehNHBjoPEcl51xluavLZOBjO+Ab0j5PVY8p2Qm8TzSFg== 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=gIRT4X+BHmhFMwKgtoHtLtgItgyKgjXL4IM1rRR5oe0=; b=KhZVpj0skMvlZJBljCeQCjzHpn3N/Pz81st6X4r8JOKFSaIZFtqbe6+z4zPxA2Rlw6PNk4XdlsuMs43xBe/3b7ZzhdvFE4JMxKaPSU+Cu6sMDQ0FqCnj4yGwv5bUxFwBRt3oruaOow4JC2CWvw/qU6o7VanLoopUdyHAtlQgg/8= Received: from MW4PR03CA0287.namprd03.prod.outlook.com (2603:10b6:303:b5::22) by SN7PR12MB7833.namprd12.prod.outlook.com (2603:10b6:806:344::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26; Fri, 26 Jan 2024 04:42:35 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:b5:cafe::dd) by MW4PR03CA0287.outlook.office365.com (2603:10b6:303:b5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.26 via Frontend Transport; Fri, 26 Jan 2024 04:42:35 +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 MWH0EPF000971E4.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.7228.16 via Frontend Transport; Fri, 26 Jan 2024 04:42:35 +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:42:34 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH v2 14/25] crypto: ccp: Provide API to issue SEV and SNP commands Date: Thu, 25 Jan 2024 22:11:14 -0600 Message-ID: <20240126041126.1927228-15-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: MWH0EPF000971E4:EE_|SN7PR12MB7833:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ee5e0df-eb93-40b6-caff-08dc1e29378a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uZkSYZdwzoWmMd6bEqa0pFnR+a8nQeMRW79xJMbALVR61dmbwhviDXxuxduFv1Tsvpk8zELywWoonGZFoOu/9ixzsMVWEXKh6sI6xWXsmAsUSz4QN6tdOU5zByE3IV/ayV0L0/wBSuxIfFOj3eHEs/GeeKi8Sa2d6O24J/EEQSb+kE2RhbFdPJkOaKm+a4NFq0+3/pUr16Hc+l+e3oigLwkqAFNEHnE+wcDUEQC6JsSbb/CXXwLz+5jvv9F3kxV4bts7OWBjpHkMj2wUY6XKo0T7vN2MMuzxep2bp9KU2/eiQV4QhIGTrA0/7+Gk4kMguOGVw/2opJTSlo6HjaStDtS33SMPiKZVtEAIg5xcZgg8l28KAeGw8rCfaCgMe8dPTmWQHg+eGSDZG21jQiOTTYiRe6UztT90+2y44GQbkwTDmKNm9iZZUlvbFmVvQ3O6K39gYJxASnv3lqU3tDEMO9QsRPbDIqNg1Pp05ovthqCGvpm2f3QZyVd9gkvqvMxF/Gpz8LOsrCDLne9GreIbRrcCSANn1Lcla4mqSzama2f7ZCUc7kA6p/jBLmY7ZrJCLy7oQbXn/7kDQIrJIF7crwDIW956RB8J5e70E+2cz5CCt0JDj1//9awKfyGBSHz1QKT1KG5sZvCPz+/igA5hV6OHVleMYCOiul1BeZxsNfz4A9cGZmrxcnz7HHKKmN1hzM8JxTCqOu2bF2MCSZ+S7bGxarlnU1hQKCqKN30ICs/b4DQzEJ/Boxf5F0CsDXZXE2WlJwTDY/smrW6F4kwzUiP2mgYnjEq7xphM3yxG0VU= 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)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(64100799003)(82310400011)(186009)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(36860700001)(47076005)(86362001)(2906002)(36756003)(41300700001)(81166007)(82740400003)(356005)(54906003)(478600001)(6916009)(70206006)(2616005)(70586007)(5660300002)(426003)(7406005)(6666004)(336012)(44832011)(7416002)(8676002)(26005)(1076003)(8936002)(316002)(83380400001)(16526019)(4326008)(40460700003)(40480700001)(36900700001)(134885004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 04:42:35.2540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ee5e0df-eb93-40b6-caff-08dc1e29378a 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7833 X-Rspam-User: X-Stat-Signature: n8zf36cx5yg5w75iss3hhfxo3td77n3i X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1EDF940005 X-HE-Tag: 1706244157-615044 X-HE-Meta: U2FsdGVkX1/cHEEq4b4KLqDDdNwOCiTJyW3j9TiZrN04hl4JNKpBCDosbXq2BybKicTz3duTQ+SekkA11/N5YKdfubCiNtyIFxk9EIWGBDiPsJGRYLWARNx0pXH74kWEPrXtTzVDFSSyMeMTb2fDfhyFilwpP0ZDqlpwYohJbD/MrAQ8KDhoTssU7mrRNHRoybVHz8amsVdD9MrywjRlLofEfoHb1EqOgNZIySv7W0VplOKehz/O4uocpfvpxMa2DYk4pzzZE3jksRV3EvtDZ41pTZ630YPetGn2RDoqubTmcw6uorKZbPlaAGTGwms8DUD3pnbFAYBT/eIHecV4M036i++1gLKBQAfcTSf11jh5ElCoa9CuIoaXdvox0X/sPc+om+KHLcZa/+o1+pQKn4rezPMNK1ycnQoBbvdcM1koZV5aPNkeA2aDX0i6CsnIbsDtYGlfiIgnBTYP7YmQPAx4u9inkSxWz9afUIc9o6b6DS/7cIz7tTlkxm14wHfZeMW1UTSUEIw1e2PGG9FUNXg7aCwEzOgy0C7LADrinsNeloBPQTCOmqKsY3b3ZIPoYc5BATMcH94d7Plg521P2dgyJdiR03rRYesP97YK38ggYyBz2de0KaM95uNus3WNs3nkUoiXTwF7cxcqZdLFGuqlHi87vGZPELpJAbWF5x1tLASwNepT37yDgLs0e4bd5wL45EqTieihN3HBlQUe4v6lLjwzqui7W9kzy8ppl3kb/OFP8NvknHOHk1V+r1O/gh9RDkwoxSWtfaznk8ef1AjwNtMksQPJDv5TfIf8prOJ8W7rPO+LnTDLJc0xqeVxir4YSKFFPKS74/aXT/5lCaJKQxlSs9OOiR/LUh9bxy1T6KGxcXCXMskgjXj7pQI7SPj/94E/OdOEJFa6C7Pw+sDo6CFaKD5NFbfrDOkWi0bbCjgav0iHgfXkW4od4/neOLRnuCbZN8XI6I+n2kt xMA== 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 Export sev_do_cmd() as a generic API for the hypervisor to issue commands to manage an SEV and SNP guest. The commands for SEV and SNP are defined in the SEV and SEV-SNP firmware specifications. Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra [mdr: kernel-doc fixups] Signed-off-by: Michael Roth --- drivers/crypto/ccp/sev-dev.c | 3 ++- include/linux/psp-sev.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 712964469612..abee1a68d609 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -431,7 +431,7 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) return ret; } -static int sev_do_cmd(int cmd, void *data, int *psp_ret) +int sev_do_cmd(int cmd, void *data, int *psp_ret) { int rc; @@ -441,6 +441,7 @@ static int sev_do_cmd(int cmd, void *data, int *psp_ret) return rc; } +EXPORT_SYMBOL_GPL(sev_do_cmd); static int __sev_init_locked(int *error) { diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 8128de17f0f4..c7dd6ff9f36b 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -915,6 +915,22 @@ int sev_guest_df_flush(int *error); */ int sev_guest_decommission(struct sev_data_decommission *data, int *error); +/** + * sev_do_cmd - issue an SEV or an SEV-SNP command + * + * @cmd: SEV or SEV-SNP firmware command to issue + * @data: arguments for firmware command + * @psp_ret: SEV command return code + * + * Returns: + * 0 if the SEV device successfully processed the command + * -%ENODEV if the PSP device is not available + * -%ENOTSUPP if PSP device does not support SEV + * -%ETIMEDOUT if the SEV command timed out + * -%EIO if PSP device returned a non-zero return code + */ +int sev_do_cmd(int cmd, void *data, int *psp_ret); + void *psp_copy_user_blob(u64 uaddr, u32 len); #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ @@ -930,6 +946,9 @@ sev_guest_deactivate(struct sev_data_deactivate *data, int *error) { return -ENO static inline int sev_guest_decommission(struct sev_data_decommission *data, int *error) { return -ENODEV; } +static inline int +sev_do_cmd(int cmd, void *data, int *psp_ret) { return -ENODEV; } + static inline int sev_guest_activate(struct sev_data_activate *data, int *error) { return -ENODEV; }