Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2622363lqb; Tue, 28 May 2024 05:59:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURxv/Tk/Ze3xyp3iWpiEcbLBgvU3JaGoejTiWlxI5xnn8UtMIMzxRI0aVdDLA8vNPuNbYtKzoYiabj0+jfMERVp8e5gxqO4Wq8J08gAQ== X-Google-Smtp-Source: AGHT+IE+fZESfZQPTyIPqjpso4iFS4kf05eA/KnWYXLYADg4kOidx7nGdSW0L9ScTduZk68WtsWr X-Received: by 2002:a17:90a:ad84:b0:2bd:85bc:5986 with SMTP id 98e67ed59e1d1-2bf5e137063mr12033215a91.9.1716901155557; Tue, 28 May 2024 05:59:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716901155; cv=pass; d=google.com; s=arc-20160816; b=Hxk0nWRwtAT2jVf99woJchDhbklWPAI+xq/iMeyPdbsYRiHVpzACA/jzpwiQdey/ZH nLmfEWmWFrxBM99UPuXi89UnMUxWclgRunB71lHiyA/+kdUCv95iVaXKVh05SEapKpZ6 Pb6wPjYYHLQ/z9shNTiAQNfxmynpt1QlHI0Z7rYyQl3VJPzBR+nD6Nw3LWPWbAwkHrXw P9HFVZ92gAWLJIi0thTHY17uZzDB+GSw4qDAnWhwkyp1YTLYGLNa2MH+PfSZXR0yJ/Ou Vd6JeItkdUXOfgIP5QCTHH4Hf8V+Tsj3X9xXjLYgK0kGsP9Et3x4p60eOom0HvWKotCF vGiA== 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=99cDKWt4nq4jRanAgWweIyKPVrFtxAFdHwdpUNcK8TI=; b=fkpX+ppZyXuNu0Tkkh/9SsDPJeHLSDgjqeqGYsGW+E8LLthu69BmMjJEj2aNWqnoxP 5rBrbnFSDzxHc039a013HkjCSkErtx/eBm/1h6r0Q0PtMIIW62hZ0ablrCtozhicZa/6 JH33XFF4gh4phqqWHtJ776F6W1EwEmNBXk7QCNu0sDo8VxWvtNb/Fc5jKwrqocV9t/JU uH3sJHQCncmybZ0Ui4WI8wahrU3KcBJ/71MMPtuQLo3VKHLZutLwC2N9ziIYeIIdM9fZ ALs1AwiO5wmjtl0j/pksrkFSDUyl2hjQTx0EzKRBU5o56XavuGJo027ogNRAjnN4JuCy IDfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z3GjFks9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bfa1aa0380si5292163a91.167.2024.05.28.05.59.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 05:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192045-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=@intel.com header.s=Intel header.b=Z3GjFks9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192045-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E7AEAB23FC1 for ; Tue, 28 May 2024 09:57:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8706516D307; Tue, 28 May 2024 09:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z3GjFks9" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 E87DE16C694; Tue, 28 May 2024 09:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716890144; cv=none; b=E1O+qOXXzUVlPVDjpxuuRkD1wjnXnxiSQSHd9qFbOakV+Y+H8eDCAdveiTHgxsO8XowN3jKaqCU0ShXOkGmVVUEz4mz8Rsrym/UM18SSX3u98FNqKqpW9JuBJH0JrhQrogEQlWBpE0sQIpfu07MoX4FImfZeXuzNIkuF7g3HQ0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716890144; c=relaxed/simple; bh=DBcJsWV4nfgk/8fw3M6vcKnfFbP1zoB1PzLmLNRfgyE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f0i9SKnXkPjd61s1Uw9Ivd+MhjVHG7PcQyBddeou/ufRN7bXnkS0vcWc/BIJIb/2dvMFzleohD0URpdWZp2IqE5dWthNGx0p0w/zsDI3ebfVC8e7K6ZG6k8nQZ3gebydMMUBRT6iGCdbwi+Fak3rFnSRMsbKMxl5qB1+KAcXT/I= 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=Z3GjFks9; arc=none smtp.client-ip=192.198.163.17 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=1716890143; x=1748426143; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DBcJsWV4nfgk/8fw3M6vcKnfFbP1zoB1PzLmLNRfgyE=; b=Z3GjFks9ZVzeYgFOk9IQ0Tc+Jw3lmIFU8mMT2phjI/USTUBwIwTY4Qqo M/faOhzQiVpDHACdYVgUEtbWu8UfT06HYkZlVlm35sPdWGvhFNCgOlHh+ G6cOSt82PH7KbIjL7S+5XyRAze4CovSr+p+Q4SsjlAIS7i0LFd91fgw1v ZgPYH2yGuY1BKb5b26AzHqn10VzMgodJK7GVJYGPtXoPAr28lG/iicGkP 0XzQDFqZ3beELfSwqrt5Y93GfD3fcbZSdg2pFgmVN0EQ4CJPK7oJH65pN vAXG8BcJkuYqOUSEqiB7s7DpgSkyFjHwVAisoIOQ51CdoEXDTD+9dFqzY g==; X-CSE-ConnectionGUID: 1QBz2EmJQlaAKZtGi6iAvw== X-CSE-MsgGUID: tqMtj6XMRbuBNqCKoZ7GjQ== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13097744" X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="13097744" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 02:55:40 -0700 X-CSE-ConnectionGUID: nYowhn8yRl2agu6ZLQpafw== X-CSE-MsgGUID: K15k1wcAQba0VOJckfd11g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="34951742" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 02:55:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id E35768EA; Tue, 28 May 2024 12:55:26 +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" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "Kirill A. Shutemov" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCHv11 13/19] x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump. Date: Tue, 28 May 2024 12:55:16 +0300 Message-ID: <20240528095522.509667-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240528095522.509667-1-kirill.shutemov@linux.intel.com> References: <20240528095522.509667-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