All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm: Fixup kernel read only mapping
@ 2016-11-24  9:39 Aneesh Kumar K.V
  2016-11-28 12:11 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Aneesh Kumar K.V @ 2016-11-24  9:39 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

With commit e58e87adc8bf9 ("powerpc/mm: Update _PAGE_KERNEL_RO") we started
using the ppp value 0b110 to map kernel readonly. But that facility
was only added as part of ISA 2.04. For earlier ISA version only supported ppp
bit value for readonly mapping is 0b011. (This implies both user and kernel
get mapped using the same ppp bit value for readonly mapping.).

Update the code such that for earlier architecture version we use ppp value
0b011 for readonly mapping. We don't differentiate between power5+ and power5
here and apply the new ppp bits only from power6 (ISA 2.05). This keep the
changes minimal.

This fixes issue with PS3 spu usage reported at
https://lkml.kernel.org/r/rep.1421449714.geoff@infradead.org

Fixes: e58e87adc8bf9 ("powerpc/mm: Update _PAGE_KERNEL_RO")
Tested-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/mmu.h  | 13 +++++++++----
 arch/powerpc/mm/hash_utils_64.c |  8 ++++++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e88368354e49..c13242bf3098 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -27,6 +27,11 @@
 /*
  * Individual features below.
  */
+/*
+ * kernel read only support
+ * We added the ppp value 0b110 in ISA 2.04
+ */
+#define MMU_FTR_KERNEL_RO		ASM_CONST(0x00004000)
 
 /*
  * We need to clear top 16bits of va (from the remaining 64 bits )in
@@ -103,10 +108,10 @@
 #define MMU_FTRS_POWER4		MMU_FTRS_DEFAULT_HPTE_ARCH_V2
 #define MMU_FTRS_PPC970		MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA
 #define MMU_FTRS_POWER5		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
-#define MMU_FTRS_POWER6		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
-#define MMU_FTRS_POWER7		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
-#define MMU_FTRS_POWER8		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
-#define MMU_FTRS_POWER9		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
+#define MMU_FTRS_POWER6		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
+#define MMU_FTRS_POWER7		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
+#define MMU_FTRS_POWER8		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
+#define MMU_FTRS_POWER9		MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
 #define MMU_FTRS_CELL		MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
 				MMU_FTR_CI_LARGE_PAGE
 #define MMU_FTRS_PA6T		MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 5503078090cd..78dabf065ba9 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -193,8 +193,12 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
 		/*
 		 * Kernel read only mapped with ppp bits 0b110
 		 */
-		if (!(pteflags & _PAGE_WRITE))
-			rflags |= (HPTE_R_PP0 | 0x2);
+		if (!(pteflags & _PAGE_WRITE)) {
+			if (mmu_has_feature(MMU_FTR_KERNEL_RO))
+				rflags |= (HPTE_R_PP0 | 0x2);
+			else
+				rflags |= 0x3;
+		}
 	} else {
 		if (pteflags & _PAGE_RWX)
 			rflags |= 0x2;
-- 
2.10.2

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

* Re: powerpc/mm: Fixup kernel read only mapping
  2016-11-24  9:39 [PATCH] powerpc/mm: Fixup kernel read only mapping Aneesh Kumar K.V
@ 2016-11-28 12:11 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-11-28 12:11 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev, Aneesh Kumar K.V

On Thu, 2016-11-24 at 09:39:54 UTC, "Aneesh Kumar K.V" wrote:
> With commit e58e87adc8bf9 ("powerpc/mm: Update _PAGE_KERNEL_RO") we started
> using the ppp value 0b110 to map kernel readonly. But that facility
> was only added as part of ISA 2.04. For earlier ISA version only supported ppp
> bit value for readonly mapping is 0b011. (This implies both user and kernel
> get mapped using the same ppp bit value for readonly mapping.).
> 
> Update the code such that for earlier architecture version we use ppp value
> 0b011 for readonly mapping. We don't differentiate between power5+ and power5
> here and apply the new ppp bits only from power6 (ISA 2.05). This keep the
> changes minimal.
> 
> This fixes issue with PS3 spu usage reported at
> https://lkml.kernel.org/r/rep.1421449714.geoff@infradead.org
> 
> Fixes: e58e87adc8bf9 ("powerpc/mm: Update _PAGE_KERNEL_RO")
> Tested-by: Geoff Levand <geoff@infradead.org>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/984d7a1ec67ce3a46324fa4bcb4c74

cheers

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

end of thread, other threads:[~2016-11-28 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24  9:39 [PATCH] powerpc/mm: Fixup kernel read only mapping Aneesh Kumar K.V
2016-11-28 12:11 ` Michael Ellerman

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.