Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/mm/tlb.c

    r7e752b2 r925be4e  
    2727 */
    2828
    29 /** @addtogroup ia64mm
     29/** @addtogroup ia64mm 
    3030 * @{
    3131 */
     
    5353#include <interrupt.h>
    5454
    55 #define IO_FRAME_BASE 0xFFFFC000000
    56 
    5755/** Invalidate all TLB entries. */
    5856void tlb_invalidate_all(void)
     
    6159        uintptr_t adr;
    6260        uint32_t count1, count2, stride1, stride2;
    63        
     61               
    6462        unsigned int i, j;
    65        
     63               
    6664        adr = PAL_PTCE_INFO_BASE();
    6765        count1 = PAL_PTCE_INFO_COUNT1();
     
    6967        stride1 = PAL_PTCE_INFO_STRIDE1();
    7068        stride2 = PAL_PTCE_INFO_STRIDE2();
    71        
     69               
    7270        ipl = interrupts_disable();
    73        
     71
    7472        for (i = 0; i < count1; i++) {
    7573                for (j = 0; j < count2; j++) {
    7674                        asm volatile (
    77                                 "ptc.e %[adr] ;;"
    78                                 :: [adr] "r" (adr)
     75                                "ptc.e %0 ;;"
     76                                :
     77                                : "r" (adr)
    7978                        );
    8079                        adr += stride2;
     
    8281                adr += stride1;
    8382        }
    84        
     83
    8584        interrupts_restore(ipl);
    86        
     85
    8786        srlz_d();
    8887        srlz_i();
    89        
    9088#ifdef CONFIG_VHPT
    9189        vhpt_invalidate_all();
    92 #endif
     90#endif 
    9391}
    9492
    9593/** Invalidate entries belonging to an address space.
    9694 *
    97  * @param asid Address space identifier.
    98  *
     95 * @param asid          Address space identifier.
    9996 */
    10097void tlb_invalidate_asid(asid_t asid)
     
    106103void tlb_invalidate_pages(asid_t asid, uintptr_t page, size_t cnt)
    107104{
    108         region_register_t rr;
     105        region_register rr;
    109106        bool restore_rr = false;
    110107        int b = 0;
    111108        int c = cnt;
    112        
     109
    113110        uintptr_t va;
    114111        va = page;
    115        
     112
    116113        rr.word = rr_read(VA2VRN(va));
    117114        if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) {
     
    120117                 * Save the old content of the register and replace the RID.
    121118                 */
    122                 region_register_t rr0;
    123                
     119                region_register rr0;
     120
    124121                rr0 = rr;
    125122                rr0.map.rid = ASID2RID(asid, VA2VRN(va));
     
    129126        }
    130127       
    131         while (c >>= 1)
     128        while(c >>= 1)
    132129                b++;
    133130        b >>= 1;
     
    172169                break;
    173170        }
    174        
    175         for (; va < (page + cnt * PAGE_SIZE); va += (1 << ps))
    176                 asm volatile (
    177                         "ptc.l %[va], %[ps] ;;"
    178                         :: [va]"r" (va),
    179                            [ps] "r" (ps << 2)
    180                 );
    181        
     171        for(; va < (page + cnt * PAGE_SIZE); va += (1 << ps))
     172                asm volatile ("ptc.l %0, %1;;" :: "r" (va), "r" (ps << 2));
    182173        srlz_d();
    183174        srlz_i();
     
    192183/** Insert data into data translation cache.
    193184 *
    194  * @param va    Virtual page address.
    195  * @param asid  Address space identifier.
    196  * @param entry The rest of TLB entry as required by TLB insertion
    197  *              format.
    198  *
     185 * @param va            Virtual page address.
     186 * @param asid          Address space identifier.
     187 * @param entry         The rest of TLB entry as required by TLB insertion
     188 *                      format.
    199189 */
    200190void dtc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry)
     
    205195/** Insert data into instruction translation cache.
    206196 *
    207  * @param va    Virtual page address.
    208  * @param asid  Address space identifier.
    209  * @param entry The rest of TLB entry as required by TLB insertion
    210  *              format.
     197 * @param va            Virtual page address.
     198 * @param asid          Address space identifier.
     199 * @param entry         The rest of TLB entry as required by TLB insertion
     200 *                      format.
    211201 */
    212202void itc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry)
     
    217207/** Insert data into instruction or data translation cache.
    218208 *
    219  * @param va    Virtual page address.
    220  * @param asid  Address space identifier.
    221  * @param entry The rest of TLB entry as required by TLB insertion
    222  *              format.
    223  * @param dtc   If true, insert into data translation cache, use
    224  *              instruction translation cache otherwise.
    225  *
     209 * @param va            Virtual page address.
     210 * @param asid          Address space identifier.
     211 * @param entry         The rest of TLB entry as required by TLB insertion
     212 *                      format.
     213 * @param dtc           If true, insert into data translation cache, use
     214 *                      instruction translation cache otherwise.
    226215 */
    227216void tc_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtc)
    228217{
    229         region_register_t rr;
     218        region_register rr;
    230219        bool restore_rr = false;
    231        
     220
    232221        rr.word = rr_read(VA2VRN(va));
    233222        if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) {
     
    236225                 * Save the old content of the register and replace the RID.
    237226                 */
    238                 region_register_t rr0;
    239                
     227                region_register rr0;
     228
    240229                rr0 = rr;
    241230                rr0.map.rid = ASID2RID(asid, VA2VRN(va));
     
    246235       
    247236        asm volatile (
    248                 "mov r8 = psr ;;\n"
    249                 "rsm %[mask] ;;\n"                 /* PSR_IC_MASK */
    250                 "srlz.d ;;\n"
    251                 "srlz.i ;;\n"
    252                 "mov cr.ifa = %[va]\n"             /* va */
    253                 "mov cr.itir = %[word1] ;;\n"      /* entry.word[1] */
    254                 "cmp.eq p6, p7 = %[dtc], r0 ;;\n"  /* decide between itc and dtc */
    255                 "(p6) itc.i %[word0] ;;\n"
    256                 "(p7) itc.d %[word0] ;;\n"
    257                 "mov psr.l = r8 ;;\n"
    258                 "srlz.d ;;\n"
    259                 :: [mask] "i" (PSR_IC_MASK),
    260                    [va] "r" (va),
    261                    [word0] "r" (entry.word[0]),
    262                    [word1] "r" (entry.word[1]),
    263                    [dtc] "r" (dtc)
     237                "mov r8 = psr;;\n"
     238                "rsm %0;;\n"                    /* PSR_IC_MASK */
     239                "srlz.d;;\n"
     240                "srlz.i;;\n"
     241                "mov cr.ifa = %1\n"             /* va */
     242                "mov cr.itir = %2;;\n"          /* entry.word[1] */
     243                "cmp.eq p6,p7 = %4,r0;;\n"      /* decide between itc and dtc */
     244                "(p6) itc.i %3;;\n"
     245                "(p7) itc.d %3;;\n"
     246                "mov psr.l = r8;;\n"
     247                "srlz.d;;\n"
     248                :
     249                : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]),
     250                    "r" (entry.word[0]), "r" (dtc)
    264251                : "p6", "p7", "r8"
    265252        );
     
    274261/** Insert data into instruction translation register.
    275262 *
    276  * @param va    Virtual page address.
    277  * @param asid  Address space identifier.
    278  * @param entry The rest of TLB entry as required by TLB insertion
    279  *              format.
    280  * @param tr    Translation register.
    281  *
    282  */
    283 void itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)
     263 * @param va            Virtual page address.
     264 * @param asid          Address space identifier.
     265 * @param entry         The rest of TLB entry as required by TLB insertion
     266 *                      format.
     267 * @param tr            Translation register.
     268 */
     269void
     270itr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)
    284271{
    285272        tr_mapping_insert(va, asid, entry, false, tr);
     
    288275/** Insert data into data translation register.
    289276 *
    290  * @param va    Virtual page address.
    291  * @param asid  Address space identifier.
    292  * @param entry The rest of TLB entry as required by TLB insertion
    293  *              format.
    294  * @param tr    Translation register.
    295  *
    296  */
    297 void dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)
     277 * @param va            Virtual page address.
     278 * @param asid          Address space identifier.
     279 * @param entry         The rest of TLB entry as required by TLB insertion
     280 *                      format.
     281 * @param tr            Translation register.
     282 */
     283void
     284dtr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, size_t tr)
    298285{
    299286        tr_mapping_insert(va, asid, entry, true, tr);
     
    302289/** Insert data into instruction or data translation register.
    303290 *
    304  * @param va    Virtual page address.
    305  * @param asid  Address space identifier.
    306  * @param entry The rest of TLB entry as required by TLB insertion
    307  *              format.
    308  * @param dtr   If true, insert into data translation register, use
    309  *              instruction translation register otherwise.
    310  * @param tr    Translation register.
    311  *
    312  */
    313 void tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr,
     291 * @param va            Virtual page address.
     292 * @param asid          Address space identifier.
     293 * @param entry         The rest of TLB entry as required by TLB insertion
     294 *                      format.
     295 * @param dtr           If true, insert into data translation register, use
     296 *                      instruction translation register otherwise.
     297 * @param tr            Translation register.
     298 */
     299void
     300tr_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry, bool dtr,
    314301    size_t tr)
    315302{
    316         region_register_t rr;
     303        region_register rr;
    317304        bool restore_rr = false;
    318        
     305
    319306        rr.word = rr_read(VA2VRN(va));
    320307        if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) {
     
    323310                 * Save the old content of the register and replace the RID.
    324311                 */
    325                 region_register_t rr0;
    326                
     312                region_register rr0;
     313
    327314                rr0 = rr;
    328315                rr0.map.rid = ASID2RID(asid, VA2VRN(va));
     
    331318                srlz_i();
    332319        }
    333        
     320
    334321        asm volatile (
    335                 "mov r8 = psr ;;\n"
    336                 "rsm %[mask] ;;\n"                       /* PSR_IC_MASK */
    337                 "srlz.d ;;\n"
    338                 "srlz.i ;;\n"
    339                 "mov cr.ifa = %[va]\n"                   /* va */
    340                 "mov cr.itir = %[word1] ;;\n"            /* entry.word[1] */
    341                 "cmp.eq p6, p7 = %[dtr], r0 ;;\n"        /* decide between itr and dtr */
    342                 "(p6) itr.i itr[%[tr]] = %[word0] ;;\n"
    343                 "(p7) itr.d dtr[%[tr]] = %[word0] ;;\n"
    344                 "mov psr.l = r8 ;;\n"
    345                 "srlz.d ;;\n"
    346                 :: [mask] "i" (PSR_IC_MASK),
    347                    [va] "r" (va),
    348                    [word1] "r" (entry.word[1]),
    349                    [word0] "r" (entry.word[0]),
    350                    [tr] "r" (tr),
    351                    [dtr] "r" (dtr)
     322                "mov r8 = psr;;\n"
     323                "rsm %0;;\n"                    /* PSR_IC_MASK */
     324                "srlz.d;;\n"
     325                "srlz.i;;\n"
     326                "mov cr.ifa = %1\n"             /* va */                 
     327                "mov cr.itir = %2;;\n"          /* entry.word[1] */
     328                "cmp.eq p6,p7 = %5,r0;;\n"      /* decide between itr and dtr */
     329                "(p6) itr.i itr[%4] = %3;;\n"
     330                "(p7) itr.d dtr[%4] = %3;;\n"
     331                "mov psr.l = r8;;\n"
     332                "srlz.d;;\n"
     333                :
     334                : "i" (PSR_IC_MASK), "r" (va), "r" (entry.word[1]),
     335                    "r" (entry.word[0]), "r" (tr), "r" (dtr)
    352336                : "p6", "p7", "r8"
    353337        );
     
    362346/** Insert data into DTLB.
    363347 *
    364  * @param page  Virtual page address including VRN bits.
    365  * @param frame Physical frame address.
    366  * @param dtr   If true, insert into data translation register, use data
    367  *              translation cache otherwise.
    368  * @param tr    Translation register if dtr is true, ignored otherwise.
    369  *
    370  */
    371 void dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr,
     348 * @param page          Virtual page address including VRN bits.
     349 * @param frame         Physical frame address.
     350 * @param dtr           If true, insert into data translation register, use data
     351 *                      translation cache otherwise.
     352 * @param tr            Translation register if dtr is true, ignored otherwise.
     353 */
     354void
     355dtlb_kernel_mapping_insert(uintptr_t page, uintptr_t frame, bool dtr,
    372356    size_t tr)
    373357{
     
    377361        entry.word[1] = 0;
    378362       
    379         entry.p = true;           /* present */
     363        entry.p = true;                 /* present */
    380364        entry.ma = MA_WRITEBACK;
    381         entry.a = true;           /* already accessed */
    382         entry.d = true;           /* already dirty */
     365        entry.a = true;                 /* already accessed */
     366        entry.d = true;                 /* already dirty */
    383367        entry.pl = PL_KERNEL;
    384368        entry.ar = AR_READ | AR_WRITE;
     
    396380 * Purge DTR entries used by the kernel.
    397381 *
    398  * @param page  Virtual page address including VRN bits.
    399  * @param width Width of the purge in bits.
    400  *
     382 * @param page          Virtual page address including VRN bits.
     383 * @param width         Width of the purge in bits.
    401384 */
    402385void dtr_purge(uintptr_t page, size_t width)
    403386{
    404         asm volatile (
    405                 "ptr.d %[page], %[width]\n"
    406                 :: [page] "r" (page),
    407                    [width] "r" (width << 2)
    408         );
     387        asm volatile ("ptr.d %0, %1\n" : : "r" (page), "r" (width << 2));
    409388}
    410389
     
    412391/** Copy content of PTE into data translation cache.
    413392 *
    414  * @param t PTE.
    415  *
     393 * @param t             PTE.
    416394 */
    417395void dtc_pte_copy(pte_t *t)
    418396{
    419397        tlb_entry_t entry;
    420        
     398
    421399        entry.word[0] = 0;
    422400        entry.word[1] = 0;
     
    432410       
    433411        dtc_mapping_insert(t->page, t->as->asid, entry);
    434        
    435412#ifdef CONFIG_VHPT
    436413        vhpt_mapping_insert(t->page, t->as->asid, entry);
    437 #endif
     414#endif 
    438415}
    439416
    440417/** Copy content of PTE into instruction translation cache.
    441418 *
    442  * @param t PTE.
    443  *
     419 * @param t             PTE.
    444420 */
    445421void itc_pte_copy(pte_t *t)
    446422{
    447423        tlb_entry_t entry;
    448        
     424
    449425        entry.word[0] = 0;
    450426        entry.word[1] = 0;
     
    461437       
    462438        itc_mapping_insert(t->page, t->as->asid, entry);
    463        
    464439#ifdef CONFIG_VHPT
    465440        vhpt_mapping_insert(t->page, t->as->asid, entry);
    466 #endif
     441#endif 
    467442}
    468443
    469444/** Instruction TLB fault handler for faults with VHPT turned off.
    470445 *
    471  * @param vector Interruption vector.
    472  * @param istate Structure with saved interruption state.
    473  *
     446 * @param vector                Interruption vector.
     447 * @param istate                Structure with saved interruption state.
    474448 */
    475449void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate)
    476450{
    477         region_register_t rr;
     451        region_register rr;
    478452        rid_t rid;
    479453        uintptr_t va;
    480454        pte_t *t;
    481455       
    482         va = istate->cr_ifa; /* faulting address */
     456        va = istate->cr_ifa;    /* faulting address */
    483457        rr.word = rr_read(VA2VRN(va));
    484458        rid = rr.map.rid;
    485        
     459
    486460        page_table_lock(AS, true);
    487461        t = page_mapping_find(AS, va);
     
    499473                page_table_unlock(AS, true);
    500474                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    501                         fault_if_from_uspace(istate, "Page fault at %p.",
    502                             (void *) va);
    503                         panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
     475                        fault_if_from_uspace(istate,"Page fault at %p.",va);
     476                        panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     477                            istate->cr_iip);
    504478                }
    505479        }
     
    514488}
    515489
     490#define IO_FRAME_BASE 0xFFFFC000000
     491
    516492/**
    517493 * There is special handling of memory mapped legacy io, because of 4KB sized
    518494 * access for userspace.
    519495 *
    520  * @param va     Virtual address of page fault.
    521  * @param istate Structure with saved interruption state.
    522  *
    523  * @return One on success, zero on failure.
    524  *
     496 * @param va            Virtual address of page fault.
     497 * @param istate        Structure with saved interruption state.
     498 *
     499 * @return              One on success, zero on failure.
    525500 */
    526501static int try_memmap_io_insertion(uintptr_t va, istate_t *istate)
     
    530505                        uint64_t io_page = (va & ((1 << IO_PAGE_WIDTH) - 1)) >>
    531506                            USPACE_IO_PAGE_WIDTH;
    532                        
     507
    533508                        if (is_io_page_accessible(io_page)) {
    534509                                uint64_t page, frame;
    535                                
     510
    536511                                page = IO_OFFSET +
    537512                                    (1 << USPACE_IO_PAGE_WIDTH) * io_page;
    538513                                frame = IO_FRAME_BASE +
    539514                                    (1 << USPACE_IO_PAGE_WIDTH) * io_page;
    540                                
     515
    541516                                tlb_entry_t entry;
    542                                
     517       
    543518                                entry.word[0] = 0;
    544519                                entry.word[1] = 0;
    545                                
    546                                 entry.p = true;             /* present */
    547                                 entry.ma = MA_UNCACHEABLE;
    548                                 entry.a = true;             /* already accessed */
    549                                 entry.d = true;             /* already dirty */
     520       
     521                                entry.p = true;         /* present */
     522                                entry.ma = MA_UNCACHEABLE;             
     523                                entry.a = true;         /* already accessed */
     524                                entry.d = true;         /* already dirty */
    550525                                entry.pl = PL_USER;
    551526                                entry.ar = AR_READ | AR_WRITE;
    552527                                entry.ppn = frame >> PPN_SHIFT;
    553528                                entry.ps = USPACE_IO_PAGE_WIDTH;
    554                                
     529       
    555530                                dtc_mapping_insert(page, TASK->as->asid, entry);
    556531                                return 1;
    557532                        } else {
    558533                                fault_if_from_uspace(istate,
    559                                     "IO access fault at %p.", (void *) va);
     534                                    "IO access fault at %p.", va);
    560535                        }
    561536                }
    562537        }
    563        
     538               
    564539        return 0;
    565540}
     
    567542/** Data TLB fault handler for faults with VHPT turned off.
    568543 *
    569  * @param vector Interruption vector.
    570  * @param istate Structure with saved interruption state.
    571  *
     544 * @param vector        Interruption vector.
     545 * @param istate        Structure with saved interruption state.
    572546 */
    573547void alternate_data_tlb_fault(uint64_t vector, istate_t *istate)
    574548{
    575         if (istate->cr_isr.sp) {
    576                 /* Speculative load. Deffer the exception
    577                    until a more clever approach can be used.
    578                    
    579                    Currently if we try to find the mapping
    580                    for the speculative load while in the kernel,
    581                    we might introduce a livelock because of
    582                    the possibly invalid values of the address. */
    583                 istate->cr_ipsr.ed = true;
    584                 return;
    585         }
    586        
    587         uintptr_t va = istate->cr_ifa;  /* faulting address */
    588        
    589         region_register_t rr;
    590         rr.word = rr_read(VA2VRN(va));
    591         rid_t rid = rr.map.rid;
     549        region_register rr;
     550        rid_t rid;
     551        uintptr_t va;
     552        pte_t *t;
     553       
     554        va = istate->cr_ifa;    /* faulting address */
     555        rr.word = rr_read(VA2VRN(va));
     556        rid = rr.map.rid;
    592557        if (RID2ASID(rid) == ASID_KERNEL) {
    593558                if (VA2VRN(va) == VRN_KERNEL) {
     
    600565                }
    601566        }
    602        
    603        
     567
    604568        page_table_lock(AS, true);
    605         pte_t *entry = page_mapping_find(AS, va);
    606         if (entry) {
     569        t = page_mapping_find(AS, va);
     570        if (t) {
    607571                /*
    608572                 * The mapping was found in the software page hash table.
    609573                 * Insert it into data translation cache.
    610574                 */
    611                 dtc_pte_copy(entry);
     575                dtc_pte_copy(t);
    612576                page_table_unlock(AS, true);
    613577        } else {
     
    615579                if (try_memmap_io_insertion(va, istate))
    616580                        return;
    617                
    618                 /*
    619                  * Forward the page fault to the address space page fault
     581                /*
     582                 * Forward the page fault to the address space page fault
    620583                 * handler.
    621584                 */
    622585                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    623                         fault_if_from_uspace(istate, "Page fault at %p.",
    624                             (void *) va);
    625                         panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
     586                        fault_if_from_uspace(istate,"Page fault at %p.",va);
     587                        panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     588                            istate->cr_iip);
    626589                }
    627590        }
     
    632595 * This fault should not occur.
    633596 *
    634  * @param vector Interruption vector.
    635  * @param istate Structure with saved interruption state.
    636  *
     597 * @param vector        Interruption vector.
     598 * @param istate        Structure with saved interruption state.
    637599 */
    638600void data_nested_tlb_fault(uint64_t vector, istate_t *istate)
    639601{
    640         ASSERT(false);
     602        panic("%s.", __func__);
    641603}
    642604
    643605/** Data Dirty bit fault handler.
    644606 *
    645  * @param vector Interruption vector.
    646  * @param istate Structure with saved interruption state.
    647  *
     607 * @param vector        Interruption vector.
     608 * @param istate        Structure with saved interruption state.
    648609 */
    649610void data_dirty_bit_fault(uint64_t vector, istate_t *istate)
    650611{
    651         region_register_t rr;
     612        region_register rr;
    652613        rid_t rid;
    653614        uintptr_t va;
    654615        pte_t *t;
    655616       
    656         va = istate->cr_ifa;  /* faulting address */
     617        va = istate->cr_ifa;    /* faulting address */
    657618        rr.word = rr_read(VA2VRN(va));
    658619        rid = rr.map.rid;
    659        
     620
    660621        page_table_lock(AS, true);
    661622        t = page_mapping_find(AS, va);
    662         ASSERT((t) && (t->p));
    663         if ((t) && (t->p) && (t->w)) {
     623        ASSERT(t && t->p);
     624        if (t && t->p && t->w) {
    664625                /*
    665626                 * Update the Dirty bit in page tables and reinsert
     
    670631        } else {
    671632                if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
    672                         fault_if_from_uspace(istate, "Page fault at %p.",
    673                             (void *) va);
    674                         panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
     633                        fault_if_from_uspace(istate,"Page fault at %p.",va);
     634                        panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     635                            istate->cr_iip);
    675636                }
    676637        }
     
    680641/** Instruction access bit fault handler.
    681642 *
    682  * @param vector Interruption vector.
    683  * @param istate Structure with saved interruption state.
    684  *
     643 * @param vector        Interruption vector.
     644 * @param istate        Structure with saved interruption state.
    685645 */
    686646void instruction_access_bit_fault(uint64_t vector, istate_t *istate)
    687647{
    688         region_register_t rr;
     648        region_register rr;
    689649        rid_t rid;
    690650        uintptr_t va;
    691         pte_t *t;
    692        
    693         va = istate->cr_ifa;  /* faulting address */
     651        pte_t *t;       
     652
     653        va = istate->cr_ifa;    /* faulting address */
    694654        rr.word = rr_read(VA2VRN(va));
    695655        rid = rr.map.rid;
    696        
     656
    697657        page_table_lock(AS, true);
    698658        t = page_mapping_find(AS, va);
    699         ASSERT((t) && (t->p));
    700         if ((t) && (t->p) && (t->x)) {
     659        ASSERT(t && t->p);
     660        if (t && t->p && t->x) {
    701661                /*
    702662                 * Update the Accessed bit in page tables and reinsert
     
    707667        } else {
    708668                if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
    709                         fault_if_from_uspace(istate, "Page fault at %p.",
    710                             (void *) va);
    711                         panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL);
     669                        fault_if_from_uspace(istate, "Page fault at %p.", va);
     670                        panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     671                            istate->cr_iip);
    712672                }
    713673        }
     
    719679 * @param vector Interruption vector.
    720680 * @param istate Structure with saved interruption state.
    721  *
    722681 */
    723682void data_access_bit_fault(uint64_t vector, istate_t *istate)
    724683{
    725         region_register_t rr;
     684        region_register rr;
    726685        rid_t rid;
    727686        uintptr_t va;
    728687        pte_t *t;
    729        
    730         va = istate->cr_ifa;  /* faulting address */
     688
     689        va = istate->cr_ifa;    /* faulting address */
    731690        rr.word = rr_read(VA2VRN(va));
    732691        rid = rr.map.rid;
    733        
     692
    734693        page_table_lock(AS, true);
    735694        t = page_mapping_find(AS, va);
    736         ASSERT((t) && (t->p));
    737         if ((t) && (t->p)) {
     695        ASSERT(t && t->p);
     696        if (t && t->p) {
    738697                /*
    739698                 * Update the Accessed bit in page tables and reinsert
     
    744703        } else {
    745704                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    746                         fault_if_from_uspace(istate, "Page fault at %p.",
    747                             (void *) va);
    748                         panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
     705                        fault_if_from_uspace(istate, "Page fault at %p.", va);
     706                        panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     707                            istate->cr_iip);
    749708                }
    750709        }
     
    756715 * @param vector Interruption vector.
    757716 * @param istate Structure with saved interruption state.
    758  *
    759717 */
    760718void data_access_rights_fault(uint64_t vector, istate_t *istate)
    761719{
    762         region_register_t rr;
     720        region_register rr;
    763721        rid_t rid;
    764722        uintptr_t va;
    765723        pte_t *t;
    766        
    767         va = istate->cr_ifa;  /* faulting address */
     724
     725        va = istate->cr_ifa;    /* faulting address */
    768726        rr.word = rr_read(VA2VRN(va));
    769727        rid = rr.map.rid;
    770        
     728
    771729        /*
    772730         * Assume a write to a read-only page.
     
    774732        page_table_lock(AS, true);
    775733        t = page_mapping_find(AS, va);
    776         ASSERT((t) && (t->p));
     734        ASSERT(t && t->p);
    777735        ASSERT(!t->w);
    778736        if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
    779                 fault_if_from_uspace(istate, "Page fault at %p.",
    780                     (void *) va);
    781                 panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL);
     737                fault_if_from_uspace(istate, "Page fault at %p.", va);
     738                panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,
     739                    istate->cr_iip);
    782740        }
    783741        page_table_unlock(AS, true);
     
    788746 * @param vector Interruption vector.
    789747 * @param istate Structure with saved interruption state.
    790  *
    791748 */
    792749void page_not_present(uint64_t vector, istate_t *istate)
    793750{
    794         region_register_t rr;
     751        region_register rr;
    795752        rid_t rid;
    796753        uintptr_t va;
    797754        pte_t *t;
    798755       
    799         va = istate->cr_ifa;  /* faulting address */
     756        va = istate->cr_ifa;    /* faulting address */
    800757        rr.word = rr_read(VA2VRN(va));
    801758        rid = rr.map.rid;
    802        
     759
    803760        page_table_lock(AS, true);
    804761        t = page_mapping_find(AS, va);
     
    818775                page_table_unlock(AS, true);
    819776                if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
    820                         fault_if_from_uspace(istate, "Page fault at %p.",
    821                             (void *) va);
    822                         panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL);
     777                        fault_if_from_uspace(istate, "Page fault at %p.", va);
     778                        panic("%s: va=%p, rid=%d.", __func__, va, rid);
    823779                }
    824780        }
Note: See TracChangeset for help on using the changeset viewer.