reported by EFI implementation. This address comment on r301714.
Approved by: re (gjb), andrew (mentor)
Differential Revision: https://reviews.freebsd.org/D6787
where we assumed TERM_EMU was defined but didn't check. Fix these by also
including them under the ifdefs.
As HO is called from loader we need a null implementation so loader.efi
doesn't need to know which version of libefi it is building against.
Sponsored by: ABT Systems Ltd
code uses the GetTime function from the Runtime Service, however this has
been shown to not return a useable time on many arm64 UEFI implementations.
Reviewed by: jhb, smh
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D6709
directly pass the request otherwise use a buffer that is a
multiple of the media size. This speeds up I/O quite a bit
when using large transfer sizes on 4Kn disks etc.
MFC after: 1 week
In r277943, the efinet_match() routine was changed to use an off by one
when matching network interfaces. The effect was that using "net1"
actually used the device attached to "net0".
Digging into the hardware that needed this workaround more, I found that
UEFI was creating two simple network protocol devices for each physical
NIC. The first device was a "raw" Ethernet device and the second device
was a "IP" device that used the IP protocol on top of the underlying
"raw" device. The PXE code in the firmware used the "IP" device to pull
across the loader.efi, so currdev was set to "net1" when booting from the
physical interface "net0". (The loaded image's device handle referenced
the "IP" device that "net1" claimed.)
However, the IP device isn't suitable for doing raw packet I/O (and the
current code to open devices exclusively actually turns the "IP" devices
off on these systems).
To fix, change the efinet driver to only attach to "raw" devices. This
is determined by fetching the DEVICE_PATH for each handle which supports
the simple network protocol and examining the last node in the path. If
the last node in the path is a MAC address, the device is assumed to be
a "raw" device and is added as a 'netX' device. If the last node is not
a MAC address, the device is ignored.
However, this causes a new problem as the device handle associated with
the loaded image no longer matches any of the handles enumerated by
efinet for systems that load the image via the "IP" device. To handle
this case, expand the logic that resolves currdev from the loaded image
in main(). First, the existing logic of looking for a handle that
matches the loaded image's handle is tried. If that fails, the device
path of the handle that loaded the loaded image is fetched via
efi_lookup_image_devpath(). This device path is then walked from the
end up to the beginning using efi_handle_lookup() to fetch the handle
associated with a path. If the handle is found and is a known handle,
then that is used as currdev. The effect for machines that load the
image via the "IP" device is that the first lookup fails (the handle
for the "IP" device isn't claimed by efinet), but walking up the
image's device path finds the handle of the raw MAC device which is used
as currdev.
With these fixes in place, the hack to subtract 1 from the unit can now
be removed, so that setting currdev to 'net0' actually uses 'net0'.
PR: 202097
Tested by: ambrisko
Sponsored by: Cisco Systems
While here, fix the various net driver callbacks to return early instead
of crashing if this fails. (The 'init' callback from the netif interface
doesn't return an error if the protocol lookup fails.)
Sponsored by: Cisco Systems
These efipart layer did several devpath related operations inline. This
just switches it over to using shared code for working with device paths.
Sponsored by: Cisco Systems
Lookup the DEVICE_PATH for each EFI network device handle and output the
string description using printf with '%S'. To honor the pager, the newline
at the end of each line is still output with pager_output().
Sponsored by: Cisco Systems
- efi_lookup_devpath() uses the DEVICE_PATH_PROTOCOL to obtain the
DEVICE_PATH for a given EFI handle.
- efi_lookup_image_devpath() uses the LOADED_IMAGE_DEVICE_PATH_PROTOCOL
to lookup the device path of the device used to load a loaded image.
- efi_devpath_name() uses the DEVICE_PATH_TO_TEXT_PROTOCOL to generate
a string description of a device path. The returned string is a CHAR16
string that can be printed via the recently added '%S' format in
libstand's printf(). Note that the returned string is returned in
allocated storage that should be freed by calling
efi_free_devpath_name().
- efi_devpath_last_node() walks a DEVICE_PATH returning a pointer to the
final node in the path (not counting the terminating node). That is,
it returns a pointer to the last meaninful node in a DEVICE_PATH.
- efi_devpath_trim() generates a new DEVICE_PATH from an existing
DEVICE_PATH. The new DEVICE_PATH does not include the last
non-terminating node in the original path. If the original DEVICE_PATH
only contains the terminating node, this function returns NULL.
The caller is responsible for freeing the returned DEVICE_PATH via
free().
- efi_devpath_handle() attempts to find a handle that corresponds to a
given device path. However, if nodes at the end of the device path do
not have valid handles associated with them, this function will return
a handle that matches a node earlier in the device path. In particular,
this function returns a handle for the node closest to the end of the
device path which has a valid handle.
Sponsored by: Cisco Systems
return value when it could return 1 (indicating we should stop).
Fix a few instances of pager_open() / pager_close() not being called.
Actually use these routines for the environment variable printing code
I just committed.
a slightly non-standard %S that's more useful in the UEFI environment,
so ignore printf errors. There's no good cast to use. We'll need to
revisit this in the future.
Coverity reports an uninitialized "len" in case the switch defaults
without hitting any case. Respect the original intent and quell the
false positive with the relatively new __unreachable() builtin.
CID: 1347796
Don't crash if the user has more than 31 of them. A follow-up to
r298230.
Reviewed by: allanjude
Relnotes: maybe
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D6212
The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache.
This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot
Submitted by: Toomas Soome <tsoome@me.com>
Reviewed by: jhb, np
Differential Revision: https://reviews.freebsd.org/D6109
The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy.
Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks.
Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device.
The cache also implements limited read-ahead to increase performance.
To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache.
Booting from a virtual CD over IPMI:
0ms latency, before: 27 second, after: 7 seconds
60ms latency, before: over 12 minutes, after: under 5 minutes.
Submitted by: Toomas Soome <tsoome@me.com>
Reviewed by: delphij (previous version), emaste (previous version)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D4713
system. This uses the hints mechnanism. This mostly works today
because when there's no static hints (the default), this value can be
fetched from the hint. When there is a static hints file, the hint
passed from the boot loader to the kernel is ignored, but for the BIOS
case we're able to find it anyway. However, with UEFI, the fallback
doesn't work, so we get a panic instead.
Switch to acpi.rsdp and use TUNABLE_ULONG_FETCH instead. Continue to
generate the old values to allow for transitions. In addition, fall
back to the old method if the new method isn't present.
Add comments about all this.
Differential Revision: https://reviews.freebsd.org/D5866
In case the firmware falls through to executing startup.sh, populate it
with the name of our boot loader. In normal operation this should not be
necessary but may allow the system to boot if it would otherwise just
remain at a shell prompt.
Reviewed by: andrew, imp, smh
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D5878
Both objdump and nm are equally capable of reporting undefined symbols.
This gets us a step closer to building without binutils as we have an nm
implementation from ELF Tool Chain.
Reviewed by: bdrewery
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D5613
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.
Sponsored by: EMC / Isilon Storage Division
stores to clear it.
While here reduce the alignment of the data from 4k to 16 byte aligned.
This should be more than enough, without wasting too much space.
Sponsored by: ABT Systems Ltd
in boot1, like is normally done. When a keyboard appears in the UEFI
device tree, assume -D -h, just like on a BIOS boot.
# It is unclear if an ACPI keyboard appearing in the tree means there's
# a real keyboard or not. A USB keyboard doesn't seem to appear unless
# it is really there.
Differential Revision: https://reviews.freebsd.org/D5223
With warnings now enabled some plaforms where failing due to warnings.
* Fix st_size printed as a size_t when its actually an off_t.
* Fix pointer conversion in load_elf for some 32bit platforms due to 64bit
off in ef.
MFC after: 2 days
X-MFC-With:
Sponsored by: Multiplay
Fix EFI boot support when presented with multiple valid boot partitions
across multiple devices.
It now prefers to boot from partitions that are present on the underlying
device that the boot1 image was loaded from. This means that it will boot
from the partitions on device the user chose from EFI boot menu in
preference to those on other devices.
Also fixed is the recovery from a failed attempt to boot, from a seemingly
valid partition, by continuing to trying all other available partitions
no matter what the error.
boot1 now use * to signify a partition what was accepted from the preferred
device and + otherwise.
Finally some error messages where improved and DPRINTF's with slowed boot
to aid debugging.
ZFS will still be preferred over UFS when both are available on the boot
device.
Reviewed by: imp
MFC after: 1 week
Sponsored by: Multiplay
Differential Revision: https://reviews.freebsd.org/D5108