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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/kernel/dexcr.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/powerpc/kernel/dexcr.c (Version linux-6.11-rc3) and /arch/sparc/kernel/dexcr.c (Version linux-6.6.45)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2                                                   
  3 #include <linux/capability.h>                     
  4 #include <linux/cpu.h>                            
  5 #include <linux/init.h>                           
  6 #include <linux/prctl.h>                          
  7 #include <linux/sched.h>                          
  8                                                   
  9 #include <asm/cpu_has_feature.h>                  
 10 #include <asm/cputable.h>                         
 11 #include <asm/processor.h>                        
 12 #include <asm/reg.h>                              
 13                                                   
 14 static int __init init_task_dexcr(void)           
 15 {                                                 
 16         if (!early_cpu_has_feature(CPU_FTR_ARC    
 17                 return 0;                         
 18                                                   
 19         current->thread.dexcr_onexec = mfspr(S    
 20                                                   
 21         return 0;                                 
 22 }                                                 
 23 early_initcall(init_task_dexcr)                   
 24                                                   
 25 /* Allow thread local configuration of these b    
 26 #define DEXCR_PRCTL_EDITABLE ( \                  
 27         DEXCR_PR_IBRTPD | \                       
 28         DEXCR_PR_SRAPD | \                        
 29         DEXCR_PR_NPHIE)                           
 30                                                   
 31 static int prctl_to_aspect(unsigned long which    
 32 {                                                 
 33         switch (which) {                          
 34         case PR_PPC_DEXCR_SBHE:                   
 35                 *aspect = DEXCR_PR_SBHE;          
 36                 break;                            
 37         case PR_PPC_DEXCR_IBRTPD:                 
 38                 *aspect = DEXCR_PR_IBRTPD;        
 39                 break;                            
 40         case PR_PPC_DEXCR_SRAPD:                  
 41                 *aspect = DEXCR_PR_SRAPD;         
 42                 break;                            
 43         case PR_PPC_DEXCR_NPHIE:                  
 44                 *aspect = DEXCR_PR_NPHIE;         
 45                 break;                            
 46         default:                                  
 47                 return -ENODEV;                   
 48         }                                         
 49                                                   
 50         return 0;                                 
 51 }                                                 
 52                                                   
 53 int get_dexcr_prctl(struct task_struct *task,     
 54 {                                                 
 55         unsigned int aspect;                      
 56         int ret;                                  
 57                                                   
 58         ret = prctl_to_aspect(which, &aspect);    
 59         if (ret)                                  
 60                 return ret;                       
 61                                                   
 62         if (aspect & DEXCR_PRCTL_EDITABLE)        
 63                 ret |= PR_PPC_DEXCR_CTRL_EDITA    
 64                                                   
 65         if (aspect & mfspr(SPRN_DEXCR))           
 66                 ret |= PR_PPC_DEXCR_CTRL_SET;     
 67         else                                      
 68                 ret |= PR_PPC_DEXCR_CTRL_CLEAR    
 69                                                   
 70         if (aspect & task->thread.dexcr_onexec    
 71                 ret |= PR_PPC_DEXCR_CTRL_SET_O    
 72         else                                      
 73                 ret |= PR_PPC_DEXCR_CTRL_CLEAR    
 74                                                   
 75         return ret;                               
 76 }                                                 
 77                                                   
 78 int set_dexcr_prctl(struct task_struct *task,     
 79 {                                                 
 80         unsigned long dexcr;                      
 81         unsigned int aspect;                      
 82         int err = 0;                              
 83                                                   
 84         err = prctl_to_aspect(which, &aspect);    
 85         if (err)                                  
 86                 return err;                       
 87                                                   
 88         if (!(aspect & DEXCR_PRCTL_EDITABLE))     
 89                 return -EPERM;                    
 90                                                   
 91         if (ctrl & ~PR_PPC_DEXCR_CTRL_MASK)       
 92                 return -EINVAL;                   
 93                                                   
 94         if (ctrl & PR_PPC_DEXCR_CTRL_SET && ct    
 95                 return -EINVAL;                   
 96                                                   
 97         if (ctrl & PR_PPC_DEXCR_CTRL_SET_ONEXE    
 98                 return -EINVAL;                   
 99                                                   
100         /*                                        
101          * We do not want an unprivileged proc    
102          * a setuid process's hash check instr    
103          */                                       
104         if (aspect == DEXCR_PR_NPHIE &&           
105             ctrl & PR_PPC_DEXCR_CTRL_CLEAR_ONE    
106             !capable(CAP_SYS_ADMIN))              
107                 return -EPERM;                    
108                                                   
109         dexcr = mfspr(SPRN_DEXCR);                
110                                                   
111         if (ctrl & PR_PPC_DEXCR_CTRL_SET)         
112                 dexcr |= aspect;                  
113         else if (ctrl & PR_PPC_DEXCR_CTRL_CLEA    
114                 dexcr &= ~aspect;                 
115                                                   
116         if (ctrl & PR_PPC_DEXCR_CTRL_SET_ONEXE    
117                 task->thread.dexcr_onexec |= a    
118         else if (ctrl & PR_PPC_DEXCR_CTRL_CLEA    
119                 task->thread.dexcr_onexec &= ~    
120                                                   
121         mtspr(SPRN_DEXCR, dexcr);                 
122                                                   
123         return 0;                                 
124 }                                                 
125                                                   

~ [ 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