Changeset 2057572 in mainline for kernel/arch/sparc64/src/mm/tsb.c


Ignore:
Timestamp:
2007-03-27T23:40:25Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
399ece9
Parents:
8d37a06
Message:

The Ultimate Solution To Illegal Virtual Aliases.
It is better to avoid them completely than to fight them.
Switch the sparc64 port to 16K pages. The TLBs and TSBs
continue to operate with 8K pages only. Page tables and
other generic parts operate with 16K pages.

Because the MMU doesn't support 16K directly, each 16K
page is emulated by a pair of 8K pages. With 16K pages,
illegal aliases cannot be created in 16K D-cache.

File:
1 edited

Legend:

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

    r8d37a06 r2057572  
    3535#include <arch/mm/tsb.h>
    3636#include <arch/mm/tlb.h>
     37#include <arch/mm/page.h>
    3738#include <arch/barrier.h>
    3839#include <mm/as.h>
     
    4142#include <debug.h>
    4243
    43 #define TSB_INDEX_MASK          ((1 << (21 + 1 + TSB_SIZE - PAGE_WIDTH)) - 1)
     44#define TSB_INDEX_MASK  ((1 << (21 + 1 + TSB_SIZE - MMU_PAGE_WIDTH)) - 1)
    4445
    4546/** Invalidate portion of TSB.
     
    6061        ASSERT(as->arch.itsb && as->arch.dtsb);
    6162       
    62         i0 = (page >> PAGE_WIDTH) & TSB_INDEX_MASK;
    63         cnt = min(pages, ITSB_ENTRY_COUNT);
     63        i0 = (page >> MMU_PAGE_WIDTH) & TSB_INDEX_MASK;
     64        cnt = min(pages * MMU_PAGES_PER_PAGE, ITSB_ENTRY_COUNT);
    6465       
    6566        for (i = 0; i < cnt; i++) {
    6667                as->arch.itsb[(i0 + i) & (ITSB_ENTRY_COUNT - 1)].tag.invalid =
    67                         true;
     68                    true;
    6869                as->arch.dtsb[(i0 + i) & (DTSB_ENTRY_COUNT - 1)].tag.invalid =
    69                         true;
     70                    true;
    7071        }
    7172}
     
    7374/** Copy software PTE to ITSB.
    7475 *
    75  * @param t Software PTE.
     76 * @param t     Software PTE.
     77 * @param index Zero if lower 8K-subpage, one if higher 8K subpage.
    7678 */
    77 void itsb_pte_copy(pte_t *t)
     79void itsb_pte_copy(pte_t *t, index_t index)
    7880{
    7981        as_t *as;
    8082        tsb_entry_t *tsb;
     83        index_t entry;
    8184       
    8285        as = t->as;
    83         tsb = &as->arch.itsb[(t->page >> PAGE_WIDTH) & TSB_INDEX_MASK];
     86        entry = ((t->page >> MMU_PAGE_WIDTH) + index) & TSB_INDEX_MASK;
     87        tsb = &as->arch.itsb[entry];
    8488
    8589        /*
     
    96100
    97101        tsb->tag.context = as->asid;
    98         tsb->tag.va_tag = t->page >> VA_TAG_PAGE_SHIFT;
     102        tsb->tag.va_tag = (t->page + (index << MMU_PAGE_WIDTH)) >>
     103            VA_TAG_PAGE_SHIFT;
    99104        tsb->data.value = 0;
    100105        tsb->data.size = PAGESIZE_8K;
    101         tsb->data.pfn = t->frame >> FRAME_WIDTH;
     106        tsb->data.pfn = (t->frame >> MMU_FRAME_WIDTH) + index;
    102107        tsb->data.cp = t->c;
    103108        tsb->data.p = t->k;             /* p as privileged */
     
    111116/** Copy software PTE to DTSB.
    112117 *
    113  * @param t Software PTE.
    114  * @param ro If true, the mapping is copied read-only.
     118 * @param t     Software PTE.
     119 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage.
     120 * @param ro    If true, the mapping is copied read-only.
    115121 */
    116 void dtsb_pte_copy(pte_t *t, bool ro)
     122void dtsb_pte_copy(pte_t *t, index_t index, bool ro)
    117123{
    118124        as_t *as;
    119125        tsb_entry_t *tsb;
     126        index_t entry;
    120127       
    121128        as = t->as;
    122         tsb = &as->arch.dtsb[(t->page >> PAGE_WIDTH) & TSB_INDEX_MASK];
     129        entry = ((t->page >> MMU_PAGE_WIDTH) + index) & TSB_INDEX_MASK;
     130        tsb = &as->arch.dtsb[entry];
    123131
    124132        /*
     
    135143
    136144        tsb->tag.context = as->asid;
    137         tsb->tag.va_tag = t->page >> VA_TAG_PAGE_SHIFT;
     145        tsb->tag.va_tag = (t->page + (index << MMU_PAGE_WIDTH)) >>
     146            VA_TAG_PAGE_SHIFT;
    138147        tsb->data.value = 0;
    139148        tsb->data.size = PAGESIZE_8K;
    140         tsb->data.pfn = t->frame >> FRAME_WIDTH;
     149        tsb->data.pfn = (t->frame >> MMU_FRAME_WIDTH) + index;
    141150        tsb->data.cp = t->c;
    142151#ifdef CONFIG_VIRT_IDX_DCACHE
Note: See TracChangeset for help on using the changeset viewer.