Thread (42 messages) 42 messages, 6 authors, 2018-10-17

Re: Crash on FSL Book3E due to pte_pgprot()? (was Re: [PATCH v3 12/24] powerpc/mm: use pte helpers in generic code)

From: Aneesh Kumar K.V <hidden>
Date: 2018-10-17 11:53:58
Also in: dri-devel, linux-arm-kernel, linux-block, linux-fbdev, lkml

On 10/17/18 4:42 PM, Christophe Leroy wrote:
quoted hunk ↗ jump to hunk

On 10/17/2018 10:32 AM, Michael Ellerman wrote:
quoted
Christophe Leroy [off-list ref] writes:
quoted
On 10/17/2018 12:59 AM, Michael Ellerman wrote:
...
quoted
quoted
The question is what's the right way to fix it? Should pte_pgprot() not
be filtering those bits out on book3e?
I think we should not use pte_pggrot() for that then. What about the
below fix ?
Thanks, that almost works.

pte_mkprivileged() also needs to not strip _PAGE_BAP_SR.
Oops, I missed it allthough I knew it. Patch below.

From: Christophe Leroy <redacted>
Date: Wed, 17 Oct 2018 10:46:24 +0000
Subject: [PATCH] powerpc/book3e: redefine pte_mkprivileged() and pte_mkuser()
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>, Paul Mackerras <redacted>, Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org

Book3e defines both _PAGE_USER and _PAGE_PRIVILEGED, so the nohash
default pte_mkprivileged() and pte_mkuser() are not usable.

This patch redefines them for book3e.

Fixes: a0da4bc166f2 ("powerpc/mm: Allow platforms to redefine some helpers")
Signed-off-by: Christophe Leroy <redacted>
---
  arch/powerpc/include/asm/nohash/pte-book3e.h | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/include/asm/nohash/pte-book3e.h b/arch/powerpc/include/asm/nohash/pte-book3e.h
index 58eef8cb569d..fb4297dff3e2 100644
--- a/arch/powerpc/include/asm/nohash/pte-book3e.h
+++ b/arch/powerpc/include/asm/nohash/pte-book3e.h
@@ -109,5 +109,19 @@
  #define PAGE_READONLY    __pgprot(_PAGE_BASE | _PAGE_USER)
  #define PAGE_READONLY_X    __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)

+static inline pte_t pte_mkprivileged(pte_t pte)
+{
+    return __pte((pte_val(pte) & ~_PAGE_USER) | _PAGE_PRIVILEGED);
+}
+
+#define pte_mkprivileged pte_mkprivileged
+
+static inline pte_t pte_mkuser(pte_t pte)
+{
+    return __pte((pte_val(pte) & ~_PAGE_PRIVILEGED) | _PAGE_USER);
+}
+
+#define pte_mkuser pte_mkuser
+
I was build testing a similar patch. We would need to put #ifndef __ASSEMBLY__ around it.



-aneesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help