Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c868e2d in mainline


Ignore:
Timestamp:
2011-12-19T23:42:44Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
398e33be
Parents:
7aaed09
Message:

Add and apply page_mapping_make_global() on each span added to the
kernel non-identity. This ensures that the kernel non-identity will use
the same set of page tables in all address spaces.

Location:
kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_ht.c

    r7aaed09 rc868e2d  
    5959static void ht_mapping_remove(as_t *, uintptr_t);
    6060static pte_t *ht_mapping_find(as_t *, uintptr_t, bool);
     61static void ht_mapping_make_global(uintptr_t, size_t);
    6162
    6263slab_cache_t *pte_cache = NULL;
     
    8889        .mapping_insert = ht_mapping_insert,
    8990        .mapping_remove = ht_mapping_remove,
    90         .mapping_find = ht_mapping_find
     91        .mapping_find = ht_mapping_find,
     92        .mapping_make_global = ht_mapping_make_global
    9193};
    9294
     
    262264}
    263265
     266void ht_mapping_make_global(uintptr_t base, size_t size)
     267{
     268        /* nothing to do */
     269}
     270
    264271/** @}
    265272 */
  • kernel/genarch/src/mm/page_pt.c

    r7aaed09 rc868e2d  
    4646#include <arch/asm.h>
    4747#include <memstr.h>
     48#include <align.h>
     49#include <macros.h>
    4850
    4951static void pt_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
    5052static void pt_mapping_remove(as_t *, uintptr_t);
    5153static pte_t *pt_mapping_find(as_t *, uintptr_t, bool);
     54static void pt_mapping_make_global(uintptr_t, size_t);
    5255
    5356page_mapping_operations_t pt_mapping_operations = {
    5457        .mapping_insert = pt_mapping_insert,
    5558        .mapping_remove = pt_mapping_remove,
    56         .mapping_find = pt_mapping_find
     59        .mapping_find = pt_mapping_find,
     60        .mapping_make_global = pt_mapping_make_global
    5761};
    5862
     
    133137        /*
    134138         * First, remove the mapping, if it exists.
    135          *
    136139         */
    137140       
     
    150153        pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
    151154       
    152         /* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */
     155        /*
     156         * Destroy the mapping.
     157         * Setting to PAGE_NOT_PRESENT is not sufficient.
     158         */
    153159        memsetb(&ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
    154160       
     
    286292}
    287293
     294/** Make the mappings in the given range global accross all address spaces.
     295 *
     296 * All PTL0 entries in the given range will be mapped to a next level page
     297 * table. The next level page table will be allocated and cleared.
     298 *
     299 * pt_mapping_remove() will never deallocate these page tables even when there
     300 * are no PTEs in them.
     301 *
     302 * @param as   Address space.
     303 * @param base Base address corresponding to the first PTL0 entry that will be
     304 *             altered by this function.
     305 * @param size Size in bytes defining the range of PTL0 entries that will be
     306 *             altered by this function.
     307 */
     308void pt_mapping_make_global(uintptr_t base, size_t size)
     309{
     310        uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
     311        uintptr_t ptl0step = (((uintptr_t) -1) / PTL0_ENTRIES) + 1;
     312        size_t order;
     313        uintptr_t addr;
     314
     315#if (PTL1_ENTRIES != 0)
     316        order = PTL1_SIZE;
     317#elif (PTL2_ENTRIES != 0)
     318        order = PTL2_SIZE;
     319#else
     320        order = PTL3_SIZE;
     321#endif
     322
     323        ASSERT(ispwr2(ptl0step));
     324
     325        for (addr = ALIGN_DOWN(base, ptl0step); addr < base + size;
     326            addr += ptl0step) {
     327                uintptr_t l1;
     328
     329                l1 = (uintptr_t) frame_alloc(order, FRAME_KA | FRAME_LOWMEM);
     330                memsetb((void *) l1, FRAME_SIZE << order, 0);
     331                SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1));
     332                SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
     333                    PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
     334                    PAGE_WRITE);
     335        }
     336}
     337
    288338/** @}
    289339 */
  • kernel/generic/include/mm/page.h

    r7aaed09 rc868e2d  
    4949        void (* mapping_remove)(as_t *, uintptr_t);
    5050        pte_t *(* mapping_find)(as_t *, uintptr_t, bool);
     51        void (* mapping_make_global)(uintptr_t, size_t);
    5152} page_mapping_operations_t;
    5253
     
    6061extern void page_mapping_remove(as_t *, uintptr_t);
    6162extern pte_t *page_mapping_find(as_t *, uintptr_t, bool);
     63extern void page_mapping_make_global(uintptr_t, size_t);
    6264extern pte_t *page_table_create(unsigned int);
    6365extern void page_table_destroy(pte_t *);
  • kernel/generic/src/mm/km.c

    r7aaed09 rc868e2d  
    3838#include <mm/km.h>
    3939#include <arch/mm/km.h>
     40#include <mm/page.h>
    4041#include <config.h>
    4142#include <typedefs.h>
     
    7071        bool span_added;
    7172
     73        page_mapping_make_global(base, size);
     74
    7275        span_added = ra_span_add(km_ni_arena, base, size);
    7376        ASSERT(span_added);
  • kernel/generic/src/mm/page.c

    r7aaed09 rc868e2d  
    178178}
    179179
     180/** Make the mapping shared by all page tables (not address spaces).
     181 *
     182 * @param base Starting virtual address of the range that is made global.
     183 * @param size Size of the address range that is made global.
     184 */
     185void page_mapping_make_global(uintptr_t base, size_t size)
     186{
     187        ASSERT(page_mapping_operations);
     188        ASSERT(page_mapping_operations->mapping_make_global);
     189       
     190        return page_mapping_operations->mapping_make_global(base, size);
     191}
     192
    180193uintptr_t hw_map(uintptr_t physaddr, size_t size)
    181194{
Note: See TracChangeset for help on using the changeset viewer.