Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1489801ybb; Fri, 29 Mar 2019 05:40:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVOo9fQOg3EzSVWECxGptCb8BCgMRdnKmiD/3GATGcZCJ6XE8DjbB5bEcnnphd5rlG7CCi X-Received: by 2002:a62:ab12:: with SMTP id p18mr34421723pff.216.1553863243264; Fri, 29 Mar 2019 05:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553863243; cv=none; d=google.com; s=arc-20160816; b=cBIfeX7+BhPrI44jNhfr1jqOTgW8i/8l9puREqDNw8aOnrDI4iFdaCn9cgRWXDFIzj YEurEoRg5cWmXey9nusB8WEOvqia/cDFKXNBMLR6nEx8fUNtN393qPCFlRTrojz+3ka1 IqNiXtb/aKAAnYPB8MeiW/GL9Kxbx+5l1cgfs5QSDd0Mee7r+8TDag9YCBo39LeWpzrh A5kWhMwRL8gvJFwkgSgBDPQgsznTJXnd5dsscQWOvGNB30dm5wWBrXI+L45uAOmUvryJ obuEvyabYYOQJAt1s2nEgM07eB4wqMRe2AnlZByWr6MBBy6UxnUmKBJa4MSrwxrEJu8R 2+pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3ePcrnpYR5xqIoKKEEgG65l52/L6pPDJSLIj5C1n+1U=; b=TQu1kHEtRmrLQODCVWKGAMYZsH4yDvssNFPBcbJQRaor3/b8idYr4TrxEQmcyuQj0Y /u3GNqgOyowwHawIHuKEyCt9M5Fn0kLqtus37jN2j++F1t9o9Nu28GcYCvbx4zqQD4Ji YWvJ5rPlz5IUk9HdAs+iEl8vZDEzm5wRjcE7JtIofOf6w8VyXbnrsSHBI2NVSiGZ+FEF 5lJPmhUSNLq6woKzCxnlICNB+Pw/B+lTfMic8hwuq6NUA5PeZ43SyUl3SgVj2/uBNkRX v60Xtdy8dFnvh7t+pmn9zJbE6GJ4CKyFGTKS0xYriS1OxhvxBxCS1EobTPwwLyedQgjT 6bMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc6si1840165plb.227.2019.03.29.05.40.27; Fri, 29 Mar 2019 05:40:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729541AbfC2Mjl (ORCPT + 99 others); Fri, 29 Mar 2019 08:39:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34734 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729384AbfC2Mjl (ORCPT ); Fri, 29 Mar 2019 08:39:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5DB53086222; Fri, 29 Mar 2019 12:39:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-53.pek2.redhat.com [10.72.12.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A829218E3F; Fri, 29 Mar 2019 12:39:30 +0000 (UTC) From: Lianbo Jiang To: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, akpm@linux-foundation.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, x86@kernel.org, hpa@zytor.com, dyoung@redhat.com, bhe@redhat.com, Thomas.Lendacky@amd.com Subject: [PATCH 1/2 RESEND v10] x86/mm, resource: add a new I/O resource descriptor 'IORES_DESC_RESERVED' Date: Fri, 29 Mar 2019 20:39:13 +0800 Message-Id: <20190329123914.20939-2-lijiang@redhat.com> In-Reply-To: <20190329123914.20939-1-lijiang@redhat.com> References: <20190329123914.20939-1-lijiang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 29 Mar 2019 12:39:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When doing kexec_file_load(), the first kernel needs to pass the e820 reserved ranges to the second kernel, because some devices may use it in kdump kernel, such as PCI devices. But, the kernel can not exactly match the e820 reserved ranges when walking through the iomem resources via the 'IORES_DESC_NONE', because there are several types of e820 that are described as the 'IORES_DESC_NONE' type. Please refer to the e820_type_to_iores_desc(). Therefore, add a new I/O resource descriptor 'IORES_DESC_RESERVED' for the iomem resources search interfaces. It is helpful to exactly match the reserved resource ranges when walking through iomem resources. In addition, since the new descriptor 'IORES_DESC_RESERVED' has been created for the reserved areas, the code originally related to the descriptor 'IORES_DESC_NONE' also need to be updated. Suggested-by: Borislav Petkov Signed-off-by: Lianbo Jiang --- arch/x86/kernel/e820.c | 2 +- arch/x86/mm/ioremap.c | 18 +++++++++++++++--- include/linux/ioport.h | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 2879e234e193..16fcde196243 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1050,10 +1050,10 @@ static unsigned long __init e820_type_to_iores_desc(struct e820_entry *entry) case E820_TYPE_NVS: return IORES_DESC_ACPI_NV_STORAGE; case E820_TYPE_PMEM: return IORES_DESC_PERSISTENT_MEMORY; case E820_TYPE_PRAM: return IORES_DESC_PERSISTENT_MEMORY_LEGACY; + case E820_TYPE_RESERVED: return IORES_DESC_RESERVED; case E820_TYPE_RESERVED_KERN: /* Fall-through: */ case E820_TYPE_RAM: /* Fall-through: */ case E820_TYPE_UNUSABLE: /* Fall-through: */ - case E820_TYPE_RESERVED: /* Fall-through: */ default: return IORES_DESC_NONE; } } diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 0029604af8a4..447eede7ba9e 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -81,9 +81,21 @@ static bool __ioremap_check_ram(struct resource *res) return false; } -static int __ioremap_check_desc_other(struct resource *res) +/* + * Originally, these areas described as IORES_DESC_NONE are not mapped + * as encrypted when using ioremap(), for example, E820_TYPE_{RESERVED, + * RESERVED_KERN,RAM,UNUSABLE}, etc. It checks for a resource that is + * not described as IORES_DESC_NONE, which can make sure the reserved + * areas are not mapped as encrypted when using ioremap(). + * + * Now IORES_DESC_RESERVED has been created for the reserved areas so + * the check needs to be expanded so that these areas are not mapped + * encrypted when using ioremap(). + */ +static int __ioremap_check_desc_none_and_reserved(struct resource *res) { - return (res->desc != IORES_DESC_NONE); + return ((res->desc != IORES_DESC_NONE) && + (res->desc != IORES_DESC_RESERVED)); } static int __ioremap_res_check(struct resource *res, void *arg) @@ -94,7 +106,7 @@ static int __ioremap_res_check(struct resource *res, void *arg) flags->system_ram = __ioremap_check_ram(res); if (!flags->desc_other) - flags->desc_other = __ioremap_check_desc_other(res); + flags->desc_other = __ioremap_check_desc_none_and_reserved(res); return flags->system_ram && flags->desc_other; } diff --git a/include/linux/ioport.h b/include/linux/ioport.h index da0ebaec25f0..6ed59de48bd5 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -133,6 +133,7 @@ enum { IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, IORES_DESC_DEVICE_PUBLIC_MEMORY = 7, + IORES_DESC_RESERVED = 8, }; /* helpers to define resources */ -- 2.17.1