public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Suresh Siddha <suresh.b.siddha@intel.com>
To: mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de, arjan@linux.intel.com
Cc: linux-kernel@vger.kernel.org, Suresh Siddha <suresh.b.siddha@intel.com>
Subject: [patch 7/7] x86, cpa: global flush tlb after splitting large page and before doing cpa
Date: Thu, 11 Sep 2008 13:30:55 -0700	[thread overview]
Message-ID: <20080911204151.287251000@linux-os.sc.intel.com> (raw)
In-Reply-To: 20080911203048.929515000@linux-os.sc.intel.com

[-- Attachment #1: global_flush_tlb.patch --]
[-- Type: text/plain, Size: 2509 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."

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-11 13:25:55.000000000 -0700
+++ tip/arch/x86/mm/pageattr.c	2008-09-11 13:25:57.000000000 -0700
@@ -131,6 +131,18 @@
 	mb();
 }
 
+static void __global_flush_tlb(void *arg)
+{
+	__flush_tlb_all();
+}
+
+static void global_flush_tlb(void)
+{
+	BUG_ON(irqs_disabled());
+
+	on_each_cpu(__global_flush_tlb, NULL, 1);
+}
+
 static void __cpa_flush_all(void *arg)
 {
 	unsigned long cache = (unsigned long)arg;
@@ -506,6 +518,25 @@
 	ref_prot = pte_pgprot(pte_mkexec(pte_clrhuge(*kpte)));
 	pgprot_val(ref_prot) |= _PAGE_PRESENT;
 	__set_pmd_pte(kpte, address, mk_pte(base, ref_prot));
+
+	/*
+	 * 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."
+	 *
+	 * We do this global tlb flush inside the pgd_lock, so that we don't
+	 * allow any other cpu, with stale tlb entries change the page table
+	 * attribute in parallel, that also falls into the just split large
+	 * page entry.
+	 */
+	global_flush_tlb();
 	base = NULL;
 
 out_unlock:
@@ -596,10 +627,8 @@
 	 * We have to split the large page:
 	 */
 	err = split_large_page(kpte, address);
-	if (!err) {
-		cpa->flags |= CPA_FLUSHTLB;
+	if (!err)
 		goto repeat;
-	}
 
 	return err;
 }

-- 


  parent reply	other threads:[~2008-09-11 21:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-11 20:30 [patch 0/7] x86, cpa: cpa related changes to be inline with TLB Application note Suresh Siddha
2008-09-11 20:30 ` [patch 1/7] x86, cpa: rename PTE attribute macros for kernel direct mapping in early boot Suresh Siddha
2008-09-11 20:30 ` [patch 2/7] x86, cpa: remove USER permission from the very early identity mapping attribute Suresh Siddha
2008-09-11 20:30 ` [patch 3/7] x86, cpa: make the kernel physical mapping initialization a two pass sequence Suresh Siddha
2008-09-11 20:30 ` [patch 4/7] x86, cpa: dont use large pages for kernel identity mapping with DEBUG_PAGEALLOC Suresh Siddha
2008-09-11 20:30 ` [patch 5/7] x86, cpa: fix taking the pgd_lock with interrupts off Suresh Siddha
2008-09-11 20:30 ` [patch 6/7] x86, cpa: remove cpa pool code Suresh Siddha
2008-09-11 20:30 ` Suresh Siddha [this message]
2008-09-13 17:10   ` [patch 7/7] x86, cpa: global flush tlb after splitting large page and before doing cpa Jeremy Fitzhardinge
2008-09-14 15:29 ` [patch 0/7] x86, cpa: cpa related changes to be inline with TLB Application note Ingo Molnar
2008-09-14 16:59   ` Ingo Molnar
2008-09-16  5:44     ` Suresh Siddha
2008-09-14 15:40 ` Arjan van de Ven
2008-09-14 15:52   ` 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=20080911204151.287251000@linux-os.sc.intel.com \
    --to=suresh.b.siddha@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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