Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/context.S

    r245e8399 recc83bd  
    2828
    2929#include <arch/context_offset.h>
    30 #include <arch/arch.h>
    31 #include <arch/regdef.h>
     30
     31/**
     32 * Both context_save_arch() and context_restore_arch() are
     33 * leaf-optimized procedures. This kind of optimization
     34 * is very important and prevents any implicit window
     35 * spill/fill/clean traps in these very core kernel
     36 * functions.
     37 */
     38       
     39#include <arch/context_offset.h>
    3240
    3341.text   
     
    3644.global context_restore_arch
    3745
    38 /*
    39  * context_save_arch() is required not to create its own stack frame. See the
    40  * generic context.h for explanation.
    41  */
    4246context_save_arch:
    43         #
    44         # Force all our active register windows to memory so that we can find
    45         # them there even if e.g. the thread is migrated to another processor.
    46         #
    47         flushw
    48 
    4947        CONTEXT_SAVE_ARCH_CORE %o0
    5048        retl
     
    5351context_restore_arch:
    5452        #
    55         # Forget all previous windows, they are not going to be needed again.
    56         # Enforce a window fill on the next RESTORE instruction by setting
    57         # CANRESTORE to zero and other window configuration registers
    58         # accordingly. Note that the same can be achieved by executing the
    59         # FLUSHW instruction, but since we don't need to remember the previous
    60         # windows, we do the former and save thus some unnecessary window
    61         # spills.
     53        # Flush all active windows.
     54        # This is essential, because CONTEXT_LOAD overwrites
     55        # %sp of CWP - 1 with the value written to %fp of CWP.
     56        # Flushing all active windows mitigates this problem
     57        # as CWP - 1 becomes the overlap window.
    6258        #
    63         rdpr %pstate, %l0
    64         andn %l0, PSTATE_IE_BIT, %l1
    65         wrpr %l1, %pstate
    66         wrpr %g0, 0, %canrestore
    67         wrpr %g0, 0, %otherwin
    68         wrpr %g0, NWINDOWS - 2, %cansave
    69         wrpr %l0, %pstate
    70 
     59        flushw
     60       
    7161        CONTEXT_RESTORE_ARCH_CORE %o0
    7262        retl
Note: See TracChangeset for help on using the changeset viewer.