1. 19 May, 2020 5 commits
  2. 06 May, 2020 1 commit
  3. 05 May, 2020 3 commits
  4. 01 May, 2020 11 commits
  5. 25 Apr, 2020 2 commits
  6. 24 Apr, 2020 11 commits
  7. 23 Apr, 2020 7 commits
    • Ard Biesheuvel's avatar
      efi/libstub/arm64: Simplify randomized loading of kernel image · 5d12da9d
      Ard Biesheuvel authored
      The KASLR code path in the arm64 version of the EFI stub incorporates
      some overly complicated logic to randomly allocate a region of the right
      alignment: there is no need to randomize the placement of the kernel
      modulo 2 MiB separately from the placement of the 2 MiB aligned allocation
      itself - we can simply follow the same logic used by the non-randomized
      placement, which is to allocate at the correct alignment, and only take
      TEXT_OFFSET into account if it is not a round multiple of the alignment.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      5d12da9d
    • Ard Biesheuvel's avatar
      efi/libstub/arm64: Replace 'preferred' offset with alignment check · 82046702
      Ard Biesheuvel authored
      The notion of a 'preferred' load offset for the kernel dates back to the
      times when the kernel's primary mapping overlapped with the linear region,
      and memory below it could not be used at all.
      
      Today, the arm64 kernel does not really care where it is loaded in physical
      memory, as long as the alignment requirements are met, and so there is no
      point in unconditionally moving the kernel to a new location in memory at
      boot. Instead, we can
      - check for a KASLR seed, and randomly reallocate the kernel if one is
        provided
      - otherwise, check whether the alignment requirements are met for the
        current placement of the kernel, and just run it in place if they are
      - finally, do an ordinary page allocation and reallocate the kernel to a
        suitably aligned buffer anywhere in memory.
      
      By the same reasoning, there is no need to take TEXT_OFFSET into account
      if it is a round multiple of the minimum alignment, which is the usual
      case for relocatable kernels with TEXT_OFFSET randomization disabled.
      Otherwise, it suffices to use the relative misaligment of TEXT_OFFSET
      when reallocating the kernel.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      82046702
    • Ard Biesheuvel's avatar
      efi/libstub/random: Increase random alloc granularity · c37c9162
      Ard Biesheuvel authored
      The implementation of efi_random_alloc() arbitrarily truncates the
      provided random seed to 16 bits, which limits the granularity of the
      randomly chosen allocation offset in memory. This is currently only
      an issue if the size of physical memory exceeds 128 GB, but going
      forward, we will reduce the allocation alignment to 64 KB, and this
      means we need to increase the granularity to ensure that the random
      memory allocations are distributed evenly.
      
      We will need to switch to 64-bit arithmetic for the multiplication,
      but this does not result in 64-bit integer intrinsic calls on ARM or
      on i386.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      c37c9162
    • Ard Biesheuvel's avatar
      efi/libstub/random: Align allocate size to EFI_ALLOC_ALIGN · e1df73e2
      Ard Biesheuvel authored
      The EFI stub uses a per-architecture #define for the minimum base
      and size alignment of page allocations, which is set to 4 KB for
      all architecures except arm64, which uses 64 KB, to ensure that
      allocations can always be (un)mapped efficiently, regardless of
      the page size used by the kernel proper, which could be a kexec'ee
      
      The API wrappers around page based allocations assume that this
      alignment is always taken into account, and so efi_free() will
      also round up its size argument to EFI_ALLOC_ALIGN.
      
      Currently, efi_random_alloc() does not honour this alignment for
      the allocated size, and so freeing such an allocation may result
      in unrelated memory to be freed, potentially leading to issues
      after boot. So let's round up size in efi_random_alloc() as well.
      
      Fixes: 2ddbfc81 ("efi: stub: add implementation of efi_random_alloc()")
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      e1df73e2
    • Arvind Sankar's avatar
      efi/gop: Allow automatically choosing the best mode · 45d97a74
      Arvind Sankar authored
      Add the ability to automatically pick the highest resolution video mode
      (defined as the product of vertical and horizontal resolution) by using
      a command-line argument of the form
      	video=efifb:auto
      
      If there are multiple modes with the highest resolution, pick one with
      the highest color depth.
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Link: https://lore.kernel.org/r/20200328160601.378299-2-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      45d97a74
    • Arvind Sankar's avatar
      efi/gop: Allow specifying depth as well as resolution · 9a1663bc
      Arvind Sankar authored
      Extend the video mode argument to handle an optional color depth
      specification of the form
      	video=efifb:<xres>x<yres>[-(rgb|bgr|<bpp>)]
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Link: https://lore.kernel.org/r/20200320020028.1936003-14-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      9a1663bc
    • Arvind Sankar's avatar
      efi/gop: Allow specifying mode by <xres>x<yres> · d9ff0323
      Arvind Sankar authored
      Add the ability to choose a video mode using a command-line argument of
      the form
      	video=efifb:<xres>x<yres>
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Link: https://lore.kernel.org/r/20200320020028.1936003-13-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      d9ff0323