From patchwork Mon Dec 16 23:59:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13910693 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2050.outbound.protection.outlook.com [40.107.101.50]) (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 7288C1DA305; Mon, 16 Dec 2024 23:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734393563; cv=fail; b=qxZkS3RsFrC/GjNDSbWcmuTSFfmBHUCAvvIviEEKnf9w6/95FH8Rb/sv7iDfNT0Mzr8IampFxKegEZ8eqoEgmHF7iRYRho1respQBJ8wolMFpj4vTSfo4uqGTJNxnV2USo1sN/KDCwydhhs+RInFQML7zTh7o0RcEn35WGhLGlU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734393563; c=relaxed/simple; bh=z96zz2l5e/UrE5xUTkiYFBvUSkoBjAbXT+XnOlMKlqE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BmZPWMXCMZX3HVm9jEH/BSdsJliaPKyfcW5vnZIE6eYTLtDr5GVT9aoh3jNK8lEhMJSOA9KazRCOf7DP7jgJVpjtDSoKGx2L2RTwfpCD3uBQ3YZBFJF5Whpt1EzDh2txK5x6Di0j13SVPnAlzX/d2f7D/HvouW93MGIeAMEVLOE= 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=MUARCNxi; arc=fail smtp.client-ip=40.107.101.50 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="MUARCNxi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QAaa/nNqgPz1oyvxei0jKRNYKuaSiwOPAmIy7wseb9kvTcb4YvOK82BoMbtalg/g+3gQNg9NeLlwAOySA6Lg16ZMeDxHrlM3Uy0LMPYBK1J/dQ+cgncsyegzKOHUhV88XOeFqHnS6YWcmjSXBQRnw+OBn7wmeGLgHrb97I9GB4CKtFKJ6MVDfOxte7ihQMMHfn0AE/M50k2uqZ6rj8Ikiq1gjtY0AFQ5ST+EUrl+qyXEZl9smAKeIao8elLwD+MUfHmUPpGkq9R0wdXuQ8Dra6HrLCJBefLGOPZuevKHrhCr9ACQvaA4pReoWiKy2HGxOPhlEsc15o4RjvIsXpUfUQ== 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=gWDt4j5npiNQiARNJc9xzgL4hq7NnujXlMDBc9bJRI4=; b=oQUQzmVnNLO9OOg8DTFvv0xFhNVDHz9ki6zswpRoRolx2y21Xocb2HL6Ri9+S/TVAQp4pUvYpTC24djIacSuPhOTBJCrlJq1DFpyXarub0Nh5t7QWs4DN+qoP3UAkmtRuREclVctR1l+cCDE1XO42KnJooRBeFgq2owSOiVPnSVtVZ5pwRxUE4BvXtQDdd6FzwGvy7UXO8N5r6zSq2xvrTTLux7lVfLAYuAVrDgTNKM/6CLr/pPLNxBAu1ESFMJHLCLmozn5uHpDZz567/iWhssYJoPlkEVMeteC2v/hn3LoBp72l2qq4yrd4rX6orevoDSCDJSb3ylwKOur8CvWnA== 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=gWDt4j5npiNQiARNJc9xzgL4hq7NnujXlMDBc9bJRI4=; b=MUARCNxi0EJTe9HlUsrbEbJNwibsoW4n1CBKY6sQb+g4X3SScGAOoqB3NkhUmv8sNXb6A4Eqb/A4A8VCwHd2DoCVTb/a9zIKRY3MtMhCnKQvbh4/BgcxQOBVFzsFc9TCVFygBnhSRxsta5TeyHCPyKDtYbM+8iH7EAJRaVgZGrs= Received: from SJ0PR03CA0359.namprd03.prod.outlook.com (2603:10b6:a03:39c::34) by IA0PR12MB8896.namprd12.prod.outlook.com (2603:10b6:208:493::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Mon, 16 Dec 2024 23:59:18 +0000 Received: from SJ5PEPF00000205.namprd05.prod.outlook.com (2603:10b6:a03:39c:cafe::b4) by SJ0PR03CA0359.outlook.office365.com (2603:10b6:a03:39c::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.21 via Frontend Transport; Mon, 16 Dec 2024 23:59:18 +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 SJ5PEPF00000205.mail.protection.outlook.com (10.167.244.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Mon, 16 Dec 2024 23:59:17 +0000 Received: from ethanolx7e2ehost.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, 16 Dec 2024 17:59:16 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v2 6/9] crypto: ccp: Add new SEV/SNP platform shutdown API Date: Mon, 16 Dec 2024 23:59:08 +0000 Message-ID: <11ce67db2349a0c18fd549be41815ccccf401e64.1734392473.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: SJ5PEPF00000205:EE_|IA0PR12MB8896:EE_ X-MS-Office365-Filtering-Correlation-Id: 138dad49-becf-4448-0e4d-08dd1e2da707 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: 6b3jpGxORKKk3jfgzwItAAOOEmOzMed0Uo+utmFmoHQvrvgj2cUD0uSuGZwE7MXqRdZQWrNOs+zTDltwdOB7twelwBQo6rT1ltW68bPsaYul2z+742eDXG3JqcZKDvLSgXB3+w7mSq9GKT9urusDWfajiC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L5Hq9n+xj6COp+j/MGOuGyy02n40KhvkEk4/RTc3wFZNu4kW0mcH4s2NK/DoR/Ah5gXuZo2Hoy2JjjGpiUDsgKk4dq5yhBiTLtIsAygg3DL+OEiQ1h38j0oazc7PUifCHD5tq+JqHppONRGMYvcVfzj/+0RnuID1MWe8KE72BUtZ8I6842qTd/UZkDWA+p+71a7CW5GH4T/atgedFB0Y2kGcEQgNCp01rl5NcbFIOawqH7TcZZmlglPovFR7NU4JSRmipBwkozlJpsL+/hQ74pu2dtzHwY0= 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)(1800799024)(7416014)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 23:59:17.9535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 138dad49-becf-4448-0e4d-08dd1e2da707 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: SJ5PEPF00000205.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8896 From: Ashish Kalra Add new API interface to do SEV/SNP platform shutdown when KVM module is unloaded. This interface does a full SEV and SNP shutdown. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 13 +++++++++++++ include/linux/psp-sev.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index cef0b590ca66..001e7a401a6d 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -2481,6 +2481,19 @@ void sev_platform_shutdown(void) } EXPORT_SYMBOL_GPL(sev_platform_shutdown); +void sev_snp_platform_shutdown(void) +{ + struct sev_device *sev; + + if (!psp_master || !psp_master->sev_data) + return; + + sev = psp_master->sev_data; + + sev_firmware_shutdown(sev); +} +EXPORT_SYMBOL_GPL(sev_snp_platform_shutdown); + void sev_dev_destroy(struct psp_device *psp) { struct sev_device *sev = psp->sev_data; diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index fea20fbe2a8a..335b29b31457 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -946,6 +946,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); +void sev_snp_platform_shutdown(void); #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ @@ -982,6 +983,8 @@ static inline void snp_free_firmware_page(void *addr) { } static inline void sev_platform_shutdown(void) { } +static inline void sev_snp_platform_shutdown(void) { } + #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ #endif /* __PSP_SEV_H__ */