Skip to content
Snippets Groups Projects
  1. Mar 23, 2023
  2. Mar 16, 2023
  3. Mar 15, 2023
  4. Mar 14, 2023
  5. Mar 10, 2023
  6. Mar 09, 2023
  7. Mar 08, 2023
  8. Mar 01, 2023
  9. Feb 28, 2023
    • Michael Brown's avatar
      [efi] Omit EFI_LOAD_FILE2_PROTOCOL for a zero-length initrd · 04e60a27
      Michael Brown authored
      
      When the Linux kernel is being used with no initrd, iPXE will still
      provide a zero-length initrd.magic file within the virtual filesystem.
      As of commit 6a004be0 ("[efi] Support the initrd autodetection
      mechanism in newer Linux kernels"), this zero-length file will also be
      exposed via an EFI_LOAD_FILE2_PROTOCOL instance on a handle with a
      fixed device path.
      
      The correct handling of zero-length files via EFI_LOAD_FILE2_PROTOCOL
      is unfortunately not well defined.
      
      Linux expects the first call to LoadFile() to always fail with
      EFI_BUFFER_TOO_SMALL.  When the initrd is genuinely zero-length, iPXE
      will return success since the buffer is not too small to hold the
      (zero-length) file.  This causes Linux to immediately report a
      spurious EFI_LOAD_ERROR boot failure.
      
      We could change the logic in iPXE's efi_file_load() to always return
      EFI_BUFFER_TOO_SMALL if Buffer is NULL on entry.  Since the correct
      behaviour of LoadFile() in the corner case of a zero-length file is
      left undefined by the UEFI specification, this would be permissible.
      
      Unfortunately this approach would not fix the problem.  If we return
      EFI_BUFFER_TOO_SMALL and set the file length to zero, then Linux will
      call the boot services AllocatePages() method with a zero length.  In
      at least the EDK2 implementation, this combination of parameters will
      cause AllocatePages() to return EFI_OUT_OF_RESOURCES, and Linux will
      again report a boot failure.
      
      Another approach would be to install the initrd device path handle
      only if we have a non-empty initrd to offer.  Unfortunately this would
      lead to a failure in yet another corner case: if a previous bootloader
      has installed an initrd device path handle (e.g. to pass a boot script
      to iPXE) then we must not leave that initrd in place, since then our
      loaded kernel would end up seeing the wrong initrd content.
      
      The cleanest fix seems to be to ensure that the initrd device path
      handle is installed with the EFI_DEVICE_PATH_PROTOCOL instance present
      but with the EFI_LOAD_FILE2_PROTOCOL instance absent (and forcibly
      uninstalled if necessary), matching the state in which we leave the
      handle after uninstalling our virtual filesystem.  Linux will then not
      find any handle that supports EFI_LOAD_FILE2_PROTOCOL within the fixed
      device path, and so will fall through to trying other mechanisms to
      locate the initrd.
      
      Reported-by: default avatarChris Bradshaw <cwbshaw@gmail.com>
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      04e60a27
  10. Feb 20, 2023
  11. Feb 17, 2023
    • Michael Brown's avatar
      [rng] Allow entropy source to be selected at runtime · 9f17d111
      Michael Brown authored
      
      As noted in commit 3c83843e ("[rng] Check for several functioning RTC
      interrupts"), experimentation shows that Hyper-V cannot be trusted to
      reliably generate RTC interrupts.  (As noted in commit f3ba0fb5
      ("[hyperv] Provide timer based on the 10MHz time reference count
      MSR"), Hyper-V appears to suffer from a general problem in reliably
      generating any legacy interrupts.)  An alternative entropy source is
      therefore required for an image that may be used in a Hyper-V Gen1
      virtual machine.
      
      The x86 RDRAND instruction provides a suitable alternative entropy
      source, but may not be supported by all CPUs.  We must therefore allow
      for multiple entropy sources to be compiled in, with the single active
      entropy source selected only at runtime.
      
      Restructure the internal entropy API to allow a working entropy source
      to be detected and chosen at runtime.
      
      Enable the RDRAND entropy source for all x86 builds, since it is
      likely to be substantially faster than any other source.
      
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      9f17d111
  12. Feb 16, 2023
    • Michael Brown's avatar
      [iscsi] Limit maximum transfer size to MaxBurstLength · 2733c476
      Michael Brown authored
      
      We currently specify only the iSCSI default value for MaxBurstLength
      and ignore any negotiated value, since our internal block device API
      allows only for receiving directly into caller-allocated buffers and
      so we have no intrinsic limit on burst length.
      
      A conscientious target may however refuse to attempt a transfer that
      we request for a number of blocks that would exceed the negotiated
      maximum burst length.
      
      Fix by recording the negotiated maximum burst length and using it to
      limit the maximum number of blocks per transfer as reported by the
      SCSI layer.
      
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      2733c476
  13. Feb 15, 2023
    • Michael Brown's avatar
      [rng] Add RDRAND as an entropy source · cff85746
      Michael Brown authored
      
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      cff85746
    • Michael Brown's avatar
      [efi] Support the initrd autodetection mechanism in newer Linux kernels · 6a004be0
      Michael Brown authored
      
      Linux 5.7 added the ability to autodetect an initrd by searching for a
      handle via a fixed vendor-specific "Linux initrd device path" and then
      locating and using the EFI_LOAD_FILE2_PROTOCOL instance on that
      handle.
      
      This maps quite naturally onto our existing concept of a "magic
      initrd" as introduced for EFI in commit e5f02551 ("[efi] Provide an
      "initrd.magic" file for use by UEFI kernels").
      
      Add an EFI_LOAD_FILE2_PROTOCOL instance to our EFI virtual files
      (backed by simply calling the existing EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
      method to read from the file), and install the protocol instance for
      the "initrd.magic" virtual file onto a new device handle that also
      provides the Linux initrd device path.
      
      The design choice in Linux of using a single fixed device path makes
      this unfortunately messy to support, since device paths must be unique
      within a system.  When multiple bootloaders are used (e.g. GRUB
      loading iPXE loading Linux) then only one bootloader can ever install
      the device path onto a handle.  Subsequent bootloaders must locate the
      existing handle and replace the load file protocol instance with their
      own.
      
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      6a004be0
    • Michael Brown's avatar
      [efi] Fix debug message when reading from EFI virtual files · cf9ad00a
      Michael Brown authored
      
      Show the requested range when a caller reads from a virtual file via
      the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL interface.
      
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      cf9ad00a
  14. Feb 14, 2023
    • Michael Brown's avatar
      [image] Check delimiters when parsing command-line key-value arguments · 76a28653
      Michael Brown authored
      
      The Linux kernel bzImage image format and the CPIO archive constructor
      will parse the image command line for certain arguments of the form
      "key=value".  This parsing is currently implemented using strstr() in
      a way that can cause a false positive suffix match.  For example, a
      command line containing "highmem=<n>" would erroneously be treated as
      containing a value for "mem=<n>".
      
      Fix by centralising the logic used for parsing such arguments, and
      including a check that the argument immediately follows a whitespace
      delimiter (or is at the start of the string).
      
      Reported-by: default avatarFilippo Giunchedi <filippo@esaurito.net>
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      76a28653
  15. Feb 11, 2023
    • Michael Brown's avatar
      [rng] Check for several functioning RTC interrupts · 3c83843e
      Michael Brown authored
      
      Commit 74222cd2 ("[rng] Check for functioning RTC interrupt") added a
      check that the RTC is capable of generating interrupts via the legacy
      PIC, since this mechanism appears to be broken in some Hyper-V virtual
      machines.
      
      Experimentation shows that the RTC is sometimes capable of generating
      a single interrupt, but will then generate no subsequent interrupts.
      This currently causes rtc_entropy_check() to falsely detect that the
      entropy gathering mechanism is functional.
      
      Fix by checking for several RTC interrupts before declaring that it is
      a functional entropy source.
      
      Reported-by: default avatarAndreas Hammarskjöld <junior@2PintSoftware.com>
      Signed-off-by: default avatarMichael Brown <mcb30@ipxe.org>
      3c83843e
  16. Feb 10, 2023
  17. Feb 06, 2023
Loading