linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/mm/subpage: Init user psize correctly
@ 2016-05-02 10:51 Aneesh Kumar K.V
  2016-05-02 10:51 ` [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config Aneesh Kumar K.V
  2016-05-04 22:40 ` [1/2] powerpc/mm/subpage: Init user psize correctly Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-05-02 10:51 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

Check against a context.id value of zero instead of MMU_NO_CONTEXT
when doing a slice psize init. Without this patch we end up with
a slice psize value of zero and we always end up using 4K hpte.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/mmu_context_book3s64.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index b5288b460bef..a28ed6a96286 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -85,8 +85,16 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 		/* The old code would re-promote on fork, we don't do that
 		 * when using slices as it could cause problem promoting slices
 		 * that have been forced down to 4K
+		 *
+		 * For book3s we have MMU_NO_CONTEXT set to be ~0. Hence check
+		 * explicitly against context.id == 0. This ensures that we
+		 * properly initialize context slice details for newly allocated
+		 * mm and don't alter context slice inherited via fork.
+		 *
+		 * We should not be calling init_new_context on init_mm. Hence a
+		 * check against 0 is ok.
 		 */
-		if (slice_mm_new_context(mm))
+		if (mm->context.id == 0)
 			slice_set_user_psize(mm, mmu_virtual_psize);
 		subpage_prot_init_new_context(mm);
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config
  2016-05-02 10:51 [PATCH 1/2] powerpc/mm/subpage: Init user psize correctly Aneesh Kumar K.V
@ 2016-05-02 10:51 ` Aneesh Kumar K.V
  2016-05-04 22:40 ` [1/2] powerpc/mm/subpage: Init user psize correctly Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-05-02 10:51 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

With Linux page size of 64K and hardware only supporting 4K hpte, if
we use subpage protection, we always fail for the subpage 0 as shown
below (using the selftest subpage_prot test).

520175565: (4520111850): Failed at 0x0x3fffad4b0000 (p=13,sp=0,w=0), want=fault, got=pass !
4520890210: (4520826495): Failed at 0x0x3fffad5b0000 (p=29,sp=0,w=0), want=fault, got=pass !
4521574251: (4521510536): Failed at 0x0x3fffad6b0000 (p=45,sp=0,w=0), want=fault, got=pass !
4522258324: (4522194609): Failed at 0x0x3fffad7b0000 (p=61,sp=0,w=0), want=fault, got=pass !

This is because hash preload wrongly insert the hpte entry for subpage 0
without looking at the subapge protection information. Don't do hash
page table entry preload if we have subpage protection configured for
that range.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hash_utils_64.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 262082e51db1..b5a454415215 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1329,15 +1329,26 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
 	unsigned long vsid;
 	pgd_t *pgdir;
 	pte_t *ptep;
+	int psize;
 	unsigned long flags;
 	int rc, ssize, update_flags = 0;
 
 	BUG_ON(REGION_ID(ea) != USER_REGION_ID);
 
 #ifdef CONFIG_PPC_MM_SLICES
-	/* We only prefault standard pages for now */
-	if (unlikely(get_slice_psize(mm, ea) != mm->context.user_psize))
+	psize = get_slice_psize(mm, ea);
+	/*
+	 * We only prefault standard pages
+	 */
+	if (psize != mm->context.user_psize)
 		return;
+#ifdef CONFIG_PPC_64K_PAGES
+	/*
+	 * Don't prefault is subpage protection is enabled for that ea
+	 */
+	if ((psize == MMU_PAGE_4K) && subpage_protection(mm, ea))
+		return;
+#endif
 #endif
 
 	DBG_LOW("hash_preload(mm=%p, mm->pgdir=%p, ea=%016lx, access=%lx,"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config
@ 2016-05-02 10:56 Aneesh Kumar K.V
  0 siblings, 0 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-05-02 10:56 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

With Linux page size of 64K and hardware only supporting 4K hpte, if
we use subpage protection, we always fail for the subpage 0 as shown
below (using the selftest subpage_prot test).

520175565: (4520111850): Failed at 0x0x3fffad4b0000 (p=13,sp=0,w=0), want=fault, got=pass !
4520890210: (4520826495): Failed at 0x0x3fffad5b0000 (p=29,sp=0,w=0), want=fault, got=pass !
4521574251: (4521510536): Failed at 0x0x3fffad6b0000 (p=45,sp=0,w=0), want=fault, got=pass !
4522258324: (4522194609): Failed at 0x0x3fffad7b0000 (p=61,sp=0,w=0), want=fault, got=pass !

This is because hash preload wrongly insert the hpte entry for subpage 0
without looking at the subapge protection information. Don't do hash
page table entry preload if we have subpage protection configured for
that range.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hash_utils_64.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 262082e51db1..b5a454415215 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1329,15 +1329,26 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
 	unsigned long vsid;
 	pgd_t *pgdir;
 	pte_t *ptep;
+	int psize;
 	unsigned long flags;
 	int rc, ssize, update_flags = 0;
 
 	BUG_ON(REGION_ID(ea) != USER_REGION_ID);
 
 #ifdef CONFIG_PPC_MM_SLICES
-	/* We only prefault standard pages for now */
-	if (unlikely(get_slice_psize(mm, ea) != mm->context.user_psize))
+	psize = get_slice_psize(mm, ea);
+	/*
+	 * We only prefault standard pages
+	 */
+	if (psize != mm->context.user_psize)
 		return;
+#ifdef CONFIG_PPC_64K_PAGES
+	/*
+	 * Don't prefault is subpage protection is enabled for that ea
+	 */
+	if ((psize == MMU_PAGE_4K) && subpage_protection(mm, ea))
+		return;
+#endif
 #endif
 
 	DBG_LOW("hash_preload(mm=%p, mm->pgdir=%p, ea=%016lx, access=%lx,"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [1/2] powerpc/mm/subpage: Init user psize correctly
  2016-05-02 10:51 [PATCH 1/2] powerpc/mm/subpage: Init user psize correctly Aneesh Kumar K.V
  2016-05-02 10:51 ` [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config Aneesh Kumar K.V
@ 2016-05-04 22:40 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-05-04 22:40 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev, Aneesh Kumar K.V

On Mon, 2016-02-05 at 10:51:50 UTC, "Aneesh Kumar K.V" wrote:
> Check against a context.id value of zero instead of MMU_NO_CONTEXT
> when doing a slice psize init. Without this patch we end up with
> a slice psize value of zero and we always end up using 4K hpte.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/64cb6a33f154e91e12f64156e2

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-04 22:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-02 10:51 [PATCH 1/2] powerpc/mm/subpage: Init user psize correctly Aneesh Kumar K.V
2016-05-02 10:51 ` [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config Aneesh Kumar K.V
2016-05-04 22:40 ` [1/2] powerpc/mm/subpage: Init user psize correctly Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2016-05-02 10:56 [PATCH 2/2] powerpc/mm/subpage: Fix subpage protection with 4K hpte config Aneesh Kumar K.V

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).