why does kernel image and direct mapping overlap in physical address space?

119 views Asked by At

below is the implementation of transforming virtual addr to physical addr of kernel space. However, by this way the kernel image and direct mapping have overlapped area in physical space. Is this way of mapping designed by purpose?

unsigned long __phys_addr(unsigned long x)
{
    unsigned long y = x - __START_KERNEL_map;

    /* use the carry flag to determine if x was < __START_KERNEL_map */
    if (unlikely(x > y)) {
        x = y + phys_base;

        VIRTUAL_BUG_ON(y >= KERNEL_IMAGE_SIZE);
    } else {
        x = y + (__START_KERNEL_map - PAGE_OFFSET);

        /* carry flag will be set if starting x was >= PAGE_OFFSET */
        VIRTUAL_BUG_ON((x > y) || !phys_addr_valid(x));
    }

0

There are 0 answers