From: Christoffer Dall <c.dall@virtualopensystems.com>
To: Steve Capper <steve.capper@arm.com>
Cc: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
aarcange@redhat.com, bill4carson@gmail.com, tawfik@marvell.com,
catalin.marinas@arm.com, will.deacon@arm.com,
cmetcalf@tilera.com, mhocko@suse.cz, maen@marvell.com,
hoffman@marvell.com, notasas@gmail.com, kirill@shutemov.name,
akpm@linux-foundation.org, shadi@marvell.com
Subject: Re: [RFC PATCH 1/6] ARM: mm: correct pte_same behaviour for LPAE.
Date: Fri, 4 Jan 2013 00:03:26 -0500 [thread overview]
Message-ID: <CANM98qJEigKksbv5QdGLWzCdaSj9NipJ-RYrouzWPRn6XVCw0Q@mail.gmail.com> (raw)
In-Reply-To: <1350576942-25299-2-git-send-email-steve.capper@arm.com>
On Thu, Oct 18, 2012 at 12:15 PM, Steve Capper <steve.capper@arm.com> wrote:
> For 3 levels of paging the PTE_EXT_NG bit will be set for user address ptes
> that are written to a page table but not for ptes created with mk_pte.
>
> This can cause some comparison tests made by pte_same to fail spuriously and
> lead to other problems.
>
> To correct this behaviour, we mask off PTE_EXT_NG for any pte that is
> present before running the comparison.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Steve Capper <steve.capper@arm.com>
> ---
> arch/arm/include/asm/pgtable-2level.h | 5 +++++
> arch/arm/include/asm/pgtable-3level.h | 5 +++++
> arch/arm/include/asm/pgtable.h | 23 +++++++++++++++++++++++
> 3 files changed, 33 insertions(+)
>
> diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
> index 2317a71..662a00e 100644
> --- a/arch/arm/include/asm/pgtable-2level.h
> +++ b/arch/arm/include/asm/pgtable-2level.h
> @@ -125,6 +125,11 @@
> #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
>
> /*
> + * for 2 levels of paging we don't mask off any bits when comparing present ptes
> + */
> +#define L_PTE_CMP_MASKOFF 0
> +
> +/*
> * These are the memory types, defined to be compatible with
> * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
> */
> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> index b249035..0eaeb55 100644
> --- a/arch/arm/include/asm/pgtable-3level.h
> +++ b/arch/arm/include/asm/pgtable-3level.h
> @@ -84,6 +84,11 @@
> #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
>
> /*
> + * we need to mask off PTE_EXT_NG when comparing present ptes.
> + */
> +#define L_PTE_CMP_MASKOFF PTE_EXT_NG
> +
> +/*
> * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers).
> */
> #define L_PTE_MT_UNCACHED (_AT(pteval_t, 0) << 2) /* strongly ordered */
> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> index 08c1231..c35bf46 100644
> --- a/arch/arm/include/asm/pgtable.h
> +++ b/arch/arm/include/asm/pgtable.h
> @@ -248,6 +248,29 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
> }
>
> /*
> + * For 3 levels of paging the PTE_EXT_NG bit will be set for user address ptes
> + * that are written to a page table but not for ptes created with mk_pte.
> + *
Why is this not the case for 2 levels of paging as well?
Is that because it's always checked against the Linux version, or?
> + * This can cause some comparison tests made by pte_same to fail spuriously and
> + * lead to other problems.
> + *
> + * To correct this behaviour, we mask off PTE_EXT_NG for any pte that is
> + * present before running the comparison.
nit: This comment doesn't really explain the rationale, I'm assuming
that pte_same is used to compare only which page gets mapped, assuming
the attributes etc. remain the same? or also the attributes should be
the same, only mk_pte sets all of these except the NG bit.
> + */
> +#define __HAVE_ARCH_PTE_SAME
> +static inline int pte_same(pte_t pte_a, pte_t pte_b)
> +{
> + pteval_t vala = pte_val(pte_a), valb = pte_val(pte_b);
> + if (pte_present(pte_a))
> + vala &= ~L_PTE_CMP_MASKOFF;
> +
> + if (pte_present(pte_b))
> + valb &= ~L_PTE_CMP_MASKOFF;
> +
> + return vala == valb;
> +}
> +
> +/*
> * Encode and decode a swap entry. Swap entries are stored in the Linux
> * page tables as follows:
> *
> --
> 1.7.9.5
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2013-01-04 5:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 16:15 [RFC PATCH 0/6] ARM: mm: HugeTLB + THP support Steve Capper
2012-10-18 16:15 ` [RFC PATCH 1/6] ARM: mm: correct pte_same behaviour for LPAE Steve Capper
2013-01-04 5:03 ` Christoffer Dall [this message]
2013-01-08 17:56 ` Steve Capper
2012-10-18 16:15 ` [RFC PATCH 2/6] ARM: mm: Add support for flushing HugeTLB pages Steve Capper
2013-01-04 5:03 ` Christoffer Dall
2013-01-08 17:56 ` Steve Capper
2012-10-18 16:15 ` [RFC PATCH 3/6] ARM: mm: HugeTLB support for LPAE systems Steve Capper
2013-01-04 5:03 ` Christoffer Dall
2013-01-08 17:57 ` Steve Capper
2013-01-08 18:10 ` Christoffer Dall
2012-10-18 16:15 ` [RFC PATCH 4/6] ARM: mm: HugeTLB support for non-LPAE systems Steve Capper
2013-01-04 5:04 ` Christoffer Dall
2013-01-04 5:04 ` Christoffer Dall
2013-01-08 17:58 ` Steve Capper
2013-01-08 18:13 ` Christoffer Dall
2013-01-08 18:13 ` Christoffer Dall
2012-10-18 16:15 ` [RFC PATCH 5/6] ARM: mm: Transparent huge page support for LPAE systems Steve Capper
2013-01-04 5:04 ` Christoffer Dall
2013-01-08 17:59 ` Steve Capper
2013-01-08 18:15 ` Christoffer Dall
2012-10-18 16:15 ` [RFC PATCH 6/6] ARM: mm: Transparent huge page support for non-LPAE systems Steve Capper
2013-01-04 5:04 ` Christoffer Dall
2013-01-08 17:59 ` Steve Capper
2013-01-08 18:17 ` Christoffer Dall
2012-12-21 13:41 ` [RFC PATCH 0/6] ARM: mm: HugeTLB + THP support Gregory CLEMENT
2012-12-23 11:11 ` Will Deacon
2012-12-23 11:11 ` Will Deacon
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=CANM98qJEigKksbv5QdGLWzCdaSj9NipJ-RYrouzWPRn6XVCw0Q@mail.gmail.com \
--to=c.dall@virtualopensystems.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bill4carson@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=cmetcalf@tilera.com \
--cc=hoffman@marvell.com \
--cc=kirill@shutemov.name \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maen@marvell.com \
--cc=mhocko@suse.cz \
--cc=notasas@gmail.com \
--cc=shadi@marvell.com \
--cc=steve.capper@arm.com \
--cc=tawfik@marvell.com \
--cc=will.deacon@arm.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 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).