aboutsummaryrefslogtreecommitdiff
path: root/stand
Commit message (Collapse)AuthorAgeFilesLines
* stand: Install gptboot.efi(8)Warner Losh2024-04-051-0/+1
| | | | | | | We need to include bsd.init.mk first when we have man pages in the boot loader. Sponsored by: Netflix
* userboot: allow for overriding the version file locationStephen J. Kiernan2024-04-031-1/+1
| | | | | | | | Use ?= when assigning VERSION_FILE Reviewed by: imp Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D44624
* stand/efi: Changes to efichar to allow it to be used in the kernelStephen J. Kiernan2024-03-282-5/+20
| | | | | | | | Replace malloc/free with EFICHAR_MALLOC and EFICHAR_FREEE macros. Obtained from: Juniper Networks, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44541
* boot0: remove reference to fdiskEd Maste2024-03-251-1/+1
| | | | | | | | fdisk is obsolete and there is no need to mention a specific tool used to update the partition table. Just refer to it as the MBR partition table. Sponsored by: The FreeBSD Foundation
* loader.4th dictthreshold too smallSimon J. Gerraty2024-03-181-2/+2
| | | | | | | | | The dictthreshold in stand/forth/loader.4th is too small resulting in full dictionary. Reviewed by: stevek, imp Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D44414
* uboot/Makefile move BINDIRSimon J. Gerraty2024-03-181-1/+2
| | | | | | | | | Set BINDIR before we include bsd.init.mk so we can override it via local.init.mk Reviewed by: imp Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D44413
* kboot: kbootfdt: fix error handlingWarner Losh2024-03-111-7/+6
| | | | | | | | If we are able to open /sys/firmware/fdt, but aren't able to read it, fall back to /proc/device-tree. Remove comment that's not really true, it turns out. Sponsored by: Netflix
* kboot: Use is_linux_error to check mmap return errorWarner Losh2024-03-111-1/+1
| | | | | | | Rather than checking against the (incorrect) -511, use the is_linux_error() function to check to see if host_mmap failed. Sponsored by: Netflix
* kboot: Print UEFI memory mapWarner Losh2024-03-111-0/+85
| | | | | | | | | If we can read the UEFI memory map, go ahead and print the memory map. While the kernel prints this with bootverbose, having it at this stage is useful for debugging other problems. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44287
* kboot: hostfs -- check for llseek failure correctlyWarner Losh2024-03-111-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | The host_* syscalls are all raw Linux system calls, not the POSIX wrappers that glibc / musl create. So we have to ranage change the return value of host_llseek correctly to use the negative value hack that all Linux system calls use. This fixes a false positive error detection when we do something like lseek(fd, 0xf1234567, ...); This returns 0xf1234567, which is a negative value which used to trigger the error path. Instead, we check using the is_linux_error() and store the return value in a long. Translate that errno to a host errno and set the global errno to that and return -1. lseek can't otherwise return a negative number, since it's the offset after seeking into the file, which by definition is positive. This kept the 'read the UEFI memory map out of physical memory' from working on aarch64 (whose boot loader falls back to reading it since there are restrictive kernel options that can also prevent it), since the physical address the memory map was at on my platform was like 0xfa008018. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44286
* kboot: Avoid UB in signed shiftWarner Losh2024-03-111-2/+3
| | | | | | | | | | offset is signed. Copy it to the unsigned res before shifting. This avoids any possible undefined behavior for right shifting signed numbers. No functional change intended (and the code generated is the nearly same for aarch64). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44285
* kboot: Create function for error checking.Warner Losh2024-03-111-4/+20
| | | | | | | | | | | | Linux has the convention of returning -ERRNO to flag errors from its system calls. Sometimes other negative values are returned that are success... However, only values -1 to -4096 (inclusive) are really errors. The rest are either truncated values that only look negative (so use long instead of int), or are things like addresses or legal unsigned file offsets or similar that are successful returns. Filter out the latter. Sponsored by: Netflix
* loader/lua: Remove workaround for command_errorWarner Losh2024-02-291-6/+1
| | | | | | | | | loader.command_error was available prior to stable/12 branching. No need to check if it is available or not. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44144
* loader/lua: Remove compat shim for loader.lua_pathWarner Losh2024-02-291-7/+1
| | | | | | | | | loader.lua_path was committed before stable/13 was branched, and merged in to for 12.2. Remove workaround for it not being present. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44143
* loader/lua: Remove pager shimWarner Losh2024-02-291-12/+0
| | | | | | | | | | | | Just after 12.2 and before the stable/13 branch, kevans added lpager.c to provide a pager interface for commands written in lua. It was merged into 12.3. Now that 12.2 is long since EOL, we can remove the pager shim here. Nobody needs that old loader + new lua scripts. Plus only one command is affected. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44142
* loader/efi: Small diff reductionWarner Losh2024-02-291-1/+2
| | | | | | | | Make doing the boot once protocol more similar to copies of this code. Sponsored by: Netflix Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D44007
* loader/zfs: Fix to actually return the last errorWarner Losh2024-02-291-8/+8
| | | | | | | | | | | The last fix, to try to return the last error, really returns the first return code after the last error, which could be zero. Instead, return the last error. Also, change rc to err to make it visually distinct from rv, which is the cause of my error in e54bb0ad8058. Reported by: Bill Sommerfeld <sommerfeld@hamachi.org> Fixes: e54bb0ad8058 Sponsored by: Netflix
* stand: Remove dangling mips referencesWarner Losh2024-02-284-1058/+0
| | | | | | Remove mips support files from ficl. Sponsored by: Netflix
* loader: Add loader.exitWarner Losh2024-02-272-4/+16
| | | | | | | | | | | | | Add loader.exit(status). While one can get alomst this behavior with loader.perform("quit"), quit doesn't allow a value to be returned to the firmware. The interpretation of 'status' is firmware specific. This can be used when autobooting doesn't work in scripts, for example, to allow the firmware to try something else... Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44094
* loader: we can only env_discard() existing variableToomas Soome2024-02-261-2/+6
| | | | | | | | | | While dropping nvpair from nvstore, we also remove the corresponding environment variable. By doing so, we should be careful not to try to unset non-existing variable. Reviewed by: imp MFC after: 2 week Differential revision: https://reviews.freebsd.org/D44083
* loader/efi: Only include interpreter's linker scriptWarner Losh2024-02-251-1/+1
| | | | | | | | | | For safety, only include the interpreter's linker script. Note that the simple loader doesn't have one, but it's not an error to copy a ELF section that does not exist. No functional change, however. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44064
* loader/ficl: Rename the ficl compile set to X4th_compile_setWarner Losh2024-02-253-4/+4
| | | | | | | | | | And upcoming change will need this set to be named this. Since it's only used in the efi Makefile, and inside if ficl itself, the change should be a nop. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44063
* loader/efi: Use unique linker set for luaWarner Losh2024-02-252-4/+5
| | | | | | | | | | After the linker set cleanup in ldscripts, there's now only one place we need to know the linkerset name, so go ahead and change the lua interpreter augmentation linker set to be uniquely named. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44062
* loader/efi: Linker sets not needed.Warner Losh2024-02-254-43/+0
| | | | | | | | | | | | | | | We don't need linker sets listed as sections. They are explicitly included in the objcopy we use to create the .efi file. This practice was added in 2002 by peter@ in a6d81d83a280 to make ia64 builds self-hosted. However, it was added back to the objcopy in 2010 by rpaulo in 8df7a05edd36 for i386 EFI support, though the ldscript file then retained them needlessly. The gcc/binutils bug having been fixed in the interim. We've not needed them since then, but the redundancy didn't matter. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44061
* loader/kboot: simplify linker set inclusion a littleWarner Losh2024-02-252-22/+0
| | | | | | | | | | | | | | Linker set sections are included by default. No need to do so explicitly. These were bogusly copied from the efi ldscripts. They were there due to a workaround introduced in 2002 by peter@ for a gcc upgrade, but whatever bugs necessitated it were filed by 2010 when rpaulo@ imported the i386 support (though they were copied even though the objcopy retained them correctly, the gcc bug having been fixed). They've never been needed. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44060
* loader/uboot: Move to foo.ldconfigWarner Losh2024-02-254-8/+8
| | | | | | | | | Move to the foo.ldconfig convention to match the rest of the boot loader. No functional change intended. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44059
* loader/powerpc: Share ldscriptWarner Losh2024-02-257-150/+13
| | | | | | | | | | | | | Share ldscript between the different ppc versions. There's two different scripts since we build 32-bit binaries for all types of powerpc, but have little endian and big endian variations that are different by only two lines. Set the output format and include the rest. Move to foo.ldscript as well. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44058
* kboot: Centralize ldscript additionWarner Losh2024-02-257-6/+3
| | | | | | | | | | | Make the pattern for ldscripts always be arch/$MACHINE_ARCH/$MACHINE_ARCH.ldscript so we can add it from a central Makefile. This also moves from ldscript.arch to arch.ldscript to match the loader's new convention. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44057
* loader: Move ldscripts to match more standard practicesWarner Losh2024-02-256-2/+2
| | | | | | | | | In the larger open source community, ld scripts are foo.ldscrpt rather than ldscript.arch like we use here. This moves the EFI ldscripts. Sponsored by: Netflix Reviewed by: tsoome, kevans, emaste Differential Revision: https://reviews.freebsd.org/D44056
* loader: rename gfx_interp_md to gfx_interp_refWarner Losh2024-02-245-5/+5
| | | | | | | | | We have the call to gfx_interp_ref to bring in the .o so that we get the linker set item to add the language bindings at the right time. Where we call it is not the right time... So the _ref name is better. Change it before we have too many others like it. Sponsored by: Netflix
* loader: These files have no copyrightable materialWarner Losh2024-02-224-0/+8
| | | | | | | These files have no copyrightable material, and so are in the public domain. Sponsored by: Netflix
* libsa: Remove redundant sys/cdefs.hWarner Losh2024-02-22165-185/+3
| | | | Sponsored by: Netflix
* loader: return errors from writing ZFS labelsWarner Losh2024-02-221-1/+1
| | | | | | | | | vdev_write_bootenv_impl can only return success. Instead, return the last error. This will make any write errors more visible. The old code masked kboot's inability to write bootenv. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44018
* kboot: Implement write support for hostdiskWarner Losh2024-02-221-7/+8
| | | | | | | | | | Don't assume that strategy is only called for read. Check the passed flag for F_READ or F_WRITE and fail if it is neither. Open the disks for writing and call host_read/host_write depending on that flag. Sponsored by: Netflix Reviewed by: kevans, gallatin Differential Revision: https://reviews.freebsd.org/D44016
* loader/efi: Make gcc friendlier by move md_devWarner Losh2024-02-211-1/+2
| | | | | | | | | | | Move the extern struct devsw md_dev out of the function. gcc is happier with this arrangemnt often. However, we really should move it to a header file, but that requires a bit of a rework of md support and config. Sponsored by: Netflix Reviewed by: manu, tsoome Differential Revision: https://reviews.freebsd.org/D44008
* loader: Retire CTASSERTWarner Losh2024-02-214-11/+6
| | | | | | | | | The project is moving away from CTASSERT in favor of _Static_assert. Cleanup the few instances in the loader proactively. Sponsored by: Netflix Reviewed by: manu, tsoome Differential Revision: https://reviews.freebsd.org/D44006
* kboot: Fix zfs bootonce protocolWarner Losh2024-02-211-20/+15
| | | | | | | | This wasn't updated when the other copies were updated. Make it identical to efi code. We should likely refactor this (with userboot), but they are all not quite identical. Sponsored by: Netflix
* loader: For the mini-stdio we have for lua, #define them to something elseWarner Losh2024-02-211-0/+21
| | | | | | | | | | | | To make it easier to port lua and some of the lua modules, we have a series of routines to implement the stdio routines, even though we don't normally implement them in the boot loader. Add a comment to this effect. Also, some tools, like sanitizers and static analysis tools, make unwarranted assumptions about these, so #define them to a different name so they stop. Sponsored by: Netflix
* loader/libofw: Fix disk size truncationJustin Hibbits2024-02-211-1/+1
| | | | | | | At present OF_ioctl first multiplies, then casts to 64-bit, meaning at the asm level it truncates the result to 32-bit, then zero-extends it to 64-bit to return. Cast `n` to 64-bit before multiplying, so that the correct result is returned.
* loader: Make MK_LOADER_BIOS_TEXTONLY workWarner Losh2024-02-184-20/+88
| | | | | | | | | | | | | | | | | | | Select between text-only and graphical frame buffer consoles for the BIOS boot loader. Pull one or the other in with #ifdef in conf.c. Add gfx_bios.c for the few routines that are needed for the BIOS support of gfx. These are stubbed out for text-only mode. Move bi_load_vbe_data here since it's only used for the graphical frame buffer. Note: This setup also allows us to build multiple BIOS loaders if we have to, some with text-only and some graphical. We don't do this today. We may be forced to turn this on in the future if ZFS keeps growing. The size savings is 41k, which helps a lot with some of our users that want to enable more options in the BIOS boot loader than are normally safe to do, and they don't need graphics. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43917
* loader: Add textvidc to buildWarner Losh2024-02-181-0/+3
| | | | | | | Add textvidc to the build. And use -DTERM_EMU to build it. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43915
* loader: bring back old text-only video consoleWarner Losh2024-02-181-0/+645
| | | | | | | | | | | | | | Bring back vidconsole.c as textvidc.c from 2a0e2c88db20. This console does no graphics stuff at all, supports no fancy logos, has known bugs in the terminal emulation, etc. However, it is small. It will be a build-time option to select between the two. The BIOS loader is running out of space when too many options are selected, so this allows people to select the smaller one to spend the space elsewhere. This is only the verbatim copy of the old vidconsole.c. It's not yet connected to the build. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43911
* loader: Bump the limit to 560,000 bytes for BIOS loaderWarner Losh2024-02-161-3/+2
| | | | | | | Further experience suggests we do not need as much margin. This was mistakenly bumped to 570,000 in a prior commit, so this undoes that. Sponsored by: Netflix
* loader: line line per src file in libi386Warner Losh2024-02-161-8/+29
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43913
* loader: Simplify build a littleWarner Losh2024-02-162-7/+4
| | | | | | | | | | | Confine -DDISK_DEBUG to biosdisc.c, the only file it affects. Use modern variable arrays instead of alloca and add a sanity size minimum for biospnp nodes. These nodes are tiny enough that we needn't do a malloc/free pair: the stack is fine. Sponsored by: Netflix Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D43914
* kboot: Add our own lua bindingsWarner Losh2024-02-165-1/+31
| | | | | | | | Create a small wrapper around the new flua hash module so we can use it here too. There's no 4th bindings, nor will they be created. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43874
* loader: Move drawer.lua over to gfx table.Warner Losh2024-02-161-6/+19
| | | | | | | | | | | | | Drawer.lua is the only bit of lua code in the base that uses any of the functons moved from the loader table to the gfx table. Move the main code to using the gfx dispatch. Add compat code for running on old loaders that creates the newer-style gfx table with the term_* functions we call in it populated. This will even work on the super old versions of the loader that don't have them (we'll still skip using them). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43908
* loader: Move gfx functions to gfx.lua.8Warner Losh2024-02-163-72/+124
| | | | | | | | | | Now that the fb_* and term_* functions are available in the gfx table, move the documentation to gfx.lua.8. Add information about backwards compatibility. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43907
* loader: Move to using linker sets to bring in optional bitsWarner Losh2024-02-163-26/+39
| | | | | | | | | The graphics stuff is optional. When it is pulled into the system, we use a linker set to initialize the lua bindings for it now. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43906
* loader: Remove gfx_fb_stub.c, it's no longer neededWarner Losh2024-02-165-85/+2
| | | | | | | | | | Now that we draw in the gfx bindings for all our interpreters only when graphics support is compiled in, we can eliminate this from all the loaders that don't have graphics support. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43905