From patchwork Fri May 31 04:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 13681122 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) (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 5DE617BB01; Fri, 31 May 2024 04:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130044; cv=fail; b=iS9D6Fylix9ZaHEgjd9ioltk0+FvwgfrJ5qmIbJG49QwoAE4NHzKUq1cibyqNHT5lNxtdtnIIKZ4TUTrZ8bA4ahQdFWg0nTdxSOPcLFfIKwQV+KhETBOkv3OII1rwErF78WTdraR3hp5LNKN/C+afJb6TutiDtwoWQQtcxv+WiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130044; c=relaxed/simple; bh=5qSYz184dG55AgMt1KcS/YHhgJrEhgfTvgTTCjahzBo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TQZCggPXISwHsYHaml62Y/6iAsS5Uy9D1mfVucKyP0kn5C2XmpbwSDz6YjcomPAGCnCeoaC/KFX/1zfBfJSZzL6KcgimKjyc3Ssn34FyGUQPI6l3hL0kHzgA3S+dDinuS6BKS59CbqQJ7srMQYf/DhThReQZZT0IMFx0ZT+HO1w= 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=z4o0+qUz; arc=fail smtp.client-ip=40.107.223.75 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="z4o0+qUz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iWIlg/+9SaMQM0244FC56ey/Q6YqLlmSSGHqeSvaWoh+akMrecvQzqJUkYgQwsFo2pK+pEpS6cOFakVKZp9CYBs6scxu4bLjWYxos6M8qSt/EZiKOJOOHYMwfsep7DEguG5g9mInetfxw/rIp7EeSAnjRKZ5llOaegDRS1W8uD+Enfoz/BGhEpXqnwdcP2tnJi+yISVc9FyN8oJ0qLuTFUN1/CIV94+ErNHkTjMUj/xTikKJmbXvKPXa6GcegTe9ic/YmN8u276c9iBoDKT9Z5bDvhmAmNiWHjUdM++87pYcPpFEzfcTmW6hu0fA8fSPR/HBIKMjPuEVrKI2lSXdTg== 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=dcHu6ihXJZRoVgQf2gK8G/BljboPy4aUZTH6uo1HfZM=; b=fi06Zkc6xInTWsVjC0nop/SdqBp3Yt/CVTSesqHWKKGjCXEvNYl12HT03KgplTFrTwW+z6vkOY4w09gCVwIyl+bq9QjHiWEQyRVwOVLKzcb9X0Z1mLCzcyj5CSPHMZaowGyi2k9JV+OJt08OAc4RHXh6BXCG50Kn4t4dgaOZ13kRZXN/h3JZFgwAJnq9/ztPgPL1uqZcMqG0XUDd/I4rDxRvGPpyq6dPJ6iV+aMPhb2qd++hY6d20h9lJMN0p6GW0jW60mS5kaBQtp+3OvL1Q2ibaZozaQWKipUvIH852bBPDemWcZ2U571/L9H+DlJg2RxvbD0S2h7Be9Kbav4IfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=dcHu6ihXJZRoVgQf2gK8G/BljboPy4aUZTH6uo1HfZM=; b=z4o0+qUzaibxsijnfj7Y4OZV9PChw8jbTeD8rKNl7zuBM+dUHwCZBZKDicAwjhWFMwI48IeZRR39Sb0qxo31UfW7bs7ud+W3PVXRL55E1eEWNPleZE3rx0cMRn19DTKg5WIndoNghQBA5N1vOJYXdOrLDdfu/Rmln9netWgQyLg= Received: from DM6PR02CA0155.namprd02.prod.outlook.com (2603:10b6:5:332::22) by SA1PR12MB6727.namprd12.prod.outlook.com (2603:10b6:806:256::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22; Fri, 31 May 2024 04:34:00 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:5:332:cafe::e) by DM6PR02CA0155.outlook.office365.com (2603:10b6:5:332::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22 via Frontend Transport; Fri, 31 May 2024 04:34:00 +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 DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 04:34:00 +0000 Received: from gomati.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.35; Thu, 30 May 2024 23:33:56 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v9 14/24] x86/sev: Handle failures from snp_init() Date: Fri, 31 May 2024 10:00:28 +0530 Message-ID: <20240531043038.3370793-15-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531043038.3370793-1-nikunj@amd.com> References: <20240531043038.3370793-1-nikunj@amd.com> 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: DS3PEPF000099D4:EE_|SA1PR12MB6727:EE_ X-MS-Office365-Filtering-Correlation-Id: 659662a1-d348-4595-2fb9-08dc812ae48f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004|7416005; X-Microsoft-Antispam-Message-Info: TXFTJ2UsDgqUjfvPcTlelKNAcfVfe9o52+uw5FeM1+1MttIkZGZLEfjkSR3GoYF+24cR0jftruJNSAbBUZkNlIxLBbcBUHkr5y3qjitRTpXW0iMZw6IilIeiXHSb6oPYTLmYjiI+gf0pTd4knzgitC+fCy6f+RQ5QXFeleMijwo+8fCR5ugzQF+6NbKq5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C6sKm8i+uJH0cd/JVoXmJlm7n1spHqIO8rOS6I8YI18/PXGeF4KQR9UwkZoZl4yxDKtIgFZC2s35Mz4uiAHNGTYKkFPiS7Ri9JdVJjcgnzXLBP3LFoLfW0FwmnTEBaBai0YEuvXtp0+svatj0L 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)(82310400017)(376005)(1800799015)(36860700004)(7416005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 04:34:00.2185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 659662a1-d348-4595-2fb9-08dc812ae48f 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6727 Failures from the snp_init() are currently being ignored by sme_enable(). Add missing error handling for cases where snp_init() fails to retrieve SEV-SNP CC blob or encounters issues while parsing CC blob. SNP guests will error out early with this change. Signed-off-by: Nikunj A Dadhania --- arch/x86/mm/mem_encrypt_identity.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index ac33b2263a43..e83b363c5e68 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -535,6 +535,13 @@ void __head sme_enable(struct boot_params *bp) if (snp && !(msr & MSR_AMD64_SEV_SNP_ENABLED)) snp_abort(); + /* + * The SEV-SNP CC blob should be present and parsing CC blob should + * succeed when SEV-SNP is enabled. + */ + if (!snp && (msr & MSR_AMD64_SEV_SNP_ENABLED)) + snp_abort(); + /* Check if memory encryption is enabled */ if (feature_mask == AMD_SME_BIT) { if (!(bp->hdr.xloadflags & XLF_MEM_ENCRYPTION))