Ignore:
Timestamp:
2016-01-07T13:41:38Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4582c6
Parents:
7254df6
Message:

sparc64: TSB needs to be naturally aligned

The ITSB and DTSB on sun4u and the TSB on sun4v are mapped by a single
64K page, so they need to be aligned to 64K. Moreover, the TSB pointer
contruction demands the natural alignment: 32K for ITSB/DTSB on sun4u
and 64K for the unified TSB on sun4v.

The code was also streamlined and made more beautiful.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    r7254df6 re08162b  
    6666{
    6767#ifdef CONFIG_TSB
    68         uintptr_t tsb =
    69             frame_alloc(SIZE2FRAMES(TSB_ENTRY_COUNT * sizeof(tsb_entry_t)),
    70             flags, 0);
    71         if (!tsb)
     68        uintptr_t tsb_base = frame_alloc(TSB_FRAMES, flags, TSB_SIZE - 1);
     69        if (!tsb_base)
    7270                return -1;
    73        
     71
     72        tsb_entry_t *tsb = (tsb_entry_t *) PA2KA(tsb_base);
     73
    7474        as->arch.tsb_description.page_size = PAGESIZE_8K;
    7575        as->arch.tsb_description.associativity = 1;
    7676        as->arch.tsb_description.num_ttes = TSB_ENTRY_COUNT;
    7777        as->arch.tsb_description.pgsize_mask = 1 << PAGESIZE_8K;
    78         as->arch.tsb_description.tsb_base = tsb;
     78        as->arch.tsb_description.tsb_base = tsb_base;
    7979        as->arch.tsb_description.reserved = 0;
    8080        as->arch.tsb_description.context = 0;
    8181       
    82         memsetb((void *) PA2KA(as->arch.tsb_description.tsb_base),
    83                 TSB_ENTRY_COUNT * sizeof(tsb_entry_t), 0);
     82        memsetb(tsb, TSB_SIZE, 0);
    8483#endif
    8584       
     
    9089{
    9190#ifdef CONFIG_TSB
    92         size_t frames = SIZE2FRAMES(TSB_ENTRY_COUNT * sizeof(tsb_entry_t));
    93         frame_free(as->arch.tsb_description.tsb_base, frames);
     91        frame_free(as->arch.tsb_description.tsb_base, TSB_FRAMES);
    9492       
    95         return frames;
     93        return TSB_FRAMES;
    9694#else
    9795        return 0;
     
    126124        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    127125       
    128         if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     126        if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    129127                /*
    130128                 * TSBs were allocated from memory not covered
     
    137135        }
    138136       
    139         __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description)));
     137        __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&as->arch.tsb_description));
    140138#endif
    141139}
     
    166164        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    167165       
    168         if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     166        if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    169167                /*
    170168                 * TSBs were allocated from memory not covered
Note: See TracChangeset for help on using the changeset viewer.