Martins3 / loongson-dune

:zap: Process virtualization based on KVM. More useable, stable and practical than Stanford Dune.
20 stars 3 forks source link

why virtual address is 40 bit long? #35

Closed Martins3 closed 3 years ago

Martins3 commented 3 years ago
void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
{
    unsigned long random_factor = 0UL;

    if (current->flags & PF_RANDOMIZE)
        random_factor = arch_mmap_rnd();

    if (mmap_is_legacy(rlim_stack)) {
        mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
        mm->get_unmapped_area = arch_get_unmapped_area;
    } else {
        mm->mmap_base = mmap_base(random_factor, rlim_stack);
        mm->get_unmapped_area = arch_get_unmapped_area_topdown;
    }
}

Legacy or not makes a difference?