linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Shin <jacob.shin@amd.com>
To: X86-ML <x86@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Yinghai Lu <yinghai@kernel.org>,
	Tejun Heo <tj@kernel.org>, Dave Young <dyoung@redhat.com>,
	Chao Wang <chaowang@redhat.com>, Vivek Goyal <vgoyal@redhat.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	Borislav Petkov <borislav.petkov@amd.com>,
	Jacob Shin <jacob.shin@amd.com>
Subject: [PATCH 5/6] x86: Fixup code testing if a pfn is direct mapped
Date: Wed, 29 Aug 2012 14:04:05 -0500	[thread overview]
Message-ID: <1346267046-6724-6-git-send-email-jacob.shin@amd.com> (raw)
In-Reply-To: <1346267046-6724-1-git-send-email-jacob.shin@amd.com>

Update code that previously assumed pfns [ 0 - max_low_pfn_mapped ) and
[ 4GB - max_pfn_mapped ) were always direct mapped, to now look up
pfn_mapped ranges instead.

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
---
 arch/x86/kernel/cpu/amd.c   |    6 +-----
 arch/x86/platform/efi/efi.c |    8 ++++----
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9d92e19..554ccfc 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -677,11 +677,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
 		 */
 		if (!rdmsrl_safe(MSR_K8_TSEG_ADDR, &tseg)) {
 			printk(KERN_DEBUG "tseg: %010llx\n", tseg);
-			if ((tseg>>PMD_SHIFT) <
-				(max_low_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) ||
-				((tseg>>PMD_SHIFT) <
-				(max_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) &&
-				(tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT))))
+			if (pfn_is_mapped(tseg))
 				set_memory_4k((unsigned long)__va(tseg), 1);
 		}
 	}
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 92660eda..f1facde 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -776,7 +776,7 @@ void __init efi_enter_virtual_mode(void)
 	efi_memory_desc_t *md, *prev_md = NULL;
 	efi_status_t status;
 	unsigned long size;
-	u64 end, systab, addr, npages, end_pfn;
+	u64 end, systab, addr, npages, start_pfn, end_pfn;
 	void *p, *va, *new_memmap = NULL;
 	int count = 0;
 
@@ -827,10 +827,10 @@ void __init efi_enter_virtual_mode(void)
 		size = md->num_pages << EFI_PAGE_SHIFT;
 		end = md->phys_addr + size;
 
+		start_pfn = PFN_DOWN(md->phys_addr);
 		end_pfn = PFN_UP(end);
-		if (end_pfn <= max_low_pfn_mapped
-		    || (end_pfn > (1UL << (32 - PAGE_SHIFT))
-			&& end_pfn <= max_pfn_mapped))
+
+		if (pfn_range_is_mapped(start_pfn, end_pfn))
 			va = __va(md->phys_addr);
 		else
 			va = efi_ioremap(md->phys_addr, size, md->type);
-- 
1.7.9.5



  parent reply	other threads:[~2012-08-29 19:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-29 19:04 [PATCH V5 0/6] x86: Create direct mappings for E820_RAM only Jacob Shin
2012-08-29 19:04 ` [PATCH 1/6] x86, mm: Add page_size_mask() Jacob Shin
2012-08-29 19:04 ` [PATCH 2/6] x86, mm: Split out split_mem_range Jacob Shin
2012-08-29 19:04 ` [PATCH 3/6] x86/mm: find_early_table_space based on memory ranges that are being mapped Jacob Shin
2012-08-29 19:04 ` [PATCH 4/6] x86: Only direct map addresses that are marked as E820_RAM Jacob Shin
2012-08-29 21:17   ` Yinghai Lu
2012-08-29 21:32     ` Borislav Petkov
2012-08-30  6:28       ` H. Peter Anvin
2012-08-30 23:06         ` [PATCH 0/8] x86, mm: init_memory_mapping cleanup Yinghai Lu
2012-08-30 23:06           ` [PATCH 1/8] x86, mm: Add global page_size_mask Yinghai Lu
2012-08-30 23:06           ` [PATCH 2/8] x86, mm: Split out split_mem_range Yinghai Lu
2012-08-30 23:06           ` [PATCH 3/8] x86, mm: Moving init_memory_mapping calling Yinghai Lu
2012-08-30 23:06           ` [PATCH 4/8] x86, mm: Revert back good_end setting for 64bit Yinghai Lu
2012-08-30 23:06           ` [PATCH 5/8] x86, mm: Find early page table only one time Yinghai Lu
2012-08-30 23:06           ` [PATCH 6/8] x86: if kernel .text .data .bss are not marked as E820_RAM, complain and fix Yinghai Lu
2012-08-30 23:06           ` [PATCH 7/8] x86: Fixup code testing if a pfn is direct mapped Yinghai Lu
2012-08-30 23:06           ` [PATCH 8/8] x86: Only direct map addresses that are marked as E820_RAM Yinghai Lu
2012-08-30 23:14           ` [PATCH 0/8] x86, mm: init_memory_mapping cleanup Yinghai Lu
2012-08-30 23:22           ` Jacob Shin
2012-08-29 21:46     ` [PATCH 4/6] x86: Only direct map addresses that are marked as E820_RAM Jacob Shin
2012-08-29 19:04 ` Jacob Shin [this message]
2012-08-29 21:02   ` [PATCH 5/6] x86: Fixup code testing if a pfn is direct mapped Yinghai Lu
2012-08-29 19:04 ` [PATCH 6/6] x86: if kernel .text .data .bss are not marked as E820_RAM, complain and fix Jacob Shin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346267046-6724-6-git-send-email-jacob.shin@amd.com \
    --to=jacob.shin@amd.com \
    --cc=andreas.herrmann3@amd.com \
    --cc=borislav.petkov@amd.com \
    --cc=chaowang@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).