• Vasily Gorbik's avatar
    s390/kaslr: generalize and improve random base distribution · 6e259bc5
    Vasily Gorbik authored
    Improve the distribution algorithm of random base address to ensure
    a uniformity among all suitable addresses. To generate a random value
    once, and to build a continuous range in which every value is suitable,
    count all the suitable addresses (referred to as positions) that can be
    used as a base address. The positions are counted by iterating over the
    usable memory ranges. For each range that is big enough to accommodate
    the image, count all the suitable addresses where the image can be placed,
    while taking reserved memory ranges into consideration.
    
    A new function "iterate_valid_positions()" has dual purpose. Firstly, it
    is called to count the positions in a given memory range, and secondly,
    to convert a random position back to an address.
    
    "get_random_base()" has been replaced with more generic
    "randomize_within_range()" which now could be called for randomizing
    base addresses not just for the kernel image.
    Acked-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    6e259bc5
boot.h 3.47 KB