On 10/17/2018 10:32 AM, Michael Ellerman wrote:
Christophe Leroy <christophe.leroy@xxxxxx> writes:
On 10/17/2018 12:59 AM, Michael Ellerman wrote:...
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 <christophe.leroy@xxxxxx>
Date: Wed, 17 Oct 2018 10:46:24 +0000
Subject: [PATCH] powerpc/book3e: redefine pte_mkprivileged() and pte_mkuser()
To: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>, Paul Mackerras <paulus@xxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx
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 <christophe.leroy@xxxxxx>
---
Â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
+