root/arch/powerpc/include/asm/kup.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. setup_kuep
  2. setup_kuap
  3. allow_user_access
  4. prevent_user_access
  5. bad_kuap_fault
  6. allow_read_from_user
  7. allow_write_to_user
  8. allow_read_write_user
  9. prevent_read_from_user
  10. prevent_write_to_user
  11. prevent_read_write_user

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 #ifndef _ASM_POWERPC_KUP_H_
   3 #define _ASM_POWERPC_KUP_H_
   4 
   5 #define KUAP_READ       1
   6 #define KUAP_WRITE      2
   7 #define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE)
   8 
   9 #ifdef CONFIG_PPC64
  10 #include <asm/book3s/64/kup-radix.h>
  11 #endif
  12 #ifdef CONFIG_PPC_8xx
  13 #include <asm/nohash/32/kup-8xx.h>
  14 #endif
  15 #ifdef CONFIG_PPC_BOOK3S_32
  16 #include <asm/book3s/32/kup.h>
  17 #endif
  18 
  19 #ifdef __ASSEMBLY__
  20 #ifndef CONFIG_PPC_KUAP
  21 .macro kuap_save_and_lock       sp, thread, gpr1, gpr2, gpr3
  22 .endm
  23 
  24 .macro kuap_restore     sp, current, gpr1, gpr2, gpr3
  25 .endm
  26 
  27 .macro kuap_check       current, gpr
  28 .endm
  29 
  30 #endif
  31 
  32 #else /* !__ASSEMBLY__ */
  33 
  34 #include <asm/pgtable.h>
  35 
  36 void setup_kup(void);
  37 
  38 #ifdef CONFIG_PPC_KUEP
  39 void setup_kuep(bool disabled);
  40 #else
  41 static inline void setup_kuep(bool disabled) { }
  42 #endif /* CONFIG_PPC_KUEP */
  43 
  44 #ifdef CONFIG_PPC_KUAP
  45 void setup_kuap(bool disabled);
  46 #else
  47 static inline void setup_kuap(bool disabled) { }
  48 static inline void allow_user_access(void __user *to, const void __user *from,
  49                                      unsigned long size, unsigned long dir) { }
  50 static inline void prevent_user_access(void __user *to, const void __user *from,
  51                                        unsigned long size, unsigned long dir) { }
  52 static inline bool
  53 bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
  54 {
  55         return false;
  56 }
  57 #endif /* CONFIG_PPC_KUAP */
  58 
  59 static inline void allow_read_from_user(const void __user *from, unsigned long size)
  60 {
  61         allow_user_access(NULL, from, size, KUAP_READ);
  62 }
  63 
  64 static inline void allow_write_to_user(void __user *to, unsigned long size)
  65 {
  66         allow_user_access(to, NULL, size, KUAP_WRITE);
  67 }
  68 
  69 static inline void allow_read_write_user(void __user *to, const void __user *from,
  70                                          unsigned long size)
  71 {
  72         allow_user_access(to, from, size, KUAP_READ_WRITE);
  73 }
  74 
  75 static inline void prevent_read_from_user(const void __user *from, unsigned long size)
  76 {
  77         prevent_user_access(NULL, from, size, KUAP_READ);
  78 }
  79 
  80 static inline void prevent_write_to_user(void __user *to, unsigned long size)
  81 {
  82         prevent_user_access(to, NULL, size, KUAP_WRITE);
  83 }
  84 
  85 static inline void prevent_read_write_user(void __user *to, const void __user *from,
  86                                            unsigned long size)
  87 {
  88         prevent_user_access(to, from, size, KUAP_READ_WRITE);
  89 }
  90 
  91 #endif /* !__ASSEMBLY__ */
  92 
  93 #endif /* _ASM_POWERPC_KUAP_H_ */

/* [<][>][^][v][top][bottom][index][help] */