Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1932554rdb; Tue, 20 Feb 2024 11:13:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQETCYj3eTpBe+H2UGnxSbT5UTa+yDIUi7kfgs81g1RVKjFs5oN7tXhCr6dz60QV1M1jjflQGNsX2ROXVXkjJuc+oTiJBHkqeDJGTkQA== X-Google-Smtp-Source: AGHT+IG5En4EaxK6oSfr6sJLJwih0eIDag27Mkk/WdZTWQ2avL2ubOVE5FZ5o9LJnlS7sJYOG00Z X-Received: by 2002:a17:90a:4414:b0:298:eacc:682f with SMTP id s20-20020a17090a441400b00298eacc682fmr15976143pjg.34.1708456421167; Tue, 20 Feb 2024 11:13:41 -0800 (PST) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t5-20020a17090abc4500b00295e3413670si6748089pjv.131.2024.02.20.11.13.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 11:13:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QlX6fLE5; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-73570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73570-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 10FB1B224DA for ; Tue, 20 Feb 2024 19:10:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75BDC13341C; Tue, 20 Feb 2024 19:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="QlX6fLE5" Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2083.outbound.protection.outlook.com [40.107.102.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 6E53912F5BF; Tue, 20 Feb 2024 19:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.83 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456186; cv=fail; b=GPNkQmJpfCnXhpe73n0/tW28zTz4xa74oVX8Li/41iWRZAWlfR9pKIO63Wa8/egNdNOmOs+H5FE82GBoJA9jKE6UpihdjUlt+CcgMuGUjQp7+f4bRUVtyGbzCfpQLu/cUj8NYdFC8RirzBrpRNHdATznT6UEfCQO2udnOadu2V4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708456186; c=relaxed/simple; bh=7XIFN4NS7TQ7hfu4JTpLGwTa1MkcAF731IY0mKtkPDA=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=iVHAUcyxLPjOgF2fPZosjqVMF+EkydwFWUk6xdk+ucr9l6qgPo7DY3vcX8KAiBOjukzfP7ySoh1PeiwX7HRi0nloFCb4IbGatbC9mXwaC2cHNvvIaEjlU6ZCzw8m0FdjvWwYsJKyvuUJNUGw5h8x3x+tlFsGiQBN4YwXPQuif34= 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=QlX6fLE5; arc=fail smtp.client-ip=40.107.102.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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONdr0biyzddykYZDghS1WQHk837ADsyJp5l5Hqy46F/vjTklgt97WQf05sVcTvOqcZokEyzRwFeDU5J9q23Zqp+DXMtD/PKkz4dxLdMBO4xWg9e6/CAZ32It6UM6detT0jYWPcoNFQ5XZROiFHZsQCj+EmaTCULKZ0zTFXgSxDuzpjNePyWAmvXRisM0DkXmV9jzfXdn5UAP2iV0N2pZmqRyXQ3Y49tzXeFTFVqgalMUsEBLAsozMH9ajPPRjHNModqq8bu1hEJtbzKSn0DQ3GpJv3872zhbxWD8La1ml6Pegcjaf5mHTy7+KYs1I9XO4lZnTMlNLlKdMWSXzJYopg== 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=gelVehWMHiBg1MgbQlhCxB/yBfSxG/zn2lh33iBLVmU=; b=juZ3cKYH5nc4Bf7wL3r7i8mQ5WODbWtv3vSIj/PCRw/1L4py67A+oR2xu6OlFnwrDVNOWweN2RsRfUS15MnvLE6FUtQU/Q35/Hja0mTrYxkffWvi5RaX70QoFavUSIbWIg48lQpol2xq5DUWLZG96rk+eCP0WvLdNMf67tlOpPr+MXjxspQHucagTuhYO9iw8ulLurgdzxKUIageyl3kMN+n9falY+LxGjO9eqOoHIFxVIa39Uqps+rIF72U2vTBiv0airI8dX8ufUsZyicX0KO/QX2gHUrOm5QfyBpjK1PN+v1P47AWJ0YgfP6PzHaM7utMI8LZkXd3cneb5sif7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=gelVehWMHiBg1MgbQlhCxB/yBfSxG/zn2lh33iBLVmU=; b=QlX6fLE5uRH/eT+QfL+l+DjW9gAZScVSxxorav/HoVJFr7tRKwwOzb9aNjMs/PjXmutwxJUURv4w2OjHImyuykvdMAfzSZaMtb6va/GWca+gRpB+CG+l3C70L4Oq16ytxQyxclSX7mH/YAzbtmXpDTFULAFoCe9UdPZfAu2cu4I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by SA0PR12MB4429.namprd12.prod.outlook.com (2603:10b6:806:73::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Tue, 20 Feb 2024 19:09:42 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::9eec:d188:63a6:1c61]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::9eec:d188:63a6:1c61%6]) with mapi id 15.20.7316.018; Tue, 20 Feb 2024 19:09:41 +0000 Message-ID: Date: Tue, 20 Feb 2024 13:09:37 -0600 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] x86/mm: Do not zap PMD entry mapping unaccepted memory table during kdump. Content-Language: en-US To: "Kirill A. Shutemov" Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, luto@kernel.org, x86@kernel.org, ardb@kernel.org, hpa@zytor.com, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, peterz@infradead.org, adrian.hunter@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, elena.reshetova@intel.com, jun.nakajima@intel.com, rick.p.edgecombe@intel.com, thomas.lendacky@amd.com, seanjc@google.com, kai.huang@intel.com, bhe@redhat.com, kexec@lists.infradead.org, linux-coco@lists.linux.dev, anisinha@redhat.com, michael.roth@amd.com, bdas@redhat.com, vkuznets@redhat.com, dionnaglaze@google.com, jroedel@suse.de, ashwin.kamat@broadcom.com References: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> From: "Kalra, Ashish" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DM6PR21CA0006.namprd21.prod.outlook.com (2603:10b6:5:174::16) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR12MB2767:EE_|SA0PR12MB4429:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c540ca8-ff72-4c8d-64cd-08dc32477dfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y6j1aYU2xO4SpAOgtKRNWmPtI983K8G0gJVev0sB6hLpVQ4eAl3FUta+EdvyFHlIV+OOfEiV9VbSSErfFvRS6oTSWnJmMafXE5Yxq+f8ukc4yvkCPseIgRoUp+RBmrE9h2GkbenEG8EcmIqpIa8ZD7NqR8VyiEPucpxo/RR7P00D5Eemhuo5Hh7FhuMZA4y8qVR2uSa7d5+C+OaqGruYvTi5ARM6ZdRqTEo9Uo3jqjxPb0CfATUIcRuzB9Xl9qrpKnedjP3vpqMDNwS49IQIMUTrBnB6A2G5Sfs5DHbKtKXetTDdQzCLDwIXea4RvBcX96KhQv/5twsmT9NQXJ6j3qzzi9yKzbLI43B4GllhKKoEJkf+CQbthMXy9/4YPgT9s7NdkDDC55eqQ3tDK23/s6DHvtLPXaq0ErlLEgYQ6JL1GOfTpWav7c4mNGoNiiZnVmbZXIoaCdmVCM3zrqxzt/nDRO8Z247uMkMqw3tOa2Wt04xnSVu9NXRLdrUm9O+Wp5/gHGbmEAG3FF/4+akxz3dyJxhWE4G9n4P2gvAygIU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Um9uaW9peDUyTGcrdVl4RG9Nc0VDZytYMmNzaFR5MFIxSGdFVU5tcjl3YkJ1?= =?utf-8?B?Uk1DenVZaFcxZnRSdjc2Qk9MdnNJbzdVYmJQeTU0dFhjeWZEdUpBb1k1Ykt3?= =?utf-8?B?V0VoUDArQXBITlBsd2Y4Z3JVVUlEOGFiQkFCaVhsTVQvSXE1azh6cEZ4ajdB?= =?utf-8?B?dSszOFV3cllURUIyUDZGcnlTMUo5bnB5VHVNUVZNSmVyL1hETmhScUpOaXRV?= =?utf-8?B?U0NtUTdKMnJDbXA0bVZGK3Ava09WR1UySjdDelRDWjF4Lzc1V2hUbFNVMXVR?= =?utf-8?B?VXRFRXdKVkZoS3FsNjFpdTZ3dFBtb3BLNDU0TFJ2clBwMVcvd081WVpiMmZs?= =?utf-8?B?Q3hHTyt1eW56QUlhbzhpMiszMWVzcEwxQzJKTFNLWk8yck40UEdzcWFOMGJr?= =?utf-8?B?SW91MitXbVV6ZlNxYjlGMTU4ZEdNS05GWlB2QnVGUmltTmc3Q1VGWVE1L3h3?= =?utf-8?B?aS95azJQQUxIZzdKQ3g4VGRLeEFjNn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wSk5UUGs3WVpZQVpEVzJyQml0VFlraWp5eWIxbFhwdEcwanFX?= =?utf-8?B?aWVISUlRcXArQ1FpS2FYMENWQkRWNHp0a29mRU5ub28vVGQ2aTBXYnBlcVBY?= =?utf-8?B?ejdVZ2R3czJOOFErcUtyNCt5M3QrRWRSTElQV2c3dFl2R3pISmpvTFo0MkxD?= =?utf-8?B?NG5iUHo1Zi9rN1hKaGpwOVJ3dkcyMCtKZmkweDlJQXRtY1lMcUs0ZU82TG9k?= =?utf-8?B?WnNKSjVybkVHeHA2cWtFZ2dYYXhJOTcyUFRBWUx4ZG5oWmJoejF0ZEJMYW5F?= =?utf-8?B?bGxtNUJkSTJTSmV3WHZTSjRyTmV6NVcyRlhQUUhDcnI1ZG9DYUNTZ0ROSVRz?= =?utf-8?B?TFNJN1MyM3dpdzRpdEcrbnA5aVpVS3pkMC80UmVoQ2YwSGhOZWU2b2M0ZzlR?= =?utf-8?B?WG5rd01zQVZyTmFiQlZKU1QzczZrUVZyU2d5VDltRGUxUThyRkhQK3RKR3RX?= =?utf-8?B?cFlkb09iWVVsaFNXclhiZGh0aEtmYmVSVmlIaFlFTnRqckcxMjBucE01b0Fv?= =?utf-8?B?c1JiSkV6T0VkVFYzN0xINndFMUd5NmdrTGFJODdNS21Oei9Pb2JUbWZlSUIy?= =?utf-8?B?dzNtREIyeDF6T2tueTBjS25haXR0ZnZtVWJ1cVpVSWxWNjBhQzVxbVJIQmJD?= =?utf-8?B?M0w1SVdvQzZzYWRxdmhIRU5mS0lOZUhrV0lSUkg5d09qTzE1RTdGSzRUeHoz?= =?utf-8?Q?3qOD/oSv1fJ3EulYRxR1IpD+T?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c540ca8-ff72-4c8d-64cd-08dc32477dfb X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 19:09:41.8952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NfXesa3yprvcV+qLkD+demF/zZWZinF288e9gcbrd6F2u2QhmrKCXZCpZSuUvLgduOyMzE2+GfIHFjeFFvqRFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4429 Hi Kirill, On 2/20/2024 6:42 AM, Kirill A. Shutemov wrote: > On Tue, Feb 20, 2024 at 01:18:29AM +0000, Ashish Kalra wrote: >> From: Ashish Kalra >> >> During crashkernel boot only pre-allocated crash memory is presented as >> E820_TYPE_RAM. This can cause PMD entry mapping unaccepted memory table >> to be zapped during phys_pmd_init() as SNP/TDX guest use E820_TYPE_ACPI >> to store the unaccepted memory table and pass it between the kernels on >> kexec/kdump. >> >> E820_TYPE_ACPI covers not only ACPI data, but also EFI tables and might >> be required by kernel to function properly. >> >> The problem was discovered during debugging kdump for SNP guest. The >> unaccepted memory table stored with E820_TYPE_ACPI and passed between >> the kernels on kdump was getting zapped as the PMD entry mapping this >> is above the E820_TYPE_RAM range for the reserved crashkernel memory. >> >> Signed-off-by: Ashish Kalra >> --- >> arch/x86/mm/init_64.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c >> index a0dffaca6d2b..207c6dddde0c 100644 >> --- a/arch/x86/mm/init_64.c >> +++ b/arch/x86/mm/init_64.c >> @@ -524,7 +524,9 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, unsigned long paddr_end, >> !e820__mapped_any(paddr & PMD_MASK, paddr_next, >> E820_TYPE_RAM) && >> !e820__mapped_any(paddr & PMD_MASK, paddr_next, >> - E820_TYPE_RESERVED_KERN)) >> + E820_TYPE_RESERVED_KERN) && >> + !e820__mapped_any(paddr & PMD_MASK, paddr_next, >> + E820_TYPE_ACPI)) >> set_pmd_init(pmd, __pmd(0), init); >> continue; > Why do you single out phys_pmd_init()? I think it has to be addressed for > all page table levels as we do for E820_TYPE_RAM and E820_TYPE_RESERVED_KERN. I believe i only discovered the issue with PMDe's (phys_pmd_init()) because of the crashkernel reserved memory size and the E820_TYPE_ACPI physical memory range mapping on my test system, but you are right this fix needs to be done for all page table levels and i will add also the fix in phys_pte_init(), phys_pud_init() and phys_p4d_init(). Thanks, Ashish