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

TOMOYO Linux Cross Reference
Linux/arch/sparc/kernel/wof.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/wof.S (Architecture mips) and /arch/sparc/kernel/wof.S (Architecture sparc)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * wof.S: Sparc window overflow handler.            3  * wof.S: Sparc window overflow handler.
  4  *                                                  4  *
  5  * Copyright (C) 1995 David S. Miller (davem@c      5  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6  */                                                 6  */
  7                                                     7 
  8 #include <asm/contregs.h>                           8 #include <asm/contregs.h>
  9 #include <asm/page.h>                               9 #include <asm/page.h>
 10 #include <asm/ptrace.h>                            10 #include <asm/ptrace.h>
 11 #include <asm/psr.h>                               11 #include <asm/psr.h>
 12 #include <asm/smp.h>                               12 #include <asm/smp.h>
 13 #include <asm/asi.h>                               13 #include <asm/asi.h>
 14 #include <asm/winmacro.h>                          14 #include <asm/winmacro.h>
 15 #include <asm/asmmacro.h>                          15 #include <asm/asmmacro.h>
 16 #include <asm/thread_info.h>                       16 #include <asm/thread_info.h>
 17                                                    17 
 18 /* WARNING: This routine is hairy and _very_ c     18 /* WARNING: This routine is hairy and _very_ complicated, but it
 19  *          must be as fast as possible as it      19  *          must be as fast as possible as it handles the allocation
 20  *          of register windows to the user an     20  *          of register windows to the user and kernel.  If you touch
 21  *          this code be _very_ careful as man     21  *          this code be _very_ careful as many other pieces of the
 22  *          kernel depend upon how this code b     22  *          kernel depend upon how this code behaves.  You have been
 23  *          duly warned...                         23  *          duly warned...
 24  */                                                24  */
 25                                                    25 
 26 /* We define macro's for registers which have      26 /* We define macro's for registers which have a fixed
 27  * meaning throughout this entire routine.  Th     27  * meaning throughout this entire routine.  The 'T' in
 28  * the comments mean that the register can onl     28  * the comments mean that the register can only be
 29  * accessed when in the 'trap' window, 'G' mea     29  * accessed when in the 'trap' window, 'G' means
 30  * accessible in any window.  Do not change th     30  * accessible in any window.  Do not change these registers
 31  * after they have been set, until you are rea     31  * after they have been set, until you are ready to return
 32  * from the trap.                                  32  * from the trap.
 33  */                                                33  */
 34 #define t_psr       l0 /* %psr at trap time        34 #define t_psr       l0 /* %psr at trap time                     T */
 35 #define t_pc        l1 /* PC for trap return       35 #define t_pc        l1 /* PC for trap return                    T */
 36 #define t_npc       l2 /* NPC for trap return      36 #define t_npc       l2 /* NPC for trap return                   T */
 37 #define t_wim       l3 /* %wim at trap time        37 #define t_wim       l3 /* %wim at trap time                     T */
 38 #define saved_g5    l5 /* Global save register     38 #define saved_g5    l5 /* Global save register                  T */
 39 #define saved_g6    l6 /* Global save register     39 #define saved_g6    l6 /* Global save register                  T */
 40 #define curptr      g6 /* Gets set to 'current     40 #define curptr      g6 /* Gets set to 'current' then stays      G */
 41                                                    41 
 42 /* Now registers whose values can change withi     42 /* Now registers whose values can change within the handler.      */
 43 #define twin_tmp    l4 /* Temp reg, only usabl     43 #define twin_tmp    l4 /* Temp reg, only usable in trap window  T */
 44 #define glob_tmp    g5 /* Global temporary reg     44 #define glob_tmp    g5 /* Global temporary reg, usable anywhere G */
 45                                                    45 
 46         .text                                      46         .text
 47         .align  4                                  47         .align  4
 48         /* BEGINNING OF PATCH INSTRUCTIONS */      48         /* BEGINNING OF PATCH INSTRUCTIONS */
 49         /* On a 7-window Sparc the boot code p     49         /* On a 7-window Sparc the boot code patches spnwin_*
 50          * instructions with the following one     50          * instructions with the following ones.
 51          */                                        51          */
 52         .globl  spnwin_patch1_7win, spnwin_pat     52         .globl  spnwin_patch1_7win, spnwin_patch2_7win, spnwin_patch3_7win
 53 spnwin_patch1_7win:     sll     %t_wim, 6, %gl     53 spnwin_patch1_7win:     sll     %t_wim, 6, %glob_tmp
 54 spnwin_patch2_7win:     and     %glob_tmp, 0x7     54 spnwin_patch2_7win:     and     %glob_tmp, 0x7f, %glob_tmp
 55 spnwin_patch3_7win:     and     %twin_tmp, 0x7     55 spnwin_patch3_7win:     and     %twin_tmp, 0x7f, %twin_tmp
 56         /* END OF PATCH INSTRUCTIONS */            56         /* END OF PATCH INSTRUCTIONS */
 57                                                    57 
 58         /* The trap entry point has done the f     58         /* The trap entry point has done the following:
 59          *                                         59          *
 60          * rd    %psr, %l0                         60          * rd    %psr, %l0
 61          * rd    %wim, %l3                         61          * rd    %wim, %l3
 62          * b     spill_window_entry                62          * b     spill_window_entry
 63          * andcc %l0, PSR_PS, %g0                  63          * andcc %l0, PSR_PS, %g0
 64          */                                        64          */
 65                                                    65 
 66         /* Datum current_thread_info->uwinmask     66         /* Datum current_thread_info->uwinmask contains at all times a bitmask
 67          * where if any user windows are activ     67          * where if any user windows are active, at least one bit will
 68          * be set in to mask.  If no user wind     68          * be set in to mask.  If no user windows are active, the bitmask
 69          * will be all zeroes.                     69          * will be all zeroes.
 70          */                                        70          */
 71         .globl  spill_window_entry                 71         .globl  spill_window_entry 
 72         .globl  spnwin_patch1, spnwin_patch2,      72         .globl  spnwin_patch1, spnwin_patch2, spnwin_patch3
 73 spill_window_entry:                                73 spill_window_entry:
 74         /* LOCATION: Trap Window */                74         /* LOCATION: Trap Window */
 75                                                    75 
 76         mov     %g5, %saved_g5          ! save     76         mov     %g5, %saved_g5          ! save away global temp register
 77         mov     %g6, %saved_g6          ! save     77         mov     %g6, %saved_g6          ! save away 'current' ptr register
 78                                                    78 
 79         /* Compute what the new %wim will be i     79         /* Compute what the new %wim will be if we save the
 80          * window properly in this trap handle     80          * window properly in this trap handler.
 81          *                                         81          *
 82          * newwim = ((%wim>>1) | (%wim<<(nwind     82          * newwim = ((%wim>>1) | (%wim<<(nwindows - 1)));
 83          */                                        83          */
 84                 srl     %t_wim, 0x1, %twin_tmp     84                 srl     %t_wim, 0x1, %twin_tmp
 85 spnwin_patch1:  sll     %t_wim, 7, %glob_tmp       85 spnwin_patch1:  sll     %t_wim, 7, %glob_tmp
 86                 or      %glob_tmp, %twin_tmp,      86                 or      %glob_tmp, %twin_tmp, %glob_tmp
 87 spnwin_patch2:  and     %glob_tmp, 0xff, %glob     87 spnwin_patch2:  and     %glob_tmp, 0xff, %glob_tmp
 88                                                    88 
 89         /* The trap entry point has set the co     89         /* The trap entry point has set the condition codes
 90          * up for us to see if this is from us     90          * up for us to see if this is from user or kernel.
 91          * Get the load of 'curptr' out of the     91          * Get the load of 'curptr' out of the way.
 92          */                                        92          */
 93         LOAD_CURRENT(curptr, twin_tmp)             93         LOAD_CURRENT(curptr, twin_tmp)
 94                                                    94 
 95         andcc   %t_psr, PSR_PS, %g0                95         andcc   %t_psr, PSR_PS, %g0
 96         be,a    spwin_fromuser                     96         be,a    spwin_fromuser                          ! all user wins, branch
 97          save   %g0, %g0, %g0                      97          save   %g0, %g0, %g0                           ! Go where saving will occur
 98                                                    98         
 99         /* See if any user windows are active      99         /* See if any user windows are active in the set. */
100         ld      [%curptr + TI_UWINMASK], %twin    100         ld      [%curptr + TI_UWINMASK], %twin_tmp      ! grab win mask
101         orcc    %g0, %twin_tmp, %g0               101         orcc    %g0, %twin_tmp, %g0                     ! check for set bits
102         bne     spwin_exist_uwins                 102         bne     spwin_exist_uwins                       ! yep, there are some
103          andn   %twin_tmp, %glob_tmp, %twin_tm    103          andn   %twin_tmp, %glob_tmp, %twin_tmp         ! compute new uwinmask
104                                                   104 
105         /* Save into the window which must be     105         /* Save into the window which must be saved and do it.
106          * Basically if we are here, this mean    106          * Basically if we are here, this means that we trapped
107          * from kernel mode with only kernel w    107          * from kernel mode with only kernel windows in the register
108          * file.                                  108          * file.
109          */                                       109          */
110         save    %g0, %g0, %g0           ! save    110         save    %g0, %g0, %g0           ! save into the window to stash away
111         wr      %glob_tmp, 0x0, %wim    ! set     111         wr      %glob_tmp, 0x0, %wim    ! set new %wim, this is safe now
112                                                   112 
113 spwin_no_userwins_from_kernel:                    113 spwin_no_userwins_from_kernel:
114         /* LOCATION: Window to be saved */        114         /* LOCATION: Window to be saved */
115                                                   115 
116         STORE_WINDOW(sp)                ! stas    116         STORE_WINDOW(sp)                ! stash the window
117         restore %g0, %g0, %g0           ! go b    117         restore %g0, %g0, %g0           ! go back into trap window
118                                                   118 
119         /* LOCATION: Trap window */               119         /* LOCATION: Trap window */
120         mov     %saved_g5, %g5          ! rest    120         mov     %saved_g5, %g5          ! restore %glob_tmp
121         mov     %saved_g6, %g6          ! rest    121         mov     %saved_g6, %g6          ! restore %curptr
122         wr      %t_psr, 0x0, %psr       ! rest    122         wr      %t_psr, 0x0, %psr       ! restore condition codes in %psr
123         WRITE_PAUSE                     ! wast    123         WRITE_PAUSE                     ! waste some time
124         jmp     %t_pc                   ! Retu    124         jmp     %t_pc                   ! Return from trap
125         rett    %t_npc                  ! we a    125         rett    %t_npc                  ! we are done
126                                                   126 
127 spwin_exist_uwins:                                127 spwin_exist_uwins:
128         /* LOCATION: Trap window */               128         /* LOCATION: Trap window */
129                                                   129 
130         /* Wow, user windows have to be dealt     130         /* Wow, user windows have to be dealt with, this is dirty
131          * and messy as all hell.  And difficu    131          * and messy as all hell.  And difficult to follow if you
132          * are approaching the infamous regist    132          * are approaching the infamous register window trap handling
133          * problem for the first time. DON'T L    133          * problem for the first time. DON'T LOOK!
134          *                                        134          *
135          * Note that how the execution path wo    135          * Note that how the execution path works out, the new %wim
136          * will be left for us in the global t    136          * will be left for us in the global temporary register,
137          * %glob_tmp.  We cannot set the new %    137          * %glob_tmp.  We cannot set the new %wim first because we
138          * need to save into the appropriate w    138          * need to save into the appropriate window without inducing
139          * a trap (traps are off, we'd get a w    139          * a trap (traps are off, we'd get a watchdog wheee)...
140          * But first, store the new user windo    140          * But first, store the new user window mask calculated
141          * above.                                 141          * above.
142          */                                       142          */
143         st      %twin_tmp, [%curptr + TI_UWINM    143         st      %twin_tmp, [%curptr + TI_UWINMASK]
144         save    %g0, %g0, %g0           ! Go t    144         save    %g0, %g0, %g0           ! Go to where the saving will occur
145                                                   145 
146 spwin_fromuser:                                   146 spwin_fromuser:
147         /* LOCATION: Window to be saved */        147         /* LOCATION: Window to be saved */
148         wr      %glob_tmp, 0x0, %wim    ! Now     148         wr      %glob_tmp, 0x0, %wim    ! Now it is safe to set new %wim
149                                                   149 
150         /* LOCATION: Window to be saved */        150         /* LOCATION: Window to be saved */
151                                                   151 
152         /* This instruction branches to a rout    152         /* This instruction branches to a routine which will check
153          * to validity of the users stack poin    153          * to validity of the users stack pointer by whatever means
154          * are necessary.  This means that thi    154          * are necessary.  This means that this is architecture
155          * specific and thus this branch instr    155          * specific and thus this branch instruction will need to
156          * be patched at boot time once the ma    156          * be patched at boot time once the machine type is known.
157          * This routine _shall not_ touch %cur    157          * This routine _shall not_ touch %curptr under any
158          * circumstances whatsoever!  It will     158          * circumstances whatsoever!  It will branch back to the
159          * label 'spwin_good_ustack' if the st    159          * label 'spwin_good_ustack' if the stack is ok but still
160          * needs to be dumped (SRMMU for insta    160          * needs to be dumped (SRMMU for instance will not need to
161          * do this) or 'spwin_finish_up' if th    161          * do this) or 'spwin_finish_up' if the stack is ok and the
162          * registers have already been saved.     162          * registers have already been saved.  If the stack is found
163          * to be bogus for some reason the rou    163          * to be bogus for some reason the routine shall branch to
164          * the label 'spwin_user_stack_is_boli    164          * the label 'spwin_user_stack_is_bolixed' which will take
165          * care of things at that point.          165          * care of things at that point.
166          */                                       166          */
167         b       spwin_srmmu_stackchk              167         b       spwin_srmmu_stackchk
168          andcc  %sp, 0x7, %g0                     168          andcc  %sp, 0x7, %g0
169                                                   169 
170 spwin_good_ustack:                                170 spwin_good_ustack:
171         /* LOCATION: Window to be saved */        171         /* LOCATION: Window to be saved */
172                                                   172 
173         /* The users stack is ok and we can sa    173         /* The users stack is ok and we can safely save it at
174          * %sp.                                   174          * %sp.
175          */                                       175          */
176         STORE_WINDOW(sp)                          176         STORE_WINDOW(sp)
177                                                   177 
178 spwin_finish_up:                                  178 spwin_finish_up:
179         restore %g0, %g0, %g0           /* Bac    179         restore %g0, %g0, %g0           /* Back to trap window. */
180                                                   180 
181         /* LOCATION: Trap window */               181         /* LOCATION: Trap window */
182                                                   182 
183         /* We have spilled successfully, and w    183         /* We have spilled successfully, and we have properly stored
184          * the appropriate window onto the sta    184          * the appropriate window onto the stack.
185          */                                       185          */
186                                                   186 
187         /* Restore saved globals */               187         /* Restore saved globals */
188         mov     %saved_g5, %g5                    188         mov     %saved_g5, %g5
189         mov     %saved_g6, %g6                    189         mov     %saved_g6, %g6
190                                                   190 
191         wr      %t_psr, 0x0, %psr                 191         wr      %t_psr, 0x0, %psr
192         WRITE_PAUSE                               192         WRITE_PAUSE
193         jmp     %t_pc                             193         jmp     %t_pc
194         rett    %t_npc                            194         rett    %t_npc
195                                                   195 
196 spwin_user_stack_is_bolixed:                      196 spwin_user_stack_is_bolixed:
197         /* LOCATION: Window to be saved */        197         /* LOCATION: Window to be saved */
198                                                   198 
199         /* Wheee, user has trashed his/her sta    199         /* Wheee, user has trashed his/her stack.  We have to decide
200          * how to proceed based upon whether w    200          * how to proceed based upon whether we came from kernel mode
201          * or not.  If we came from kernel mod    201          * or not.  If we came from kernel mode, toss the window into
202          * a special buffer and proceed, the k    202          * a special buffer and proceed, the kernel _needs_ a window
203          * and we could be in an interrupt han    203          * and we could be in an interrupt handler so timing is crucial.
204          * If we came from user land we build     204          * If we came from user land we build a full stack frame and call
205          * c-code to gun down the process.        205          * c-code to gun down the process.
206          */                                       206          */
207         rd      %psr, %glob_tmp                   207         rd      %psr, %glob_tmp
208         andcc   %glob_tmp, PSR_PS, %g0            208         andcc   %glob_tmp, PSR_PS, %g0
209         bne     spwin_bad_ustack_from_kernel      209         bne     spwin_bad_ustack_from_kernel
210          nop                                      210          nop
211                                                   211 
212         /* Oh well, throw this one window into    212         /* Oh well, throw this one window into the per-task window
213          * buffer, the first one.                 213          * buffer, the first one.
214          */                                       214          */
215         st      %sp, [%curptr + TI_RWIN_SPTRS]    215         st      %sp, [%curptr + TI_RWIN_SPTRS]
216         STORE_WINDOW(curptr + TI_REG_WINDOW)      216         STORE_WINDOW(curptr + TI_REG_WINDOW)
217         restore %g0, %g0, %g0                     217         restore %g0, %g0, %g0
218                                                   218 
219         /* LOCATION: Trap Window */               219         /* LOCATION: Trap Window */
220                                                   220 
221         /* Back in the trap window, update win    221         /* Back in the trap window, update winbuffer save count. */
222         mov     1, %twin_tmp                      222         mov     1, %twin_tmp
223         st      %twin_tmp, [%curptr + TI_W_SAV    223         st      %twin_tmp, [%curptr + TI_W_SAVED]
224                                                   224 
225                 /* Compute new user window mas    225                 /* Compute new user window mask.  What we are basically
226                  * doing is taking two windows    226                  * doing is taking two windows, the invalid one at trap
227                  * time and the one we attempt    227                  * time and the one we attempted to throw onto the users
228                  * stack, and saying that ever    228                  * stack, and saying that everything else is an ok user
229                  * window.  umask = ((~(%t_wim    229                  * window.  umask = ((~(%t_wim | %wim)) & valid_wim_bits)
230                  */                               230                  */
231                 rd      %wim, %twin_tmp           231                 rd      %wim, %twin_tmp
232                 or      %twin_tmp, %t_wim, %tw    232                 or      %twin_tmp, %t_wim, %twin_tmp
233                 not     %twin_tmp                 233                 not     %twin_tmp
234 spnwin_patch3:  and     %twin_tmp, 0xff, %twin    234 spnwin_patch3:  and     %twin_tmp, 0xff, %twin_tmp      ! patched on 7win Sparcs
235                 st      %twin_tmp, [%curptr +     235                 st      %twin_tmp, [%curptr + TI_UWINMASK]
236                                                   236 
237 #define STACK_OFFSET (THREAD_SIZE - TRACEREG_S    237 #define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ)
238                                                   238 
239         sethi   %hi(STACK_OFFSET), %sp            239         sethi   %hi(STACK_OFFSET), %sp
240         or      %sp, %lo(STACK_OFFSET), %sp       240         or      %sp, %lo(STACK_OFFSET), %sp
241         add     %curptr, %sp, %sp                 241         add     %curptr, %sp, %sp
242                                                   242 
243         /* Restore the saved globals and build    243         /* Restore the saved globals and build a pt_regs frame. */
244         mov     %saved_g5, %g5                    244         mov     %saved_g5, %g5
245         mov     %saved_g6, %g6                    245         mov     %saved_g6, %g6
246         STORE_PT_ALL(sp, t_psr, t_pc, t_npc, g    246         STORE_PT_ALL(sp, t_psr, t_pc, t_npc, g1)
247                                                   247 
248         sethi   %hi(STACK_OFFSET), %g6            248         sethi   %hi(STACK_OFFSET), %g6
249         or      %g6, %lo(STACK_OFFSET), %g6       249         or      %g6, %lo(STACK_OFFSET), %g6
250         sub     %sp, %g6, %g6           ! curp    250         sub     %sp, %g6, %g6           ! curptr
251                                                   251 
252         /* Turn on traps and call c-code to de    252         /* Turn on traps and call c-code to deal with it. */
253         wr      %t_psr, PSR_ET, %psr              253         wr      %t_psr, PSR_ET, %psr
254         nop                                       254         nop
255         call    window_overflow_fault             255         call    window_overflow_fault
256          nop                                      256          nop
257                                                   257 
258         /* Return from trap if C-code actually    258         /* Return from trap if C-code actually fixes things, if it
259          * doesn't then we never get this far     259          * doesn't then we never get this far as the process will
260          * be given the look of death from Com    260          * be given the look of death from Commander Peanut.
261          */                                       261          */
262         b       ret_trap_entry                    262         b       ret_trap_entry
263          clr    %l6                               263          clr    %l6
264                                                   264 
265 spwin_bad_ustack_from_kernel:                     265 spwin_bad_ustack_from_kernel:
266         /* LOCATION: Window to be saved */        266         /* LOCATION: Window to be saved */
267                                                   267 
268         /* The kernel provoked a spill window     268         /* The kernel provoked a spill window trap, but the window we
269          * need to save is a user one and the     269          * need to save is a user one and the process has trashed its
270          * stack pointer.  We need to be quick    270          * stack pointer.  We need to be quick, so we throw it into
271          * a per-process window buffer until w    271          * a per-process window buffer until we can properly handle
272          * this later on.                         272          * this later on.
273          */                                       273          */
274         SAVE_BOLIXED_USER_STACK(curptr, glob_t    274         SAVE_BOLIXED_USER_STACK(curptr, glob_tmp)
275         restore %g0, %g0, %g0                     275         restore %g0, %g0, %g0
276                                                   276 
277         /* LOCATION: Trap window */               277         /* LOCATION: Trap window */
278                                                   278 
279         /* Restore globals, condition codes in    279         /* Restore globals, condition codes in the %psr and
280          * return from trap.  Note, restoring     280          * return from trap.  Note, restoring %g6 when returning
281          * to kernel mode is not necessarily t    281          * to kernel mode is not necessarily these days. ;-)
282          */                                       282          */
283         mov     %saved_g5, %g5                    283         mov     %saved_g5, %g5
284         mov     %saved_g6, %g6                    284         mov     %saved_g6, %g6
285                                                   285 
286         wr      %t_psr, 0x0, %psr                 286         wr      %t_psr, 0x0, %psr
287         WRITE_PAUSE                               287         WRITE_PAUSE
288                                                   288 
289         jmp     %t_pc                             289         jmp     %t_pc
290         rett    %t_npc                            290         rett    %t_npc
291                                                   291 
292 /* Undefine the register macros which would on    292 /* Undefine the register macros which would only cause trouble
293  * if used below.  This helps find 'stupid' co    293  * if used below.  This helps find 'stupid' coding errors that
294  * produce 'odd' behavior.  The routines below    294  * produce 'odd' behavior.  The routines below are allowed to
295  * make usage of glob_tmp and t_psr so we leav    295  * make usage of glob_tmp and t_psr so we leave them defined.
296  */                                               296  */
297 #undef twin_tmp                                   297 #undef twin_tmp
298 #undef curptr                                     298 #undef curptr
299 #undef t_pc                                       299 #undef t_pc
300 #undef t_npc                                      300 #undef t_npc
301 #undef t_wim                                      301 #undef t_wim
302 #undef saved_g5                                   302 #undef saved_g5
303 #undef saved_g6                                   303 #undef saved_g6
304                                                   304 
305 /* Now come the per-architecture window overfl    305 /* Now come the per-architecture window overflow stack checking routines.
306  * As noted above %curptr cannot be touched by    306  * As noted above %curptr cannot be touched by this routine at all.
307  */                                               307  */
308                                                   308 
309         /* This is a generic SRMMU routine.  A    309         /* This is a generic SRMMU routine.  As far as I know this
310          * works for all current v8/srmmu impl    310          * works for all current v8/srmmu implementations, we'll
311          * see...                                 311          * see...
312          */                                       312          */
313         .globl  spwin_srmmu_stackchk              313         .globl  spwin_srmmu_stackchk
314 spwin_srmmu_stackchk:                             314 spwin_srmmu_stackchk:
315         /* LOCATION: Window to be saved on the    315         /* LOCATION: Window to be saved on the stack */
316                                                   316 
317         /* Because of SMP concerns and speed w    317         /* Because of SMP concerns and speed we play a trick.
318          * We disable fault traps in the MMU c    318          * We disable fault traps in the MMU control register,
319          * Execute the stores, then check the     319          * Execute the stores, then check the fault registers
320          * to see what happens.  I can hear Li    320          * to see what happens.  I can hear Linus now
321          * "disgusting... broken hardware...".    321          * "disgusting... broken hardware...".
322          *                                        322          *
323          * But first, check to see if the user    323          * But first, check to see if the users stack has ended
324          * up in kernel vma, then we would suc    324          * up in kernel vma, then we would succeed for the 'wrong'
325          * reason... ;(  Note that the 'sethi'    325          * reason... ;(  Note that the 'sethi' below assumes the
326          * kernel is page aligned, which shoul    326          * kernel is page aligned, which should always be the case.
327          */                                       327          */
328         /* Check results of callers andcc %sp,    328         /* Check results of callers andcc %sp, 0x7, %g0 */
329         bne     spwin_user_stack_is_bolixed       329         bne     spwin_user_stack_is_bolixed
330          sethi   %hi(PAGE_OFFSET), %glob_tmp      330          sethi   %hi(PAGE_OFFSET), %glob_tmp
331         cmp     %glob_tmp, %sp                    331         cmp     %glob_tmp, %sp
332         bleu    spwin_user_stack_is_bolixed       332         bleu    spwin_user_stack_is_bolixed
333          mov    AC_M_SFSR, %glob_tmp              333          mov    AC_M_SFSR, %glob_tmp
334                                                   334 
335         /* Clear the fault status and turn on     335         /* Clear the fault status and turn on the no_fault bit. */
336 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS,     336 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS, %g0)      ! eat SFSR
337 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %g0    337 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %g0)         ! eat SFSR
338                                                   338 
339 LEON_PI(lda     [%g0] ASI_LEON_MMUREGS, %glob_    339 LEON_PI(lda     [%g0] ASI_LEON_MMUREGS, %glob_tmp)      ! read MMU control
340 SUN_PI_(lda     [%g0] ASI_M_MMUREGS, %glob_tmp    340 SUN_PI_(lda     [%g0] ASI_M_MMUREGS, %glob_tmp)         ! read MMU control
341         or      %glob_tmp, 0x2, %glob_tmp         341         or      %glob_tmp, 0x2, %glob_tmp               ! or in no_fault bit
342 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUR    342 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUREGS)      ! set it
343 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS    343 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS)         ! set it
344                                                   344 
345         /* Dump the registers and cross finger    345         /* Dump the registers and cross fingers. */
346         STORE_WINDOW(sp)                          346         STORE_WINDOW(sp)
347                                                   347 
348         /* Clear the no_fault bit and check th    348         /* Clear the no_fault bit and check the status. */
349         andn    %glob_tmp, 0x2, %glob_tmp         349         andn    %glob_tmp, 0x2, %glob_tmp
350 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUR    350 LEON_PI(sta     %glob_tmp, [%g0] ASI_LEON_MMUREGS)
351 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS    351 SUN_PI_(sta     %glob_tmp, [%g0] ASI_M_MMUREGS)
352                                                   352 
353         mov     AC_M_SFAR, %glob_tmp              353         mov     AC_M_SFAR, %glob_tmp
354 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS,     354 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS, %g0)
355 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %g0    355 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %g0)
356                                                   356 
357         mov     AC_M_SFSR, %glob_tmp              357         mov     AC_M_SFSR, %glob_tmp
358 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS,     358 LEON_PI(lda     [%glob_tmp] ASI_LEON_MMUREGS, %glob_tmp)
359 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %gl    359 SUN_PI_(lda     [%glob_tmp] ASI_M_MMUREGS, %glob_tmp)
360         andcc   %glob_tmp, 0x2, %g0               360         andcc   %glob_tmp, 0x2, %g0                     ! did we fault?
361         be,a    spwin_finish_up + 0x4             361         be,a    spwin_finish_up + 0x4                   ! cool beans, success
362          restore %g0, %g0, %g0                    362          restore %g0, %g0, %g0
363                                                   363 
364         rd      %psr, %glob_tmp                   364         rd      %psr, %glob_tmp
365         b       spwin_user_stack_is_bolixed +     365         b       spwin_user_stack_is_bolixed + 0x4       ! we faulted, ugh
366          nop                                      366          nop
                                                      

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