david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

97 Commits

Author SHA1 Message Date
Michael Brown 14e3b4b29a [crypto] Expose pem_asn1() for use with non-image data
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-20 10:14:07 +01:00
Michael Brown 36cffe054d [crypto] Free correct pointer on the error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:07:40 +02:00
Michael Brown 84add97ce9 [crypto] Add PEM image format
Add PEM-encoded ASN.1 as an image format.  We accept as PEM any image
containing a line starting with a "-----BEGIN" boundary marker.

We allow for PEM files containing multiple ASN.1 objects, such as a
certificate chain produced by concatenating individual certificate
files.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-07-29 01:13:27 +01:00
Michael Brown eb7188d04b [crypto] Add DER image format
Add DER-encoded ASN.1 as an image format.  There is no fixed signature
for DER files.  We treat an image as DER if it comprises a single
valid SEQUENCE object covering the entire length of the image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-07-29 01:12:58 +01:00
Michael Brown 1f65ed53da [build] Allow assembler section type character to vary by architecture
On some architectures (such as ARM) the "@" character is used as a
comment delimiter.  A section type argument such as "@progbits"
therefore becomes "%progbits".

This is further complicated by the fact that the "%" character has
special meaning for inline assembly when input or output operands are
used, in which cases "@progbits" becomes "%%progbits".

Allow the section type character(s) to be defined via Makefile
variables.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-13 11:20:53 +00:00
Michael Brown 6847232e70 [efi] Add support for EFI_GRAPHICS_OUTPUT_PROTOCOL frame buffer consoles
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-16 16:38:41 +01:00
Michael Brown 7107334391 [efi] Provide efi_devpath_len()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-13 12:54:31 +01:00
Michael Brown 3376fa520b [efi] Implement the EFI_PXE_BASE_CODE_PROTOCOL
Many UEFI NBPs expect to find an EFI_PXE_BASE_CODE_PROTOCOL installed
in addition to the EFI_SIMPLE_NETWORK_PROTOCOL.  Most NBPs use the
EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the cached DHCP packets.

This implementation has been tested with grub.efi, shim.efi,
syslinux.efi, and wdsmgfw.efi.  Some methods (such as Discover() and
Arp()) are not used by any known NBP and so have not (yet) been
implemented.

Usage notes for the tested bootstraps are:

  - grub.efi uses EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the
    cached DHCP packet, and uses no other methods.

  - shim.efi uses EFI_PXE_BASE_CODE_PROTOCOL to retrieve the cached
    DHCP packet and to retrieve the next NBP via the Mtftp() method.
    If shim.efi was downloaded via HTTP (or other non-TFTP protocol)
    then shim.efi will blindly call Mtftp() with an HTTP URI as the
    filename: this allows the next NBP (e.g. grubx64.efi) to also be
    transparently retrieved by HTTP.

    shim.efi can also use the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL to
    retrieve files previously loaded by "imgfetch" or similar commands
    in iPXE.  The current implementation of shim.efi will use the
    EFI_SIMPLE_FILE_SYSTEM_PROTOCOL only if it does not find an
    EFI_PXE_BASE_CODE_PROTOCOL; this patch therefore prevents this
    usage of our EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.  This logic could be
    trivially reversed in shim.efi if needed.

  - syslinux.efi uses EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the
    cached DHCP packet.  Versions 6.03 and earlier have a bug which
    may cause syslinux.efi to attach to the wrong NIC if there are
    multiple NICs in the system (or if the UEFI firmware supports
    IPv6).

  - wdsmgfw.efi (ab)uses EFI_PXE_BASE_CODE_PROTOCOL to retrieve the
    cached DHCP packets, and to send and retrieve UDP packets via the
    UdpWrite() and UdpRead() methods.  (This was presumably done in
    order to minimise the amount of benefit obtainable by switching to
    UEFI, by replicating all of the design mistakes present in the
    original PXE specification.)

The EFI_DOWNGRADE_UX configuration option remains available for now,
until this implementation has received more widespread testing.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-02 13:45:12 +01:00
Michael Brown ae7f22eb28 [elf] Reject ELFBoot images requiring virtual addressing
We do not set up any kind of virtual addressing before invoking an
ELFBoot image.  Reject if the image's program headers indicate that
virtual addresses are not equal to physical addresses.

This avoids problems when loading some RHEL5 kernels, which seem to
include ELFBoot headers using virtual addressing.  With this change,
these kernels are no longer detected as ELFBoot, and so may be
(correctly) detected as bzImage instead.

Reported-by: Torgeir.Wulfsberg@kongsberg.com
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-29 14:17:09 +01:00
Michael Brown 2f020a8df3 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
These files cannot be automatically relicensed by util/relicense.pl
since they either contain unusual but trivial contributions (such as
the addition of __nonnull function attributes), or contain lines
dating back to the initial git revision (and so require manual
knowledge of the code's origin).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:29 +00:00
Michael Brown b6ee89ffb5 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicense files for which I am the sole author (as identified by
util/relicense.pl).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:17:31 +00:00
Michael Brown 5d9fbf34ee [efi] Provide dummy device path in efi_image_probe()
Some UEFI platforms will fail the call to LoadImage() with
EFI_INVALID_PARAMETER if we do not provide a device path (even though
we are providing a non-NULL SourceBuffer).

Fix by providing an empty device path for the call to LoadImage() in
efi_image_probe().

The call to LoadImage() in efi_image_exec() already constructs and
provides a device path (based on the most recently opened SNP device),
and so does not require this fix.

Reported-by: NICOLAS CATTIE <nicolas.cattie@mpsa.com>
Tested-by: NICOLAS CATTIE <nicolas.cattie@mpsa.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-19 13:22:04 +01:00
Michael Brown 0cc2f42f46 [efi] Wrap any images loaded by our wrapped image
Propagate our modified EFI system table to any images loaded by the
image that we wrap, thereby allowing us to observe boot services calls
made by all subsequent EFI images.

Also show details of intercepted ExitBootServices() calls.  When
wrapping is used, exiting boot services will almost certainly fail,
but this at least allows us to see when it happens.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-29 13:10:18 +01:00
Michael Brown 2bf428c2a9 [efi] Move abstract device path and handle functions to efi_utils.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06 14:27:45 +01:00
Michael Brown 7b3cc18462 [efi] Open device path protocol only at point of use
Some EFI 1.10 systems (observed on an Apple iMac) do not allow us to
open the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_BY_DRIVER and so we cannot maintain a safe,
long-lived pointer to the device path.  Work around this by instead
opening the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_GET_PROTOCOL whenever we need to use it.

Debugged-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:10:33 +01:00
Michael Brown 3b42ed477f [efi] Provide centralised definitions of commonly-used GUIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:08:32 +01:00
Michael Brown 4a480f1d15 [efi] Avoid unnecessarily passing pointers to EFI_HANDLEs
efi_file_install() and efi_download_install() are both used to install
onto existing handles.  There is therefore no need to allow for each
of their calls to InstallMultipleProtocolInterfaces() to create a new
handle.

By passing the handle directly (rather than a pointer to the handle),
we avoid potential confusion (and erroneous debug message colours).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 12:50:09 +01:00
Michael Brown 79419a1c69 [efi] Fill in loaded image's DeviceHandle if firmware fails to do so
Some EFI 1.10 implementations (observed with a mid-2011 iMac) seem to
fail to fill in the DeviceHandle for our loaded images.  It is
plausible that these implementations fill in the DeviceHandle only if
loading the image from a device path (rather than directly from a
memory buffer).

Work around this problem by filling in DeviceHandle if the firmware
leaves it empty.

We cannot sensibly fill in FilePath, because we have no way of knowing
whether or not the firmware will treat this as a pointer to be freed
when the image returns.

Reported-by: Curtis Larsen <larsen@dixie.edu>
Tested-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 16:16:10 +01:00
Michael Brown b53d4ae398 [efi] Unload started images only on failure
If the StartImage() call returns with no error, then the image must
have been started and returned successfully.  It either unloaded
itself, or it intended to remain loaded (e.g. it was a driver).  We
therefore do not unload successful images.

If there was an error, we attempt to unload the image.  This may not
work.  In particular, there is no way to tell whether an error
returned from StartImage() was due to being unable to start the image
(in which case we probably should call UnloadImage()), or due to the
image itself returning an error (in which case we probably should not
call UnloadImage()).  We therefore ignore any failures from the
UnloadImage() call itself.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 16:07:25 +01:00
Michael Brown c3b6ccf65b [efi] Allow for interception of boot services calls by loaded image
When building with DEBUG=efi_wrap, print details of calls made by the
loaded image to selected boot services functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16 01:58:19 +01:00
Michael Brown f473b9c3f6 [efi] Disable SNP devices when running iPXE as the application
Some UEFI builds will set up a timer to continuously poll any SNP
devices.  This can drain packets from the network device's receive
queue before iPXE gets a chance to process them.

Use netdev_rx_[un]freeze() to explicitly indicate when we expect our
network devices to be driven via the external SNP API (as we do with
the UNDI API on the standard BIOS build), and disable the SNP API
except when receive queue processing is frozen.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 17:09:51 +00:00
Michael Brown c6c8078964 [png] Add support for PNG images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown 0ee89338dd [pnm] Add support for PNM images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:51 +00:00
Michael Brown 43eba2f555 [cmdline] Generate command option help text automatically
Generate the command option help text automatically from the list of
defined options.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-07 17:00:51 +00:00
Michael Brown 5e1fa5cd40 [parseopt] Add parse_timeout()
Parsing a timeout value (specified in milliseconds) into an internal
timeout value measured in timer ticks is a common operation.  Provide
a parse_timeout() value to carry out this conversion automatically.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 02:26:19 +00:00
Michael Brown 31f5211035 [script] Allow commands following a script label
Allow commands to be placed on the same line as a label.  This allows
for improved legibility of loop constructions by incorporating the
loop check condition into the same line as the loop label.  For
example, to iterate over network devices using the forthcoming "inc"
command:

  set idx:int16 0
  :loop isset ${net${idx}/mac} || goto loop_done
    echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac}
    inc idx && goto loop
  :loop_done

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-25 13:22:43 +01:00
Michael Brown 7fc18ea8ab [script] Allow initial whitespace on lines containing labels
Initial whitespace is already accepted on lines containing commands,
since it gets ignored by the system() call.  Minimise surprise and
allow for neater indentation of scripts by also allowing whitespace on
lines containing labels.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-25 13:03:42 +01:00
Michael Brown e52c24492a [script] Avoid trying to read final character of a zero-length string
Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15 18:06:41 +02:00
Michael Brown bba5a39026 [script] Allow for backslash continuation of script lines
Allow long script lines to be broken up using backslash continuation.
For example:

   choose --default linux --timeout 3000 os \
   	  && goto boot_${os} || goto cancelled

Requested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15 11:20:04 +02:00
Michael Brown 9cb60c8a21 [efi] Add sample platform-generated error disambiguations
Add disambiguated errors for LoadImage() and StartImage(), primarily
to demonstrate how to use __einfo_uniqify() and __einfo_platformify()
in the context of EFI platform errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:19 +01:00
Michael Brown 54409583e2 [efi] Perform meaningful error code conversions
Exploit the redefinition of iPXE error codes to include a "platform
error code" to allow for meaningful conversion of EFI_STATUS values to
iPXE errors and vice versa.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:19 +01:00
Michael Brown e05dcf0e01 [efi] Fix minor typos in efi_image.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-19 23:21:15 +00:00
Michael Brown fc87adb46c [efi] Expose downloaded images via EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
Expose iPXE's images as a UEFI file system, allowing the booted image
to access all images downloaded by iPXE.

This functionality is complementary to the custom iPXE download
protocol.  The iPXE download protocol allows a booted image to utilise
iPXE to download arbitrary URIs, but requires the booted image to
specifically support the custom iPXE download protocol.  The new
functionality limits the booted image to accessing only files that
were already downloaded by iPXE (e.g. as part of a script), but can
work with any generic UEFI image (e.g. the UEFI shell).  Both
protocols are provided simultaneously, and are attached to the SNP
device handle.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-13 22:42:16 +00:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown a026a27f04 [script] Avoid using stack-allocated memory in process_line()
Script lines can be arbitrarily long; allocate on the heap rather than
on the stack.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-23 22:42:10 +01:00
Michael Brown 62eb2294f0 [multiboot] Place multiboot modules low in memory
Solaris assumes that there is enough space above the Multiboot modules
to use as a decompression and scratch area.  This assumption is
invalid when using iPXE, which places the Multiboot modules near the
top of (32-bit) memory.

Fix by copying the modules to an area of memory immediately following
the loaded kernel.

Debugged-by: Michael Brown <mcb30@ipxe.org>
Debugged-by: Scott McWhirter <scottm@joyent.com>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-19 13:13:32 +01:00
Michael Brown 61851e685d [elf] Avoid attempting to load 64-bit ELF binaries
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-09 15:15:05 +01:00
Michael Brown 0b1fe005b3 [parseopt] Allow "prompt" command to accept character literals for --key
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-29 00:21:19 +01:00
Jarrod Johnson 32c4a3a255 [efi] Add iPXE download protocol
iPXE exposes some extended capabilities via the PXE FILE API to allow
NBPs such as pxelinux to use protocols other than TFTP.  Provide an
equivalent interface as a UEFI protocol so that EFI binaries may also
take advantage of iPXE's extended capabilities.

This can be used with a patched version of elilo, for example:

  http://comments.gmane.org/gmane.comp.boot-loaders.elilo.general/147

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-15 12:08:39 +00:00
Michael Brown 174df77359 [script] Accept labels on lines terminated with CRLF
CRLF line terminators are allowed in scripts; the carriage return is
simply interpreted as trailing whitespace and so is ignored.  This
fails on lines containing script labels, since the label-finding code
checks for a line containing only the ":" marker and the label itself
(without any trailing whitespace).

Fix by allowing a label to be terminated by either a NUL or a
whitespace character.

Reported-by: Bovey Christian <Christian.Bovey@chuv.ch>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-08-08 16:35:30 +01:00
Michael Brown fc7239bdc8 [efi] Ensure that all drivers are shut down before the OS boots
Reported-by: Itay Gazit <itayg@mellanox.co.il>
Suggested-by: Michael R Turner <mikeyt@us.ibm.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-29 22:08:05 +01:00
Michael Brown e934447a60 [script] Allow scripts to be replaced
A script that downloads a new image using imgdownload() with the
action register_and_replace_image() can now be freed immediately
before the replacement image is executed.  This functionality is not
yet exposed via an iPXE command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 17:32:32 +00:00
Michael Brown ae92700fd4 [image] Generalise "currently-running script" to "currently-running image"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 13:38:56 +00:00
Michael Brown b2332d5118 [prefix] Allow iPXE's own command line to be executed as a script
Some prefixes (e.g. .lkrn) allow a command line to be passed in to
iPXE.  At present, this command line is ignored.

If a command line is provided, treat it as an embedded script (without
an explicit "#!ipxe" magic marker).  This allows for patterns of
invocation such as

  title  iPXE
  kernel /boot/ipxe.lkrn dhcp && \
         sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage

Here GRUB is instructed to load ipxe.lkrn with an embedded script
equivalent to

  #!ipxe
  dhcp
  sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage

This can be used to effectively vary the embedded script without
having to rebuild ipxe.lkrn.

Originally-implemented-by: Dave Hansen <dave@sr71.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 22:28:31 +00:00
Michael Brown e87fc5e743 [script] Add "prompt" command
The "prompt" command exposes the prompt() function, allowing a script
to prompt the user for a keypress and take action depending on the
result.  For example

  #!ipxe

  prompt -k 0x197e -t 2000 Press F12 to boot from network... || exit
  autoboot

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:53:58 +00:00
Michael Brown 9e162121b1 [script] Add an iPXE error URI to the "not in a script" message
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 03:11:14 +00:00
Michael Brown 34b6ecb2f1 [image] Simplify image management
Refactor the {load,exec} image operations as {probe,exec}.  This makes
the probe mechanism cleaner, eliminates some forward declarations,
avoids holding magic state in image->priv, eliminates the possibility
of screwing up between the "load" and "exec" stages, and makes the
documentation simpler since the concept of "loading" (as distinct from
"executing") no longer needs to be explained.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 00:37:50 +00:00
Michael Brown 7d5dcc9299 [parseopt] Refer to online documentation for command help
The online documentation (e.g. http://ipxe.org/cmd/ifopen), though not
yet complete, is far more comprehensive than could be provided within
the iPXE binary.  Save around 200 bytes (compressed) by removing the
command descriptions from the interactive help, and instead referring
users directly to the web page describing the relevant command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-04 12:18:51 +00:00
Michael Brown 962cada830 [init] Remove concept of "shutdown exit flags"
Remove the concept of shutdown exit flags, and replace it with a
counter used to keep track of exposed interfaces that require devices
to remain active.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-27 20:40:26 +00:00
Michael Brown 930f009bfa [script] Remove "Aborting on <line>" message
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-29 14:38:03 +00:00