From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
npiggin@gmail.com, msuchanek@suse.de
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [RFC PATCH v2 02/13] powerpc/32s: Create C version of kuap_restore() and kuap_check()
Date: Sun, 5 Apr 2020 17:44:37 +0000 (UTC) [thread overview]
Message-ID: <6e7e16e234125dfa11a8004e1e1d0fe47fd1adf5.1586108649.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <029e1064b1ad738785718221ea468c9cfc282457.1586108649.git.christophe.leroy@c-s.fr>
In preparation of porting PPC32 to C syscall entry/exit,
create C version of kuap_restore() and kuap_check() on book3s/32.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/book3s/32/kup.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h
index 3c0ba22dc360..c85bc5b56366 100644
--- a/arch/powerpc/include/asm/book3s/32/kup.h
+++ b/arch/powerpc/include/asm/book3s/32/kup.h
@@ -102,6 +102,27 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end)
isync(); /* Context sync required after mtsrin() */
}
+static inline void kuap_restore(struct pt_regs *regs)
+{
+ u32 kuap = current->thread.kuap;
+ u32 addr = kuap & 0xf0000000;
+ u32 end = kuap << 28;
+
+ if (unlikely(!kuap))
+ return;
+
+ current->thread.kuap = 0;
+ kuap_update_sr(mfsrin(addr) & ~SR_KS, addr, end); /* Clear Ks */
+}
+
+static inline void kuap_check(void)
+{
+ if (!IS_ENABLED(CONFIG_PPC_KUAP_DEBUG))
+ return;
+
+ WARN_ON_ONCE(current->thread.kuap != 0);
+}
+
static __always_inline void allow_user_access(void __user *to, const void __user *from,
u32 size, unsigned long dir)
{
--
2.25.0
next prev parent reply other threads:[~2020-04-05 17:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-05 17:44 [RFC PATCH v2 01/13] powerpc/radix: Make kuap_check_amr() and kuap_restore_amr() generic Christophe Leroy
2020-04-05 17:44 ` Christophe Leroy [this message]
2020-04-05 17:44 ` [RFC PATCH v2 03/13] powerpc/8xx: Create C version of kuap_restore() and kuap_check() Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 04/13] powerpc/irq: Add new helpers to play with MSR_EE and MSR_RI on PPC32 Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 05/13] powerpc/syscall: Rename syscall_64.c into syscall.c Christophe Leroy
2020-04-06 1:42 ` Nicholas Piggin
2020-04-06 18:20 ` Christophe Leroy
2020-04-07 0:22 ` Nicholas Piggin
2020-04-05 17:44 ` [RFC PATCH v2 06/13] powerpc/syscall: Make syscall_64.c buildable on PPC32 Christophe Leroy
2020-04-06 1:52 ` Nicholas Piggin
2020-04-06 18:21 ` Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 07/13] powerpc/syscall: Use is_compat_task() Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 08/13] powerpc/syscall: Save r3 in regs->orig_r3 Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 09/13] powerpc/syscall: Selectively check MSR_RI and MSR_PR on syscall entry Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 10/13] powerpc/syscall: system call implement entry/exit logic in C for PPC32 Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 11/13] powerpc/syscall: Avoid stack frame in likely part of syscall_call_exception() Christophe Leroy
2020-04-06 1:29 ` Nicholas Piggin
2020-04-06 18:19 ` Christophe Leroy
2020-04-05 17:44 ` [RFC PATCH v2 12/13] powerpc/kernel: Do not inconditionally save non volatile registers on system call Christophe Leroy
2020-04-06 1:25 ` Nicholas Piggin
2020-04-06 18:18 ` Christophe Leroy
2020-04-07 0:26 ` Nicholas Piggin
2020-04-05 17:44 ` [RFC PATCH v2 13/13] powerpc/kernel: Do not use READ_ONCE() to access current thread_info flags Christophe Leroy
2020-04-06 1:39 ` Nicholas Piggin
2020-04-06 1:40 ` [RFC PATCH v2 01/13] powerpc/radix: Make kuap_check_amr() and kuap_restore_amr() generic Nicholas Piggin
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=6e7e16e234125dfa11a8004e1e1d0fe47fd1adf5.1586108649.git.christophe.leroy@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
/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).