Changeset 11e9061d in mainline


Ignore:
Timestamp:
2008-06-11T19:00:55Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
80dabb8d
Parents:
f1fa2657
Message:

Issue a memory barrier after modifying a page table mapping in order to
prevent memory prefetching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/page.c

    rf1fa2657 r11e9061d  
    4646#include <mm/as.h>
    4747#include <mm/frame.h>
     48#include <arch/barrier.h>
    4849#include <arch/types.h>
    4950#include <arch/asm.h>
     
    6667 * of page boundaries.
    6768 *
    68  * @param s Address of the structure.
    69  * @param size Size of the structure.
     69 * @param s             Address of the structure.
     70 * @param size          Size of the structure.
    7071 */
    7172void map_structure(uintptr_t s, size_t size)
     
    7778
    7879        for (i = 0; i < cnt; i++)
    79                 page_mapping_insert(AS_KERNEL, s + i * PAGE_SIZE, s + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
     80                page_mapping_insert(AS_KERNEL, s + i * PAGE_SIZE,
     81                    s + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    8082
     83        /* Repel prefetched accesses to the old mapping. */
     84        memory_barrier();
    8185}
    8286
     
    8892 * The page table must be locked and interrupts must be disabled.
    8993 *
    90  * @param as Address space to wich page belongs.
    91  * @param page Virtual address of the page to be mapped.
    92  * @param frame Physical address of memory frame to which the mapping is done.
    93  * @param flags Flags to be used for mapping.
     94 * @param as            Address space to wich page belongs.
     95 * @param page          Virtual address of the page to be mapped.
     96 * @param frame         Physical address of memory frame to which the mapping is
     97 *                      done.
     98 * @param flags         Flags to be used for mapping.
    9499 */
    95100void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
     
    99104       
    100105        page_mapping_operations->mapping_insert(as, page, frame, flags);
     106       
     107        /* Repel prefetched accesses to the old mapping. */
     108        memory_barrier();
    101109}
    102110
     
    109117 * The page table must be locked and interrupts must be disabled.
    110118 *
    111  * @param as Address space to wich page belongs.
    112  * @param page Virtual address of the page to be demapped.
     119 * @param as            Address space to wich page belongs.
     120 * @param page          Virtual address of the page to be demapped.
    113121 */
    114122void page_mapping_remove(as_t *as, uintptr_t page)
     
    118126       
    119127        page_mapping_operations->mapping_remove(as, page);
     128
     129        /* Repel prefetched accesses to the old mapping. */
     130        memory_barrier();
    120131}
    121132
     
    126137 * The page table must be locked and interrupts must be disabled.
    127138 *
    128  * @param as Address space to wich page belongs.
    129  * @param page Virtual page.
     139 * @param as            Address space to wich page belongs.
     140 * @param page          Virtual page.
    130141 *
    131  * @return NULL if there is no such mapping; requested mapping otherwise.
     142 * @return              NULL if there is no such mapping; requested mapping
     143 *                      otherwise.
    132144 */
    133145pte_t *page_mapping_find(as_t *as, uintptr_t page)
Note: See TracChangeset for help on using the changeset viewer.