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

TOMOYO Linux Cross Reference
Linux/arch/sparc/kernel/etrap_32.S

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/sparc/kernel/etrap_32.S (Architecture sparc) and /arch/mips/kernel/etrap_32.S (Architecture mips)


  1 /* SPDX-License-Identifier: GPL-2.0 */            
  2 /*                                                
  3  * etrap.S: Sparc trap window preparation for     
  4  *          Linux kernel.                         
  5  *                                                
  6  * Copyright (C) 1995 David S. Miller (davem@c    
  7  */                                               
  8                                                   
  9 #include <asm/head.h>                             
 10 #include <asm/asi.h>                              
 11 #include <asm/contregs.h>                         
 12 #include <asm/page.h>                             
 13 #include <asm/psr.h>                              
 14 #include <asm/ptrace.h>                           
 15 #include <asm/winmacro.h>                         
 16 #include <asm/asmmacro.h>                         
 17 #include <asm/thread_info.h>                      
 18                                                   
 19 /* Registers to not touch at all. */              
 20 #define t_psr        l0 /* Set by caller */       
 21 #define t_pc         l1 /* Set by caller */       
 22 #define t_npc        l2 /* Set by caller */       
 23 #define t_wim        l3 /* Set by caller */       
 24 #define t_twinmask   l4 /* Set at beginning of    
 25 #define t_kstack     l5 /* Set right before pt    
 26 #define t_retpc      l6 /* If you change this,    
 27 #define t_systable   l7 /* Never touch this, c    
 28 #define curptr       g6 /* Set after pt_regs f    
 29                                                   
 30         .text                                     
 31         .align 4                                  
 32                                                   
 33         /* SEVEN WINDOW PATCH INSTRUCTIONS */     
 34         .globl  tsetup_7win_patch1, tsetup_7wi    
 35         .globl  tsetup_7win_patch3, tsetup_7wi    
 36         .globl  tsetup_7win_patch5, tsetup_7wi    
 37 tsetup_7win_patch1:     sll     %t_wim, 0x6, %    
 38 tsetup_7win_patch2:     and     %g2, 0x7f, %g2    
 39 tsetup_7win_patch3:     and     %g2, 0x7f, %g2    
 40 tsetup_7win_patch4:     and     %g1, 0x7f, %g1    
 41 tsetup_7win_patch5:     sll     %t_wim, 0x6, %    
 42 tsetup_7win_patch6:     and     %g2, 0x7f, %g2    
 43         /* END OF PATCH INSTRUCTIONS */           
 44                                                   
 45         /* At trap time, interrupts and all ge    
 46          * following:                             
 47          *                                        
 48          * rd   %psr, %l0                         
 49          * b    some_handler                      
 50          * rd   %wim, %l3                         
 51          * nop                                    
 52          *                                        
 53          * Then 'some_handler' if it needs a t    
 54          * to call c-code and the trap cannot     
 55          * then it does the SAVE_ALL macro in     
 56          *                                        
 57          * sethi        %hi(trap_setup), %l4      
 58          * jmpl         %l4 + %lo(trap_setup),    
 59          * nop                                    
 60          */                                       
 61                                                   
 62         /* 2 3 4  window number                   
 63          * -----                                  
 64          * O T S  mnemonic                        
 65          *                                        
 66          * O == Current window before trap        
 67          * T == Window entered when trap occur    
 68          * S == Window we will need to save if    
 69          *                                        
 70          * Before execution gets here, it must    
 71          * %l0 contains trap time %psr, %l1 an    
 72          * trap pc and npc, and %l3 contains t    
 73          */                                       
 74                                                   
 75         .globl  trap_setup, tsetup_patch1, tse    
 76         .globl  tsetup_patch3, tsetup_patch4      
 77         .globl  tsetup_patch5, tsetup_patch6      
 78 trap_setup:                                       
 79         /* Calculate mask of trap window.  See    
 80          * or kernel and branch conditionally.    
 81          */                                       
 82         mov     1, %t_twinmask                    
 83         andcc   %t_psr, PSR_PS, %g0               
 84         be      trap_setup_from_user              
 85          sll    %t_twinmask, %t_psr, %t_twinma    
 86                                                   
 87         /* From kernel, allocate more kernel s    
 88          * build a pt_regs trap frame.            
 89          */                                       
 90         sub     %fp, (STACKFRAME_SZ + TRACEREG    
 91         STORE_PT_ALL(t_kstack, t_psr, t_pc, t_    
 92                                                   
 93         /* See if we are in the trap window. *    
 94         andcc   %t_twinmask, %t_wim, %g0          
 95         bne     trap_setup_kernel_spill           
 96          nop                                      
 97                                                   
 98         /* Trap from kernel with a window avai    
 99          * Just do it...                          
100          */                                       
101         jmpl    %t_retpc + 0x8, %g0     ! retu    
102          mov    %t_kstack, %sp          ! jump    
103                                                   
104 trap_setup_kernel_spill:                          
105         ld      [%curptr + TI_UWINMASK], %g1      
106         orcc    %g0, %g1, %g0                     
107         bne     trap_setup_user_spill   ! ther    
108         /* Spill from kernel, but only kernel     
109          * %wim and go.                           
110          */                                       
111          srl    %t_wim, 0x1, %g2        ! begi    
112 tsetup_patch1:                                    
113         sll     %t_wim, 0x7, %t_wim     ! patc    
114         or      %t_wim, %g2, %g2                  
115 tsetup_patch2:                                    
116         and     %g2, 0xff, %g2          ! patc    
117                                                   
118         save    %g0, %g0, %g0                     
119                                                   
120         /* Set new %wim value */                  
121         wr      %g2, 0x0, %wim                    
122                                                   
123         /* Save the kernel window onto the cor    
124         STORE_WINDOW(sp)                          
125                                                   
126         restore %g0, %g0, %g0                     
127                                                   
128         jmpl    %t_retpc + 0x8, %g0     ! retu    
129          mov    %t_kstack, %sp          ! and     
130                                                   
131 #define STACK_OFFSET (THREAD_SIZE - TRACEREG_S    
132                                                   
133 trap_setup_from_user:                             
134         /* We can't use %curptr yet. */           
135         LOAD_CURRENT(t_kstack, t_twinmask)        
136                                                   
137         sethi   %hi(STACK_OFFSET), %t_twinmask    
138         or      %t_twinmask, %lo(STACK_OFFSET)    
139         add     %t_kstack, %t_twinmask, %t_kst    
140                                                   
141         mov     1, %t_twinmask                    
142         sll     %t_twinmask, %t_psr, %t_twinma    
143                                                   
144         /* Build pt_regs frame. */                
145         STORE_PT_ALL(t_kstack, t_psr, t_pc, t_    
146                                                   
147 #if 0                                             
148         /* If we're sure every task_struct is     
149            we can speed this up. */               
150         sethi   %hi(STACK_OFFSET), %curptr        
151         or      %curptr, %lo(STACK_OFFSET), %c    
152         sub     %t_kstack, %curptr, %curptr       
153 #else                                             
154         sethi   %hi(~(THREAD_SIZE - 1)), %curp    
155         and     %t_kstack, %curptr, %curptr       
156 #endif                                            
157                                                   
158         /* Clear current_thread_info->w_saved     
159         st      %g0, [%curptr + TI_W_SAVED]       
160                                                   
161         /* See if we are in the trap window. *    
162         andcc   %t_twinmask, %t_wim, %g0          
163         bne     trap_setup_user_spill             
164          orn    %g0, %t_twinmask, %g1             
165                                                   
166         /* Trap from user, but not into the in    
167          * Calculate new umask.  The way this     
168          * any window from the %wim at trap ti    
169          * the window right before the one we     
170          * is a user window.  A diagram:          
171          *                                        
172          *      7 6 5 4 3 2 1 0    window numb    
173          *      ---------------                   
174          *        I     L T        mnemonic       
175          *                                        
176          * Window 'I' is the invalid window in    
177          * window 'L' is the window the user w    
178          * the trap occurred, window T is the     
179          * we are in now.  So therefore, windo    
180          * 3 are user windows.  The following     
181          * computes the user winmask to repres    
182          */                                       
183         subcc   %t_wim, %t_twinmask, %g2          
184         bneg,a  1f                                
185          sub    %g2, 0x1, %g2                     
186 1:                                                
187         andn    %g2, %t_twinmask, %g2             
188 tsetup_patch3:                                    
189         and     %g2, 0xff, %g2                    
190         st      %g2, [%curptr + TI_UWINMASK]      
191                                                   
192         jmpl    %t_retpc + 0x8, %g0               
193          mov    %t_kstack, %sp                    
194                                                   
195 trap_setup_user_spill:                            
196         /* A spill occurred from either kernel    
197          * and there exist some user windows t    
198          * A mask of the currently valid user     
199          * is in %g1 upon entry to here.          
200          */                                       
201                                                   
202 tsetup_patch4:                                    
203         and     %g1, 0xff, %g1          ! patc    
204         srl     %t_wim, 0x1, %g2        ! comp    
205 tsetup_patch5:                                    
206         sll     %t_wim, 0x7, %t_wim     ! patc    
207         or      %t_wim, %g2, %g2        ! %g2     
208 tsetup_patch6:                                    
209         and     %g2, 0xff, %g2          ! patc    
210         andn    %g1, %g2, %g1           ! clea    
211         st      %g1, [%curptr + TI_UWINMASK]      
212                                                   
213         save    %g0, %g0, %g0                     
214                                                   
215         wr      %g2, 0x0, %wim                    
216                                                   
217         /* Call MMU-architecture dependent sta    
218          * routine.                               
219          */                                       
220         b       tsetup_srmmu_stackchk             
221          andcc  %sp, 0x7, %g0                     
222                                                   
223         /* Architecture specific stack checkin    
224          * of these routines are called, the g    
225          * as they have been safely stashed on    
226          * pointer.  Thus the definition below    
227          */                                       
228 #define glob_tmp     g1                           
229                                                   
230         .globl  tsetup_srmmu_stackchk             
231 tsetup_srmmu_stackchk:                            
232         /* Check results of callers andcc %sp,    
233         bne     trap_setup_user_stack_is_bolix    
234          sethi   %hi(PAGE_OFFSET), %glob_tmp      
235                                                   
236         cmp     %glob_tmp, %sp                    
237         bleu,a  1f                                
238 LEON_PI( lda    [%g0] ASI_LEON_MMUREGS, %glob_    
239 SUN_PI_( lda    [%g0] ASI_M_MMUREGS, %glob_tmp    
240                                                   
241 trap_setup_user_stack_is_bolixed:                 
242         /* From user/kernel into invalid windo    
243          * stack. Save bad user stack, and ret    
244          */                                       
245         SAVE_BOLIXED_USER_STACK(curptr, g3)       
246         restore %g0, %g0, %g0                     
247                                                   
248         jmpl    %t_retpc + 0x8, %g0               
249          mov    %t_kstack, %sp                    
250                                                   
251 1:                                                
252         /* Clear the fault status and turn on     
253         or      %glob_tmp, 0x2, %glob_tmp         
254 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUR    
255 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS    
256                                                   
257         /* Dump the registers and cross finger    
258         STORE_WINDOW(sp)                          
259                                                   
260         /* Clear the no_fault bit and check th    
261         andn    %glob_tmp, 0x2, %glob_tmp         
262 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUR    
263 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS    
264                                                   
265         mov     AC_M_SFAR, %glob_tmp              
266 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS,     
267 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %g0    
268                                                   
269         mov     AC_M_SFSR, %glob_tmp              
270 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS,     
271 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %gl    
272                                                   
273         andcc   %glob_tmp, 0x2, %g0               
274         bne     trap_setup_user_stack_is_bolix    
275          nop                                      
276                                                   
277         restore %g0, %g0, %g0                     
278                                                   
279         jmpl    %t_retpc + 0x8, %g0               
280          mov    %t_kstack, %sp                    
281                                                   
                                                      

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