From patchwork Fri Jan 3 19:59:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925872 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2083.outbound.protection.outlook.com [40.107.93.83]) (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 579DC1BBBE5; Fri, 3 Jan 2025 19:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934399; cv=fail; b=iGn89iYYmC8l7pxV0lUhB3jmXZfaPS0ecERSvFUToeAUAdHZB/0GAtaeNK4q0mwp8Sj6KvnE7DpsNcPPElZ9et+d1CHfeav7G2AVoOLqfb4pHcOsmlN5yvYnhPewIGzgL16PsZqKjn4vspffqkjybJLGo8gWLblkX3vC3efvuu0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934399; c=relaxed/simple; bh=6FdxdC3qNIfl5cXPz6sqwQFZCfSEJDOg8y/TwaTsY/8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OPYBzhUUepKdB3DvCHBZ2JqO7YqQOKSmGDGGXhjYmtG/RDr3sXqr/+hSSasXiY7OFX4s/vQajL28SSORHOs8ab/Tlf8ul+Utkq0C5d/YnIYuu/atwwNefRtOJG0VWFvk8wuJT57ZSDSEOGhL8eNxbigmNw95nt8izY0O4hCCvgQ= 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=ZKQavZXe; arc=fail smtp.client-ip=40.107.93.83 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="ZKQavZXe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wn/5x8w2eCpQYpfXAaW8E+eblcVCrUnQqHBSnxlzdTJ2V7SdZcicD0pyE0k8dzSWKYrhaMhLoTc/EkTqRdFroafVUhThlADOi23PWSLfvug84OL04koQ3DtMZCEF6Sua/QCMosPyPimnknL956ajgKkou0ZApqV+zWjQkNmZpxJO90x41dtrAsbtRY5zTt+Yf7kIqg18c/+nN01uSwVKL+jtc8tqu53IbxWUZoA/Ks1PUciqAcwcPRRtQDYhZRaNn6Ui5LRFM7LEWxlGZsbusrGrJGAT7E0xO714ZRtDfNIqp9Qmxn3UrWaPl3q8lkoDTVGN/ipsDsE8UC/cIRXc4g== 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=y28cJaSX8GxadSnRF6IQ3KU7BGogRdcwSui/xAVveOs=; b=o0O6wG67UAgtV8pnsiw8qrjFRqF6D2hFwTMCGR8VFQl78qSlwDc8+GRNd9tN8K67yzRQd3kieikIJdJ7Oi3jMfusIUlC7TOiQXLi4gWuRGBLTnIdEzPnNfLn3NW6JOpOXwc+1DFBNeiQ5+F47D/IqK/ZIbHqLRX8EjjWwffuyFCKkQzfAfNXzFx+wSu4p+tdA6O5v4hUfSt1v7FqH7mZ7XYfG5zCaAXTISWrovg91DqvArYqlw92JHHWR9PyG0Gm0zwvw6iumfEVvVWrKOUhP4r27b2Q1GB4FOnE6UeqlsOEjFfOF6eW1gWgQ2R61Vzgk9YHbvpuj8iCJzG+VVU0AQ== 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=y28cJaSX8GxadSnRF6IQ3KU7BGogRdcwSui/xAVveOs=; b=ZKQavZXeY6hWYMKOHa2T36cC5dY0DpxEN9310ZjqVYEJeY/o/W7HxGgJFr8Ur9ixDwdnFwnDRTdUY/1RnbYDVw9bmKUsOmLpl9GVPISrRKhShAGehvH2yWjEnmQWHdPINMuo2uPpFsw8TW36IZ24BjgaBBchXczbit1HLGZYTb8= Received: from SJ0PR13CA0031.namprd13.prod.outlook.com (2603:10b6:a03:2c2::6) by IA0PR12MB8253.namprd12.prod.outlook.com (2603:10b6:208:402::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.11; Fri, 3 Jan 2025 19:59:46 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::bf) by SJ0PR13CA0031.outlook.office365.com (2603:10b6:a03:2c2::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.6 via Frontend Transport; Fri, 3 Jan 2025 19:59:46 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 19:59:45 +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; Fri, 3 Jan 2025 13:59:44 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 1/7] crypto: ccp: Move dev_info/err messages for SEV/SNP initialization Date: Fri, 3 Jan 2025 19:59:17 +0000 Message-ID: <707efae1123d13115bd8517324b58c763e9377d8.1735931639.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: SJ1PEPF000023D2:EE_|IA0PR12MB8253:EE_ X-MS-Office365-Filtering-Correlation-Id: b29372ac-5b35-4599-c075-08dd2c312c1b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: I8Oe3DbiBsenMHQ/YdKqwetXPo5MywI06onhexf05HQDMYDjiJT8rpymJHQrtA0+ucu3IHX7fAUUlbqUfLO3cpcaVot24NIYW/a8r/S042tMTMTXpvrU4ehT5dpGbwUbisU79MxndgAoefbmeWiaQOAfIejUFbky7DSspDnBwz09KfxgGyKSw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h+ddKIAMk1iURlZyX9Vn+HDR7bS8KraadBwpz1cwn8DuPsxzghT1nCaR6MOuH1/ulvy8bmGzXxa4lgQ807RcONkEaOGC8srb9+dNcK3pdi7/E0ioRoqZ0MtcOx3iiZJt2M8LnSd5XitQM0mWuVkW1MXsZqfRFDIGg7z4TK2e0jpq8tePdd4kQR0BDGjZzS/JDcyOtQjhM7Cid5b8dPcYzacQCFWD0SWqUClAqPaTiIz2SJ2xZgbaW60vmJcFSq1dY233CSeKwMUs 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)(82310400026)(36860700013)(1800799024)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 19:59:45.9951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b29372ac-5b35-4599-c075-08dd2c312c1b 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8253 From: Ashish Kalra Remove dev_info and dev_err messages related to SEV/SNP initialization from callers and instead move those inside __sev_platform_init_locked() and __sev_snp_init_locked(). This allows both _sev_platform_init_locked() and various SEV/SNP ioctls to call __sev_platform_init_locked() and __sev_snp_init_locked() for implicit SEV/SNP initialization and shutdown without additionally printing any errors/success messages. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index af018afd9cd7..1c1c33d3ed9a 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1177,19 +1177,27 @@ static int __sev_snp_init_locked(int *error) rc = __sev_do_cmd_locked(cmd, arg, error); if (rc) - return rc; + goto err; /* Prepare for first SNP guest launch after INIT. */ wbinvd_on_all_cpus(); rc = __sev_do_cmd_locked(SEV_CMD_SNP_DF_FLUSH, NULL, error); if (rc) - return rc; + goto err; sev->snp_initialized = true; dev_dbg(sev->dev, "SEV-SNP firmware initialized\n"); + dev_info(sev->dev, "SEV-SNP API:%d.%d build:%d\n", sev->api_major, + sev->api_minor, sev->build); + sev_es_tmr_size = SNP_TMR_SIZE; + return 0; + +err: + dev_err(sev->dev, "SEV-SNP: failed to INIT rc %d, error %#x\n", + rc, *error); return rc; } @@ -1268,7 +1276,7 @@ static int __sev_platform_init_locked(int *error) rc = __sev_platform_init_handle_init_ex_path(sev); if (rc) - return rc; + goto err; rc = __sev_do_init_locked(&psp_ret); if (rc && psp_ret == SEV_RET_SECURE_DATA_INVALID) { @@ -1288,7 +1296,7 @@ static int __sev_platform_init_locked(int *error) *error = psp_ret; if (rc) - return rc; + goto err; sev->state = SEV_STATE_INIT; @@ -1296,7 +1304,7 @@ static int __sev_platform_init_locked(int *error) wbinvd_on_all_cpus(); rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error); if (rc) - return rc; + goto err; dev_dbg(sev->dev, "SEV firmware initialized\n"); @@ -1304,6 +1312,11 @@ static int __sev_platform_init_locked(int *error) sev->api_minor, sev->build); return 0; + +err: + dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n", + psp_ret, rc); + return rc; } static int _sev_platform_init_locked(struct sev_platform_init_args *args) From patchwork Fri Jan 3 20:00:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925873 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) (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 B06431BC073; Fri, 3 Jan 2025 20:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934442; cv=fail; b=u03INa81rqs570ny5ht3/L+hC5Sbv6KKxGga8poaY9AyL43LAiAq4Exr9cRbdfGQ0v42n6I82v47UZP4OIMVuEhJlenFPLwVWNeN7dzP61u/xhup2lmoNY1fzNfVNtKKTT87nMZ8C+TndXJgL4NGUvOXq0phLCbL286YltWxiec= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934442; c=relaxed/simple; bh=wAjzagrjnQYlNz4RahDlYC60WiOzIIh8vYOQE4YSCvA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ETEXILRK+++7xJqfeqpbEZkRiGGAMoYcP6DdbkTzUbFzAImtk6EW6Ie0ekE6QwxDJyhRq9cLL3Q3okk5JDpRDNTkdsAHZE22VAjomNp4rZFJG+2sKvCUUjjtWqK9mzDawzDuOk+AKP1obyRiwGBUZmYP1I8o4eERFZzsjUBWA+c= 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=Kpb6Qgfy; arc=fail smtp.client-ip=40.107.223.74 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="Kpb6Qgfy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gp6wET3ZVd/T7m+a5GphMCSZlcCe0zW0rLf9lKCSRXn06n4dbDB4ZYARyAHiTVrRinZXmx0hUD8/3+9wO7iBwjGmTH6NXfV4N8C8Ll4pEdSu7x5tg5TXGJ1EWWibtRWBifQpLFoTqLqwo7H1tVXqgrcUtVRyRsSqnngO8h3UjGPYzh4affwAXDLHgYC8ROVlNz/kBvDrvjYjpD4RBWa6LkAroBeEvRmtzmweEjceRyENNZGgdWR/RXjqOFmMaMQo6wKukBb4h6iDMBdOkmY7UoihdC0MuMoLllytWmbE7Kqw/CfX2TUe/z7zXiPmncWPrtMsdW50aA2Q8GgNwzLBpg== 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=1Ul4UykFP1ClnSkG/fx9CZiwqIzhD67N/nKgrRojTP4=; b=goI/C5w5fJSGHNEj3Vv1ltpv+1wy2ehuML8NBlRnJxH4aBuiOnQ5LNN3UDJByJrP7Jf9cptKhxyydRCdCxcQtXInoGpCWZ8d7EbwuHfE+PyS5X5lATUWO2Fa1+ov8zUV6p6RnCquR7KCK1nQ2R2t2m2L8X4YbpHVh3XLh68kB01rrBz3PDsgoU5CAd7c4LOenkEEeUnNf3NqnQZBLC8cEtrQ7+IaUDkSfEs97pDyZqgr12hmGIpGuPvTVsQyZCXr09WYrkSr/IZIrIkBuSfQJ7MEGo4WZx7R20heKMvw7UKm7ZjHuapMsUzjl/lkoLpjzhsytEeFRWhWG4MoihGDPQ== 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=1Ul4UykFP1ClnSkG/fx9CZiwqIzhD67N/nKgrRojTP4=; b=Kpb6QgfycGX4ZbXA/1HcKJRI0LrN31mhmNEH4SSuH/tcIRIikH8F46aAPWgZymWxtIEtwyAVgTUxcLKke39MtdEicLriQFnOkYiCsgmO4Ecv0iuA3F+cm/hwHn3t43l7rK5u7wXMEwSNvtj4KdK5LWlKB14n1PmbCysnoqKKC00= Received: from SJ0PR13CA0037.namprd13.prod.outlook.com (2603:10b6:a03:2c2::12) by DS0PR12MB7560.namprd12.prod.outlook.com (2603:10b6:8:133::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Fri, 3 Jan 2025 20:00:33 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::5d) by SJ0PR13CA0037.outlook.office365.com (2603:10b6:a03:2c2::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.5 via Frontend Transport; Fri, 3 Jan 2025 20:00:33 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:00:32 +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; Fri, 3 Jan 2025 14:00:31 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 2/7] crypto: ccp: Fix implicit SEV/SNP init and shutdown in ioctls Date: Fri, 3 Jan 2025 20:00:22 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: SJ1PEPF000023D2:EE_|DS0PR12MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 32b18807-91b1-4d6b-c39f-08dd2c31480e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: gtTIzIm/MkHFnBEtha+nvEO42JFYQS8CR5+RKuWN+p/f6joRym7QdigYFn2SOsZHMZUuFSoG3QMYluwUra9OeZUyUFavj7/ZHHgvxYnTCNCTykYYM/xOYduXPY9eB6y/2mksHocAevrgP/rfXXUnKt65mM2vfaaoORDAa6nSUF/B7JrX7lJ2iLJhdcpsWjm6muqCCep/S0XEBniCMv0YiKyseGZ3+/n36dEOvb4mGk1uLnlZ8SAuKgDC5IrkWk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ib7Ra5qJ9V/RB8QTXVhKcnD6g3yZCpr7+e0sKT2k1h3eUKQwJA2eAO/KiOn5KuYsdJj5tw0uWg//1jiCCaiWD7Kw1C1HO2XKGHRj/O2sSz+pNzPUb58DV433CbRrZRZLZG2WGQF9m2YOeD4DYyGFiw2TuftitWcqvjEj7JZ2TkceQp57oONxd5eoQVdqYD3kT9A98VpWf7psy2WO 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)(1800799024)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:00:32.8862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32b18807-91b1-4d6b-c39f-08dd2c31480e 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7560 From: Ashish Kalra Modify the behavior of implicit SEV initialization in some of the SEV ioctls to do both SEV initialization and shutdown and adds implicit SNP initialization and shutdown to some of the SNP ioctls so that the change of SEV/SNP platform initialization not being done during PSP driver probe time does not break userspace tools such as sevtool, etc. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 149 +++++++++++++++++++++++++++++------ 1 file changed, 125 insertions(+), 24 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 1c1c33d3ed9a..0ec2e8191583 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1454,7 +1454,8 @@ static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp) static int sev_ioctl_do_pek_pdh_gen(int cmd, struct sev_issue_cmd *argp, bool writable) { struct sev_device *sev = psp_master->sev_data; - int rc; + bool shutdown_required = false; + int rc, ret, error; if (!writable) return -EPERM; @@ -1463,19 +1464,30 @@ static int sev_ioctl_do_pek_pdh_gen(int cmd, struct sev_issue_cmd *argp, bool wr rc = __sev_platform_init_locked(&argp->error); if (rc) return rc; + shutdown_required = true; + } + + rc = __sev_do_cmd_locked(cmd, NULL, &argp->error); + + if (shutdown_required) { + ret = __sev_platform_shutdown_locked(&error); + if (ret) + dev_err(sev->dev, "SEV: failed to SHUTDOWN error %#x, rc %d\n", + error, ret); } - return __sev_do_cmd_locked(cmd, NULL, &argp->error); + return rc; } static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) { struct sev_device *sev = psp_master->sev_data; struct sev_user_data_pek_csr input; + bool shutdown_required = false; struct sev_data_pek_csr data; void __user *input_address; + int ret, rc, error; void *blob = NULL; - int ret; if (!writable) return -EPERM; @@ -1506,6 +1518,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) ret = __sev_platform_init_locked(&argp->error); if (ret) goto e_free_blob; + shutdown_required = true; } ret = __sev_do_cmd_locked(SEV_CMD_PEK_CSR, &data, &argp->error); @@ -1524,6 +1537,13 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) } e_free_blob: + if (shutdown_required) { + rc = __sev_platform_shutdown_locked(&error); + if (rc) + dev_err(sev->dev, "SEV: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + kfree(blob); return ret; } @@ -1739,8 +1759,9 @@ static int sev_ioctl_do_pek_import(struct sev_issue_cmd *argp, bool writable) struct sev_device *sev = psp_master->sev_data; struct sev_user_data_pek_cert_import input; struct sev_data_pek_cert_import data; + bool shutdown_required = false; void *pek_blob, *oca_blob; - int ret; + int ret, rc, error; if (!writable) return -EPERM; @@ -1772,11 +1793,19 @@ static int sev_ioctl_do_pek_import(struct sev_issue_cmd *argp, bool writable) ret = __sev_platform_init_locked(&argp->error); if (ret) goto e_free_oca; + shutdown_required = true; } ret = __sev_do_cmd_locked(SEV_CMD_PEK_CERT_IMPORT, &data, &argp->error); e_free_oca: + if (shutdown_required) { + rc = __sev_platform_shutdown_locked(&error); + if (rc) + dev_err(sev->dev, "SEV: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + kfree(oca_blob); e_free_pek: kfree(pek_blob); @@ -1893,17 +1922,8 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) struct sev_data_pdh_cert_export data; void __user *input_cert_chain_address; void __user *input_pdh_cert_address; - int ret; - - /* If platform is not in INIT state then transition it to INIT. */ - if (sev->state != SEV_STATE_INIT) { - if (!writable) - return -EPERM; - - ret = __sev_platform_init_locked(&argp->error); - if (ret) - return ret; - } + bool shutdown_required = false; + int ret, rc, error; if (copy_from_user(&input, (void __user *)argp->data, sizeof(input))) return -EFAULT; @@ -1944,6 +1964,16 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) data.cert_chain_len = input.cert_chain_len; cmd: + /* If platform is not in INIT state then transition it to INIT. */ + if (sev->state != SEV_STATE_INIT) { + if (!writable) + return -EPERM; + ret = __sev_platform_init_locked(&argp->error); + if (ret) + goto e_free_cert; + shutdown_required = true; + } + ret = __sev_do_cmd_locked(SEV_CMD_PDH_CERT_EXPORT, &data, &argp->error); /* If we query the length, FW responded with expected data. */ @@ -1970,6 +2000,13 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) } e_free_cert: + if (shutdown_required) { + rc = __sev_platform_shutdown_locked(&error); + if (rc) + dev_err(sev->dev, "SEV: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + kfree(cert_blob); e_free_pdh: kfree(pdh_blob); @@ -1979,12 +2016,13 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) static int sev_ioctl_do_snp_platform_status(struct sev_issue_cmd *argp) { struct sev_device *sev = psp_master->sev_data; + bool shutdown_required = false; struct sev_data_snp_addr buf; struct page *status_page; + int ret, rc, error; void *data; - int ret; - if (!sev->snp_initialized || !argp->data) + if (!argp->data) return -EINVAL; status_page = alloc_page(GFP_KERNEL_ACCOUNT); @@ -1993,6 +2031,13 @@ static int sev_ioctl_do_snp_platform_status(struct sev_issue_cmd *argp) data = page_address(status_page); + if (!sev->snp_initialized) { + ret = __sev_snp_init_locked(&argp->error); + if (ret) + goto cleanup; + shutdown_required = true; + } + /* * Firmware expects status page to be in firmware-owned state, otherwise * it will report firmware error code INVALID_PAGE_STATE (0x1A). @@ -2021,6 +2066,13 @@ static int sev_ioctl_do_snp_platform_status(struct sev_issue_cmd *argp) ret = -EFAULT; cleanup: + if (shutdown_required) { + rc = __sev_snp_shutdown_locked(&error, false); + if (rc) + dev_err(sev->dev, "SEV-SNP: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + __free_pages(status_page, 0); return ret; } @@ -2029,21 +2081,38 @@ static int sev_ioctl_do_snp_commit(struct sev_issue_cmd *argp) { struct sev_device *sev = psp_master->sev_data; struct sev_data_snp_commit buf; + bool shutdown_required = false; + int ret, rc, error; - if (!sev->snp_initialized) - return -EINVAL; + if (!sev->snp_initialized) { + ret = __sev_snp_init_locked(&argp->error); + if (ret) + return ret; + shutdown_required = true; + } buf.len = sizeof(buf); - return __sev_do_cmd_locked(SEV_CMD_SNP_COMMIT, &buf, &argp->error); + ret = __sev_do_cmd_locked(SEV_CMD_SNP_COMMIT, &buf, &argp->error); + + if (shutdown_required) { + rc = __sev_snp_shutdown_locked(&error, false); + if (rc) + dev_err(sev->dev, "SEV-SNP: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + + return ret; } 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; + bool shutdown_required = false; + int ret, rc, error; - if (!sev->snp_initialized || !argp->data) + if (!argp->data) return -EINVAL; if (!writable) @@ -2052,17 +2121,34 @@ static int sev_ioctl_do_snp_set_config(struct sev_issue_cmd *argp, bool writable 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); + if (!sev->snp_initialized) { + ret = __sev_snp_init_locked(&argp->error); + if (ret) + return ret; + shutdown_required = true; + } + + ret = __sev_do_cmd_locked(SEV_CMD_SNP_CONFIG, &config, &argp->error); + + if (shutdown_required) { + rc = __sev_snp_shutdown_locked(&error, false); + if (rc) + dev_err(sev->dev, "SEV-SNP: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + + return ret; } static int sev_ioctl_do_snp_vlek_load(struct sev_issue_cmd *argp, bool writable) { struct sev_device *sev = psp_master->sev_data; struct sev_user_data_snp_vlek_load input; + bool shutdown_required = false; + int ret, rc, error; void *blob; - int ret; - if (!sev->snp_initialized || !argp->data) + if (!argp->data) return -EINVAL; if (!writable) @@ -2081,8 +2167,23 @@ static int sev_ioctl_do_snp_vlek_load(struct sev_issue_cmd *argp, bool writable) input.vlek_wrapped_address = __psp_pa(blob); + if (!sev->snp_initialized) { + ret = __sev_snp_init_locked(&argp->error); + if (ret) + goto cleanup; + shutdown_required = true; + } + ret = __sev_do_cmd_locked(SEV_CMD_SNP_VLEK_LOAD, &input, &argp->error); + if (shutdown_required) { + rc = __sev_snp_shutdown_locked(&error, false); + if (rc) + dev_err(sev->dev, "SEV-SNP: failed to SHUTDOWN error %#x, rc %d\n", + error, rc); + } + +cleanup: kfree(blob); return ret; From patchwork Fri Jan 3 20:00:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925874 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) (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 32F5A1BEF9C; Fri, 3 Jan 2025 20:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934469; cv=fail; b=SoeQlMMTMpGolNOCY8DZV8147rUTGnhLvr5NtwhYosiobWcy6qv7fpV5NxW4O6KaT/TTmaKeZCetg0VoTPdEk+s2/sDQUR6n4eGB31tdJAi7M7owuvCxQURYAiGX3OX37p6MD/7w7s9qZwvJ5aUTXQXuR24L/1GwpWSs70o57l8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934469; c=relaxed/simple; bh=e3L9DsLMZta3TZFGP3V8ILR11hrCz4RTozquZEk9UcQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YFXCki4y/AcfXYEbRImLJoWLeEPr8p4UYaJoyNYiSWJVowFJZ+K5auydtm/1IUbad15ODWsAuuCCCBfW36axtx+R988hEVF/OylvphMRyjwv+6VRThJLLuWSmOVnBNjGwJ03fImE2C80bCM0V38WVWbDgSf3Pdus2Y5W7tUY3Ug= 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=FWICDPq4; arc=fail smtp.client-ip=40.107.244.58 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="FWICDPq4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BgwcR8gsbz26EsNv7smAiSd1k1RsbU9JdQ4s3JD8Awzu1b5cKP7/wJ8QsdCq5dmhaUk25oJK00A2emQqhVYXkwv4Bl6b72htMS2x0c4PWQ0A4UqwcDwuU5K0tkAu6vUg1TzxDAhV8Q/NT2ybZKKFfuMtEGy3K6wLBc2rISpGhSMDqJ5CmUFt+TcrEEk0kLVi50uh3R1BkbFqhgVd/PE8jAa9Wr5WOqv5twUCzOAUPBd28H0mYxvK2XLF/xj3uW0GWX6iBkoti0+B9NatAjUEjynHKFZXiJnzz8d5Y+iyLscj+lGQTXOA410YjdoldKR2inzG8mf2qrBkhbawO/l5LA== 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=wsggXyd3M7q7o8HxFouKHNcmagYw1VBF1z16lrf7JSA=; b=pzZjG+wUglQVetRkTMWWQKH+/xM0g7ZSV4hdz4O/MkHJZ1LvhLSNucklEXG08H56h8ihC5t9BPZottadXZZrFGMMJn/JORhCczM/vBuhmxqPTa2l3xrPQ30auCNurVnTR+OMVV4qwDr+UPLetQlDrwqy3weV/0alSI22vOnCfgWpi73nSSC+uIkaxn2tWLVYm5r5zSYolSKSkehjxeD5g74Co9bPe7IKAW1KDUP444ps2EG3abU9DTc2pPS3qpEGe6cgh7Os1SWgkYSKnJzOOyEisdhjuv+DC/5tVwUpgK4msDcrp0FNIXL7OdrQih6IkTTtyEgmmP8gpT1uBmWRPQ== 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=wsggXyd3M7q7o8HxFouKHNcmagYw1VBF1z16lrf7JSA=; b=FWICDPq4IGitU3wOJ3N+L6Jet3RQ9vn3MmVKxlJVWnbDNgZlk3zKtGuPvmuDCcRPMUbvCEpw++22pjtg8zZf40HpvZpAOtMckfXJXdPGCYQxyppseIeqFjoIHD9uj7w9vgn/j0PlbciwPShL2c5YsvxKp8P0TflVMTJNzv4ohEM= Received: from BL1P222CA0014.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::19) by IA1PR12MB8538.namprd12.prod.outlook.com (2603:10b6:208:455::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 20:00:56 +0000 Received: from BL02EPF0001A100.namprd03.prod.outlook.com (2603:10b6:208:2c7:cafe::d6) by BL1P222CA0014.outlook.office365.com (2603:10b6:208:2c7::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.14 via Frontend Transport; Fri, 3 Jan 2025 20:00:56 +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 BL02EPF0001A100.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:00:56 +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; Fri, 3 Jan 2025 14:00:52 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 3/7] crypto: ccp: Reset TMR size at SNP Shutdown Date: Fri, 3 Jan 2025 20:00:38 +0000 Message-ID: <425ecdc1df6566d1b76f7a8deb30471b0ce8dca3.1735931639.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: BL02EPF0001A100:EE_|IA1PR12MB8538:EE_ X-MS-Office365-Filtering-Correlation-Id: 867449e4-cfba-47e9-b044-08dd2c3155f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: INNlcRBG3wtigH37cNoHXQAMmrmgNaEY4PjII+e4ISd+sxBHr6GYU3sclpWSjLDFZlpOkVqd+qII9IrQB2DR2eTzrIHNKE3pgkvyW/eLEoieQuInOqBtJBnCMeUcU9ln+v8ZiQR8bhCl37ELJ7gNpan2H6AqF+oXEvtydQ2pWfmHtWeSSOwAUmhK9zTFd1iFS6jIhFTuq8PoozNJjtvzPLFdaxjW3/fi2NZtH42AEc7bv24K3pVmb4dB89N+cdi8zI9//fWZhjx9EOTAM0f+HrJ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wWVV5Qk2FyiOC2eZlK6ozS6DoQ4/0Xgx+PyV5cAizcUUPtxfHyGD10PsIFLoI4ZggZj5Mwdy6oTtdJ/Ak+dbSf34mJm8dBO4wfgtCnt1MJ2V2zJo0TTVo0Ks2NRfyhvuye16bUoS1ixZ4ARKwJ2I0rvqHJ9GM9B+2Q8sT6Mlz1kPymP4E2Py/m8cVvAhrHCm 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)(1800799024)(7416014)(376014)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:00:56.3103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 867449e4-cfba-47e9-b044-08dd2c3155f6 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: BL02EPF0001A100.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8538 From: Ashish Kalra When SEV-SNP is enabled the TMR needs to be 2MB aligned and 2MB sized, ensure that TMR size is reset back to default when SNP is shutdown as SNP initialization and shutdown as part of some SNP ioctls may leave TMR size modified and cause subsequent SEV only initialization to fail. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 0ec2e8191583..9632a9a5c92e 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -1751,6 +1751,9 @@ static int __sev_snp_shutdown_locked(int *error, bool panic) sev->snp_initialized = false; dev_dbg(sev->dev, "SEV-SNP firmware shutdown\n"); + /* Reset TMR size back to default */ + sev_es_tmr_size = SEV_TMR_SIZE; + return ret; } From patchwork Fri Jan 3 20:00:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925875 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) (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 AA5871B4F17; Fri, 3 Jan 2025 20:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934493; cv=fail; b=qp6zAKUOrVkZKNv96b+uMxA+y8z+Ad9JunHFdFUPqir8BwGSVSRqeFnyfJB4ycJUWoUbPjYEa4vw98TVyM+K2Ff0ofrg3n8fusY9Ujk5WtccyDUYGFkWBxSOGESK+BM0ikrAPLo5ZKby5d/GdxqqZU2bzhcKhYPz7IZQzzmAltY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934493; c=relaxed/simple; bh=syGqMyaizm6LEec9pfcxvi7BPhvLcG+T+ty2iLvU3mk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L/eKXcEeWWmXxfpQE5V9cbnBk/+/O5EL/B5Lh3lVK0L855TGT3vOGsqGJpll4TkjKQE+V24YdCjnAI/biAIHaX3lHx+VTVgoYuN9KfnIKMCmqtiC7e1xUhuNEI9CUq8Fz2JqLQEDiHs1VycBH5RxEHzS63QZV72vAlYJZtUNXk8= 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=P0NTGel9; arc=fail smtp.client-ip=40.107.93.63 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="P0NTGel9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MbKt8ze1EE0jx9AWGi3ahQ+u1zK0qY13r1ViBSPx0LCq/tERER7fF3rJNMigwsO3L5dkYQszZmCDbPTIQ9RW/W7JuPCJiJqze6xzt36T3SgTvrcqUGTBmLS/P//2uHBZNABKppCPGjIwmDOAF2fGt08L3620f1wHqUjrQQpjqi1Fr1mcL/7JjTiR4UqVmQc0sAC+WLaOH5EmfFAN8dcmx2yT9AOgl+sCo/axhhDmgiF0GC40Kdfxd64vyjJKUY2nyMPxsZoiIDA2L08kM9PFOIghqkIAloq/KVuHZdo6QgpJwm3t5ABqTBmDpBy5BRdt6v+MqZqPiNoRl9HfYplrtg== 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=rhTHE/dT4zAyu9CTo6Xv6Y3HGPzAIfnLVVr2hn0wfg4=; b=V2cJSz8VTuzTiiFKoCPYHA9nmOwDjNykAep4WUr+bKRMmWlD8GJqUMUFa5he+ZnHpqE4rlAO/67UxxWFQMFk56NOrOPIA8wgSQgyuc65py3NIWAqeBmUkebCyMjJ+FibMtuiscnasKGTPkjapB9pD8Xjn96Kyz2PeKAdZxPUdN5lUIqXovrRme8AxL/LvAw9pqsRwK1i7jUC4akB89Jp4PLaSkYSYyvdcgOgK8mqUMTFxouIDyefnPk3YbPlttxwp6rwlb6djhFsJc/EQCuj5Dn3tQGeg/Mk3Btyt/Gcl4b3OoOvxyoZENHWZoJg+e8JCQEr/aUoPD+L6XGOViFCSQ== 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=rhTHE/dT4zAyu9CTo6Xv6Y3HGPzAIfnLVVr2hn0wfg4=; b=P0NTGel9h7vYvvq63ZLZf1+IUoQNU4emGqOpgCJS04LsSUCwyT+DEeyv7korkDkMnEcZ0+UfsFnUge+9z9OwpuAtBO0WKhubz32JIIQ71sv9mYu9MRm3qdD66KHfaHNRFmEkE+ZtYQcfJpI9TeXFEfTegkX41y1KD/wkmQqkOlA= Received: from CH0P223CA0024.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::12) by PH7PR12MB7985.namprd12.prod.outlook.com (2603:10b6:510:27b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Fri, 3 Jan 2025 20:01:16 +0000 Received: from CH1PEPF0000A34C.namprd04.prod.outlook.com (2603:10b6:610:116:cafe::b7) by CH0P223CA0024.outlook.office365.com (2603:10b6:610:116::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.14 via Frontend Transport; Fri, 3 Jan 2025 20:01:16 +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 CH1PEPF0000A34C.mail.protection.outlook.com (10.167.244.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:01:16 +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; Fri, 3 Jan 2025 14:01:15 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 4/7] crypto: ccp: Register SNP panic notifier only if SNP is enabled Date: Fri, 3 Jan 2025 20:00:59 +0000 Message-ID: <674affc649968994f95b6259f162d5f0732b102c.1735931639.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: CH1PEPF0000A34C:EE_|PH7PR12MB7985:EE_ X-MS-Office365-Filtering-Correlation-Id: ecab5043-c0bb-4a1f-cc8f-08dd2c316220 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|82310400026|376014|1800799024|921020; X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VutiAY8SA7pkOruC3AkQi2M6yfPJtxApw+oVLXYkFeQVVY/56dFpg2xXPGDdeKZs5oPyseWfFaKWDRyTm0sCj8JJ0FvzUd58ax8fC2mvmrg1gOj0iOs7EVB1Z6TCHH0o8K8kBjcBgCVo0tkJ3LChwD02Kxz14QOhau7KuGRFhAbWbGiAQVReZ7mHJtwdU9qfRQLCRTgFG1v/m+wjui4QVePmZkhm63Ydz8U+mbrc6UEhu/03vAm2v3Lxd/+RwIvra09I3M76k3tJCylj6DTYY6kwYDh07NJLbuyj3Gku+HElhE+MDYdI6vREJOMz5ZjbMCJjl/SWxzgv9wdJq2msls1iemh1j+is0MB+G/3b/Bar71/m1yuhXIN23kPIgFvEbbOijnXFGwl2TQfTxJM7tRJdWvGz5fvJ/F6/F5q7io0z+EHxz47RiZLHRm3YVRBsEO3otm01cJ1ecibwHXmSk8P+y1Naf2kO6ld4n 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)(7416014)(36860700013)(82310400026)(376014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:01:16.7033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecab5043-c0bb-4a1f-cc8f-08dd2c316220 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: CH1PEPF0000A34C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7985 From: Ashish Kalra Register the SNP panic notifier if and only if SNP is actually initialized and deregistering the notifier when shutting down SNP in PSP driver when KVM module is unloaded. Currently the SNP panic notifier is being registered irrespective of SNP being enabled/initialized and with this change the SNP panic notifier is registered only if SNP support is enabled and initialized. Signed-off-by: Ashish Kalra Reviewed-by: Dionna Glaze --- drivers/crypto/ccp/sev-dev.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 9632a9a5c92e..7c15dec55f58 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -109,6 +109,13 @@ static void *sev_init_ex_buffer; */ static struct sev_data_range_list *snp_range_list; +static int snp_shutdown_on_panic(struct notifier_block *nb, + unsigned long reason, void *arg); + +static struct notifier_block snp_panic_notifier = { + .notifier_call = snp_shutdown_on_panic, +}; + static inline bool sev_version_greater_or_equal(u8 maj, u8 min) { struct sev_device *sev = psp_master->sev_data; @@ -1191,6 +1198,9 @@ static int __sev_snp_init_locked(int *error) dev_info(sev->dev, "SEV-SNP API:%d.%d build:%d\n", sev->api_major, sev->api_minor, sev->build); + atomic_notifier_chain_register(&panic_notifier_list, + &snp_panic_notifier); + sev_es_tmr_size = SNP_TMR_SIZE; return 0; @@ -1751,6 +1761,9 @@ static int __sev_snp_shutdown_locked(int *error, bool panic) sev->snp_initialized = false; dev_dbg(sev->dev, "SEV-SNP firmware shutdown\n"); + atomic_notifier_chain_unregister(&panic_notifier_list, + &snp_panic_notifier); + /* Reset TMR size back to default */ sev_es_tmr_size = SEV_TMR_SIZE; @@ -2490,10 +2503,6 @@ static int snp_shutdown_on_panic(struct notifier_block *nb, return NOTIFY_DONE; } -static struct notifier_block snp_panic_notifier = { - .notifier_call = snp_shutdown_on_panic, -}; - int sev_issue_cmd_external_user(struct file *filep, unsigned int cmd, void *data, int *error) { @@ -2542,8 +2551,6 @@ void sev_pci_init(void) dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ? "-SNP" : "", sev->api_major, sev->api_minor, sev->build); - atomic_notifier_chain_register(&panic_notifier_list, - &snp_panic_notifier); return; err: @@ -2561,6 +2568,4 @@ void sev_pci_exit(void) sev_firmware_shutdown(sev); - atomic_notifier_chain_unregister(&panic_notifier_list, - &snp_panic_notifier); } From patchwork Fri Jan 3 20:01:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925876 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2080.outbound.protection.outlook.com [40.107.220.80]) (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 4FEF91B4F17; Fri, 3 Jan 2025 20:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934512; cv=fail; b=KQccuB5cLEUJHfbgFetIr8ACT+72/2+qnMup5zSQjdEYL43GSvkbbQgaVllDJ+YXiwmEmmVrwgCcqg5Ll4mvy8piNleqLcuigXOM9m3PK1Q+Qk47FwjBYhiNfFmBe08wxthPXhlLj0Hkh02IVCyOllLUSZZoV29Nbl73ADgvz04= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934512; c=relaxed/simple; bh=jCFt++qCQk9Sg5jbRA1/795ly9eisyXkC1b++cEoVEw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z67IjzgZtS0Ca08m8naMAnhVf3LrtywZ+OuWl6WMmXK71zQazkhrPHBL/FVLw0lnWptuIH6hMMzBuutRb+47d0hA+byM4m11moSRw0PXDqNUrezs6typHQJKQMhh2tDgol9GRQiLDLe0JMmQNW0n0FcAh0c8VsfFcI4jOavJYpc= 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=dgPlJOrL; arc=fail smtp.client-ip=40.107.220.80 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="dgPlJOrL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rY7oaTANnLU6btgTBi1hjn6usYysfcDH4Y9yRiioSbubK+VA9I85nQot2RJoLiF05GCx3lAX/QbaCZdHbP/RmGlASZC8ebblfXltz2npAVTeAku0W8CtCE7EYzOkx4CdtegkUK9z5TOmn1U0uxJ0TwW/0LYswrAvqJsxLFGxlA/yG8OEow4MLtMhMXtv5nekUZI8wWEclpmBAYwJumSz0dFdv9XB+5amw0Kka4WF8z/Mipqjt3JVAlQ+muptvL8ibGI7d/w+FG1ROpnUzWfOuM+mOXGPOsR7JvLrVSr3KJjzVu0DxSoEno/jCIGGeutS+z+NhL8JsceyaXQBXSaoZg== 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=jLhdquEZpBE9GOKFIxrmmYxxn4rshYnt4bu0esjBJgI=; b=AFs4LPkuJUi9vsvg3ui7N/t138VdQULWTgjmml5lvvkCBqDZnXJVe3kmfkfuJEk461R/rS4PmaV0JiV13mV5bOdyvZr3Q8S/P5nJNyB9GS5swaxfXd+cy1RMmiGf9SCczrn6CepLm0oU7hju4l1xQmlOjKq7tyHOJTGnHdf9jExjrfM21rcrECopaNI8fRsHmmfYoHJj23IqEWuWwxawmY75I5o3hOUMfxRlmuOFLDcA8Z+JB/MKJyC4NvgFeU88UjhszWo707qYNQD3ZWZ4495Y4sYS4WmVbGTrknb243hGg3twPrRy5+zULEVpj3/zMLRv49sw4sJyjNpS5lOrrQ== 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=jLhdquEZpBE9GOKFIxrmmYxxn4rshYnt4bu0esjBJgI=; b=dgPlJOrLMPKTmVjifBDcwBHLIlyOQ+FsRAZlA9J3HVtKp0GK36KewlfChgkGoV1aSAahUvfmm+YIEY3WSfIMg1Y1zpw9a46xjRFdthzlrr2E8tpKZEz1dSxB6M8J+sd/jpyDUXAyfoDwfCSTIlFPD0nhyLwjBbxP5rSWpvDN2Hk= Received: from CH0P220CA0008.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::6) by SA1PR12MB8721.namprd12.prod.outlook.com (2603:10b6:806:38d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Fri, 3 Jan 2025 20:01:40 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:ef:cafe::42) by CH0P220CA0008.outlook.office365.com (2603:10b6:610:ef::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.15 via Frontend Transport; Fri, 3 Jan 2025 20:01:40 +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 CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:01:40 +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; Fri, 3 Jan 2025 14:01:39 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 5/7] crypto: ccp: Add new SEV/SNP platform shutdown API Date: Fri, 3 Jan 2025 20:01:26 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: CH1PEPF0000A34B:EE_|SA1PR12MB8721:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d19c4b9-633b-4f70-a69b-08dd2c317063 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: gJJiukiyCwcBUfMmfOvGRtNReFWmp046hM5IG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EF22+Ua6yyr8pK7Y9R+eL3Nq8cRc5g+1u9CXmUVfG1Bg+4z70vQp13L8+htLefr5Fz9DkPvPyJITQCuT3H+UT+sBNw2O1q5XdlgL/SfQ7ZcSIqle8mqlyaLJ645tvE53gNcNv4eLf1JwuDnL29fqARSm7qy3JxaCsMcvQq4cMM6M4zLRpS4I5y6QCLvAAeEMXTdu1EMpBq4y/FH+CP5YIOv8Jdd8IoEGsqBQG5QG/VAAMg3wZCplZr2lUU4lIpxidMU/wJoGV9VpdSBV30j3f5ZiQ4F7KldMwpnArz093tUa0GOZKbh+KVPkVrORzJOrabNJwE6Ti7cpcq2kC90uuHJ6bMUqu1iwIS9FFePEsIfFnz0bRFDMt+PhSTx+3R4fZq24Z9ZXkAISn7uh53q2wyUxjfhL+28GZrPdgb38mFj 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)(1800799024)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:01:40.6295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d19c4b9-633b-4f70-a69b-08dd2c317063 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: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8721 From: Ashish Kalra Add new API interface to do SEV/SNP platform shutdown when KVM module is unloaded. Signed-off-by: Ashish Kalra Reviewed-by: Dionna Glaze --- 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 7c15dec55f58..1ad66c3451fb 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -2469,6 +2469,19 @@ static void sev_firmware_shutdown(struct sev_device *sev) mutex_unlock(&sev_cmd_mutex); } +void sev_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_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 903ddfea8585..fea20fbe2a8a 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -945,6 +945,7 @@ int sev_do_cmd(int cmd, void *data, int *psp_ret); 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); #else /* !CONFIG_CRYPTO_DEV_SP_PSP */ @@ -979,6 +980,8 @@ static inline void *snp_alloc_firmware_page(gfp_t mask) static inline void snp_free_firmware_page(void *addr) { } +static inline void sev_platform_shutdown(void) { } + #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ #endif /* __PSP_SEV_H__ */ From patchwork Fri Jan 3 20:01:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925877 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2058.outbound.protection.outlook.com [40.107.223.58]) (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 9A2301BBBF1; Fri, 3 Jan 2025 20:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934529; cv=fail; b=jTFb/ZZyd86Ek6zIE2Qf1OLX1F+bgRGsvD6JE3mTO+fObF2VkzAeOh/z3uCrzeiR8TAnqxXBNVaNYm/vusjg2BVq4hVWaCG0B+KjERZtVMQmY4EO7klz5L3/+o9yw5khgxuRUpKm7S3OQHCGKzyLbczoyafDY7+tf1QV/kz8OXs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934529; c=relaxed/simple; bh=3WVBlN6W2cc3jq7KTXYDW0VvO1JMun4z1wdx2ZFHe3o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZGaHjqu1yhjNLPPTrOIyhfm86GmRrrsirlCGWNsHQAOxcTHRFJZzt6/0DT67bs5LHQA/YXt+EBgFPH7ARPvvAioVgV3hhehi8TKQYK/rFolg3lJOMzQPQVEOzMb5jRCVhyLEvwyAlBmEFBSHDvdBBYF9u1fAxQJ+r/NFuobv3dM= 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=2psI60Qh; arc=fail smtp.client-ip=40.107.223.58 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="2psI60Qh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gb0Ng/1YNOMgLcEJ3jU26msG1KpZEdWPFuiOkhBWnZI/5uZQJtuemGG+a84VdiLeTJJp3ohNsSCCeA0bxZw1HjczFwwGP0p4j83aty2K77WITB6yuhrRa61yUZyabcuQ2DISNSWQt7sEuDQQhpEYJxleMNyX+vFqj2OseVDPiDMnXSOkZNziFHNgCJUgHLsWl6WbAuOaHPAL2DGx3tE1+ZUCJxlXVx1vZN63A5diiQWM+DVpqR43/Z2y4VXCzMdfmgQHb71nwK8l2fhWlnIspwDw6KG8P20gZKU2Lp1PpTdDV4HuDURSaHKc9gpmV1wLL8wVvxz5XbWDOPaDEUBKaA== 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=fJp5bO021neq9pm8lBDqNpqpM5PPNhfaH5qCwyw4Prg=; b=ilKQTVPZ0I5Y8tm7nyu47BW4MUpF24egOFQBH00AcxFZQMc1CrloHxDpDyJZIXxHoEuYIcsiQwXjPRVUiIj1Xfr2w1nZ8X3VfsOhf8zheelp1NmLj6agePymbTxweOYdvFa9pRN+pkHc60Nxb2LKs0YlrxV2MtdWteihfV2SmUqoqyqHRJUZnl5PvduXIfSocu5Eg31XjjJWNFJ4kLW8ObFOqv5QF/lzt9nUdJLgqpXg9uM1UFit/0TIci29j42pFXP8sKtvVYCNknPLnSV7vHZqjUMakNfSKjgd14QYDyXSoiH4C0U2JsbOTapXroDlXD0cjURVdNxJO64HG8yPsg== 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=fJp5bO021neq9pm8lBDqNpqpM5PPNhfaH5qCwyw4Prg=; b=2psI60QhWbwERj2BI1OdthH1RRavcLNKYh5D94d+OnUBfMfOx6F1YEd2KKZVeZ/53Ms3LzOX9bE01hZkRRMHH1UY9RU/UoTZD5ji5NEsgOYvacskrt6MTJgfoYNtS8K60+FGMf9auH/ZVPz78sMNMQnagD3EF4SAsMO2YQkFnfc= Received: from CH0PR13CA0036.namprd13.prod.outlook.com (2603:10b6:610:b2::11) by MN6PR12MB8516.namprd12.prod.outlook.com (2603:10b6:208:46f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.11; Fri, 3 Jan 2025 20:01:57 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::ae) by CH0PR13CA0036.outlook.office365.com (2603:10b6:610:b2::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.6 via Frontend Transport; Fri, 3 Jan 2025 20:01:57 +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 CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:01:57 +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; Fri, 3 Jan 2025 14:01:56 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 6/7] KVM: SVM: Add support to initialize SEV/SNP functionality in KVM Date: Fri, 3 Jan 2025 20:01:47 +0000 Message-ID: <14f97f58d6150c6784909261db7f9a05d8d32566.1735931639.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: CH1PEPF0000A346:EE_|MN6PR12MB8516:EE_ X-MS-Office365-Filtering-Correlation-Id: b33d7066-6869-44eb-bf7e-08dd2c317a55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: eIn1hxulqCYQGbasD1CXokWxWftffDD3x2Na0bo+xOO4gvVpi59h90102+FLBAK6cXRfzLlfjSd3MZJaGFnVmPOeWs64T8HCCH10LdKktLLad1U6aaB5l2S1r4qyulCiDI3SFtgIt23ykKRsVaNDtsuE54lydVsatSwL5OiAmXs1Xiru4nPzZLokOY6mXgL/qOKUTKhA6z7QbjNM5vSKepySBx+hwSpabqpqeGHP26+WbXqdnB4uAO9xM7FkabFp2v0Z//ROUSQhJQ4Dg2utHwKO9gwjyEF3vz14Nnb1QC86hrNcuUL1gpgC+SlFaa0DT2HOARRIwWlHL/u3HLHfGKDPB+sIEr/YoNHFbMa2RzT1Lr9Y+VMVeoko+wggr/9VN4aLOYUIVNMiXuvV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a680FtFA+KPqvz2XdsOEFqn1mW3mDkEc617Gj1hfxnJMpcZRkZG1t0 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)(1800799024)(36860700013)(82310400026)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:01:57.3155 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b33d7066-6869-44eb-bf7e-08dd2c317a55 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8516 From: Ashish Kalra Remove platform initialization of SEV/SNP from PSP driver probe time and move it to KVM module load time so that KVM can do SEV/SNP platform initialization explicitly if it actually wants to use SEV/SNP functionality. With this patch, KVM will explicitly call into the PSP driver at load time to initialize SEV/SNP by default but this behavior can be altered with KVM module parameters to not do SEV/SNP platform initialization at module load time if required. Additionally SEV/SNP platform shutdown is invoked during KVM module unload time. Signed-off-by: Ashish Kalra --- arch/x86/kvm/svm/sev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 943bd074a5d3..0dc8294582c6 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -444,7 +444,6 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, if (ret) goto e_no_asid; - init_args.probe = false; ret = sev_platform_init(&init_args); if (ret) goto e_free; @@ -2953,6 +2952,7 @@ void __init sev_set_cpu_caps(void) void __init sev_hardware_setup(void) { unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; + struct sev_platform_init_args init_args = {0}; bool sev_snp_supported = false; bool sev_es_supported = false; bool sev_supported = false; @@ -3069,6 +3069,16 @@ void __init sev_hardware_setup(void) sev_supported_vmsa_features = 0; if (sev_es_debug_swap_enabled) sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP; + + if (!sev_enabled) + return; + + /* + * NOTE: Always do SNP INIT regardless of sev_snp_supported + * as SNP INIT has to be done to launch legacy SEV/SEV-ES + * VMs in case SNP is enabled system-wide. + */ + sev_platform_init(&init_args); } void sev_hardware_unsetup(void) @@ -3084,6 +3094,9 @@ void sev_hardware_unsetup(void) misc_cg_set_capacity(MISC_CG_RES_SEV, 0); misc_cg_set_capacity(MISC_CG_RES_SEV_ES, 0); + + /* Do SEV and SNP Shutdown */ + sev_platform_shutdown(); } int sev_cpu_init(struct svm_cpu_data *sd) From patchwork Fri Jan 3 20:02:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalra, Ashish" X-Patchwork-Id: 13925878 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.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 63F161BEF6C; Fri, 3 Jan 2025 20:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934553; cv=fail; b=t7qdQ5kRGSNR5k9rdLW5/WUkw0O5w/wxYKc3x1vW/ESekM3y1JwrSpSWQxJkjflkSNFLPel1Cv10SrcWe+kUzZxHB+TUsovcsNxvNpumkEjKJjxrJW+sKX+TMKHb0kZXCEK2+81DFq3k22EmGvzapXDhYnmpH29D+HG1y/kMlyA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735934553; c=relaxed/simple; bh=V7VoLwJfWfCPOpOaBGkxvtUdLF1A7Y9d/YLU6/XTZuU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CyZdUlhFoW6nmAQJOEQgPYYM2js/SD8z3nvpl5pEx7613cFwnyr5bt9U0ooNLQLI5ePKvhzLm+HowWdqEcCjgDxtjupWLoed63eUI54e1Ot9qTqviaREhzJo59WDg8WVFwmYifbdNXRurA2QCuRWtwRGnd25E3Zsjk2Yf9P4gow= 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=sVA7SClf; arc=fail smtp.client-ip=40.107.94.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="sVA7SClf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oDwhub5Wu5n/P9AHHitzpzn3j7hKZzcUvjzeY0+PZxfjpUMD4wnxKOsjfUVuUKAyJWsBPed1rUEoBAITv5TT0Fu6ybIzD3WC/IbYlyqv43kRepnl4dZDoIES2axdvKxrk3AH6FlMixYkA9dBhH7hKG2SexOs805uxMvwvjOQD5EHae/bzNk2CZuOLyRH6ICj228W/i+O8B9wO/kKa/Fnalf57Y1q6G5EQ+OviWuf7DTJge8XtwkJDBc8HOwCcjELtu4woKG9fwFGLRMnBB5Oo423Jhf/gjNYIs6nNPOBGE2NZ8Rrl3a8heNMDh3qQFke68Z0FdsR73K3yxWMuO42/g== 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=PEmz5Fr3bysDhwauhsVFRG25d8gj6d0+aL0ayDKmIKo=; b=frszzKK2WiXEdSPBfGs68CwaNv59oIX9+uPzTrrhAixxPtbKe8lhAY+tSXo+8amU2w0ZQxe9arlIU2C6X3T+Zr9iIs7PdROgCp7Qd2aP/L8Yz6b2bMhR52XxcaqEXUadoi3CXOVRb+OMDjul4WzyBGLTVnKNyjqBWDKsP5WAbMkcQhlgN4u6ZGZ5uwv5iM3lcXGYIp+Mji/n1fD4B5QnEeRkSvTrnkRKA99ZF8pgw5MBGv5JwFB+rd7syuoC8a8nCmqrqa1ceNPFJV/4ijwd7CH4p5mwd3pCeOtEnGCQNJ/G/WsDCLhf8bnSBfn4GVIPFtMNM2eFz6dIfy6CagH64g== 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=PEmz5Fr3bysDhwauhsVFRG25d8gj6d0+aL0ayDKmIKo=; b=sVA7SClfsAXwoYTcIuQCLZzEY29nxO3UiyPUVuFaqVxpxsPdPuMFDpGLOXC1Nearz3/7rwT+QCHr0cmqVWJwGbY18q6pp0+WsMMCexYr1uAmgDz5drTP/SC0i7XlY49MZsO1vgSFsaoa4YiGJEM/B36Xi3phtzl1EOI2NjC5HDE= Received: from CH0PR07CA0003.namprd07.prod.outlook.com (2603:10b6:610:32::8) by DM3PR12MB9414.namprd12.prod.outlook.com (2603:10b6:0:47::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.20; Fri, 3 Jan 2025 20:02:20 +0000 Received: from CH1PEPF0000A347.namprd04.prod.outlook.com (2603:10b6:610:32:cafe::8a) by CH0PR07CA0003.outlook.office365.com (2603:10b6:610:32::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.14 via Frontend Transport; Fri, 3 Jan 2025 20:02:20 +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 CH1PEPF0000A347.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Fri, 3 Jan 2025 20:02:20 +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; Fri, 3 Jan 2025 14:02:19 -0600 From: Ashish Kalra To: , , , , , , , , , , , CC: , , , , , Subject: [PATCH v3 7/7] crypto: ccp: Move SEV/SNP Platform initialization to KVM Date: Fri, 3 Jan 2025 20:02:10 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: kvm@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: CH1PEPF0000A347:EE_|DM3PR12MB9414:EE_ X-MS-Office365-Filtering-Correlation-Id: 72387c3d-3773-44f7-b37f-08dd2c3187e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: evCAbAqCK+NXbAzH4n3ufylmffc96tZlRMEiYukKdGnn726lDVGt9AZG5VPEKSj66JpHw37UOpXWeuZC2noyly4bWo/b0A7QCodvhB5Fi8yuijhKD8eX3NBSmWj45JCRtiDeY7lkkrNVjJdodLmowQ1kAYdjMWRPMUoF+c4WTIhfn+iRz3JyfgF+yY142WnlW1SC31KriSuHBY2fFgdPaEp2c7uku2iYB5tE9M2mU+amasiAUlIy70rthxbdXxofOmieQjDDrEAyNJNikEvUH96c5KuS6Fk95u5Ho+rXcPvtbuJBa95/TNSZk5UyA+MYGEsTyjtibVe/Oof9xSOETKn6Ug0BTfs0SyubVFbkL6OW4L8Zw1PIsT6Z+SrUKIC+qW75phEHF5vNisL7OzenJVv6x8EmLYgcGSHLqWyi7utSmXrIya7cuht20qhwiljSfYJ8TH3Aiivr1rGJbP0WgkSJtgMv9Ua+YOhhDJ6cj6Dl5pHbkBmvSvPApDRxq0S3ZmrM8LEpZ3gY3/k/N3zABfyd5EivAZVtK188FOo1+O4MDCUya+eNzLK1653tqnysM5FnLs1yhxWJWqbP+awNLRIHlvKuqLAxRoWf47T9AM+wFHiL4urt3JWtAzbnE9IDP0tUU6qOjrUJHDjX2ehlm8PfDAI2cj/wmtsUKPEF+WYxCNLGyjsiNk9wCVgBpSMjKZ8omAELZDs/1nqZ3zSw3aTIzQebYl11w/UQc+CrNANWCt9TUCyIaYM29txw/2sg3KiDGyfgWBMleEWZIxZLdHiObQjF3M3NaVc1h37sevoBg9UMIeyXGtZ4XvLAhA5ZfgINC4K5ACQzi6JXBf9rMvrWLGk4sMhLmLDJj+cSdukdwQRZv6nU0Dg+arHCPR87dapM2foxKiKeS10f85M0L//AUSv7oKaBAWgSfq1n6BpfExJW2PWaMCqop1ACeL+LCLuwANmHaF5r7XpOKYzbUe+/23a3UrwjfzlH5RzycXuOBESQrZtbRNVd8+k2k5D81wPZbaik8KUK/3598YxGt8z0SLdOWJxCpPJLtFyr2iK+QKfOQfdTiSbIpvbJE537l8MOQmYZSd8pl9I3R7105OQ2F7vPcYqprSEZyLLJWah+tDWeXixkL4w+X9xkISCEkEis890UKjyY3WJxuh5+F4UhidmU7Gik2FaQNxT26Xru6/Yibkg3HEEWmQkmU0N01R+ng2pATTXNtZun6VDX56FbJXQ6eF0WC5abLbEJUDBKSh9dfKOxVmgGXni+9tCktcFHCrplGwMWzsNiv4VYwJHkrq4zqo0KAeM2XuHk1u0LB/8LFijCpcyUOtBevGnzqOvMm5FgYM77pXeVlL5WC/dxfNfiKWgeJCj7SMECPSBDW/VpF7SdGUJhllHTBO+1IUgvQeWqjEj8DIO3jQ4KK3RMYmwXaj4RnMRwS0vA0njnx9Tz4dvoCAaxL4kIjxhKBYjLCHNGy2GhlSb7nQs76fAkTfSgeJpVJErvcCl35iNQhFPPU9geuHGfx3RbwxG4 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)(82310400026)(376014)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 20:02:20.0407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72387c3d-3773-44f7-b37f-08dd2c3187e3 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: CH1PEPF0000A347.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9414 From: Ashish Kalra SNP initialization is forced during PSP driver probe purely because SNP can't be initialized if VMs are running. But the only in-tree user of SEV/SNP functionality is KVM, and KVM depends on PSP driver for the same. Forcing SEV/SNP initialization because a hypervisor could be running legacy non-confidential VMs make no sense. This patch removes SEV/SNP initialization from the PSP driver probe time and moves the requirement to initialize SEV/SNP functionality to KVM if it wants to use SEV/SNP. Remove the psp_init_on_probe parameter as it not used anymore. Remove the probe field from struct sev_platform_init_args as it is not used anymore. Signed-off-by: Ashish Kalra --- drivers/crypto/ccp/sev-dev.c | 30 +----------------------------- include/linux/psp-sev.h | 4 ---- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 1ad66c3451fb..55a8dd762b67 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -69,10 +69,6 @@ static char *init_ex_path; module_param(init_ex_path, charp, 0444); MODULE_PARM_DESC(init_ex_path, " Path for INIT_EX data; if set try INIT_EX"); -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"); - 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 */ @@ -1342,24 +1338,15 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args) if (sev->state == SEV_STATE_INIT) return 0; - /* - * Legacy guests cannot be running while SNP_INIT(_EX) is executing, - * so perform SEV-SNP initialization at probe time. - */ rc = __sev_snp_init_locked(&args->error); if (rc && rc != -ENODEV) { /* * Don't abort the probe if SNP INIT failed, * continue to initialize the legacy SEV firmware. */ - dev_err(sev->dev, "SEV-SNP: failed to INIT rc %d, error %#x\n", - rc, args->error); + dev_err(sev->dev, "SEV-SNP: failed to INIT, continue SEV INIT\n"); } - /* Defer legacy SEV/SEV-ES support if allowed by caller/module. */ - if (args->probe && !psp_init_on_probe) - return 0; - return __sev_platform_init_locked(&args->error); } @@ -2529,9 +2516,7 @@ EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user); void sev_pci_init(void) { struct sev_device *sev = psp_master->sev_data; - struct sev_platform_init_args args = {0}; u8 api_major, api_minor, build; - int rc; if (!sev) return; @@ -2554,16 +2539,6 @@ void sev_pci_init(void) api_major, api_minor, build, sev->api_major, sev->api_minor, sev->build); - /* Initialize the platform */ - args.probe = true; - rc = sev_platform_init(&args); - if (rc) - dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n", - args.error, rc); - - dev_info(sev->dev, "SEV%s API:%d.%d build:%d\n", sev->snp_initialized ? - "-SNP" : "", sev->api_major, sev->api_minor, sev->build); - return; err: @@ -2578,7 +2553,4 @@ void sev_pci_exit(void) if (!sev) return; - - sev_firmware_shutdown(sev); - } diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index fea20fbe2a8a..b0884dbe7d33 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -794,13 +794,9 @@ struct sev_data_snp_shutdown_ex { * struct sev_platform_init_args * * @error: SEV firmware error code - * @probe: True if this is being called as part of CCP module probe, which - * will defer SEV_INIT/SEV_INIT_EX firmware initialization until needed - * unless psp_init_on_probe module param is set */ struct sev_platform_init_args { int error; - bool probe; }; /**