Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1912273lqe; Tue, 9 Apr 2024 04:32:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTUvABzZnO+fUzLSp8liIFyP+9CrIwPgUh7ge8z5bpkaZHfg442GFMtRvemBxo186gPQfPHxJRl4AY1PJStrdmfomh0jj+/a4cPSn3LA== X-Google-Smtp-Source: AGHT+IGrdjFxOpa4UirrEMRtOY2HG02fc/NXT+xn8NAVSQndDE0EwZ9f7d92SbyjTI0NwfqouDPF X-Received: by 2002:a25:360a:0:b0:de0:e368:fa59 with SMTP id d10-20020a25360a000000b00de0e368fa59mr5853145yba.31.1712662326761; Tue, 09 Apr 2024 04:32:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712662326; cv=pass; d=google.com; s=arc-20160816; b=RQ6iJnrqiiFOvcrQ1z17Qv+/MhtgOI8KdRpPv+oZ3EWoio4EIFhVknygr4T4GbBJfo /48g4K3IdH8UHBsTKzxe5K2752zGqlDYGhbX+4fT4GttndXqaPMW68GC8yxJDzJBfgSx fSgSzyoSWgi5qq7wwc7CW0j9+Con9+Qq68xzbsXg92GEJoTiWGNUp96zSbkOPsMooL7K 3D16dNyQmZjTesFr1Rf8wldFW5iI3yAI8MaA59xHlXauDiV9yoKUn5hJWSw6+xXOLJTm yinGLOFLUTJOitlgi2Dr+nEj4xWcnCpYuor5EIu/K6K+hYPgnj77z3PB5J6+Ev12MA/7 M35g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yD6pKFJEwd1Pf3yr4LdSkudp69H/jlmf9ePeviQ/Shg=; fh=qNVGjfxpjp9Agdx4Q0nht0G/AWuthRkX101slHg1kF8=; b=jfSmVA2wzOEePSuTbBsm0FHtSBeP3JbYUzyrj/ecVRYvQ+k8RHtxx0slbOuvf/P6KI ZPidUzmnrerTt6A0T9eqCuiTPpOpplZpuZ5OfD0fznl+9pdU7b3713pNiRXC8WguofvH 7hnNCP5ekQVLAAwOSMbNoXONCaIZUUgO8v7O8mjEP6FyfTmuG9WgOGVQ9Qcw6X+5gp1V ++BwlZZf1Re5zd1lwy07pE0nT4Ftasa1TCjuHFDCOgdGGCbDjnZpv934GCkHlM5m9N1U OnzZssQvV5WQWMyBCvvfLqspivrWNRftHgmiP9WPTIUuTyJjP5IWntdFmrMJuc1PNFuR WSZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=npaABGW3; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r17-20020a0ccc11000000b0069b162a3619si5051071qvk.36.2024.04.09.04.32.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 04:32:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=npaABGW3; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 7B7EA1C23DC4 for ; Tue, 9 Apr 2024 11:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B4CD12F380; Tue, 9 Apr 2024 11:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="npaABGW3" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 67B8E12D75F for ; Tue, 9 Apr 2024 11:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662233; cv=none; b=HmwoqWNPMCwUJ49keKACvj3gyuXS0kJlwy/pXEPC84D3e6CR1EkXuZxJLubePvmLLLRtLuA+JM8CY/TK9GStoHE0FCJ/3KrhNeTLwPz0/bvvMA0hprC98YYaRGKvkalWFXndXjbrvPDO9cGvX497FVFjPf2A2twS0yz7Lj8DrRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662233; c=relaxed/simple; bh=DBcJsWV4nfgk/8fw3M6vcKnfFbP1zoB1PzLmLNRfgyE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hcZXTqaBlb8zgSq0d562HnXoZhzgsX5O3piC7F38ZaPqZJ0/XC8T0BFGbz4lRY6RwaZ4qvYL7ygAjJchN8L0PirCM5j4ZJmY5PG0vtoHYKChJaQN6rxhyYUqZIxpzsTnTRtW90jRX1YkkJt1bVaTdzLJ2HJva5XzQnEMeWd9Bxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=npaABGW3; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712662232; x=1744198232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DBcJsWV4nfgk/8fw3M6vcKnfFbP1zoB1PzLmLNRfgyE=; b=npaABGW3ZiTiRiQZQ6bPIEc0m0Qn2yApAwArDHHFO/QmzGWJWKytFRkC kGvl2WHp7GDwE73D8HtokeEU6R0Fs+XzCy1iYa/P99N2oQSf5Qhk6C1A7 8/JkF9LSwbCzPvjZw7JJVQD2soRSp2W6h4NVdecCQKDNdfmaCDotBkzy9 h2m9U47CBAe0KWsD0o6QGZbia/v+PS+w7q+B5BnCrYgonUGn8Wiy2o+YV jLpnY2sdFiHGXn7ZfPfkAZvZ/u69lFi4GmbGstBPtwDeA19hoqEYy3mH6 rZMag7EsR6wG+mmIEE3tEV0Ll8ZIZv3b0T+XV2WgTlTgwEwa+dNpdITgK A==; X-CSE-ConnectionGUID: uhmJcgCSSeOBO9mFvx1v0Q== X-CSE-MsgGUID: iU4l+MOkS5KTc36wqfSqBw== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="30460383" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="30460383" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 04:30:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="937093331" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093331" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 04:30:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 11CC1C09; Tue, 9 Apr 2024 14:30:18 +0300 (EEST) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" Subject: [PATCHv10 12/18] x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump. Date: Tue, 9 Apr 2024 14:30:04 +0300 Message-ID: <20240409113010.465412-13-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409113010.465412-1-kirill.shutemov@linux.intel.com> References: <20240409113010.465412-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ashish Kalra During crashkernel boot only pre-allocated crash memory is presented as E820_TYPE_RAM. This can cause page table entries mapping unaccepted memory table to be zapped during phys_pte_init(), phys_pmd_init(), phys_pud_init() and phys_p4d_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 Signed-off-by: Kirill A. Shutemov --- arch/x86/mm/init_64.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 7e177856ee4f..28002cc7a37d 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -469,7 +469,9 @@ phys_pte_init(pte_t *pte_page, unsigned long paddr, unsigned long paddr_end, !e820__mapped_any(paddr & PAGE_MASK, paddr_next, E820_TYPE_RAM) && !e820__mapped_any(paddr & PAGE_MASK, paddr_next, - E820_TYPE_RESERVED_KERN)) + E820_TYPE_RESERVED_KERN) && + !e820__mapped_any(paddr & PAGE_MASK, paddr_next, + E820_TYPE_ACPI)) set_pte_init(pte, __pte(0), init); continue; } @@ -524,7 +526,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; } @@ -611,7 +615,9 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end, !e820__mapped_any(paddr & PUD_MASK, paddr_next, E820_TYPE_RAM) && !e820__mapped_any(paddr & PUD_MASK, paddr_next, - E820_TYPE_RESERVED_KERN)) + E820_TYPE_RESERVED_KERN) && + !e820__mapped_any(paddr & PUD_MASK, paddr_next, + E820_TYPE_ACPI)) set_pud_init(pud, __pud(0), init); continue; } @@ -698,7 +704,9 @@ phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end, !e820__mapped_any(paddr & P4D_MASK, paddr_next, E820_TYPE_RAM) && !e820__mapped_any(paddr & P4D_MASK, paddr_next, - E820_TYPE_RESERVED_KERN)) + E820_TYPE_RESERVED_KERN) && + !e820__mapped_any(paddr & P4D_MASK, paddr_next, + E820_TYPE_ACPI)) set_p4d_init(p4d, __p4d(0), init); continue; } -- 2.43.0