/* * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
*/ staticunsignedlong get_align_mask(struct file *filp)
{ if (filp && is_file_hugepages(filp)) return huge_page_mask_align(filp); /* handle 32- and 64-bit case with a single conditional */ if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32()))) return 0;
if (!(current->flags & PF_RANDOMIZE)) return 0;
return va_align.mask;
}
/* * To avoid aliasing in the I$ on AMD F15h, the bits defined by the * va_align.bits, [12:upper_bit), are set to a random value instead of * zeroing them. This random value is computed once per boot. This form * of ASLR is known as "per-boot ASLR". * * To achieve this, the random value is added to the info.align_offset * value before calling vm_unmapped_area() or ORed directly to the * address.
*/ staticunsignedlong get_align_bits(void)
{ return va_align.bits & get_align_mask(NULL);
}
staticint __init control_va_addr_alignment(char *str)
{ /* guard against enabling this on other CPU families */ if (va_align.flags < 0) return 1;
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
}
staticvoid find_start_end(unsignedlong addr, unsignedlong flags, unsignedlong *begin, unsignedlong *end)
{ if (!in_32bit_syscall() && (flags & MAP_32BIT)) { /* This is usually used needed to map code in small model, so it needs to be in the first 31bit. Limit it to that. This means we need to move the unmapped base down for this case. This can give conflicts with the heap, but we assume that glibc malloc knows how to fall back to mmap. Give it 1GB
of playground for now. -AK */
*begin = 0x40000000;
*end = 0x80000000; if (current->flags & PF_RANDOMIZE) {
*begin = randomize_page(*begin, 0x02000000);
} return;
}
/* * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area * in the full address space. * * !in_32bit_syscall() check to avoid high addresses for x32 * (and make it no op on native i386).
*/ if (addr > DEFAULT_MAP_WINDOW && !in_32bit_syscall())
info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW;
bottomup: /* * A failed mmap() very likely causes application failure, * so fall back to the bottom-up function here. This scenario * can happen with large stack limits and large mmap() * allocations.
*/ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags, 0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.