/* Just like the overflow handler we define macros for registers *withfixedmeaningsinthisroutine.
*/
#define t_psr l0
#define t_pc l1
#define t_npc l2
#define t_wim l3 /* Don't touch the above registers or else you die horribly... */
/* Now macros for the available scratch registers in this routine. */
#define twin_tmp1 l4
#define twin_tmp2 l5
#define curptr g6
.text
.align4
/* The trap entry point has executed the following: * *rd%psr,%l0 *rd%wim,%l3 *bfill_window_entry *andcc%l0,PSR_PS,%g0
*/
/* Datum current_thread_info->uwinmask contains at all times a bitmask *whereifanyuserwindowsareactive,atleastonebitwill *besetintomask.Ifnouserwindowsareactive,thebitmask *willbeallzeroes.
*/
/* To get an idea of what has just happened to cause this *traptakealookatthisdiagram: * *1234<--Windownumber *---------- *TOWI<--Symbolicname * *O==thewindowthatexecutionwasinwhen *therestorewasattempted * *T==thetrapitselfhassave'dusintothis *window * *W==thiswindowistheonewhichisnowinvalid *andmustbemadevalidplusloadedfromthe *stack * *I==thiswindowwillbetheinvalidonewhenwe *aredoneandreturnfromtrapifsuccessful
*/
/* BEGINNING OF PATCH INSTRUCTIONS */
/* On 7-window Sparc the boot code patches fnwin_patch1 *withthefollowinginstruction.
*/
.globl fnwin_patch1_7win, fnwin_patch2_7win
fnwin_patch1_7win: srl %t_wim, 6, %twin_tmp2
fnwin_patch2_7win: and %twin_tmp1, 0x7f, %twin_tmp1 /* END OF PATCH INSTRUCTIONS */
/* Compute what the new %wim is going to be if we retrieve *theproperwindowoffofthestack.
*/ sll %t_wim, 1, %twin_tmp1
fnwin_patch1: srl %t_wim, 7, %twin_tmp2
or %twin_tmp1, %twin_tmp2, %twin_tmp1
fnwin_patch2: and %twin_tmp1, 0xff, %twin_tmp1
wr %twin_tmp1, 0x0, %wim /* Make window 'I' invalid */
andcc %t_psr, PSR_PS, %g0
be fwin_from_user
restore %g0, %g0, %g0 /* Restore to window 'O' */
/* Trapped from kernel, we trust that the kernel does not *'overrestore'sortaspeakandjustgrabthewindow *fromthestackandreturn.Easyenough.
*/
fwin_from_kernel: /* LOCATION: Window 'O' */
restore %g0, %g0, %g0
/* LOCATION: Window 'W' */
LOAD_WINDOW(sp) /* Load it up */
/* Spin the wheel... */
save %g0, %g0, %g0
save %g0, %g0, %g0 /* I'd like to buy a vowel please... */
/* LOCATION: Window 'T' */
/* Now preserve the condition codes in %psr, pause, and *returnfromtrap.Thisisthesimplestcaseofall.
*/
wr %t_psr, 0x0, %psr
WRITE_PAUSE
jmp %t_pc
rett %t_npc
fwin_from_user: /* LOCATION: Window 'O' */
restore %g0, %g0, %g0 /* Restore to window 'W' */
/* LOCATION: Window 'W' */
/* Branch to the stack validation routine */
b srmmu_fwin_stackchk
andcc %sp, 0x7, %g0
/* re-set trap time %wim value */
wr %t_wim, 0x0, %wim
/* Fix users window mask and buffer save count. */
mov 0x1, %g5 sll %g5, %g3, %g5 st %g5, [%curptr + TI_UWINMASK] ! one live user window still st %g0, [%curptr + TI_W_SAVED] ! no windows in the buffer
/* The users stack area is kosher and mapped, load the *windowandfallthroughtothefinishuproutine.
*/
LOAD_WINDOW(sp)
/* Round and round she goes... */
save %g0, %g0, %g0 /* Save to window 'O' */
save %g0, %g0, %g0 /* Save to window 'T' */ /* Where she'll trap nobody knows... */
/* LOCATION: Window 'T' */
fwin_user_finish_up: /* LOCATION: Window 'T' */
wr %t_psr, 0x0, %psr
WRITE_PAUSE
jmp %t_pc
rett %t_npc
/* Here come the architecture specific checks for stack. *mappings.Notethatunlikethewindowoverflowhandler *weonlyneedtocheckwhethertheusercanreadfrom *theappropriateaddresses.Alsonotethatwearein *aninvalidwindowwhichwillbeloaded,andthismeans *thatuntilweactuallyloadthewindowupwearefree *touseanyofthelocalregisterscontainedwithin. * *Onsuccesstheseroutinebranchtofwin_user_stack_is_ok *iftheareaat%spisuserreadableandthewindowstill *needstobeloaded,elsefwin_user_finish_upifthe *routinehasdonetheloadingitself.Onfailure(bogus *userstack)theroutineshallbranchtothelabelcalled *fwin_user_stack_is_bolixed. * *Contrarytothearch-specificwindowoverflowstack *checkroutinesinwof.S,theseroutinesarefreetouse *anyofthelocalregisterstheywanttoasthiswindow *doesnotbelongtoanyoneatthispoint,howeverthe *outsandinsarestillverbotenastheyarepartof *'someoneelses'windowpossibly.
*/
/* Check if the users stack is in kernel vma, then our *trialanderrortechniquebelowwouldsucceedfor *the'wrong'reason.
*/
mov AC_M_SFSR, %l4
cmp %l5, %sp
bleu fwin_user_stack_is_bolixed
LEON_PI( lda [%l4] ASI_LEON_MMUREGS, %g0) ! clear fault status
SUN_PI_( lda [%l4] ASI_M_MMUREGS, %g0) ! clear fault status
/* The technique is, turn off faults on this processor, *justlettheloadrip,thencheckthesfsrtoseeif *afaultdidoccur.Thenweturnonfaulttrapsagain *andbranchconditionallybaseduponwhathappened.
*/
LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %l5) ! read mmu-ctrl reg
SUN_PI_(lda [%g0] ASI_M_MMUREGS, %l5) ! read mmu-ctrl reg
or %l5, 0x2, %l5 ! turn on no-fault bit
LEON_PI(sta %l5, [%g0] ASI_LEON_MMUREGS) ! store it
SUN_PI_(sta %l5, [%g0] ASI_M_MMUREGS) ! store it
/* Cross fingers and go for it. */
LOAD_WINDOW(sp)
/* A penny 'saved'... */
save %g0, %g0, %g0
save %g0, %g0, %g0 /* Is a BADTRAP earned... */
/* LOCATION: Window 'T' */
LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %twin_tmp1) ! load mmu-ctrl again
SUN_PI_(lda [%g0] ASI_M_MMUREGS, %twin_tmp1) ! load mmu-ctrl again
andn %twin_tmp1, 0x2, %twin_tmp1 ! clear no-fault bit
LEON_PI(sta %twin_tmp1, [%g0] ASI_LEON_MMUREGS) ! store it
SUN_PI_(sta %twin_tmp1, [%g0] ASI_M_MMUREGS) ! store it
mov AC_M_SFSR, %twin_tmp2
LEON_PI(lda [%twin_tmp2] ASI_LEON_MMUREGS, %twin_tmp2) ! read fault status
SUN_PI_(lda [%twin_tmp2] ASI_M_MMUREGS, %twin_tmp2) ! read fault status
andcc %twin_tmp2, 0x2, %g0 ! did fault occur?
bne 1f ! yep, cleanup
nop
wr %t_psr, 0x0, %psr
nop
b fwin_user_finish_up + 0x4
nop
/* Did I ever tell you about my window lobotomy? *anyways...fwin_user_stack_is_bolixedexpects *tobeinwindow'W'somakeithappyorelse *wewatchdogbadly.
*/ 1:
restore %g0, %g0, %g0
b fwin_user_stack_is_bolixed ! oh well
restore %g0, %g0, %g0
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.