aboutsummaryrefslogtreecommitdiff
path: root/stand/common
Commit message (Collapse)AuthorAgeFilesLines
* stand: Add support for 64-bit machines with 32-bit UEFI implementationsAhmad Khalifa2025-03-262-3/+3
| | | | | | | | | | | | | | Some machines have 64-bit capable cpus but are stuck on 32-bit uefi firmware. Add support for them by building a new "loader_ia32" with LOADER_DEFAULT_INTERP along with the 64-bit one. The loader can be disabled using MK_LOADER_IA32. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1098 (cherry picked from commit f8ca5d45c3c1829759ecd87cb95d53e5ab7d0811)
* loader: Increase buffer size to accommodate longer commandsAhmad Khalifa2025-03-261-2/+3
| | | | | | | | | | | | | | | | The longest command we have is "efi-autoresizecons". That combined with the two spaces before and after the command gives us a total of 23 characters including the null-terminator. Also move the two trailing spaces to their own pager_output call so they don't get truncated if the command is too long and increase the minimum string length to 20 in order to fix alignment issues caused by the increased buffer size. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1277 (cherry picked from commit ab08da5328b4175e399d8e59adc4dfad0eea24f1)
* loader: Add TSLOG to interpreter built-insColin Percival2024-09-291-0/+2
| | | | | | | | | | | Wrap each call to a built-in command with TSENTER/TSEXIT to make it easier to see where time is going in the loader. MFC after: 1 week Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D46630 (cherry picked from commit 58ec2d0d4a3c3bcf741d9694dc7696c7b4e753b9)
* stand: Kill commented out lineWarner Losh2024-08-011-1/+0
| | | | | | | | | | | | | This line is no longer needed as fallback, and should have been deleted in 7870a52598ad8 instead of commented out, but 26 years later, I have a high degree of confidence that old change was right and we won't need this line as a fallback. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D45880 (cherry picked from commit 65300ca729452f62c201baedcbb4a67f2afc5ed5)
* loader: Load a splash screen if "splash" variable is definedEmmanuel Vadot2024-07-292-0/+49
| | | | | | | | | | | | | | | | | Load a splash screen that vt(4) can use if the "splash" env variable is defined. For now only png is supported and decoding is done in loader and not in kernel compared to splash screen support in sc(4). For using this add: boot_mute="YES" splash="/boot/images/freebsd-logo-rev.png" in loader.conf Differential Revision: https://reviews.freebsd.org/D45932 Reviewed by: imp, tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 00460cc8c5ad02b628e81eec9e493a1df8393d36)
* stand: module: unlink the entire tail when dependencies fail to loadKyle Evans2024-07-211-5/+26
| | | | | | | | | | | | | | | | | | | | | | | Assume you have loader configured to load linux64, which has a dependency on both linux_common and mqueuefs but neither the kernel nor kernel config in question have the mqueuefs module included. When the load command for linux64 fails to find mqueuefs, it will free both linux64 and linux_common as they were loaded first, but only linux64 gets removed from the module list. As a result, future traversals hit an easy use-after-free with linux_common. Fix it so that we unlink the entire tail of the list. Anything after the initially loaded module is, by definition, a dependency on the loaded module while we're still in the load command, so we can just discard the entire tail. If linux_common were loaded before linux64, it should not move to a position during this load where it would suddenly be missing from the view presented to the kernel. Reported by: philip Reviewed by: imp, philip, tsoome (cherry picked from commit 3da568710fde08251996c117b87bedb326dedb57)
* loader: rename gfx_interp_md to gfx_interp_refWarner Losh2024-04-163-3/+3
| | | | | | | | | | | 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 (cherry picked from commit 6faf55c86d9b86f40de8d19970e42cb42a892c47)
* loader: These files have no copyrightable materialWarner Losh2024-04-164-0/+8
| | | | | | | | | These files have no copyrightable material, and so are in the public domain. Sponsored by: Netflix (cherry picked from commit 27c0f2a544989760c4b3b16a3615839c8ab44b32)
* libsa: Remove redundant sys/cdefs.hWarner Losh2024-04-1625-31/+0
| | | | | | Sponsored by: Netflix (cherry picked from commit 3e15b01d6914c927e37d1699645783acf286655c)
* loader: Retire CTASSERTWarner Losh2024-04-161-4/+0
| | | | | | | | | | | 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 (cherry picked from commit 32568e5f2435a2539b0c4177a6fefe7a9e0a0c89)
* loader: Move to using linker sets to bring in optional bitsWarner Losh2024-04-161-26/+3
| | | | | | | | | | | 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 (cherry picked from commit 0921a771da8a9117edf26352a8a047bacbfcee45)
* loader: Remove gfx_fb_stub.c, it's no longer neededWarner Losh2024-04-161-76/+0
| | | | | | | | | | | | 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 (cherry picked from commit 23d9b5c9febf4b02957d01bc46ee75530b0dcb4a)
* loader: Only create gfx 4th bindings when gfx is availableWarner Losh2024-04-161-0/+1
| | | | | | | | | | | | | | Only create the gfx bindings for 4th when it's compiled into the loader. We do this with a linker set that only gets brought in to those loaders that call gfx_framework_init. This calls gfx_interp_md() will will drag in gfx_loader.c which will add to the linker set that registers these bindings. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43904 (cherry picked from commit 9c8bf69a53f628b62fb196182ea55fb34c1c19e1)
* loader: Add prototype for gfx_interp_mdWarner Losh2024-04-162-0/+10
| | | | | | | | | | | | This function will be used to draw in the graphics bindings when the loader is compiled with graphics (gfx) support. Provide definitions for lua and the simple interpreter. 4th support is forthcoming. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43903 (cherry picked from commit 60e199d9fde1c3c60a96b969bf6982278cbc1e88)
* loader: Create new gfx tableWarner Losh2024-04-161-0/+27
| | | | | | | | | | | | Create a new gfx global table. Put into it all the graphics bindings that we have in loader today. For now, have compatability binding for loader. Remove them from loader. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43902 (cherry picked from commit 9b16231032ddb40be282d76ec0d82b3a0ec96d60)
* loader: Fetch initial script from loader_lua envWarner Losh2024-04-161-1/+3
| | | | | | | | | | | Sometimes it is nice to override the initial script that we run. Make it possible by fetching loader_lua from the env and using that instead of the default if prsent. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43819 (cherry picked from commit cd147a2a024301a796f307c7bae686305d2bf302)
* libsecureboot do not report expected unverified filesSimon J. Gerraty2024-04-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default only report unverified files at severity VE_WANT and above. This inlcudes *.conf but not *.hints, *.cookie or *.tgz which get VE_TRY as their severity. If Verbose is set to 0, then VerifyFlags should default to 0 too. Thus the combination of module_verbose=0 VE_VEBOSE=0 is sufficient to make the loader almost totally silent. When verify_prep has to find_manifest and it is verified ok return VE_NOT_CHECKED to verify_file so that it can skip repeating verify_fd Also add better debugging output for is_verified and add_verify_status. vectx handle compressed modules When verifying a compressed module (.ko.gz or .ko.bz2) stat() reports the size as -1 (unknown). vectx_lseek needs to spot this during closing - and just read until EOF is hit. Note: because of the way libsa's open() works, verify_prep will see the path to be verified as module.ko not module.ko.bz2 etc. This is actually ok, because we need a separate module.ko.bz2 entry so that the package can be verified, and the hash for module.ko is of the uncompressed file which is what vectx will see. Re-work local.trust.mk so site.trust.mk need only set VE_SIGN_URL_LIST (if using the mentioned signing server) interp.c: restrict interactive input Apply the same restrictions to interactive input as for unverified conf and hints files. Use version.veriexec when LOADER_VERIEXEC is yes Reviewed by: kevans Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43810 (cherry picked from commit f616d61ab6b071e5fbfdbae7033a9ef04c1444ad)
* loader: Move build_font_module to gfx_fb.cWarner Losh2024-04-162-87/+89
| | | | | | | | | The font module is part and parsel of the gfx_fb support. Move it to gfx_fb.c where it can access the data it needs. Sponsored by: Netflix (cherry picked from commit 18968b8274b56d8b60ab4e0d606e7f53f3a02014)
* stand: Use modern function definitionsWarner Losh2024-04-161-1/+1
| | | | | | | | Use modern function definitions for functions with no args. Sponsored by: Netflix (cherry picked from commit dcc20bced51583df83e49af269ff7be5fb48dbf8)
* stand: Automated cleanup of cdefs and other formattingWarner Losh2024-04-1611-11/+0
| | | | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix (cherry picked from commit 7c43148a974877188a930e4078a164f83da8e652)
* stand: Remove ancient SCCS tags.Warner Losh2024-04-161-2/+0
| | | | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix (cherry picked from commit 6e28a6bc2e83d56a5d2d5ee4f5da72d798de2d07)
* Stop #defining FREEBSD_ELFJohn Baldwin2024-01-053-3/+0
| | | | | | | | | | | | | | This was originally used (along with FREEBSD_AOUT) to prefer the use of ELF in various tools instead of a.out as part of the a.out to ELF transition in the 3.x days. The last use of it was removed from <link.h> in commit 66422f5b7a1a6055f0b2358268eb902aab6e2e3e back in 2002, but various files still #define it. Reviewed by: kevans, imp, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42964 (cherry picked from commit 4a3cf5f329d69076aa9d093d596eb0ee82d917f5)
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1636-72/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1610-20/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* base: Remove support for the VTOC8 partitioning schemeMarius Strobl2023-07-262-101/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The removal of the sparc64 support in February 2020 obsoleted the VTOC8 partitioning scheme as no other FreeBSD platform makes use of it. Moreover, the code is bitrotting as nothing defines e. g. LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With this change, the following commits are reverted as far as VTOC8 is concerned and parts haven't already previously been deleted along with prior sparc64 removals: 094fcb157d4c98211899cf09d06e2cf19149b7e0 a7d366e9589c95feda6f3bc78c59c6355d51f126 ba8d50d08b9df4e8213f9a6997ff6792ecebcd9b The alignment example d9711c28efc4ec89ba5ea11f8fd63e9d0a7fc81b added to the VTOC8 section of gpart.8 is folded into the MBR one. This should finally conclude the deorbit of sparc64-specific bits. We had joy, we had fun we ran Unix on a Sun. But that source and the song of FreeBSD have all gone. Credits to Michael Bueker for the original "Unix on a Sun" and Rod McKuen for the "Seasons in the Sun" lyrics.
* stand: Make non-matching console names OKerWarner Losh2023-05-111-2/+2
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D39984
* stand: Fix warning about variable unusedWarner Losh2023-05-011-3/+9
| | | | | | | dflag is unused when LOADER_VERIEXEC isn't defined, so move it under the ifdef. Sponsored by: Netflix
* loader: Change version calculation to be more consistent.Stephen J. Kiernan2023-04-193-2/+2
| | | | | | | | | | | | Use 1000 * major + minor when calculating the version number that gets set in the Ficl environment or lua loader property. This allows for more room if the minor number needs to go above 9. Add loader.version property to lua loader. Reviewed by: imp Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39631
* stand: fix buffer overflow in getrootmount()Robert Wing2023-02-251-4/+5
| | | | | | | Reviewed by: imp, allanjude Sponsored By: Beckhoff Automation GmbH & Co. KG Sponsored By: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38734
* loader: always install help filesMitchell Horne2023-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address two issues with current help file logic: The existing condition prevents the common help file from being installed when there are no additional help files defined. This results in no loader.help on EFI platforms, for example. Second, due to the fact that we build and install multiple loader types, each successive install will clobber the previous loader.help. The result is that we could lose type-specific commands, or possibly list them in loaders that do not have such commands. Instead, give each loader type a uniquely named help file. The EFI loader will look for /boot/loader.help.efi, userboot will look for /boot/loader.help.userboot, etc. The interpreter variant has no effect on which help file is loaded. This leaves the old /boot/loader.help unused. Some credit for the final approach goes to Mathieu <sigsys@gmail.com> for their version of the fix in https://reviews.freebsd.org/D22951. PR: 267134 Reported by: Daniel O'Connor <darius@dons.net.au> Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28591
* kboot: Don't need an arch pointer to get segmentsWarner Losh2023-02-031-3/+0
| | | | | | | | | | There's no need for an arch pointer to get segments. We can call the routine directly since we don't need this code to be called from different context where a pointer is needed. Sponsored by: Netflix Reviewed by: kevans, andrew Differential Revision: https://reviews.freebsd.org/D38266
* stand: only compute symidx on x86Warner Losh2023-02-021-1/+8
| | | | | | | | | We only use symidx on x86, so only compute it on x86 to fix a set but not used warning on aarch64. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38246
* loader: md: Use default func for fmtdev and parsedevEmmanuel Vadot2023-01-271-2/+0
| | | | | | | | | | The default function are enough for md so use them instead of the disks ones that doesn't work for it anymore. Reviewed by: imp Sponsored by: Beckhoff Automation GmbH & Co. KG MFC after: now Differential Revision: https://reviews.freebsd.org/D38218
* stand: Separate base and cli parts of nvstoreWarner Losh2023-01-132-160/+3
| | | | | | | | | | | | | | | zfs lives in libsa. However, it depends on nvstore (and other things) that are in common. Fix part of this layering violation by splitting nvstore into a libsa piece (which is the base implementation) and keeping a much smaller common piece (to implement the nvstore command). This just leaves zfs' knowledge of device names that's specific to common and its calling platform specific init code to resolve. Add a nvstore.h file for these two parts to communicate private things and move the public nvstore api from bootstrap.h to stand.h. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D38043
* stand: create common set_currdevWarner Losh2023-01-112-0/+18
| | | | | | | | | | | | Pull together the nearly identical copies of set_currdev in i386, userboot and efi. Other boot loaders have variances that might be fine to use the common routine, or not. Since they are harder to test for me, and ofw and uboot do handle these setting differently, leave them be for now. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38005
* stand: Move dev_cleanup into libsaWarner Losh2023-01-112-13/+0
| | | | | | | | | | | | | | Since dev_cleanup() walks through all the devsw devices with dv_cleanup rotuines, move it into libsa rather than having it in 'common'. Logically, it operates only on things that are in libsa, and would never be different for different loaders: either people would call it as is, or they'd do the loop themselves with 'special' things inline between calls to cleanup (not that I think that will ever be needed though). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38004
* stand: Create common gen_setcurrdev and replace codeWarner Losh2023-01-112-1/+18
| | | | | | | | | | Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid having to create a 5th copy. uboot_setcurrdev is actually different and needs to remain separate (even though it's quite similar). Sponsored by: Netflix Reviewed by: fuz@fuz.su, kevans Differential Revision: https://reviews.freebsd.org/D38003
* stand: update prototypes for md_load and md_load64Warner Losh2022-12-051-0/+3
| | | | | | | | | | | These are declared as extern in a number of files (some with the wrong return type). Centralize this in modinfo.h and remove a few extra stray declarations as well that are no longer used. No functional change. Note: I've not tried to cope with the bi_load() functions which are the same logical thing. These will be handled separately. Sponsored by: Netflix
* kboot: Add md_addr to metadataWarner Losh2022-12-042-1/+4
| | | | | | Save the address of where the metadata is loaded. Sponsored by: Netflix
* stand: parsedev API change: devspec now points to start of full device nameWarner Losh2022-11-301-1/+1
| | | | | | | | | | | | | | | | | | | | To support more flexible device matching, we now pass in the full devspec to the parsedev routines. For everything execpt uboot, this is just a drop in (since everything except uboot and openfirmware always uses disk...: and/or zfs:, but openfirmware isn't really affected). uboot we kludge around it by subtracting 4 from where the rest of the device name starts. This is unforunate, and can compute the address one before the string. But we never dereference that address. uboot needs more work, and this is an acceptable UB until that other work happens. OFW doesn't really use the parsedev routines these days (since none of the supported device uses this... yet). It too needs more work, but it needs device matching support first. Sponsored by: Netflix Reviewed by: delphij Differential Revision: https://reviews.freebsd.org/D37553
* stand: For all disk drivers, connect dv_parsedev to disk_parsedevWarner Losh2022-11-302-0/+2
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37339
* stand: Change disk_parsedev() APIWarner Losh2022-11-302-2/+7
| | | | | | | | | | | Change the first argument to disk_parsedev() to be a pointer to a struct devdesc *. This now gets filled in with a malloc'd structure that's returned to the caller that the caller is repsonsible for freeing. Most places in the tree passed in a malloc'd pointer anyway, and this moves knowledge of disk_devdesc more firmly into the disk.[ch] code. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37335
* stand: Remove unused enumWarner Losh2022-11-041-5/+0
| | | | | | | | enum disk_ioctl is unused. It's only ever defined. All of the stand code uses DIOCGSECTORSIZE and DIOCGMEDIASIZE instead, both to query and to implement ioctl. Sponsored by: Netflix
* stand: Nuke double-semicolonsElliott Mitchell2022-11-021-1/+1
| | | | | | | | | A distinct number of double-semicolons have ended up in FreeBSD. Take a pass at getting rid of many of these harmless typos. Reviewed by: emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/609 Differential Revision: https://reviews.freebsd.org/D31717
* geli: Move check for DEVT_DISK into geli_probe_and_attachWarner Losh2022-10-231-3/+1
| | | | | | | We only work on DEVT_DISK disks, so move that into the probe to drive the point home better. Sponsored by: Netflix
* loader: fix elf lookup_symbol type filteringKyle Evans2022-10-141-3/+2
| | | | | | | | | | | | | | | | | | The existing logic doesn't seem to make much sense, as we won't filter on the type if st_shndx != SHN_UNDEF. In practice, this breaks booting 12.3 kernels on newer loaders, as they do have a `kernphys` symbol of the wrong type (NOTYPE, rather than OBJECT) -- we end up deriving the wrong value for copy_staging. It's unclear if this version makes any more sense, but it seems to match what rtld's matched_symbol() does. Loader doesn't need to care about STT_FUNC w/ UND shndx, because we won't encounter those; in kmods, undefined (kernel) functions are NOTYPE. Reported by: Christian McDonald <cmcdonald netgate com> Reviewed by: imp, kib, tsoome MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D36975
* stand: fix mismergeWarner Losh2022-09-161-1/+0
| | | | | | | | Remove stray line from mismerge of 5d1531d9d4e7. This is no longer needed. Fixes: 5d1531d9d4e7 Sponsored by: Netflix
* stand/elf: Only support swapping headers on powerpc.Warner Losh2022-09-161-0/+16
| | | | | | | | | Powerpc is currently the only architecture that we support more than one endian. It's the only one that benefits from this swapping, so restrict the code to there. This saves about 1k in the i386 BIOS loader. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36577
* stand: collapse all copies of *copyenv into md_copyenvWarner Losh2022-09-163-28/+40
| | | | | | | | Use the efi's bi_copyenv to md_copyenv and place it in modinfo.c. Remove all other nearly identical and efi's has the best error handling. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36574