From: Suresh Siddha <suresh.b.siddha@intel.com>
To: mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de,
arjan@linux.intel.com, venkatesh.pallipadi@intel.com,
jeremy@goop.org
Cc: linux-kernel@vger.kernel.org, Suresh Siddha <suresh.b.siddha@intel.com>
Subject: [patch 7/7] x86, cpa: srlz cpa(), global flush tlb after splitting big page and before doing cpa
Date: Tue, 23 Sep 2008 14:00:42 -0700 [thread overview]
Message-ID: <20080923211444.950008000@linux-os.sc.intel.com> (raw)
In-Reply-To: 20080923210035.413932000@linux-os.sc.intel.com
[-- Attachment #1: introduce_cpa_lock.patch --]
[-- Type: text/plain, Size: 3246 bytes --]
Do a global flush tlb after splitting the large page and before we do the
actual change page attribute in the PTE.
With out this, we violate the TLB application note, which says
"The TLBs may contain both ordinary and large-page translations for
a 4-KByte range of linear addresses. This may occur if software
modifies the paging structures so that the page size used for the
address range changes. If the two translations differ with respect
to page frame or attributes (e.g., permissions), processor behavior
is undefined and may be implementation-specific."
And also serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity
mappings) using cpa_lock. So that we don't allow any other cpu, with stale
large tlb entries change the page attribute in parallel to some other cpu
splitting a large page entry along with changing the attribute.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
Index: tip/arch/x86/mm/pageattr.c
===================================================================
--- tip.orig/arch/x86/mm/pageattr.c 2008-09-23 13:47:51.000000000 -0700
+++ tip/arch/x86/mm/pageattr.c 2008-09-23 13:47:54.000000000 -0700
@@ -35,6 +35,14 @@
int curpage;
};
+/*
+ * Serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity mappings)
+ * using cpa_lock. So that we don't allow any other cpu, with stale large tlb
+ * entries change the page attribute in parallel to some other cpu
+ * splitting a large page entry along with changing the attribute.
+ */
+static DEFINE_SPINLOCK(cpa_lock);
+
#define CPA_FLUSHTLB 1
#define CPA_ARRAY 2
@@ -453,7 +461,13 @@
unsigned int i, level;
pte_t *pbase, *tmp;
pgprot_t ref_prot;
- struct page *base = alloc_pages(GFP_KERNEL, 0);
+ struct page *base;
+
+ if (!debug_pagealloc)
+ spin_unlock(&cpa_lock);
+ base = alloc_pages(GFP_KERNEL, 0);
+ if (!debug_pagealloc)
+ spin_lock(&cpa_lock);
if (!base)
return -ENOMEM;
@@ -594,7 +608,25 @@
*/
err = split_large_page(kpte, address);
if (!err) {
- cpa->flags |= CPA_FLUSHTLB;
+ /*
+ * Do a global flush tlb after splitting the large page
+ * and before we do the actual change page attribute in the PTE.
+ *
+ * With out this, we violate the TLB application note, that says
+ * "The TLBs may contain both ordinary and large-page
+ * translations for a 4-KByte range of linear addresses. This
+ * may occur if software modifies the paging structures so that
+ * the page size used for the address range changes. If the two
+ * translations differ with respect to page frame or attributes
+ * (e.g., permissions), processor behavior is undefined and may
+ * be implementation-specific."
+ *
+ * We do this global tlb flush inside the cpa_lock, so that we
+ * don't allow any other cpu, with stale tlb entries change the
+ * page attribute in parallel, that also falls into the
+ * just split large page entry.
+ */
+ flush_tlb_all();
goto repeat;
}
@@ -686,7 +718,11 @@
if (cpa->flags & CPA_ARRAY)
cpa->numpages = 1;
+ if (!debug_pagealloc)
+ spin_lock(&cpa_lock);
ret = __change_page_attr(cpa, checkalias);
+ if (!debug_pagealloc)
+ spin_unlock(&cpa_lock);
if (ret)
return ret;
--
next prev parent reply other threads:[~2008-09-23 21:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 21:00 [patch 0/7] x86, cpa: cpa related changes to be inline with TLB Application note - v2 Suresh Siddha
2008-09-23 21:00 ` [patch 1/7] x86, cpa: rename PTE attribute macros for kernel direct mapping in early boot Suresh Siddha
2008-09-23 21:00 ` [patch 2/7] x86, cpa: remove USER permission from the very early identity mapping attribute Suresh Siddha
2008-09-23 21:00 ` [patch 3/7] x86, cpa: make the kernel physical mapping initialization a two pass sequence Suresh Siddha
2008-10-06 20:48 ` Jeremy Fitzhardinge
2008-10-06 23:09 ` Jeremy Fitzhardinge
2008-10-07 1:58 ` Suresh Siddha
2008-10-07 15:28 ` Jeremy Fitzhardinge
2008-10-07 20:58 ` Suresh Siddha
2008-10-07 21:33 ` Jeremy Fitzhardinge
2008-10-08 19:46 ` Jeremy Fitzhardinge
2008-10-08 21:08 ` Ingo Molnar
2008-09-23 21:00 ` [patch 4/7] x86, cpa: dont use large pages for kernel identity mapping with DEBUG_PAGEALLOC Suresh Siddha
2008-09-23 21:00 ` [patch 5/7] x86, cpa: no need to check alias for __set_pages_p/__set_pages_np Suresh Siddha
2008-09-23 21:00 ` [patch 6/7] x86, cpa: remove cpa pool code Suresh Siddha
2008-09-23 21:00 ` Suresh Siddha [this message]
2008-09-24 8:15 ` [patch 0/7] x86, cpa: cpa related changes to be inline with TLB Application note - v2 Ingo Molnar
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=20080923211444.950008000@linux-os.sc.intel.com \
--to=suresh.b.siddha@intel.com \
--cc=arjan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=venkatesh.pallipadi@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.