Ignore:
Timestamp:
2006-08-31T11:05:30Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e0b241f
Parents:
ee454eb
Message:

sparc64 work.
Handle situation when there are more valid windows than NWINDOW - 2 during
the return to userspace in preemtpible_handler().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/trap/trap_table.S

    ree454eb rbeb3926a  
    492492        bnz 1f                                  ! ...skip restoring userspace windows
    493493        nop
     494
     495        /*
     496         * Spills and fills will be processed by the {spill,fill}_1_normal
     497         * handlers.
     498         */
     499        wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
    494500       
    495501        rdpr %cwp, %g1
     
    546552        wrpr %g1, 0, %cwp
    547553        add %g4, %g2, %g2
    548         mov NWINDOW - 2, %g1
     554        cmp %g2, NWINDOW - 2
     555        bg 2f                                   ! fix the CANRESTORE=NWINDOW-1 anomaly
     556        mov NWINDOW - 2, %g1                    ! use dealy slot for both cases
    549557        sub %g1, %g2, %g1
    550558       
     
    554562        wrpr %g2, 0, %cleanwin                  ! avoid information leak
    555563
    556         /*
    557          * Spills and fills will be processed by the {spill,fill}_1_normal
    558          * handlers.
    559          */
    560         wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
    561 
    5625641:
    563565        restore
    564566        retry
     567
     568        /*
     569         * We got here in order to avoid inconsistency of the window state registers.
     570         * If the:
     571         *
     572         *      save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
     573         *
     574         * instruction trapped and spilled a register window into the userspace
     575         * window buffer, we have just restored NWINDOW - 1 register windows.
     576         * However, CANRESTORE can be only NWINDOW - 2 at most.
     577         *
     578         * The solution is to manually switch to (CWP - 1) mod NWINDOW
     579         * and set the window state registers so that:
     580         *
     581         *      CANRESTORE      = NWINDOW - 2
     582         *      CLEANWIN        = NWINDOW - 2
     583         *      CANSAVE         = 0
     584         *      OTHERWIN        = 0
     585         *
     586         * The RESTORE isntruction is therfore to be skipped.
     587         */
     5882:
     589        wrpr %g0, 0, %otherwin
     590        wrpr %g0, 0, %cansave
     591        wrpr %g1, 0, %canrestore
     592        wrpr %g1, 0, %cleanwin
     593
     594        rdpr %cwp, %g1
     595        dec %g1
     596        and %g1, NWINDOW - 1, %g1
     597        wrpr %g1, 0, %cwp                       ! CWP--
     598       
     599        retry
Note: See TracChangeset for help on using the changeset viewer.