Disable some compiler warnings for GCC (non-standard compiler) fixing
build failures introduced by r293724, which enabled WARNS in the EFI boot
code, when compiling with none standard compiler (GCC).
Raised by: ian
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
Non-interactive forth command errors where silent even for critical issues
e.g. failing to load a required kernel module or mfs_root.
This resulted in later unexplained and hard to trace errors such as mount
root failures.
This introduces additional command return codes that are treated
appropriately by the non-interactive command processor (bf_command).
* CMD_CRIT = print error
* CMD_FATAL = panic
Also fix minor style(9) issues with command_load return codes.
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
infinitely less buggy than code that is theoretically correct in some
alternate universe.
The uintfptr_t type is apparently a freebsd invention, and exists only when
compiling the kernel. It's a little hard to say for sure, since it doesn't
seem to be documented anywhere except in email advice to unsuspecting and
overly-trusting souls, who then get to wear the pointy hat for blindly
following advice without investigating or testing it first.
because rounding down cannot increase the number of bits needed to express
the result.
I had no idea there was such a thing as uintfptr_t.
Requested by: bde
Set WARNS if not set for EFI boot code and fix the issues highlighted by
setting it.
Most components are set to WARNS level 6 with few being left at lower
levels due to the amount of changes needed to fix at higher levels.
Error types fixed:
* Missing / invalid casts
* Missing inner structs
* Unused vars
* Missing static for internal only funcs
* Missing prototypes
* Alignment changes
* Use of uninitialised vars
* Unknown pragma (intrinsic)
* Missing types etc due to missing includes
* printf formatting types
Reviewed by: emaste (in part)
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
Differential Revision: https://reviews.freebsd.org/D4839
member secsz was a uint16_t
sys/boot/zfs/zfs.c has a probe args structure member, secsz, that is a
uint16_t for media sector size; it is used as an argument for ioctl()
at line 484. however, this ioctl writes 32 bits of data (u_int *) and
therefore this ioctl will overwrite and corrupt 16 bits of memory.
other use cases seem to use correct u_int type for secsz.
PR: 204358
Submitted by: Toomas Soome <tsoome at me.com>
Reviewed by: asomers, delphij, smh
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D4811
When called to early, new_currdev->d_type was not yet set
zfs_fmtdev() would then return null
While here, guard call to init_zfs_bootenv with if d_type == DEVT_ZFS
Reported by: tsoome at me.com
MFC after: 3 days
Sponsored by: ScaleEngine Inc.
Remove the printf("Not ufs\n") from the boot code which was hidden by the
local printf implementations, allowing these to have that code removed too.
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
ARM and i386 already required libstand so switch to using it for all
patforms, allowing the removal of custom print and memory methods.
This is also a pre-cursor to enabling WARNS which highlighted a number
of issues with the removed methods.
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
Add a few other safeguards to ensure things do not break when the
boot device cannot be determined
Reported by: flo
MFC after: 3 days
Sponsored by: ScaleEngine Inc.
Userboot's copy of the libstand Makefile had more extensive changes
compared to the one in sys/boot/libstand32, but it turns out these are
not intentional and we can just include lib/libstand/Makefile as done
for libstand32 in r293040.
Reviewed by: imp, jhb
Tested by: allanjude
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D4793
r279533 increased the boot1 size from 64k to 128k but didn't regenerate the
fat templates, hence the change was never activated.
With recent and upcoming changes the efi boot1 binary is now > 64k.
To avoid fat corruption in the created boot images regenerate the
templates to activate the boot1 size increase.
MFC after: 2 weeks
X-MFC-With: r293268
This is based on the vidconsole implementation.
Submitted by: Toomas Soome <tsoome@me.com>
Reviewed by: adrian
MFC after: 2 weeks
Relnotes: Yes
Differential Revision: https://reviews.freebsd.org/D4797
a problem on 32-bit systems which have ram occupying the end of the physical
address space -- for example, a block of ram at 0x80000000 with a size of
0x80000000 was overflowing 32 bit math and ending up with a calculated size
of zero.
This is a fix for one of the two problems mentioned in the PR. Something
similar will need to be done on the kernel side before the PR is closed.
PR: 201614
providing compiled-in static environment data that is used instead of any
data passed in from a boot loader.
Previously 'env' worked only on i386 and arm xscale systems, because it
required the MD startup code to examine the global envmode variable and
decide whether to use static_env or an environment obtained from the boot
loader, and set the global kern_envp accordingly. Most startup code wasn't
doing so. Making things even more complex, some mips startup code uses an
alternate scheme that involves calling init_static_kenv() to pass an empty
buffer and its size, then uses a series of kern_setenv() calls to populate
that buffer.
Now all MD startup code calls init_static_kenv(), and that routine provides
a single point where envmode is checked and the decision is made whether to
use the compiled-in static_kenv or the values provided by the MD code.
The routine also continues to serve its original purpose for mips; if a
non-zero buffer size is passed the routine installs the empty buffer ready
to accept kern_setenv() values. Now if the size is zero, the provided buffer
full of existing env data is installed. A NULL pointer can be passed if the
boot loader provides no env data; this allows the static env to be installed
if envmode is set to do so.
Most of the work here is a near-mechanical change to call the init function
instead of directly setting kern_envp. A notable exception is in xen/pv.c;
that code was originally installing a buffer full of preformatted env data
along with its non-zero size (like mips code does), which would have allowed
kern_setenv() calls to wipe out the preformatted data. Now it passes a zero
for the size so that the buffer of data it installs is treated as
non-writeable.
libstand is built in three places (lib/libstand, sys/boot/libstand32,
and sys/boot/userboot/libstand). Reduce Makefile duplication by
.including libstand/Makefile from sys/boot/libstand32/Makefile.
sys/boot/userboot/libstand/Makefile will be addressed later, as it
contains additional differences yet to be handled.
This change also switches libstand32 to use the new uuid_from_string
and uuid_to_string, which was not included in r292473.
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D4747
If the system was booted with ZFS, a new menu item (#7) appears
It contains an autogenerated list of ZFS Boot Environments
This allows the user to switch to an alternate root file system
Use Cases:
- Revert a failed upgrade
- Concurrently run different versions of FreeBSD with common home directory
- Easier integration with the sysadmin/beadm utility
Requested by: many
Reviewed by: dteske
MFC after: 10 days
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3167
Thinking this through, and looking at process_assignment, I believe
moving the code would be wrong considering that set_conf_files is
called in one condition while set_nextboot_conf is guarded by a
different condition of having nextboot_enable="YES". So these must
stay separated and not combined.
MFC after: 1 week
Fix erroneous error path in error messages when processing boot_conf.
Fixup stack comments for functions introduced by SVN r97201.
Remove a questioning stack comment introduced by SVN r186789.
NB: Comment removed because strdup usage here is correct/not a leak.
MFC after: 1 week
empty ldvar (which amounts to the varname string starting with '=') into
the if block that manipulates ldvar, which avoids later referencing ldvar
when it was never initialized.
Submitted by: Thomas Skibo
Pointy hat: ian
magic number to use V86_CY() instead. These should have been fixed as
part of the cleanup in r226746 but were missed.
The md5 sums of the object files were unchanged, so there should be no
functional change.
PR: 205424
Submitted by: Alexander Kuleshov <kuleshovmail@gmail.com>
MFC after: 1 week
i386 is the only current FreeBSD architecture that ever used a.out
format.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D4687
Examine each cmdline arg and if it contains an '=' convert it to ascii and
pass it to putenv(). This allows var=value settings to come in on the
command line.
This will allow overriding dhcp server-provided data in loader(8), as
discussed in PR 202098
PR: 202098
Differential Revision: https://reviews.freebsd.org/D4561
EFI return values set the high bit to indicate an error. The log
messages changed here are printed only in the case of an error,
so including the error bit is redundant. Also switch to decimal to
match the error definitions (in sys/boot/efi/include/efierr.h).
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
If ExitBootServices fails due to a changed efi_mapkey then GetMemoryMap
must be called again. In this case it is also possible for the memory
map to grow, so repeat the initial GetMemoryMap call to fetch the new
size.
Also roll bi_add_efi_data_and_exit into bi_load_efi_data as there's no
need for it to be a separate function.
PR: 202455
Reported by: Berislav Purgar <bpurgar@gmail.com>
Tested by: Berislav Purgar <bpurgar@gmail.com>
Reviewed by: kib
MFC after: 1 week
MFC with: r292338
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D4621
EFI return values set the high bit to indicate an error. The log
messages changed here are printed only in the case of an error,
so including the error bit is redundant. Also switch to decimal to
match the error definitions (in sys/boot/efi/include/efierr.h).
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
pxeboot in tftp loader mode (when built with LOADER_TFTP_SUPPORT) now
prefix all the path to open with the path obtained via the option 'root-path'
directive.
This allows to be able to use the traditional content /boot out of box. Meaning
it now works pretty much like all other loaders. It simplifies hosting hosting
multiple version of FreeBSD on a tftp server.
As a consequence, pxeboot does not look anymore for a pxeboot.4th (which was
never provided)
Note: that pxeboot in tftp loader mode is not built by default.
Reviewed by: rpokala
Relnotes: yes
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D4590
The EFI memory map may change before or during the first
ExitBootServices call. In that case ExitBootServices returns an error,
and GetMemoryMap and ExitBootServices must be retried.
Glue together calls to GetMemoryMap(), ExitBootServices() and storage of
(now up-to-date) MODINFOMD_EFI_MAP metadata within a single function.
That new function - bi_add_efi_data_and_exit() - uses space previously
allocated in bi_load_efi_data() to store the memory map (it will fail if
that space is too short). It handles re-calling GetMemoryMap() once to
update the map key if necessary. Finally, if ExitBootServices() is
successful, it stores the memory map and its header as MODINFOMD_EFI_MAP
metadata.
ExitBootServices() calls are now done earlier, from within arch-
independent bi_load() code.
PR: 202455
Submitted by: Ganael LAPLANCHE
Reviewed by: kib
MFC after: 2 weeks
Relnotes: Yes
Differential Revision: https://reviews.freebsd.org/D4296
directly into a loader (and thus kernel) env var, using the syntax
ubenv import ldvarname=ubvarname
Without the varname= prefix it uses the historical behavior of importing
to the name uboot.ubvarname.
When we are detecting a partition table and didn't find PMBR, try to
read backup GPT header from the last sector and if it is correct,
assume that we have GPT.
Reviewed by: rpokala
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D4282
This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so. A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR. These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package. The current implementation of targets/ is
very unmaintainable.
Currently rescue/rescue and sys/modules are still not connected.
Sponsored by: EMC / Isilon Storage Division
Previous value was not enough on Arndale platform.
Reviewed by: hselasky
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4145
During cv_wait we may be waiting for an event triggered by callout.
Run callbacks here to avoid code blocking.
Reviewed by: hselasky
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4144
The initial IOCTL implementation supports reading disk physical
geometry.
Two additional functions were added. They allow reading/writing raw
data to the disk (default partition).
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4143
The detach function is called very often, for example from
get_capacity function. We don't want to loose any pointers
here, so disable detaching for umass driver.
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4141
The PA adress must be gathered from an aligned VA,
not the RAW pointer to the memory space.
Reviewed by: hselasky
Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4140
Tracking these leads to situations where meta mode will consider the
file to be out of date if /bin/sh or /bin/ln are newer than the source
file. There's no reason for meta mode to do this as make is already
handling the rebuild dependency fine.
Sponsored by: EMC / Isilon Storage Division
No behavioral changes, just cosmetics.
A partition number of zero is not a wildcard, it's the 'a' partition in
a BSD slice, so don't print it as "<auto>". (Only slices are 1-based,
unit and partition numbers are 0-based and -1 is their wildcard marker.)
Also, after doing all the probing and choosing, print the final result as
"Booting from <disk spec>" where disk spec has all the wildcards resolved
and looks like familiar BSD slice-and-partition notation (disk0s3a, etc).
This was [re-]added in r127458 (apparently with disconnected history as well)
and never connected to the build.
It is no longer relevant for modern systems from the past 20 years.
Discussed with: jhb
Sponsored by: EMC / Isilon Storage Division
Zybo needs its own DTB and has a different PHY, so add it to
the base kernel. Details on building bootable SD images at
http://www.thomasskibo.com/zedbsd/
Submitted By: Thomas Skibo
the temporary file to vers.c at the end of the script
The previous logic wrote out to vers.c multiple times, so the file
could be incorrectly interpreted as being completely written out
after one of the echo calls with recursive make, when in reality it
was only partially written.
Also, in the event the build was interrupted when creating vers.c
(small race window), it would have a leftover file that needed to
be cleaned up before resuming the build.
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
bytes of boot2. Since we're in 16-bit mode, we can't copy all 128kB at
once; instead we loop four times and copy 32 kB each time.
This change was made necessary by an upcoming increase in the size of the
boot2 binary; should it increase further, the COPY_BLKS value can be
adjusted without anyone needing to remember 8086 assembly language again.
Requested by: allanjude
Tested by: allanjude
MFC after: 1 week
hold the kernel, modules, and any other loaded data. This memory block
is relocated to the kernel's expected location during the transfer of
control from the loader to the kernel.
The GENERIC kernel on amd64 has recently grown such that a kernel + zfs.ko
no longer fits in the default staging size. Bump the default size from
32MB to 48MB to provide more breathing room.
PR: 201679
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D3666
no option but to use the smbios information to fill in the blanks.
It's a good thing UGA is a protocol of the past and GOP has all the
info we need.
Anyway, the logic has been tweaked a little to get the easier bits
of information up front. This includes the resolution and the frame
buffer address. Then we look at the smbios information and define
expected values as well as the missing bits (frame buffer offset and
stride). If the values obtained match the expect values, we fill in
the blanks and return. Otherwise we use the existing detection logic
to figure it out.
Rename the environment variables from uga_framebuffer abd uga_stride
to hw.efifb.address and hw.efifb.stride. The latter names are more
in line with other variable names.
We currently have hardcoded settings for:
1. Mid-2007 iMac (iMac7,1)
2. Late-2007 MacBook (MacBook3,1)
striking a delicate balance between exhaustive searching and
banking on assumptions. The environment variables can be used
as a fall-back anyway. With this change, all known and tested
Macs with only UGA should have a working console out of the
box... for now...
in the frame buffer when we flip pixels. Allow the detection
to be bypassed by setting the uga_framebuffer and uga_stride
variables. The kernel console works fine even when we can't
detect pixel changes in the frame buffer, which indicates
that the problem could be with reading from the frame buffer
and not writing to it.
PCI BARs does not necessarily correspond to the upper-left
most pixel. Scan the frame buffer for which byte changed
when changing the pixel at (0,0).
Use the same technique to determine the stride. Except for
changing the pixel at (0,0), we change the pixel at (0,1).
PR: 202730
Tested by: hartzell (at) alerce.com
so they were disabled during DTS transition. Though there are
no standard devices/drivers on them people might use iic(4) userland
interface to access these buses.
command called 'uga' to show whether UGA is implemented by the
firmware and what the settings are. It also includes filling
the efi_fb structure from the UGA information when GOP isn't
implemented by the firmware.
Since UGA does not provide information about the stride, we
set the stride to the horizontal resolution. This is likely
not correct and we should determine the stride by trial and
error. For now, this should show something on the console
rather than nothing.
Refactor this file to maximize code reuse.
PR: 202730
command has the following sub-commands:
list - list all possible modes (paged)
get - return the current mode
set <mode> - set the current mode to <mode>
Go ahead and defined -D_STANDALONE for all targets (only strictly
needed for some architecture, but harmless on those it isn't required
for). Also add -msoft-float to all architectures uniformly rather
that higgley piggley like it is today.
Differential Revision: https://reviews.freebsd.org/D3496
"fdt_file" and "fdtfile" U-Boot variables. Add one more check for
"fdt_file" loader(8) variable.
loader(8) variable takes precedence over u-boot env one