Changeset caed0279 in mainline


Ignore:
Timestamp:
2012-05-05T13:24:58Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1295a1da
Parents:
ee04c28
Message:

Fix computation of the address increment between two PTL0 entries.

The previous computation divided the theoretical address space size
(either 232 or 264 bytes) by the number of PTL0 entries. This,
however, provides wrong results on some 64-bit architectures that use
smaller virtual address spaces. For example, amd64 has only 48-bit
virtual address space and so the computation needs to take this into
account.

File:
1 edited

Legend:

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

    ree04c28 rcaed0279  
    4848#include <align.h>
    4949#include <macros.h>
     50#include <bitops.h>
    5051
    5152static void pt_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
     
    292293}
    293294
     295/** Return the size of the region mapped by a single PTL0 entry.
     296 *
     297 * @return Size of the region mapped by a single PTL0 entry.
     298 */
     299static uintptr_t ptl0_step_get(void)
     300{
     301        size_t va_bits;
     302
     303        va_bits = fnzb(PTL0_ENTRIES) + fnzb(PTL1_ENTRIES) + fnzb(PTL2_ENTRIES) +
     304            fnzb(PTL3_ENTRIES) + PAGE_WIDTH;
     305
     306        return 1UL << (va_bits - fnzb(PTL0_ENTRIES));
     307}
     308
    294309/** Make the mappings in the given range global accross all address spaces.
    295310 *
     
    309324{
    310325        uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
    311         uintptr_t ptl0step = (((uintptr_t) -1) / PTL0_ENTRIES) + 1;
     326        uintptr_t ptl0_step = ptl0_step_get();
    312327        size_t order;
    313328        uintptr_t addr;
     
    321336#endif
    322337
    323         ASSERT(ispwr2(ptl0step));
    324338        ASSERT(size > 0);
    325339
    326         for (addr = ALIGN_DOWN(base, ptl0step); addr - 1 < base + size - 1;
    327             addr += ptl0step) {
     340        for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1;
     341            addr += ptl0_step) {
    328342                uintptr_t l1;
    329343
Note: See TracChangeset for help on using the changeset viewer.