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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/mm/book3s32/mmu_context.c

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/powerpc/mm/book3s32/mmu_context.c (Version linux-6.12-rc7) and /arch/i386/mm/book3s32/mmu_context.c (Version linux-5.16.20)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * This file contains the routines for handlin    
  4  * PowerPC implementations where the MMU subst    
  5  * architecture specification.  This includes     
  6  * and 8260 implementations but excludes the 8    
  7  *  -- paulus                                     
  8  *                                                
  9  *  Derived from arch/ppc/mm/init.c:              
 10  *    Copyright (C) 1995-1996 Gary Thomas (gdt    
 11  *                                                
 12  *  Modifications by Paul Mackerras (PowerMac)    
 13  *  and Cort Dougan (PReP) (cort@cs.nmt.edu)      
 14  *    Copyright (C) 1996 Paul Mackerras           
 15  *                                                
 16  *  Derived from "arch/i386/mm/init.c"            
 17  *    Copyright (C) 1991, 1992, 1993, 1994  Li    
 18  */                                               
 19                                                   
 20 #include <linux/mm.h>                             
 21 #include <linux/init.h>                           
 22 #include <linux/export.h>                         
 23                                                   
 24 #include <asm/mmu_context.h>                      
 25                                                   
 26 /*                                                
 27  * Room for two PTE pointers, usually the kern    
 28  * to their respective root page table.           
 29  */                                               
 30 void *abatron_pteptrs[2];                         
 31                                                   
 32 /*                                                
 33  * On 32-bit PowerPC 6xx/7xx/7xxx CPUs, we use    
 34  * (virtual segment identifiers) for each cont    
 35  * hardware supports 24-bit VSIDs, and thus >1    
 36  * we only use 32,768 of them.  That is ample,    
 37  * at most around 30,000 tasks in the system a    
 38  * that we can use a bitmap to indicate which     
 39  * Using a bitmap means that we entirely avoid    
 40  * that we used to have when the context numbe    
 41  * particularly on SMP systems.                   
 42  *  -- paulus.                                    
 43  */                                               
 44 #define NO_CONTEXT              ((unsigned lon    
 45 #define LAST_CONTEXT            32767             
 46 #define FIRST_CONTEXT           1                 
 47                                                   
 48 static unsigned long next_mmu_context;            
 49 static unsigned long context_map[LAST_CONTEXT     
 50                                                   
 51 unsigned long __init_new_context(void)            
 52 {                                                 
 53         unsigned long ctx = next_mmu_context;     
 54                                                   
 55         while (test_and_set_bit(ctx, context_m    
 56                 ctx = find_next_zero_bit(conte    
 57                 if (ctx > LAST_CONTEXT)           
 58                         ctx = 0;                  
 59         }                                         
 60         next_mmu_context = (ctx + 1) & LAST_CO    
 61                                                   
 62         return ctx;                               
 63 }                                                 
 64 EXPORT_SYMBOL_GPL(__init_new_context);            
 65                                                   
 66 /*                                                
 67  * Set up the context for a new address space.    
 68  */                                               
 69 int init_new_context(struct task_struct *t, st    
 70 {                                                 
 71         mm->context.id = __init_new_context();    
 72         mm->context.sr0 = CTX_TO_VSID(mm->cont    
 73                                                   
 74         if (IS_ENABLED(CONFIG_PPC_KUEP))          
 75                 mm->context.sr0 |= SR_NX;         
 76         if (!kuap_is_disabled())                  
 77                 mm->context.sr0 |= SR_KS;         
 78                                                   
 79         return 0;                                 
 80 }                                                 
 81                                                   
 82 /*                                                
 83  * Free a context ID. Make sure to call this w    
 84  */                                               
 85 void __destroy_context(unsigned long ctx)         
 86 {                                                 
 87         clear_bit(ctx, context_map);              
 88 }                                                 
 89 EXPORT_SYMBOL_GPL(__destroy_context);             
 90                                                   
 91 /*                                                
 92  * We're finished using the context for an add    
 93  */                                               
 94 void destroy_context(struct mm_struct *mm)        
 95 {                                                 
 96         preempt_disable();                        
 97         if (mm->context.id != NO_CONTEXT) {       
 98                 __destroy_context(mm->context.    
 99                 mm->context.id = NO_CONTEXT;      
100         }                                         
101         preempt_enable();                         
102 }                                                 
103                                                   
104 /*                                                
105  * Initialize the context management stuff.       
106  */                                               
107 void __init mmu_context_init(void)                
108 {                                                 
109         /* Reserve context 0 for kernel use */    
110         context_map[0] = (1 << FIRST_CONTEXT)     
111         next_mmu_context = FIRST_CONTEXT;         
112 }                                                 
113                                                   
114 void switch_mmu_context(struct mm_struct *prev    
115 {                                                 
116         long id = next->context.id;               
117                                                   
118         if (id < 0)                               
119                 panic("mm_struct %p has no con    
120                                                   
121         isync();                                  
122                                                   
123         update_user_segments(next->context.sr0    
124                                                   
125         if (IS_ENABLED(CONFIG_BDI_SWITCH))        
126                 abatron_pteptrs[1] = next->pgd    
127                                                   
128         if (!mmu_has_feature(MMU_FTR_HPTE_TABL    
129                 mtspr(SPRN_SDR1, rol32(__pa(ne    
130                                                   
131         mb();   /* sync */                        
132         isync();                                  
133 }                                                 
134 EXPORT_SYMBOL(switch_mmu_context);                
135                                                   

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