LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: ebiederm@xmission.com, vgoyal@redhat.com, mingo@elte.hu,
tglx@linutronix.de, linux-kernel@vger.kernel.org
Subject: [PATCH] [1/8] Handle kernel near memory hole in clear_kernel_mapping
Date: Sat, 19 Jan 2008 07:48:29 +0100 (CET) [thread overview]
Message-ID: <20080119064829.4C2AB14F35@wotan.suse.de> (raw)
In-Reply-To: <20080119748.170864000@suse.de>
This was a long standing obscure problem in the relocatable kernel. The
AMD GART driver needs to unmap part of the GART in the kernel direct mapping to
prevent cache corruption. With the relocatable kernel it is in theory possible
that the separate kernel text mapping straddles that area too.
Normally it should not happen because GART tends to be >= 2GB, and the kernel
is normally not loaded that high, but it is possible in theory.
Teach clear_kernel_mapping() about this case.
This will become more important once the kernel mapping uses 1GB pages.
Cc: ebiederm@xmission.com
Cc: vgoyal@redhat.com
Signed-off-by: Andi Kleen <ak@suse.de>
---
arch/x86/mm/init_64.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
Index: linux/arch/x86/mm/init_64.c
===================================================================
--- linux.orig/arch/x86/mm/init_64.c
+++ linux/arch/x86/mm/init_64.c
@@ -415,7 +415,8 @@ void __init paging_init(void)
from the CPU leading to inconsistent cache lines. address and size
must be aligned to 2MB boundaries.
Does nothing when the mapping doesn't exist. */
-void __init clear_kernel_mapping(unsigned long address, unsigned long size)
+static void __init
+__clear_kernel_mapping(unsigned long address, unsigned long size)
{
unsigned long end = address + size;
@@ -445,6 +446,28 @@ void __init clear_kernel_mapping(unsigne
__flush_tlb_all();
}
+#define overlaps(as, ae, bs, be) ((ae) >= (bs) && (as) <= (be))
+
+void __init clear_kernel_mapping(unsigned long address, unsigned long size)
+{
+ int sh = PMD_SHIFT;
+ unsigned long kernel = __pa(__START_KERNEL_map);
+
+ /*
+ * Note that we cannot unmap the kernel itself because the unmapped
+ * holes here are always at least 2MB aligned.
+ * This just applies to the trailing areas of the 40MB kernel mapping.
+ */
+ if (overlaps(kernel >> sh, (kernel + KERNEL_TEXT_SIZE) >> sh,
+ __pa(address) >> sh, __pa(address + size) >> sh)) {
+ printk(KERN_WARNING
+ "Kernel mapping at %lx within 2MB of memory hole\n",
+ kernel);
+ __clear_kernel_mapping(__START_KERNEL_map+__pa(address), size);
+ }
+ __clear_kernel_mapping(address, size);
+}
+
/*
* Memory hotplug specific functions
*/
next prev parent reply other threads:[~2008-01-19 6:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-19 6:48 [PATCH] [0/8] GBpages support for x86-64, v2 Andi Kleen
2008-01-19 6:48 ` Andi Kleen [this message]
2008-01-19 6:48 ` [PATCH] [2/8] GBPAGES: Add feature macros for the gbpages cpuid bit Andi Kleen
2008-01-23 21:26 ` Jan Engelhardt
2008-01-24 6:57 ` Andi Kleen
2008-01-19 6:48 ` [PATCH] [3/8] GBPAGES: Split LARGE_PAGE_SIZE/MASK into PUD_PAGE_SIZE/PMD_PAGE_SIZE Andi Kleen
2008-01-19 6:48 ` [PATCH] [4/8] Add pgtable accessor functions for GB pages Andi Kleen
2008-01-19 6:48 ` [PATCH] [5/8] GBPAGES: Support gbpages in pagetable dump Andi Kleen
2008-01-19 6:48 ` [PATCH] [6/8] Add an option to disable direct mapping gbpages and a global variable Andi Kleen
2008-01-19 6:48 ` [PATCH] [7/8] CPA: Implement GBpages support in change_page_attr() Andi Kleen
2008-01-19 18:53 ` Ingo Molnar
2008-01-19 19:27 ` Andi Kleen
2008-01-19 6:48 ` [PATCH] [8/8] GBPAGES: Do kernel direct mapping at boot using GB pages Andi Kleen
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=20080119064829.4C2AB14F35@wotan.suse.de \
--to=ak@suse.de \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
--subject='Re: [PATCH] [1/8] Handle kernel near memory hole in clear_kernel_mapping' \
/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
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).