From: Zachary Amsden <zach@vmware.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: Hugh Dickins <hugh@veritas.com>,
Jan Beulich <jbeulich@novell.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i386: PAE entries must have their low word cleared first
Date: Wed, 26 Apr 2006 08:44:26 -0700 [thread overview]
Message-ID: <444F955A.6050206@vmware.com> (raw)
In-Reply-To: <946b367619cfd3dcd3ba547e216e494b@cl.cam.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
Keir Fraser wrote:
>
> We cannot use pte_clear() unless we redefine it for PAE. Currently it
> reduces to set_pte() which explicitly uses the wrong ordering (sets
> high *then* low, because it's normally used to introduce a mapping).
Yes, that means pte_clear() has the same bug. Why don't we redefine
pte_clear for PAE? Then the ifdef can go away.
> Also, I think wmb() should be used in PAE's set_pte(), rather than the
> current smp_wmb(). They reduce to the same thing, but wmb() makes it
> clear this is is not an issue specific to SMP systems.
I agree with that. The problem is not related to SMP at all. I would
propose this approach.
[-- Attachment #2: fix-pte-clear --]
[-- Type: text/plain, Size: 2468 bytes --]
Proposed fix for ptep_get_and_clear_full PAE bug. Pte_clear had the same
bug, so use the same fix for both.
Signed-off-by: Zachary Amsden <zach@vmware.com>
Index: linux-2.6.17-rc/include/asm-i386/pgtable.h
===================================================================
--- linux-2.6.17-rc.orig/include/asm-i386/pgtable.h 2006-04-25 15:41:06.000000000 -0700
+++ linux-2.6.17-rc/include/asm-i386/pgtable.h 2006-04-26 08:39:42.000000000 -0700
@@ -204,7 +204,6 @@ extern unsigned long long __PAGE_KERNEL,
extern unsigned long pg0[];
#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
#define pmd_none(x) (!(unsigned long)pmd_val(x))
@@ -268,7 +267,7 @@ static inline pte_t ptep_get_and_clear_f
pte_t pte;
if (full) {
pte = *ptep;
- *ptep = __pte(0);
+ pte_clear(mm, addr, ptep);
} else {
pte = ptep_get_and_clear(mm, addr, ptep);
}
Index: linux-2.6.17-rc/include/asm-i386/pgtable-3level.h
===================================================================
--- linux-2.6.17-rc.orig/include/asm-i386/pgtable-3level.h 2006-04-25 15:41:06.000000000 -0700
+++ linux-2.6.17-rc/include/asm-i386/pgtable-3level.h 2006-04-26 08:38:57.000000000 -0700
@@ -85,6 +85,13 @@ static inline void pud_clear (pud_t * pu
#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
pmd_index(address))
+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+ ptep->pte_low = 0;
+ wmb();
+ ptep->pte_high = 0;
+}
+
static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
{
pte_t res;
Index: linux-2.6.17-rc/include/asm-i386/pgtable-2level.h
===================================================================
--- linux-2.6.17-rc.orig/include/asm-i386/pgtable-2level.h 2006-04-25 15:41:06.000000000 -0700
+++ linux-2.6.17-rc/include/asm-i386/pgtable-2level.h 2006-04-26 08:37:34.000000000 -0700
@@ -18,6 +18,8 @@
#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
+#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
+
#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte_low, 0))
#define pte_same(a, b) ((a).pte_low == (b).pte_low)
#define pte_page(x) pfn_to_page(pte_pfn(x))
next prev parent reply other threads:[~2006-04-26 15:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-26 13:46 [PATCH] i386: PAE entries must have their low word cleared first Jan Beulich
2006-04-26 14:46 ` Hugh Dickins
2006-04-26 15:06 ` Keir Fraser
2006-04-26 15:44 ` Zachary Amsden [this message]
2006-04-26 15:57 ` Hugh Dickins
2006-04-26 16:12 ` Keir Fraser
2006-04-26 15:45 ` Hugh Dickins
2006-04-26 16:06 ` Nick Piggin
2006-04-26 15:58 ` Nick Piggin
2006-04-27 10:27 ` Sonny Rao
2006-04-27 13:39 ` Nick Piggin
-- strict thread matches above, loose matches on Subject: below --
2006-04-26 22:11 Brunner, Richard
2006-04-26 22:22 ` Zachary Amsden
2006-04-26 22:27 ` Zachary Amsden
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=444F955A.6050206@vmware.com \
--to=zach@vmware.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=hugh@veritas.com \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.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).