Changeset 97c7682 in mainline for kernel/genarch/src/mm/page_pt.c


Ignore:
Timestamp:
2012-07-14T11:18:40Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
804d9b6
Parents:
0747468 (diff), f0348c8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Text conflict in boot/arch/arm32/Makefile.inc:

Trivial conflict around ifeq condition.

Text conflict in kernel/arch/arm32/include/mm/page.h:

Added defines and set_pt_levelx_present function.
COnflict looked horrible because of the armv4/v7 split.

File:
1 edited

Legend:

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

    r0747468 r97c7682  
    4343#include <arch/mm/page.h>
    4444#include <arch/mm/as.h>
     45#include <arch/barrier.h>
    4546#include <typedefs.h>
    4647#include <arch/asm.h>
     
    4849#include <align.h>
    4950#include <macros.h>
     51#include <bitops.h>
    5052
    5153static void pt_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
     
    8587                SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
    8688                SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page),
    87                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
     89                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    8890                    PAGE_WRITE);
     91                write_barrier();
     92                SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page));
    8993        }
    9094       
     
    97101                SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
    98102                SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page),
    99                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
     103                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    100104                    PAGE_WRITE);
     105                write_barrier();
     106                SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page));       
    101107        }
    102108       
     
    109115                SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
    110116                SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page),
    111                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
     117                    PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    112118                    PAGE_WRITE);
     119                write_barrier();
     120                SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page));
    113121        }
    114122       
     
    116124       
    117125        SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame);
    118         SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags);
     126        SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT);
     127        write_barrier();
     128        SET_FRAME_PRESENT(ptl3, PTL3_INDEX(page));
    119129}
    120130
     
    278288        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
    279289                return NULL;
     290
     291        read_barrier();
    280292       
    281293        pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
    282294        if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
    283295                return NULL;
     296
     297#if (PTL1_ENTRIES != 0)
     298        read_barrier();
     299#endif
    284300       
    285301        pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
    286302        if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
    287303                return NULL;
     304
     305#if (PTL2_ENTRIES != 0)
     306        read_barrier();
     307#endif
    288308       
    289309        pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
    290310       
    291311        return &ptl3[PTL3_INDEX(page)];
     312}
     313
     314/** Return the size of the region mapped by a single PTL0 entry.
     315 *
     316 * @return Size of the region mapped by a single PTL0 entry.
     317 */
     318static uintptr_t ptl0_step_get(void)
     319{
     320        size_t va_bits;
     321
     322        va_bits = fnzb(PTL0_ENTRIES) + fnzb(PTL1_ENTRIES) + fnzb(PTL2_ENTRIES) +
     323            fnzb(PTL3_ENTRIES) + PAGE_WIDTH;
     324
     325        return 1UL << (va_bits - fnzb(PTL0_ENTRIES));
    292326}
    293327
     
    309343{
    310344        uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
    311         uintptr_t ptl0step = (((uintptr_t) -1) / PTL0_ENTRIES) + 1;
     345        uintptr_t ptl0_step = ptl0_step_get();
    312346        size_t order;
    313347        uintptr_t addr;
     
    321355#endif
    322356
    323         ASSERT(ispwr2(ptl0step));
    324357        ASSERT(size > 0);
    325358
    326         for (addr = ALIGN_DOWN(base, ptl0step); addr - 1 < base + size - 1;
    327             addr += ptl0step) {
     359        for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1;
     360            addr += ptl0_step) {
    328361                uintptr_t l1;
    329362
     
    332365                SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1));
    333366                SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
    334                     PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE |
    335                     PAGE_WRITE);
     367                    PAGE_PRESENT | PAGE_USER | PAGE_CACHEABLE |
     368                    PAGE_EXEC | PAGE_WRITE | PAGE_READ);
    336369        }
    337370}
Note: See TracChangeset for help on using the changeset viewer.