Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1743045lqp; Mon, 15 Apr 2024 16:23:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvrwPHDEakgBW9rf4cb8l5nEOIwj9KyxBT/XIb7/JbKpq3kj/CvPQqYVu79vjHyL1Q7n9RAUw4KCgVW3G/GIGoWHgvRtbMVvfI/htVKQ== X-Google-Smtp-Source: AGHT+IFR9rpgAednYwH2v2lfE8ppcD1mh6GReAlSE1KoFPQUFK3hGTxf2UC/Mxip33pV/YG7BFzu X-Received: by 2002:aca:f10:0:b0:3c5:fceb:27fb with SMTP id 16-20020aca0f10000000b003c5fceb27fbmr11460992oip.22.1713223409695; Mon, 15 Apr 2024 16:23:29 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l16-20020ac87250000000b004364296082asi10388659qtp.420.2024.04.15.16.23.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 16:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146002-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Qn68Oz5H; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-146002-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146002-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 597651C20D9D for ; Mon, 15 Apr 2024 23:23:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 179BD158DCC; Mon, 15 Apr 2024 23:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Qn68Oz5H" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2081.outbound.protection.outlook.com [40.107.243.81]) (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 918001272B8 for ; Mon, 15 Apr 2024 23:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.81 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713223402; cv=fail; b=XVhVPvTvz6PhiB35/HZF8uP7PyCTaFhjjWKOF1ngyMiPSTn5AcK0I1enki/rCbIOzXqMgN53K3BfwjfBD1UuhIAbR8T7AlftxsX9uRlNdxCw5g9W0GSejGKRqBNHBi5O7iUhCOBf3/aWnJx74urahNEvpxeYBcoDzF5z/ZWQiFM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713223402; c=relaxed/simple; bh=gmEjNqnBZ+m031/5e1nPfs0DGk2kdd+4KO5faRtrh/Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=plf3YykpBuiDn1scrAS/1uOD0gUDfvQhhvsrGY2f8HdNqP6aBQCcJj3QdmPbrjoYOrtgLXPuCHZlmsEc35+pycYdubutWL949GrcDUqcJnGEDUnHNOkGMrl3WD4qvl28tDSpVb1Tys4U1GuHdU5WvIchhW2/hlwvcFgtEezJumM= 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=Qn68Oz5H; arc=fail smtp.client-ip=40.107.243.81 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=haNDZYdk7eJLWYzlSJcbgCpIWWC5h3Po53T0ijpf4x0eQBmBmJi4DXDAva4It/1DMrJcQtHkabL81YVw52wpgu+jvnCeJLHJrQVvsRllH+L1JWdut3tavMmq2i3zyQzFjNtQF9oDU01kzoNhMyE58+fhM+AtPal4cjOxXI9TgfjSETl9Qn7LDhGVXysBXFMq9lrLu1emrt7Tl6qm9CAge7gx+6+RyV8Rkr2NMmJyYTeyfWAwIeoP/BRDm2wmanpxWxPqCAY6D+sWz5BjezPJY2wCTkUyvitzTbO9S7eaL/U+WVoLiFfI0SsmGA0yWgrV4xllu6Cziv5EeJV9NY7auQ== 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=PELSJenkUMgeqWvNCdjkpMx5JK7Rlf/5sCsFjgBJcM4=; b=B6HNZaX1yWgjHiKtKhHlK9bxa1RRXWhp2ToF2Cx+RBXqDO1gFOUZcUOXyFuQGwQ4/AK+T2IUBC0/gdmaWa3BqVFIengM3q0jWgLrKwtuYBO3i4HhylxUDaLT8CU2Z18ehNNHluomBJJzNSBWj8207LD0Ey4nyw5xaddnx0x98ZM6RrVmzCfd5ei5uG18xru55QPIg6HJLLabAOo2MB53niZHONvkwHhCJIFPOKh4BrmQcbSpa5J5GGoq9neDlUwkeRFTgFn1iEugv67cwStHR8JlXqJG8g8ido2UXZwHxNxkCTtkHAXqBb8GtoyZjDANmShyxV98KkoxPhbIyCUiHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de 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=PELSJenkUMgeqWvNCdjkpMx5JK7Rlf/5sCsFjgBJcM4=; b=Qn68Oz5HcM1RH4WDCyl9Ov7q3cw7fO37TKzIoGMnQd+nXMO3wKmgYekUGs4bxiFFraK2V0k2zRcxA86OjL0FQ1jst6Kl7bGyB7hKiiF/8ijQCsARzcfDAvbRXopUq0PCDBOZ6Y8RAoYyF5x5wOQoLtRBD8dQvjZZmXoMrmBc4O8= Received: from BL0PR03CA0031.namprd03.prod.outlook.com (2603:10b6:208:2d::44) by DS7PR12MB8082.namprd12.prod.outlook.com (2603:10b6:8:e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Mon, 15 Apr 2024 23:23:08 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:208:2d:cafe::60) by BL0PR03CA0031.outlook.office365.com (2603:10b6:208:2d::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.33 via Frontend Transport; Mon, 15 Apr 2024 23:23:08 +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 BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Mon, 15 Apr 2024 23:23:07 +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.35; Mon, 15 Apr 2024 18:23:07 -0500 From: Ashish Kalra To: , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 1/3] efi/x86: skip efi_arch_mem_reserve() in case of kexec. Date: Mon, 15 Apr 2024 23:22:58 +0000 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|DS7PR12MB8082:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f951751-a4f1-44c5-d6c8-08dc5da30251 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i13mXz6TOcRSGo6bCjvnRIVsXsAWiFwMu2kZgIxfXGY9YIZeD1lJnny0QprkRGOQotDf4386OlB/FWSOHAwM2qL2g3KFeyYfMg5jcUxGR1BMvh3hinzkvX9sYjZTReBgxkVjTMhWx0YXzM5ptS+4R/TMMN0W0mfHcHU0xDbHi4Hc8WgloqC/afpLrnPqSreTR29DdTI8j8/8i8l/f4iL3/5JEEEje6VwSVETxKQjdiQZ+7EiAdUC91NitzxSFnpRGmzzqBfxitAxU205sNYTZP0WTx26u4ZWJMNXzXP5NJQrLa4HhIHYe6U7ElTZsMww66lze9kUvqbEYgFcD1c3Hh5TxiLRYInw/0ey42OuFTsqroZbfs5sk23+BrDdzfGb1YJxEIeMgmTyb66EMvRhqI6fQMCoJxsDgAKnxYYlYkxC3Nkvm/xhSz83jxyNf++tSkGcS8VzvQ22tX9YQoOsvRvNN7BucfLADHGQqRV4cRW4YIw/bJxi624PqE2zXSZDCNad9akoofmRbCMMbvUZ68MJCNncxyjUF1vH+u6bjlryH4bxd2wFdWzKbYTz34x4YKZypYu0oWYKpR4AOZvShUjCjHJK387o8b87m7ZCqve3hXfPRzMRwBg69DdQwakhFVVJuqqFGBEnqlBP4TCeaylp8iRdI8gmLychUwzuHYiYxYiwyFbEW3kKPFG0rfZtrxejO3VBP7iR/MEWt8bkOLJOwGpRBbNDYA+vHRG+Isxq9dTZDtiAkhY4wuVyCWMj 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)(82310400014)(376005)(1800799015)(7416005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2024 23:23:07.9113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f951751-a4f1-44c5-d6c8-08dc5da30251 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: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8082 From: Ashish Kalra For kexec use case, need to use and stick to the EFI memmap passed from the first kernel via boot-params/setup data, hence, skip efi_arch_mem_reserve() during kexec. Additionally during SNP guest kexec testing discovered that EFI memmap is corrupted during chained kexec. kexec_enter_virtual_mode() during late init will remap the efi_memmap physical pages allocated in efi_arch_mem_reserve() via memblock & then subsequently cause random EFI memmap corruption once memblock is freed/teared-down. Suggested-by: Dave Young [Dave Young: checking the md attribute instead of checking the efi_setup] Signed-off-by: Ashish Kalra --- arch/x86/platform/efi/quirks.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index f0cc00032751..982f5e50a4b3 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -258,12 +258,28 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) int num_entries; void *new; - if (efi_mem_desc_lookup(addr, &md) || - md.type != EFI_BOOT_SERVICES_DATA) { + /* + * For kexec use case, we need to use the EFI memmap passed from the first + * kernel via setup data, so we need to skip this. + * Additionally kexec_enter_virtual_mode() during late init will remap + * the efi_memmap physical pages allocated here via memboot & then + * subsequently cause random EFI memmap corruption once memblock is freed. + */ + + if (efi_mem_desc_lookup(addr, &md)) { pr_err("Failed to lookup EFI memory descriptor for %pa\n", &addr); return; } + if (md.type != EFI_BOOT_SERVICES_DATA) { + pr_err("Skip reserving non EFI Boot Service Data memory for %pa\n", &addr); + return; + } + + /* Kexec copied the efi memmap from the first kernel, thus skip the case */ + if (md.attribute & EFI_MEMORY_RUNTIME) + return; + if (addr + size > md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT)) { pr_err("Region spans EFI memory descriptors, %pa\n", &addr); return; -- 2.34.1