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

5400 Commits

Author SHA1 Message Date
Michael Brown a4923354e3 [build] Fix building on older versions of binutils
Some older versions of binutils have issues with both the use of
PROVIDE() and the interpretation of numeric literals within a section
description.

Work around these older versions by defining the required numeric
literals outside of any section description, and by automatically
determining whether or not to generate extra space for page tables
rather than relying on LDFLAGS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 20:03:30 +00:00
Michael Brown 163f8acba0 [librm] Generate page tables for 64-bit builds
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 03:21:38 +00:00
Michael Brown d1562c38a6 [librm] Prepare for long-mode memory map
The bulk of the iPXE binary (the .textdata section) is physically
relocated at runtime to the top of the 32-bit address space in order
to allow space for an OS to be loaded.  The relocation is achieved
with the assistance of segmentation: we adjust the code and data
segment bases so that the link-time addresses remain valid.

Segmentation is not available (for normal code and data segments) in
long mode.  We choose to compile the C code with -mcmodel=kernel and
use a link-time address of 0xffffffffeb000000.  This choice allows us
to identity-map the entirety of the 32-bit address space, and to alias
our chosen link-time address to the physical location of our .textdata
section.  (This requires the .textdata section to always be aligned to
a page boundary.)

We simultaneously choose to set the 32-bit virtual address segment
bases such that the link-time addresses may simply be truncated to 32
bits in order to generate a valid 32-bit virtual address.  This allows
symbols in .textdata to be trivially accessed by both 32-bit and
64-bit code.

There is no (sensible) way in 32-bit assembly code to generate the
required R_X86_64_32S relocation records for these truncated symbols.
However, subtracting the fixed constant 0xffffffff00000000 has the
same effect as truncation, and can be represented in a standard
R_X86_64_32 relocation record.  We define the VIRTUAL() macro to
abstract away this truncation operation, and apply it to all
references by 32-bit (or 16-bit) assembly code to any symbols within
the .textdata section.

We define "virt_offset" for a 64-bit build as "the value to be added
to an address within .textdata in order to obtain its physical
address".  With this definition, the low 32 bits of "virt_offset" can
be treated by 32-bit code as functionally equivalent to "virt_offset"
in a 32-bit build.

We define "text16" and "data16" for a 64-bit build as the physical
addresses of the .text16 and .data16 sections.  Since a physical
address within the 32-bit address space may be used directly as a
64-bit virtual address (thanks to the identity map), this definition
provides the most natural access to variables in .text16 and .data16.
Note that this requires a minor adjustment in prot_to_real(), which
accesses .text16 using 32-bit virtual addresses.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 02:58:09 +00:00
Michael Brown bfe6e3e90e [relocate] Preserve page alignment during relocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 02:39:56 +00:00
Michael Brown 6eb1c927a3 [librm] Transition to protected mode within init_librm()
Long-mode operation will require page tables, which are too large to
sensibly fit in our .data16 segment in base memory.

Add a portion of init_librm() running in 32-bit protected mode to
provide access to high memory.  Use this portion of init_librm() to
initialise the .textdata variables "virt_offset", "text16", and
"data16", eliminating the redundant (re)initialisation currently
performed on every mode transition as part of real_to_prot().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 01:01:27 +00:00
Michael Brown 31b5c2e753 [librm] Provide an abstraction wrapper for prot_call
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 23:23:38 +00:00
Michael Brown 196f0f2551 [librm] Convert prot_call() to a real-mode near call
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 17:12:16 +00:00
Michael Brown df2509db95 [prefix] Standardise calls to prot_call()
Use the standard "pushl $function ; pushw %cs ; call prot_call"
sequence everywhere that prot_call() is used.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 16:42:33 +00:00
Michael Brown adac4b1984 [librm] Simplify definitions for prot_call() and real_call() stack frames
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 16:41:48 +00:00
Michael Brown 02a88b7489 [prefix] Use garbage-collectable section names
Allow unused sections of libprefix.o to be removed via --gc-sections.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 16:03:47 +00:00
Michael Brown f0ea1f4d77 [bios] Use an 8kB stack for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 15:56:41 +00:00
Michael Brown b1436e0b83 [librm] Use garbage-collectable section names
Allow unused sections of librm.o to be removed via --gc-sections.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 15:43:33 +00:00
Michael Brown a3b4d6328c [bios] Make uses of REAL_CODE() and PHYS_CODE() 64-bit clean
On a 64-bit CPU, any modification of a register by 32-bit or 16-bit
code will destroy the invisible upper 32 bits of the corresponding
64-bit register.  For example: a 32-bit "pushl %eax" followed by a
"popl %eax" will zero the upper half of %rax.  This differs from the
treatment of upper halves of 32-bit registers by 16-bit code: a
"pushw %ax" followed by a "popw %ax" will leave the upper 16 bits of
%eax unmodified.

Inline assembly generated using REAL_CODE() or PHYS_CODE() will
therefore have to preserve the upper halves of all registers, to avoid
clobbering registers that gcc expects to be preserved.

Output operands from REAL_CODE() and PHYS_CODE() assembly may
therefore contain undefined values in the upper 32 bits.

Fix by using explicit variable widths (e.g. uint32_t) for
non-discarded output operands, to ensure that undefined values in the
upper 32 bits of 64-bit registers are ignored.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 15:12:51 +00:00
Michael Brown 4e4727079b [romprefix] Align PMM temporary decompression area to a page boundary
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 13:37:36 +00:00
Michael Brown a4f5c4647e [prefix] Align INT 15,88 temporary decompression area to a page boundary
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18 13:27:47 +00:00
Michael Brown 079b98b63a [librm] Discard argument as part of return from real_call()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 23:37:46 +00:00
Michael Brown 9dc340d735 [librm] Discard argument as part of return from prot_call()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 23:16:49 +00:00
Michael Brown f468f12b1e [bios] Add bin-x86_64-pcbios build platform
Move most arch/i386 files to arch/x86, and adjust the contents of the
Makefiles and the include/bits/*.h headers to reflect the new
locations.

This patch makes no substantive code changes, as can be seen using a
rename-aware diff (e.g. "git show -M5").

This patch does not make the pcbios platform functional for x86_64; it
merely allows it to compile without errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 43515f9f1a [bios] Move isolinux definitions to Makefile.pcbios
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 1a457e933a [bios] Allow librm to be compiled for x86_64
This commit does not make librm functional for x86_64; it merely
allows it to compile without errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 8819a34c0e [bios] Allow memmap.c to be compiled for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 7691e5eedb [bios] Allow bios_console.c to be compiled for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 4d224c95d4 [bios] Allow bzimage.c to be compiled for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 9c58ba2cd7 [bios] Allow rtc_entropy.c to be compiled for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 44e05b0ffc [bios] Allow relocate.c to be compiled for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 9f79f5f1a5 [bios] Use size_t when casting _text16_memsz and _data16_memsz
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown 15fadab533 [bios] Use intptr_t when casting .text16 function pointers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 19:32:32 +00:00
Michael Brown b9c4c2676b [libc] Split rmsetjmp() and rmlongjmp() into a separate rmsetjmp.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16 16:06:25 +00:00
Michael Brown 7ecfe7159f [prefix] Pad .text16 and .data16 segment sizes at build time
Commit c64747d ("[librm] Speed up real-to-protected mode transition
under KVM") rounded down the .text16 segment address calculated in
alloc_basemem() to a multiple of 64 bytes in order to speed up mode
transitions under KVM.

This creates a potential discrepancy between alloc_basemem() and
free_basemem(), meaning that free_basemem() may free less memory than
was allocated by alloc_basemem().

Fix by padding the calculated sizes of both .text16 and .data16 to a
multiple of 64 bytes at build time.

Debugged-by: Yossef Efraim <yossefe@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-12 14:04:51 +00:00
Mika Tiainen 0588c03772 [intel] Add INTEL_NO_PHY_RST for another I218-LM variant
Fixed booting on HP EliteBook 820 G2 laptop.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-12 13:23:44 +00:00
Michael Brown 1ae9adee42 [efi] Add missing definitions for function key scancodes
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-12 13:08:52 +00:00
Michael Brown 6de378aae8 [pxe] Clarify comments regarding shrinking of cached DHCP packet
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-11 19:14:00 +00:00
Michael Brown 12b3b57886 [iobuf] Improve robustness of I/O buffer allocation
Guard against various corner cases (such as zero-length buffers, zero
alignments, and integer overflow when rounding up allocation lengths
and alignments) and ensure that the struct io_buffer is correctly
aligned even when the caller requests a non-zero alignment for the I/O
buffer itself.

Add self-tests to verify that the resulting alignments and lengths are
correct for a range of allocations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-11 19:04:23 +00:00
Michael Brown e2b1140486 [malloc] Guard against unsigned integer overflow
Commit f3fbb5f ("[malloc] Avoid integer overflow for excessively large
memory allocations") fixed signed integer overflow issues caused by
the use of ssize_t, but did not guard against unsigned integer
overflow.

Add explicit checks for unsigned integer overflow where needed.  As a
side bonus, erroneous calls to malloc_dma() with an (illegal) size of
zero will now fail cleanly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-06 10:47:45 +00:00
Michael Brown 17a200257a [ehci] Add extra debugging information
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-05 21:03:17 +00:00
Michael Brown d0bfd830e4 [ath9k] Remove broken ath_rxbuf_alloc()
ath_rx_init() demonstrates some serious confusion over how to use
pointers, resulting in (uint32_t*)NULL being used as a temporary
variable.  This does not end well.

The broken code in question is performing manual alignment of I/O
buffers, which can now be achieved more simply using alloc_iob_raw().
Fix by removing ath_rxbuf_alloc() entirely.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-28 14:24:24 +00:00
Michael Brown 4ddd3d99c3 [slam] Avoid potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-27 23:27:47 +00:00
Michael Brown fef8e34b6f [tcp] Guard against malformed TCP options
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-27 23:06:50 +00:00
Hummel Frank 6366fa7af6 [intel] Add INTEL_NO_PHY_RST for I218-LM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-27 13:07:42 +00:00
Michael Brown e55ec845e6 [uri] Apply URI decoding for all parsed URIs
The various early-exit paths in parse_uri() accidentally bypass the
URI field decoding.  The result is that opaque or relative URIs do not
undergo URI field decoding, resulting in double-encoding when the URIs
are subsequently used.  For example:

  #!ipxe
  set mac ${macstring}
  imgfetch /boot/by-mac/${mac:uristring}

would result in an HTTP GET such as

  GET /boot/by-mac/00%253A0c%253A29%253Ac5%253A39%253Aa1 HTTP/1.1

rather than the expected

  GET /boot/by-mac/00%3A0c%3A29%3Ac5%3A39%3Aa1 HTTP/1.1

Fix by ensuring that URI decoding is always applied regardless of the
URI format.

Reported-by: Andrew Widdersheim <awiddersheim@inetu.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-26 16:16:13 +00:00
Michael Brown f0e9e55442 [tftp] Mangle initial slash on TFTP URIs
TFTP URIs are intrinsically problematic, since:

- TFTP servers may use either normal slashes or backslashes as a
  directory separator,

- TFTP servers allow filenames to be specified using relative paths
  (with no initial directory separator),

- TFTP filenames present in a DHCP filename field may use special
  characters such as "?" or "#" that prevent parsing as a generic URI.

As of commit 7667536 ("[uri] Refactor URI parsing and formatting"), we
have directly constructed TFTP URIs from DHCP next-server and filename
pairs, avoiding the generic URI parser.  This eliminated the problems
related to special characters, but indirectly made it impossible to
parse a "tftp://..." URI string into a TFTP URI with a non-absolute
path.

Re-introduce the convention of requiring an extra slash in a
"tftp://..." URI string in order to specify a TFTP URI with an initial
slash in the filename.  For example:

  tftp://192.168.0.1/boot/pxelinux.0  => RRQ "boot/pxelinux.0"
  tftp://192.168.0.1//boot/pxelinux.0 => RRQ "/boot/pxelinux.0"

This is ugly, but there seems to be no other sensible way to provide
the ability to specify all possible TFTP filenames.

A side-effect of this change is that format_uri() will no longer add a
spurious initial "/" when formatting a relative URI string.  This
improves the console output when fetching an image specified via a
relative URI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-21 18:00:33 +00:00
Michael Brown 42c2a6aab7 [ocsp] Avoid including a double path separator in request URI
The OCSP responder URI included within an X.509 certificate may or may
not include a trailing slash.  We currently rely on the fact that
format_uri() incorrectly inserts an initial slash, which we include
unconditionally within the OCSP request URI.

Switch to using uri_encode() directly, and insert a slash only if the
X.509 certificate's OCSP responder URI does not already include a
trailing slash.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-21 17:50:34 +00:00
Michael Brown 295ad11367 [uri] Avoid potentially large stack allocation
Avoid potentially large stack allocation in resolve_path().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-21 15:53:44 +00:00
Michael Brown 3c26ffafce [autoboot] Fix incorrect boolean logic
Commit 53d2d9e ("[uri] Generalise tftp_uri() to pxe_uri()") introduced
a regression in which an NFS root path would no longer be treated as
an unsupported root path, causing a boot with an NFS root path to fail
with a "Could not open SAN device" error.

Reported-by: David Evans <dave.evans55@googlemail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-19 08:16:17 +00:00
Michael Brown 207edc4615 [smsc95xx] Reserve headroom in received packets
Some protocols (such as ARP) may modify the received packet and re-use
the same I/O buffer for transmission of a reply.  The SMSC95XX
transmit header is larger than the receive header: the re-used I/O
buffer therefore does not have sufficient headroom for the transmit
header, and the ARP reply will therefore fail to be transmitted.  This
is essentially the same problem as in commit 2e72d10 ("[ncm] Reserve
headroom in received packets").

Fix by reserving sufficient space at the start of each received packet
to allow for the difference between the lengths of the transmit and
receive headers.

This problem is not caught by the current driver development test
suite (documented at http://ipxe.org/dev/driver), since even the large
file transfer tests tend to completely sufficiently quickly that there
is no need for the server to ever send an ARP request.  The failure
shows up only when using a very slow protocol such as RFC7440-enhanced
TFTP (as used by Windows Deployment Services).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-19 00:23:06 +00:00
Michael Brown 71b83a6d00 [usb] Allow USB endpoints to specify a reserved header length for refills
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-19 00:01:11 +00:00
Michael Brown 8dc23d9b83 [smsc95xx] Enable LEDs
The LED pins are configured by default as GPIO inputs.  While it is
conceivable that a board might actually use these pins as GPIOs, no
such board is known to exist.

The Linux smsc95xx driver configures these pins unconditionally as LED
outputs.  Assume that it is safe to do likewise.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-18 21:46:09 +00:00
Andrew Widdersheim 3fd81799ba [netdevice] Add "ifname" setting
Expose the network interface name (e.g. "net0") as a setting.  This
allows a script to obtain the name of the most recently opened network
interface via ${netX/ifname}.

Signed-off-by: Andrew Widdersheim <amwiddersheim@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-18 08:50:44 +00:00
Michael Brown cc252605ce [build] Add named configuration for public cloud environments
Add a named CONFIG=cloud configuration, which enables console types
useful for obtaining output from virtual machines in public clouds
such as AWS EC2.

An image suitable for use in AWS EC2 can be built using

  make bin/ipxe.usb CONFIG=cloud EMBED=config/cloud/aws.ipxe

The embedded script will direct iPXE to download and execute the EC2
"user-data" file, which is always available to an EC2 VM via the URI
http://169.254.169.254/latest/user-data (regardless of the VPC
networking settings).  The boot can therefore be controlled by
modifying the per-instance user data, without having to modify the
boot disk image.

Console output can be obtained via syslog (with a syslog server
configured in the user-data script), via the AWS "System Log" (after
the instance has been stopped), or as a last resort from the log
partition on the boot disk.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-18 08:37:27 +00:00
Michael Brown 8af8886d0a [stp] Fix incorrectly disambiguated errors
The three nominally-disambiguated ENOTSUP errors accidentally all used
the same error disambiguator, rendering them identical.  Fix by
changing all three values.  We avoid reusing the 0x01 disambiguator
value, since that remains ambiguous in older binaries.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-14 12:39:35 +00:00