Changeset d70ebffe in mainline


Ignore:
Timestamp:
2014-10-27T15:10:14Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aef669b
Parents:
ec443d5
Message:

Let the fast MMU traps use exc_dispatch() in their slow-path.

In order to get proper exception accounting, the MMU related traps need
to go through the code in exc_dispatch(). To make this possible, we pass
the DTLB Tag Access register in istate_t in order to make way for the
trap type argument, which needs to be passed as the first argument to
exc_dispatch().

As a collateral change, this commit modifies the istate_t structure to
match the SPARC V9 ABI stack frame layout. It gives us a richer istate_t
with more information in it and also simplifies calculation of stack
offsets inside of preemptible_handler.

Location:
kernel/arch
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/include/arch/stack.h

    rec443d5 rd70ebffe  
    5454#define STACK_ARG_SAVE_AREA_SIZE  (6 * STACK_ITEM_SIZE)
    5555
    56 /**
    57  * Offsets of arguments on stack.
    58  */
    59 #define STACK_ARG0  0
    60 #define STACK_ARG1  4
    61 #define STACK_ARG2  8
    62 #define STACK_ARG3  12
    63 #define STACK_ARG4  16
    64 #define STACK_ARG5  20
    65 #define STACK_ARG6  24
    66 
    6756#endif
    6857
  • kernel/arch/sparc64/include/arch/istate_struct.ag

    rec443d5 rd70ebffe  
    4141
    4242        members : [
     43
     44                #
     45                # Window save area for locals and inputs. Required by ABI.
     46                # Before using these, make sure that the corresponding register
     47                # window has been spilled into memory, otherwise l0-l7 and
     48                # i0-i7 will have undefined values.
     49                #
     50                {
     51                        name : l0,
     52                        type : uint64_t,
     53                },
     54                {
     55                        name : l1,
     56                        type : uint64_t,
     57                },
     58                {
     59                        name : l2,
     60                        type : uint64_t,
     61                },
     62                {
     63                        name : l3,
     64                        type : uint64_t,
     65                },
     66                {
     67                        name : l4,
     68                        type : uint64_t,
     69                },
     70                {
     71                        name : l5,
     72                        type : uint64_t,
     73                },
     74                {
     75                        name : l6,
     76                        type : uint64_t,
     77                },
     78                {
     79                        name : l7,
     80                        type : uint64_t,
     81                },
     82                {
     83                        name : i0,
     84                        type : uint64_t,
     85                },
     86                {
     87                        name : i1,
     88                        type : uint64_t,
     89                },
     90                {
     91                        name : i2,
     92                        type : uint64_t,
     93                },
     94                {
     95                        name : i3,
     96                        type : uint64_t,
     97                },
     98                {
     99                        name : i4,
     100                        type : uint64_t,
     101                },
     102                {
     103                        name : i5,
     104                        type : uint64_t,
     105                },
     106                {
     107                        name : i6,
     108                        type : uint64_t,
     109                },
     110                {
     111                        name : i7,
     112                        type : uint64_t,
     113                },
     114
     115                #
     116                # Six mandatory argument slots, required by the ABI, plus an
     117                # optional argument slot for the 7th argument used by our
     118                # syscalls. Since the preemptible handler is always passing
     119                # integral arguments, undef_arg[0] - undef_arg[5] are always
     120                # undefined.
     121                #
     122                {
     123                        name : undef_arg,
     124                        type : uint64_t,
     125                        elements : 6,
     126                },
     127                {
     128                        name : arg6,
     129                        type : uint64_t,
     130                },
     131
     132                #
     133                # From this point onwards, the istate layout is not dicated by
     134                # the ABI. The only requirement is the stack alignment.
     135                #
     136
    43137                {
    44138                        name : tnpc,
     
    51145                {
    52146                        name : tstate,
     147                        type : uint64_t
     148                },
     149                {
     150                        name : y,
     151                        type : uint64_t,
     152                },
     153
     154                #
     155                # At the moment, these are defined only when needed by the
     156                # preemptible handler, so consider them undefined for now.
     157                #
     158                {
     159                        name : o0,
     160                        type : uint64_t,
     161                },
     162                {
     163                        name : o1,
     164                        type : uint64_t,
     165                },
     166                {
     167                        name : o2,
     168                        type : uint64_t,
     169                },
     170                {
     171                        name : o3,
     172                        type : uint64_t,
     173                },
     174                {
     175                        name : o4,
     176                        type : uint64_t,
     177                },
     178                {
     179                        name : o5,
     180                        type : uint64_t,
     181                },
     182                {
     183                        name : o6,
     184                        type : uint64_t,
     185                },
     186                {
     187                        name : o7,
     188                        type : uint64_t,
     189                },
     190
     191                #
     192                # I/DTLB Tag Access register or zero for non-MMU traps.
     193                #
     194                {
     195                        name : tlb_tag_access,
    53196                        type : uint64_t
    54197                }
  • kernel/arch/sparc64/include/arch/mm/sun4u/tlb.h

    rec443d5 rd70ebffe  
    678678}
    679679
    680 extern void fast_instruction_access_mmu_miss(sysarg_t, istate_t *);
    681 extern void fast_data_access_mmu_miss(tlb_tag_access_reg_t, istate_t *);
    682 extern void fast_data_access_protection(tlb_tag_access_reg_t , istate_t *);
     680extern void fast_instruction_access_mmu_miss(unsigned int, istate_t *);
     681extern void fast_data_access_mmu_miss(unsigned int, istate_t *);
     682extern void fast_data_access_protection(unsigned int, istate_t *);
    683683
    684684extern void dtlb_insert_mapping(uintptr_t, uintptr_t, int, bool, bool);
  • kernel/arch/sparc64/include/arch/trap/sun4u/mmu.h

    rec443d5 rd70ebffe  
    74740:
    7575        wrpr %g0, PSTATE_PRIV_BIT | PSTATE_AG_BIT, %pstate
    76         PREEMPTIBLE_HANDLER fast_instruction_access_mmu_miss
     76        mov TT_FAST_INSTRUCTION_ACCESS_MMU_MISS, %g2
     77        mov VA_IMMU_TAG_ACCESS, %g5
     78        ldxa [%g5] ASI_IMMU, %g5                        ! read the faulting Context and VPN
     79        PREEMPTIBLE_HANDLER exc_dispatch
    7780.endm
    7881
     
    107110        wr %g0, ASI_DMMU, %asi
    108111        ldxa [VA_DMMU_TAG_ACCESS] %asi, %g1             ! read the faulting Context and VPN
    109         set TLB_TAG_ACCESS_CONTEXT_MASK, %g2
     112        ldx [%g7 + %lo(tlb_tag_access_context_mask)], %g2
    110113        andcc %g1, %g2, %g3                             ! get Context
    111114        bnz %xcc, 0f                                    ! Context is non-zero
     
    138141        wrpr %g0, PSTATE_PRIV_BIT | PSTATE_AG_BIT, %pstate
    139142
    140         /*
    141          * Read the Tag Access register for the higher-level handler.
    142          * This is necessary to survive nested DTLB misses.
    143          */     
    144         ldxa [VA_DMMU_TAG_ACCESS] %asi, %g2
    145 
    146         /*
    147          * g2 will be passed as an argument to fast_data_access_mmu_miss().
    148          */
    149         PREEMPTIBLE_HANDLER fast_data_access_mmu_miss
     143        mov TT_FAST_DATA_ACCESS_MMU_MISS, %g2
     144        ldxa [VA_DMMU_TAG_ACCESS] %asi, %g5             ! read the faulting Context and VPN
     145        PREEMPTIBLE_HANDLER exc_dispatch
    150146.endm
    151147
     
    164160        wrpr %g0, PSTATE_PRIV_BIT | PSTATE_AG_BIT, %pstate
    165161
    166         /*
    167          * Read the Tag Access register for the higher-level handler.
    168          * This is necessary to survive nested DTLB misses.
    169          */     
    170         mov VA_DMMU_TAG_ACCESS, %g2
    171         ldxa [%g2] ASI_DMMU, %g2
    172 
    173         /*
    174          * g2 will be passed as an argument to fast_data_access_mmu_miss().
    175          */
    176         PREEMPTIBLE_HANDLER fast_data_access_protection
     162        mov TT_FAST_DATA_ACCESS_PROTECTION, %g2
     163        mov VA_DMMU_TAG_ACCESS, %g5
     164        ldxa [%g5] ASI_DMMU, %g5                        ! read the faulting Context and VPN
     165        PREEMPTIBLE_HANDLER exc_dispatch
    177166.endm
    178167
  • kernel/arch/sparc64/include/arch/trap/trap_table.h

    rec443d5 rd70ebffe  
    4343#define TRAP_TABLE_SIZE         (TRAP_TABLE_ENTRY_COUNT * TRAP_TABLE_ENTRY_SIZE)
    4444
    45 #define ISTATE_END_OFFSET(o)    ((o) - ISTATE_SIZE)
    46 
    47 /*
    48  * The one STACK_ITEM_SIZE is counted for space holding the 7th
    49  * argument to syscall_handler (i.e. syscall number) and the other
    50  * STACK_ITEM_SIZE is counted because of the required alignment.
    51  */
    52 #define PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE \
    53     (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE + \
    54     (2 * STACK_ITEM_SIZE) + (ISTATE_SIZE + 9 * 8))
    55 /* <-- istate_t ends here */
    56 #define SAVED_TSTATE    ISTATE_END_OFFSET(ISTATE_OFFSET_TSTATE)
    57 #define SAVED_TPC       ISTATE_END_OFFSET(ISTATE_OFFSET_TPC)
    58 #define SAVED_TNPC      ISTATE_END_OFFSET(ISTATE_OFFSET_TNPC)
    59 /* <-- istate_t begins here */
    60 #define SAVED_Y         -(1 * 8 + ISTATE_SIZE)
    61 #define SAVED_I0        -(2 * 8 + ISTATE_SIZE)
    62 #define SAVED_I1        -(3 * 8 + ISTATE_SIZE)
    63 #define SAVED_I2        -(4 * 8 + ISTATE_SIZE)
    64 #define SAVED_I3        -(5 * 8 + ISTATE_SIZE)
    65 #define SAVED_I4        -(6 * 8 + ISTATE_SIZE)
    66 #define SAVED_I5        -(7 * 8 + ISTATE_SIZE)
    67 #define SAVED_I6        -(8 * 8 + ISTATE_SIZE)
    68 #define SAVED_I7        -(9 * 8 + ISTATE_SIZE)
    69 
    7045#ifndef __ASM__
    7146
     
    8055extern trap_table_entry_t trap_table[TRAP_TABLE_ENTRY_COUNT];
    8156extern trap_table_entry_t trap_table_save[TRAP_TABLE_ENTRY_COUNT];
     57
    8258#endif /* !__ASM__ */
    8359
  • kernel/arch/sparc64/src/debug/stacktrace.c

    rec443d5 rd70ebffe  
    4242#include <arch/trap/trap_table.h>
    4343
     44#include <arch/istate_struct.h>
     45
    4446#if defined(SUN4V)
    4547#include <arch/sun4v/arch.h>
     
    6264
    6365        kstack += STACK_BIAS;
    64         kstack -= PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE;
     66        kstack -= ISTATE_SIZE;
    6567
    6668        if (THREAD && (ctx->fp == kstack))
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    rec443d5 rd70ebffe  
    194194
    195195/** ITLB miss handler. */
    196 void fast_instruction_access_mmu_miss(sysarg_t unused, istate_t *istate)
     196void fast_instruction_access_mmu_miss(unsigned int tt, istate_t *istate)
    197197{
    198198        size_t index = (istate->tpc >> MMU_PAGE_WIDTH) % MMU_PAGES_PER_PAGE;
     
    224224 * low-level, assembly language part of the fast_data_access_mmu_miss handler.
    225225 *
    226  * @param tag           Content of the TLB Tag Access register as it existed
    227  *                      when the trap happened. This is to prevent confusion
    228  *                      created by clobbered Tag Access register during a nested
    229  *                      DTLB miss.
     226 * @param tt            Trap type.
    230227 * @param istate        Interrupted state saved on the stack.
    231228 */
    232 void fast_data_access_mmu_miss(tlb_tag_access_reg_t tag, istate_t *istate)
    233 {
     229void fast_data_access_mmu_miss(unsigned int tt, istate_t *istate)
     230{
     231        tlb_tag_access_reg_t tag;
    234232        uintptr_t page_8k;
    235233        uintptr_t page_16k;
     
    238236        as_t *as = AS;
    239237
     238        tag.value = istate->tlb_tag_access;
    240239        page_8k = (uint64_t) tag.vpn << MMU_PAGE_WIDTH;
    241240        page_16k = ALIGN_DOWN(page_8k, PAGE_SIZE);
     
    276275/** DTLB protection fault handler.
    277276 *
    278  * @param tag           Content of the TLB Tag Access register as it existed
    279  *                      when the trap happened. This is to prevent confusion
    280  *                      created by clobbered Tag Access register during a nested
    281  *                      DTLB miss.
     277 * @param tt            Trap type.
    282278 * @param istate        Interrupted state saved on the stack.
    283279 */
    284 void fast_data_access_protection(tlb_tag_access_reg_t tag, istate_t *istate)
    285 {
     280void fast_data_access_protection(unsigned int tt, istate_t *istate)
     281{
     282        tlb_tag_access_reg_t tag;
    286283        uintptr_t page_16k;
    287284        size_t index;
     
    289286        as_t *as = AS;
    290287
     288        tag.value = istate->tlb_tag_access;
    291289        page_16k = ALIGN_DOWN((uint64_t) tag.vpn << MMU_PAGE_WIDTH, PAGE_SIZE);
    292290        index = tag.vpn % MMU_PAGES_PER_PAGE;   /* 16K-page emulation */
  • kernel/arch/sparc64/src/sun4u/start.S

    rec443d5 rd70ebffe  
    401401
    402402/*
    403  * The fast_data_access_mmu_miss_data_hi label and the end_of_identity and
    404  * kernel_8k_tlb_data_template variables are meant to stay together,
    405  * aligned on 16B boundary.
     403 * The fast_data_access_mmu_miss_data_hi label, the end_of_identity,
     404 * kernel_8k_tlb_data_template and tlb_tag_access_context_mask variables
     405 * are meant to stay together, aligned on a 32B boundary.
    406406 */
    407407.global fast_data_access_mmu_miss_data_hi
    408408.global end_of_identity
    409409.global kernel_8k_tlb_data_template
    410 
    411 .align 16
     410.global tlb_tag_access_context_mask
     411
     412.align 32
    412413/*
    413414 * This label is used by the fast_data_access_MMU_miss trap handler.
     
    435436#endif /* CONFIG_VIRT_IDX_DCACHE */
    436437
     438/*
     439 * This variable is used by the fast_data_access_MMU_miss trap handler.
     440 * It allows us to save one precious instruction slot of this handler.
     441 */
     442tlb_tag_access_context_mask:
     443        .quad TLB_TAG_ACCESS_CONTEXT_MASK
     444
  • kernel/arch/sparc64/src/trap/interrupt.c

    rec443d5 rd70ebffe  
    3737#include <arch/trap/interrupt.h>
    3838#include <arch/trap/exception.h>
     39#include <arch/trap/mmu.h>
    3940#include <arch/sparc64.h>
    4041#include <interrupt.h>
     
    120121            interrupt);
    121122#endif
    122        
     123
     124        exc_register(TT_FAST_INSTRUCTION_ACCESS_MMU_MISS,
     125            "fast_instruction_access_mmu_miss", true,
     126            fast_instruction_access_mmu_miss);
     127        exc_register(TT_FAST_DATA_ACCESS_MMU_MISS,
     128            "fast_data_access_mmu_miss", true,
     129            fast_data_access_mmu_miss);
     130        exc_register(TT_FAST_DATA_ACCESS_PROTECTION,
     131            "fast_data_access_protection", true,
     132            fast_data_access_protection);       
    123133}
    124134
  • kernel/arch/sparc64/src/trap/sun4u/trap_table.S

    rec443d5 rd70ebffe  
    6464        wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
    6565        mov TT_INSTRUCTION_ACCESS_EXCEPTION, %g2
     66        clr %g5
    6667        PREEMPTIBLE_HANDLER exc_dispatch
    6768
     
    7172instruction_access_error_tl0:
    7273        mov TT_INSTRUCTION_ACCESS_ERROR, %g2
     74        clr %g5
    7375        PREEMPTIBLE_HANDLER exc_dispatch
    7476
     
    7880illegal_instruction_tl0:
    7981        mov TT_ILLEGAL_INSTRUCTION, %g2
     82        clr %g5
    8083        PREEMPTIBLE_HANDLER exc_dispatch
    8184
     
    8588privileged_opcode_tl0:
    8689        mov TT_PRIVILEGED_OPCODE, %g2
     90        clr %g5
    8791        PREEMPTIBLE_HANDLER exc_dispatch
    8892
     
    9296unimplemented_LDD_tl0:
    9397        mov TT_UNIMPLEMENTED_LDD, %g2
     98        clr %g5
    9499        PREEMPTIBLE_HANDLER exc_dispatch
    95100
     
    99104unimplemented_STD_tl0:
    100105        mov TT_UNIMPLEMENTED_STD, %g2
     106        clr %g5
    101107        PREEMPTIBLE_HANDLER exc_dispatch
    102108
     
    106112fp_disabled_tl0:
    107113        mov TT_FP_DISABLED, %g2
     114        clr %g5
    108115        PREEMPTIBLE_HANDLER exc_dispatch
    109116
     
    113120fp_exception_ieee_754_tl0:
    114121        mov TT_FP_EXCEPTION_IEEE_754, %g2
     122        clr %g5
    115123        PREEMPTIBLE_HANDLER exc_dispatch
    116124
     
    120128fp_exception_other_tl0:
    121129        mov TT_FP_EXCEPTION_OTHER, %g2
     130        clr %g5
    122131        PREEMPTIBLE_HANDLER exc_dispatch
    123132
     
    127136tag_overflow_tl0:
    128137        mov TT_TAG_OVERFLOW, %g2
     138        clr %g5
    129139        PREEMPTIBLE_HANDLER exc_dispatch
    130140
     
    140150division_by_zero_tl0:
    141151        mov TT_DIVISION_BY_ZERO, %g2
     152        clr %g5
    142153        PREEMPTIBLE_HANDLER exc_dispatch
    143154
     
    148159        wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
    149160        mov TT_DATA_ACCESS_EXCEPTION, %g2
     161        clr %g5
    150162        PREEMPTIBLE_HANDLER exc_dispatch
    151163
     
    155167data_access_error_tl0:
    156168        mov TT_DATA_ACCESS_ERROR, %g2
     169        clr %g5
    157170        PREEMPTIBLE_HANDLER exc_dispatch
    158171
     
    162175mem_address_not_aligned_tl0:
    163176        mov TT_MEM_ADDRESS_NOT_ALIGNED, %g2
     177        clr %g5
    164178        PREEMPTIBLE_HANDLER exc_dispatch
    165179
     
    169183LDDF_mem_address_not_aligned_tl0:
    170184        mov TT_LDDF_MEM_ADDRESS_NOT_ALIGNED, %g2
     185        clr %g5
    171186        PREEMPTIBLE_HANDLER exc_dispatch
    172187
     
    176191STDF_mem_address_not_aligned_tl0:
    177192        mov TT_STDF_MEM_ADDRESS_NOT_ALIGNED, %g2
     193        clr %g5
    178194        PREEMPTIBLE_HANDLER exc_dispatch
    179195
     
    183199privileged_action_tl0:
    184200        mov TT_PRIVILEGED_ACTION, %g2
     201        clr %g5
    185202        PREEMPTIBLE_HANDLER exc_dispatch
    186203
     
    190207LDQF_mem_address_not_aligned_tl0:
    191208        mov TT_LDQF_MEM_ADDRESS_NOT_ALIGNED, %g2
     209        clr %g5
    192210        PREEMPTIBLE_HANDLER exc_dispatch
    193211
     
    197215STQF_mem_address_not_aligned_tl0:
    198216        mov TT_STQF_MEM_ADDRESS_NOT_ALIGNED, %g2
     217        clr %g5
    199218        PREEMPTIBLE_HANDLER exc_dispatch
    200219
     
    204223interrupt_level_1_handler_tl0:
    205224        mov TT_INTERRUPT_LEVEL_1, %g2
     225        clr %g5
    206226        PREEMPTIBLE_HANDLER exc_dispatch
    207227
     
    211231interrupt_level_2_handler_tl0:
    212232        mov TT_INTERRUPT_LEVEL_2, %g2
     233        clr %g5
    213234        PREEMPTIBLE_HANDLER exc_dispatch
    214235
     
    218239interrupt_level_3_handler_tl0:
    219240        mov TT_INTERRUPT_LEVEL_3, %g2
     241        clr %g5
    220242        PREEMPTIBLE_HANDLER exc_dispatch
    221243
     
    225247interrupt_level_4_handler_tl0:
    226248        mov TT_INTERRUPT_LEVEL_4, %g2
     249        clr %g5
    227250        PREEMPTIBLE_HANDLER exc_dispatch
    228251
     
    232255interrupt_level_5_handler_tl0:
    233256        mov TT_INTERRUPT_LEVEL_5, %g2
     257        clr %g5
    234258        PREEMPTIBLE_HANDLER exc_dispatch
    235259
     
    239263interrupt_level_6_handler_tl0:
    240264        mov TT_INTERRUPT_LEVEL_6, %g2
     265        clr %g5
    241266        PREEMPTIBLE_HANDLER exc_dispatch
    242267
     
    246271interrupt_level_7_handler_tl0:
    247272        mov TT_INTERRUPT_LEVEL_7, %g2
     273        clr %g5
    248274        PREEMPTIBLE_HANDLER exc_dispatch
    249275
     
    253279interrupt_level_8_handler_tl0:
    254280        mov TT_INTERRUPT_LEVEL_8, %g2
     281        clr %g5
    255282        PREEMPTIBLE_HANDLER exc_dispatch
    256283
     
    260287interrupt_level_9_handler_tl0:
    261288        mov TT_INTERRUPT_LEVEL_9, %g2
     289        clr %g5
    262290        PREEMPTIBLE_HANDLER exc_dispatch
    263291
     
    267295interrupt_level_10_handler_tl0:
    268296        mov TT_INTERRUPT_LEVEL_10, %g2
     297        clr %g5
    269298        PREEMPTIBLE_HANDLER exc_dispatch
    270299
     
    274303interrupt_level_11_handler_tl0:
    275304        mov TT_INTERRUPT_LEVEL_11, %g2
     305        clr %g5
    276306        PREEMPTIBLE_HANDLER exc_dispatch
    277307
     
    281311interrupt_level_12_handler_tl0:
    282312        mov TT_INTERRUPT_LEVEL_12, %g2
     313        clr %g5
    283314        PREEMPTIBLE_HANDLER exc_dispatch
    284315
     
    288319interrupt_level_13_handler_tl0:
    289320        mov TT_INTERRUPT_LEVEL_13, %g2
     321        clr %g5
    290322        PREEMPTIBLE_HANDLER exc_dispatch
    291323
     
    295327interrupt_level_14_handler_tl0:
    296328        mov TT_INTERRUPT_LEVEL_14, %g2
     329        clr %g5
    297330        PREEMPTIBLE_HANDLER exc_dispatch
    298331
     
    302335interrupt_level_15_handler_tl0:
    303336        mov TT_INTERRUPT_LEVEL_15, %g2
     337        clr %g5
    304338        PREEMPTIBLE_HANDLER exc_dispatch
    305339
     
    309343interrupt_vector_trap_handler_tl0:
    310344        mov TT_INTERRUPT_VECTOR_TRAP, %g2
     345        clr %g5
    311346        PREEMPTIBLE_HANDLER exc_dispatch
    312347
     
    377412.global trap_instruction_\cur\()_tl0
    378413trap_instruction_\cur\()_tl0:
     414        mov \cur, %g2
    379415        ba %xcc, trap_instruction_handler
    380         mov \cur, %g2
     416        clr %g5
    381417.endr
    382418
     
    392428        wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
    393429        mov TT_INSTRUCTION_ACCESS_EXCEPTION, %g2
     430        clr %g5
    394431        PREEMPTIBLE_HANDLER exc_dispatch
    395432
     
    400437        wrpr %g0, 1, %tl
    401438        mov TT_INSTRUCTION_ACCESS_ERROR, %g2
     439        clr %g5
    402440        PREEMPTIBLE_HANDLER exc_dispatch
    403441
     
    408446        wrpr %g0, 1, %tl
    409447        mov TT_ILLEGAL_INSTRUCTION, %g2
     448        clr %g5
    410449        PREEMPTIBLE_HANDLER exc_dispatch
    411450
     
    422461        wrpr %g0, 1, %tl
    423462        mov TT_DIVISION_BY_ZERO, %g2
     463        clr %g5
    424464        PREEMPTIBLE_HANDLER exc_dispatch
    425465
     
    431471        wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
    432472        mov TT_DATA_ACCESS_EXCEPTION, %g2
     473        clr %g5
    433474        PREEMPTIBLE_HANDLER exc_dispatch
    434475
     
    439480        wrpr %g0, 1, %tl
    440481        mov TT_DATA_ACCESS_ERROR, %g2
     482        clr %g5
    441483        PREEMPTIBLE_HANDLER exc_dispatch
    442484
     
    447489        wrpr %g0, 1, %tl
    448490        mov TT_MEM_ADDRESS_NOT_ALIGNED, %g2
     491        clr %g5
    449492        PREEMPTIBLE_HANDLER exc_dispatch
    450493
     
    512555 *      %g1             Address of function to call if this is not a syscall.
    513556 *      %g2             First argument for the function.
     557 *      %g5             I/DTLB_TAG_ACCESS register if applicable.
    514558 *      %g6             Pre-set as kernel stack base if trap from userspace.
    515559 *      %g7             Pre-set as address of the userspace window buffer.
    516560 */
    517561.macro PREEMPTIBLE_HANDLER_TEMPLATE is_syscall
    518         /*
    519          * ASSERT(%tl == 1)
    520          */
    521         rdpr %tl, %g3
    522         cmp %g3, 1
    523         be %xcc, 1f
    524         nop
    525         ! this is for debugging, if we ever get here it will be easy to find
    526 0:      ba,a %xcc, 0b
    527 
    528 1:
    529562.if NOT(\is_syscall)
    530563        rdpr %tstate, %g3
     
    544577        bnz %xcc, 0f                            ! ...skip setting of kernel stack and primary context
    545578        nop
    546        
    547579.endif
     580
    548581        /*
    549582         * Normal window spills will go to the userspace window buffer.
     
    558591         * and the new window's %fp.
    559592         */
    560         save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
     593        save %g6, -ISTATE_SIZE, %sp
    561594
    562595.if \is_syscall
     
    590623        ba,a %xcc, 1f
    5916240:
    592         save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
     625        save %sp, -ISTATE_SIZE, %sp
    593626
    594627        /*
     
    612645.else
    613646        ! store the syscall number on the stack as 7th argument
    614         stx %g2, [%sp + STACK_WINDOW_SAVE_AREA_SIZE + STACK_BIAS + STACK_ARG6]
     647        stx %g2, [%sp + STACK_BIAS + ISTATE_OFFSET_ARG6]
    615648.endif
    616649
    617650        /*
    618          * Save TSTATE, TPC and TNPC aside.
     651         * Save TSTATE, TPC, TNPC and I/DTLB_TAG_ACCESS aside.
    619652         */
    620653        rdpr %tstate, %g1
     
    623656        rd %y, %g4
    624657
    625         stx %g1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE]
    626         stx %g2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC]
    627         stx %g3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC]
     658        stx %g1, [%sp + STACK_BIAS + ISTATE_OFFSET_TSTATE]
     659        stx %g2, [%sp + STACK_BIAS + ISTATE_OFFSET_TPC]
     660        stx %g3, [%sp + STACK_BIAS + ISTATE_OFFSET_TNPC]
     661        stx %g5, [%sp + STACK_BIAS + ISTATE_OFFSET_TLB_TAG_ACCESS]
    628662
    629663        /*
    630664         * Save the Y register.
    631          * This register is deprecated according to SPARC V9 specification
    632          * and is only present for backward compatibility with previous
    633          * versions of the SPARC architecture.
    634          * Surprisingly, gcc makes use of this register without a notice.
    635          */
    636         stx %g4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y]
     665         */
     666        stx %g4, [%sp + STACK_BIAS + ISTATE_OFFSET_Y]
    637667       
    638668        wrpr %g0, 0, %tl
     
    645675         */
    646676        call %l0
    647         add %sp, PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC, %o1
     677        add %sp, STACK_BIAS, %o1
    648678.else
    649679        /*
     
    663693         * Read TSTATE, TPC and TNPC from saved copy.
    664694         */
    665         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE], %g1
    666         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC], %g2
    667         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC], %g3
     695        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_TSTATE], %g1
     696        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_TPC], %g2
     697        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_TNPC], %g3
    668698
    669699        /*
     
    686716         * Restore Y.
    687717         */
    688         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y], %g4
     718        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_Y], %g4
    689719        wr %g4, %y
    690720
     
    726756         */
    727757        mov %sp, %g2
    728         stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
    729         stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
    730         stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
    731         stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
    732         stx %i4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4]
    733         stx %i5, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5]
    734         stx %i6, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6]
    735         stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7]
     758        stx %i0, [%sp + STACK_BIAS + ISTATE_OFFSET_O0]
     759        stx %i1, [%sp + STACK_BIAS + ISTATE_OFFSET_O1]
     760        stx %i2, [%sp + STACK_BIAS + ISTATE_OFFSET_O2]
     761        stx %i3, [%sp + STACK_BIAS + ISTATE_OFFSET_O3]
     762        stx %i4, [%sp + STACK_BIAS + ISTATE_OFFSET_O4]
     763        stx %i5, [%sp + STACK_BIAS + ISTATE_OFFSET_O5]
     764        stx %i6, [%sp + STACK_BIAS + ISTATE_OFFSET_O6]
     765        stx %i7, [%sp + STACK_BIAS + ISTATE_OFFSET_O7]
    736766        wrpr %l0, 0, %cwp
    737767        mov %g2, %sp
    738         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0
    739         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1
    740         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2], %i2
    741         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3], %i3
    742         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4], %i4
    743         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5], %i5
    744         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6
    745         ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7
     768        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O0], %i0
     769        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O1], %i1
     770        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O2], %i2
     771        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O3], %i3
     772        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O4], %i4
     773        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O5], %i5
     774        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O6], %i6
     775        ldx [%sp + STACK_BIAS + ISTATE_OFFSET_O7], %i7
    746776
    747777        /*
Note: See TracChangeset for help on using the changeset viewer.