kup.h (475c8749d9542392d7e0855097d29ed14877ad0a) kup.h (3dc12dfe74300febc568c3b530c0f9bee01f2821)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_BOOK3S_64_KUP_H
3#define _ASM_POWERPC_BOOK3S_64_KUP_H
4
5#include <linux/const.h>
6#include <asm/reg.h>
7
8#define AMR_KUAP_BLOCK_READ UL(0x5455555555555555)

--- 357 unchanged lines hidden (view full) ---

366 * We do have exception table entry, but accessing the
367 * userspace results in fault. This could be because we
368 * didn't unlock the AMR or access is denied by userspace
369 * using a key value that blocks access. We are only interested
370 * in catching the use case of accessing without unlocking
371 * the AMR. Hence check for BLOCK_WRITE/READ against AMR.
372 */
373 if (is_write) {
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_BOOK3S_64_KUP_H
3#define _ASM_POWERPC_BOOK3S_64_KUP_H
4
5#include <linux/const.h>
6#include <asm/reg.h>
7
8#define AMR_KUAP_BLOCK_READ UL(0x5455555555555555)

--- 357 unchanged lines hidden (view full) ---

366 * We do have exception table entry, but accessing the
367 * userspace results in fault. This could be because we
368 * didn't unlock the AMR or access is denied by userspace
369 * using a key value that blocks access. We are only interested
370 * in catching the use case of accessing without unlocking
371 * the AMR. Hence check for BLOCK_WRITE/READ against AMR.
372 */
373 if (is_write) {
374 return WARN(((regs->amr & AMR_KUAP_BLOCK_WRITE) == AMR_KUAP_BLOCK_WRITE),
375 "Bug: Write fault blocked by AMR!");
374 return (regs->amr & AMR_KUAP_BLOCK_WRITE) == AMR_KUAP_BLOCK_WRITE;
376 }
375 }
377 return WARN(((regs->amr & AMR_KUAP_BLOCK_READ) == AMR_KUAP_BLOCK_READ),
378 "Bug: Read fault blocked by AMR!");
376 return (regs->amr & AMR_KUAP_BLOCK_READ) == AMR_KUAP_BLOCK_READ;
379}
380
381static __always_inline void allow_user_access(void __user *to, const void __user *from,
382 unsigned long size, unsigned long dir)
383{
384 unsigned long thread_amr = 0;
385
386 // This is written so we can resolve to a single case at build time

--- 58 unchanged lines hidden ---
377}
378
379static __always_inline void allow_user_access(void __user *to, const void __user *from,
380 unsigned long size, unsigned long dir)
381{
382 unsigned long thread_amr = 0;
383
384 // This is written so we can resolve to a single case at build time

--- 58 unchanged lines hidden ---