~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/include/asm/pkeys.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/include/asm/pkeys.h (Version linux-6.12-rc7) and /arch/i386/include/asm-i386/pkeys.h (Version linux-6.1.116)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 /*                                                
  3  * Copyright (C) 2023 Arm Ltd.                    
  4  *                                                
  5  * Based on arch/x86/include/asm/pkeys.h          
  6  */                                               
  7                                                   
  8 #ifndef _ASM_ARM64_PKEYS_H                        
  9 #define _ASM_ARM64_PKEYS_H                        
 10                                                   
 11 #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_    
 12                                                   
 13 #define arch_max_pkey() 8                         
 14                                                   
 15 int arch_set_user_pkey_access(struct task_stru    
 16                 unsigned long init_val);          
 17                                                   
 18 static inline bool arch_pkeys_enabled(void)       
 19 {                                                 
 20         return system_supports_poe();             
 21 }                                                 
 22                                                   
 23 static inline int vma_pkey(struct vm_area_stru    
 24 {                                                 
 25         return (vma->vm_flags & ARCH_VM_PKEY_F    
 26 }                                                 
 27                                                   
 28 static inline int arch_override_mprotect_pkey(    
 29                 int prot, int pkey)               
 30 {                                                 
 31         if (pkey != -1)                           
 32                 return pkey;                      
 33                                                   
 34         return vma_pkey(vma);                     
 35 }                                                 
 36                                                   
 37 static inline int execute_only_pkey(struct mm_    
 38 {                                                 
 39         // Execute-only mappings are handled b    
 40         return -1;                                
 41 }                                                 
 42                                                   
 43 #define mm_pkey_allocation_map(mm)      (mm)->    
 44 #define mm_set_pkey_allocated(mm, pkey) do {      
 45         mm_pkey_allocation_map(mm) |= (1U << p    
 46 } while (0)                                       
 47 #define mm_set_pkey_free(mm, pkey) do {           
 48         mm_pkey_allocation_map(mm) &= ~(1U <<     
 49 } while (0)                                       
 50                                                   
 51 static inline bool mm_pkey_is_allocated(struct    
 52 {                                                 
 53         /*                                        
 54          * "Allocated" pkeys are those that ha    
 55          * from pkey_alloc() or pkey 0 which i    
 56          * implicitly when the mm is created.     
 57          */                                       
 58         if (pkey < 0 || pkey >= arch_max_pkey(    
 59                 return false;                     
 60                                                   
 61         return mm_pkey_allocation_map(mm) & (1    
 62 }                                                 
 63                                                   
 64 /*                                                
 65  * Returns a positive, 3-bit key on success, o    
 66  */                                               
 67 static inline int mm_pkey_alloc(struct mm_stru    
 68 {                                                 
 69         /*                                        
 70          * Note: this is the one and only plac    
 71          * that the pkey is valid as far as th    
 72          * concerned.  The rest of the kernel     
 73          * only good, valid pkeys come out of     
 74          */                                       
 75         u8 all_pkeys_mask = GENMASK(arch_max_p    
 76         int ret;                                  
 77                                                   
 78         if (!arch_pkeys_enabled())                
 79                 return -1;                        
 80                                                   
 81         /*                                        
 82          * Are we out of pkeys?  We must handl    
 83          * because ffz() behavior is undefined    
 84          * zeros.                                 
 85          */                                       
 86         if (mm_pkey_allocation_map(mm) == all_    
 87                 return -1;                        
 88                                                   
 89         ret = ffz(mm_pkey_allocation_map(mm));    
 90                                                   
 91         mm_set_pkey_allocated(mm, ret);           
 92                                                   
 93         return ret;                               
 94 }                                                 
 95                                                   
 96 static inline int mm_pkey_free(struct mm_struc    
 97 {                                                 
 98         if (!mm_pkey_is_allocated(mm, pkey))      
 99                 return -EINVAL;                   
100                                                   
101         mm_set_pkey_free(mm, pkey);               
102                                                   
103         return 0;                                 
104 }                                                 
105                                                   
106 #endif /* _ASM_ARM64_PKEYS_H */                   
107                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php