Commit graph

1349 commits

Author SHA1 Message Date
Marcin Wojtas
5b042fcbdf Disable PIE for powerpc bootloaders.
Bootloaders for powerpc are not built as position independent
code. Since bsd.prog.mk is used for building, when PIE is enabled,
the PIE flags are added and that causes the build to fail.
Adding MK_PIE=no stops bsd.prog.mk from adding PIE specific flags.

Submitted by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D28893

(cherry picked from commit 3aa023643e)
2022-01-23 11:09:53 +01:00
Marcin Wojtas
afd4a49407 Disable PIE for MIPS ubldr
When performing buildworld for MIPS with PIE enabled, the build fails
with "position-independent code requires '-mabicalls'" message.
-mno-abicalls and -fno-pic flags are explicitly set in MIPS ubldr
makefile, so to work around this problem, set MK_PIE=no for MIPS
ubldr.

Submitted by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D28370

(cherry picked from commit cd992885bc)
2022-01-23 11:09:53 +01:00
Marcin Wojtas
f79791ab60 Disable PIE for MIPS BERI boot loader
MIPS BERI boot loader is built with -mno-abicalls and -fno-pic
so prevent adding PIE-related build flags.

Fix build after 9a227a2fd6 ("Enable PIE by default on 64-bit architectures")

Obtained from: Semihalf
Sponsored by: Stormshield

(cherry picked from commit 19cd12a32a)
2022-01-23 11:09:52 +01:00
Emmanuel Vadot
b47fc941b0 loader: Fix dtb loading
When calling file_findfile with only a type it returns
the first file matching the type. But in fdt_apply_overlays we
then iterate on the next files and try loading them as dtb overlays.
Fix this by checking the type one more time.

Sponsored by:	Diablotin Systems
Reported by:	Mark Millard <marklmi@yahoo.com>

(cherry picked from commit b464c459ea)
2022-01-14 14:44:36 +01:00
Emmanuel Vadot
7f08e54f52 loader: Do not force comconsole for arm and arm64
This makes GOP not probed on some situation (AMD Card on PCIe slot
with EDK2 as we have a SERIAL_IO_PROTOCOL compatible uart).

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D32992
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 123b5b8763)
2022-01-14 14:38:34 +01:00
Emmanuel Vadot
50af79ac2d loader: lsefi: Print more information
Printing the EFI_HANDLE pointer isn't very useful.
If the handle have a IMAGE_DEVICE_PATH or a DEVICE_PATH protocol print it.
This makes it easier to see which devices are present and what protocol they
expose.

Reviewed by:	imp, tsoome
Differential Revision:	https://reviews.freebsd.org/D32991
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 2e0d67c3ed)
2022-01-14 14:38:25 +01:00
Emmanuel Vadot
14f0497aa4 loader: Add more bus name to pnpautoload
Add ofwbus, iicbus and spibus to pnpautoload so modules under those
buses will be loaded.
On my rockpro64 now :
OK pnpautoload -v
Autoloading modules for simplebus
Using DTB provided by EFI at 0x8100000.
Autoloading modules for ofwbus
/boot/kernel/rk_spi.ko text=0x14b2 text=0xd4c data=0x4d0+0x8 syms=[0x8+0xa98+0x8+0x807]
/boot/kernel/dwwdt.ko text=0x12e2 text=0x78c data=0x4c8+0x10 syms=[0x8+0x990+0x8+0x6e1]
Autoloading modules for iicbus
Autoloading modules for spibus
/boot/kernel/mx25l.ko text=0x1613 text=0x114c data=0x6e8+0x8 syms=[0x8+0xa08+0x8+0x665]
loading required module 'fdt_slicer'
/boot/kernel/fdt_slicer.ko text=0x95e text=0x340 data=0x290 syms=[0x8+0x6c0+0x8+0x4a0]

(cherry picked from commit 4c0c353d0e)
2022-01-14 14:38:07 +01:00
Emmanuel Vadot
e52cb5ee22 loader: Fix pnpload and add some usage
pnpload needs a busname and a compat data.

(cherry picked from commit d4874307fd)
2022-01-14 14:37:55 +01:00
Emmanuel Vadot
a327bd3058 loader: Fix pnpmatch and add some usage
pnpmatch needs a busname and a compat data.

(cherry picked from commit 544af629a4)
2022-01-14 14:37:39 +01:00
Emmanuel Vadot
9418a62610 stand: Don't build readtest command on mips
MIPS doesn't have getsecs which is used in this command.
Simply don't include it for this arch.

This is a direct commit to stable/13.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-01-13 14:38:24 +01:00
Emmanuel Vadot
d37a33f52c loader: tftp: Copy the first block into the cache
tftp_open reads the first block so copy it in the cached data.
If we have more than one block (i.e. we called tftp_read before
tftp_preload) simply just reset the transfer.

Reported by:	mmel
Reviewed by:	mmel, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33697

(cherry picked from commit dfc9c1d493)
2022-01-13 08:59:03 +01:00
Emmanuel Vadot
28d2b8b700 loader: lua: test that /boot exists first
Otherwise on fs like tftp where no directory listing is possible we fail
on the .dir method.

Reviewed by:	imp, kevans
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33414

(cherry picked from commit c4dc907254)
2022-01-13 08:58:54 +01:00
Emmanuel Vadot
c95afea4a8 loader: bcache: Fix debug printf
Use %j to it works on 64 and 32 bits system.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33430

(cherry picked from commit 8ed8b4203a)
2022-01-13 08:58:46 +01:00
Emmanuel Vadot
d852525555 loader: tftp: Add preload method
The preload method will transfer the whole file in a buffer and cache it
so read/lseek operations are faster.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33410

(cherry picked from commit 3eb019000c)
2022-01-13 08:58:39 +01:00
Emmanuel Vadot
37e1449d29 loader: Add preload operation to fs_ops
When we load an ELF file (kernel or module) we do seek(2) a lot to
parse/load the different sections of the ELF file.
Protocol like TFTP suffers a lot from this as there is no resume or
a way to start the tranfer from a specified offset in the file.
fs_preload is added to help those protocol.
Call preload just after opening the ELF file that we need to load so
the underlying method can cache the hole file and then read/lseek operations
are faster.

Reviewed by:	imp
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33409

(cherry picked from commit c25d9aff46)
2022-01-13 08:58:31 +01:00
Toomas Soome
bc9154a208 loader: implement mount/unmount rootfs
We want to keep our root file system open to preserve bcache segment
between file accesses, thus reducing physical disk IO.

Reviewed by:	imp, allanjude, kevans (previous version)
Differential Revision:	https://reviews.freebsd.org/D30848
MFC after:	1 month

(cherry picked from commit b4cb3fe0e3)
2022-01-13 08:58:21 +01:00
Emmanuel Vadot
4003cdd81b loader: ip: Do not call getsecs so much
getsecs is very costly, reuse the values we got before.

Fetching a ~30MB kernel with the tftp command use to take ~26 seconds
and now it's ~18 seconds.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33408

(cherry picked from commit c5f24f5e0d)
2022-01-13 08:56:00 +01:00
Emmanuel Vadot
e3ef89ba96 loader: tftp: Don't let tftp timeout
When we load a kernel or module we open/close it a few times.
Since we're using the same port number each time and that we requested
the same file the ACK that we send are valid on the server side and the
server send us the file multiple times.
This makes tftp loading time very inconsistant due to the UDP "flood" that
we have to process.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33407

(cherry picked from commit 4f36ed513c)
2022-01-13 08:55:51 +01:00
Emmanuel Vadot
0078d54c09 loader: Add a readtest command
readtest will simply load the file in memory, useful for timing
loading on some filesystems.

Reviewed by:	tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33411

(cherry picked from commit 70661eaafa)
2022-01-13 08:55:42 +01:00
Emmanuel Vadot
62c7a7774f loader: tftp: Don't error on tftp error 0
tftp-hpa sends NAK with tftp error set to 0 when trying to get
a directory and this is the first thing that loader tries to do
and this make it hangs.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33406

(cherry picked from commit bf07f2f862)
2022-01-13 08:55:22 +01:00
Toomas Soome
835f59f324 loader.efi: to preserve heap space, use AllocatePages() for shadow_fb
shadow FB size could be rather large and depends on resolution,
instead of using heap, allocate dedicated space outside of heap.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D33600

(cherry-picked from 221376db0c)
2022-01-10 12:28:30 +02:00
Toomas Soome
04a0bd52d6 loader: framebuffer should only be written into
Reading from Write Combining memory can be very-very slow. Try to use
shadow buffer to avoid such reads.

Differential Revision: https://reviews.freebsd.org/D33305

(cherry-picked from 6102f43cf0)
2022-01-10 12:26:57 +02:00
Andrew Turner
d41cd6cce7 Add an loader command on arm64 to sync the cache
On boot we don't need to perform any CPU cache management when the IDC
and DIC fields in the ctr_el0 register are set. Add a command to tell
loader to ignore these fields. This could be useful, for example, if the
hardware is misreporting the values and we are missing a quirk to enable
it.

It is not expected this will be needed, but is only intended as a
workaround to ensure the kernel can still boot.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c399283c71)
2022-01-04 10:08:32 +00:00
Andrew Turner
cc217b6881 Don't sync the I/D caches when they are coherent
In the arm64 loader we need to syncronise the I and D caches. On some
newer CPUs the I and D caches are coherent so we don't need to perform
these operations.

While here remove the arguments to cpu_inval_icache as they are unneeded.

Reported by:	cperciva
Tested by:	cperciva
Sponsored by:	Innovate UK

(cherry picked from commit c1381f07f6)
2022-01-04 10:08:31 +00:00
Colin Percival
3684bb89d5 MFC: Improve readahead in loader
style: Fix leading whitespace in bcache.c
loader: Refactor readahead adjustment in bcache
loader bcache: Track unconsumed readahead
loader bcache: Allow readahead up to 256 kB I/Os

Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 5a01dea7e8)
(cherry picked from commit b841148bbb)
(cherry picked from commit 04b9b7c507)
(cherry picked from commit 248682a589)
2021-12-29 14:53:19 -08:00
Maxim Sobolev
57e897ec3d Only trigger read-ahead if two adjacent blocks have been requested.
The change makes block caching algorithm to work better for remote
media on low-BW/high-delay links.

This cuts boot time over IP KVMs noticeably, since the initialization
stage reads bunch of small 4th (and now lua) files that are not in
the same cache stripe (usually), thus wasting lot of bandwidth and
increasing latency even further.

The original regression came in 2017 with revision 87ed2b7f5. We've
seen increase of time it takes for the loader to get to the kernel
loading from under a minute to 10-15 minutes in many cases.

Reviewed by:	tsoome
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D31623

(cherry picked from commit 0d13f5343f)
2021-12-29 14:53:19 -08:00
Colin Percival
cdbcf636d3 EFI loader: Don't free bcache for DEVT_DISK devs
Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os
performed from 609 to 432, reduces the total number of blocks read
from 61963 to 60797, and reduces the time spent in the loader by 39 ms.

Note that b4cb3fe0e3 allowed the bcache to be retained for most of
the boot process, but relies on mounting filesystems; this commit
allows the bcache to be retained at the start of the boot process,
before the root filesystem has been located.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D32239

(cherry picked from commit ce73f768b7)
2021-12-29 14:53:19 -08:00
Colin Percival
b80a1b584f MFC: Add TSLOG to loader sprintf
loader tslog: Don't use sprintf
loader printf: Profile with TSLOG

Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 242923eb84)
(cherry picked from commit 0a35c4b3ca)
2021-12-29 14:53:19 -08:00
Colin Percival
45156a9468 loader: Set twiddle globaldiv to 16 by default
Booting FreeBSD on an EC2 c5.xlarge instance, the loader "twiddles"
810 times over the course of 510 ms, a rate of 1.59 kHz. Even accepting
that many systems are slower than this particular VM and will take
longer to boot (especially if using spinning-rust disks), this seems
like an unhelpfully large amount of twiddling when compared to the
~60 Hz frame rate of many displays; printing the twiddles also consumes
roughly 10% of the boot time on the aforementioned VM.

Setting the default globaldiv to 16 dramatically reduces the time spent
printing twiddles to the console while still twiddling at roughly 100
Hz; this should be ample even for systems which take longer to boot and
consequently twiddle slower.

Note that this can adjusted via the twiddle_divisor variable in
loader.conf, but that file is not processed until nearly halfway
through the loader's runtime.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D32163

(cherry picked from commit 7457840230)
2021-12-29 14:53:19 -08:00
Colin Percival
c2de531781 MFC: arm64 fixes for TSLOG
arm64: Disable early printf if TSLOG
arm64: Instrument initarm with TSLOG
libsa: Add tslog support for arm64

Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 0acc529dc3)
(cherry picked from commit ccadcb8f33)
(cherry picked from commit e6caac717b)
2021-12-29 14:53:18 -08:00
Colin Percival
89a9852f32 MFC loader+userland TSLOG support
stand/common: Add file_addbuf()
libsa: Add support for timestamp logging (tslog)
stand/common: Add support for timestamp logging (tslog)
i386/loader: Call tslog_init
efi/loader: Call tslog_init (+ bugfix)
stand/common command_boot: Pass tslog to kernel
kern_tslog: Include tslog data from loader
loader: Use tslog to instrument some functions
Add userland boot profiling to TSLOG (+ bugfix)

Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 60a978bec9)
(cherry picked from commit e193d3ba33)
(cherry picked from commit c8dfc327db)
(cherry picked from commit c4b65e954f)
(cherry picked from commit f49381ccb6)
(cherry picked from commit 537a44bf28)
(cherry picked from commit fe51b5a76d)
(cherry picked from commit 313724bab9)
(cherry picked from commit 46dd801acb)
(cherry picked from commit 52e125c2bd)
(cherry picked from commit 19e4f2f289)
2021-12-29 14:53:18 -08:00
Gordon Bergling
1c53a9d354 gfx_fb: Fix a typo in a source code comment
- s/decriptor/descriptor/

(cherry picked from commit b5e0a70193)
2021-12-25 11:40:36 +01:00
Alexander Motin
76cbf78640 loader.efi: Do not use as frame buffer BLT-only GOPs.
Kernel needs physical frame buffer address and size, which Block
Transfer-only Graphics Output Protocol instances do not have.

Some recent ASUS boards like PRIME Z690M-PLUS D4 and PRIME H570-Plus
report two GOPs, out of which the second one support ConOut protocol,
that made it preferable, but is BLT-only, that made console unusable.

Discussed with:	tsoome (previous version)
MFC after:	1 week

(cherry picked from commit 02732f945e)
2021-12-22 23:02:11 -05:00
Ed Maste
bf4a70bb40 libc: Use musl's optimized strchr and strchrnul
Parentheses added to HASZERO macro to avoid a GCC warning, and formatted
with clang-format as we have adopted these and don't consider them
'contrib' code.

Obtained from:	musl (snapshot at commit 4d0a82170a25)
Reviewed by:	kib (libc integration), mjg (both earlier)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17630

(cherry picked from commit 7f72497ef7)
2021-12-12 17:32:33 -05:00
Alfonso
85ba40da4c ANSIify libsa functions
Convert libsa files to use ANSI function definitions.

Pull request: https://github.com/freebsd/freebsd-src/pull/508
[ cut and paste error corrected ]

(cherry picked from commit 1f629966d6)
2021-12-06 08:55:54 -07:00
Gordon Bergling
179e795f0d ficl: Fix a typo in a comment
- s/segement/segment/

(cherry picked from commit 54c1a65736)
2021-12-03 16:53:00 +01:00
Gordon Bergling
0729442a85 efi(8): Fix a typo in a source code comment
- s/writting/writing/

(cherry picked from commit 2b0f6ad444)
2021-11-11 17:26:43 +01:00
Leandro Lupori
8a62b07bce powerpc64le: stand fixes
Fix boot1 and loader on PowerPC64 little-endian (LE).

Due to endian issues, boot1 couldn't find the UFS boot partition
and loader wasn't able to load the kernel. Most of the issues
happened because boot1 and loader were BE binaries trying to access
LE UFS partitions and because loader expects the kernel ELF image
to use the same endian as itself.

To fix these issues, boot1 and loader are now built as LE binaries
on PPC64LE. To support this, the functions that call OpenFirmware
were enhanced to correctly perform endian conversion on its input
and output arguments and to change the CPU into BE mode before
making the calls, as OpenFirmware always runs in BE. Besides that,
some other small fixes were needed.

Submitted by:		bdragon (initial version)
Reviewed by:		alfredo, jhibbits
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D32160

(cherry picked from commit f83288645c)
2021-11-05 11:29:40 -03:00
John Baldwin
de705beeef crypto: Permit variable-sized IVs for ciphers with a reinit hook.
Add a 'len' argument to the reinit hook in 'struct enc_xform' to
permit support for AEAD ciphers such as AES-CCM and Chacha20-Poly1305
which support different nonce lengths.

Reviewed by:	markj
Sponsored by:	Chelsio Communications, The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32105

(cherry picked from commit 1833d6042c)
(cherry picked from commit d586c978b9)
2021-10-21 13:47:58 -07:00
Toomas Soome
b91af716ed loader: dev_net.c should use __func__ with printf
We have printf calls with function name hardwired to string,
sometimes wrong name. Use __func__ instead.

(cherry picked from commit 1a25c51e38)
2021-10-01 09:55:18 +03:00
Konstantin Belousov
caaf4ae21e amd64 UEFI loader: enable automatic disable of staging area copying
(cherry picked from commit 6032b6ba95)
2021-10-01 03:32:24 +03:00
Leandro Lupori
cc8e726c85 powerpc64: change CAS to support Radix MMU
Use radix_mmu environment variable to select between Hash or Radix
MMU, when performing the CAS method call. This matches kernel's
behavior, by selecting Hash MMU by default and Radix if radix_mmu
is not zero, to make sure that both loader and kernel always select
the same MMU.

The device tree is queried to detect Radix/GTSE support and to
find out if CAS is supported, making the old CPU version and HV
bit checks unnecessary now.

Reviewed by:		jhibbits
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31951

(cherry picked from commit a58abcde2c)
2021-09-30 08:34:16 -03:00
Mark Johnston
bd4fbd4e14 efi loader: Typo
(cherry picked from commit 0e3ce6d082)
2021-09-24 09:00:56 -04:00
Dimitry Andric
6d8f2277de i386 loaders: avoid lld 13 garbage collecting linker sets
Because lld 13 and higher default to garbage collecting start/stop
symbols when using --gc-sections, the linker sets used in the i386 boot
loaders will disappear. This leads to the loaders not recognizing any
commands, and failure to boot.

Until we have a good set of linker scripts for the loaders, work around
it by disabling the start-stop-gc feature.

(cherry picked from commit c90cab0d66)
2021-09-15 12:28:44 +02:00
Warner Losh
c5d7cc4fb4 stand: Add MK_PIE=no to defs.mk
There's no need to build both pie and non-pie .o's for stand. There's
some other build thing with MK_BEAR_SSL=yes and/or MK_LOADER_VERIEXEC=yes
that causes the pie build to fail that the 'ar' stage now. Since we don't
need the PIE stuff and the non-PIE stuff, disable PIE for the boot loader.

Reviewed by:	emaste
Sponsored by:	Netflix

(cherry picked from commit 879675e9a0)
2021-09-12 09:56:17 -06:00
Warner Losh
6c8ad124a2 cli.lua.8: make the command match the code
It's disable-device, not device-disable

Spotted by:		jrtc27
Sponsored by:		Netflix

(cherry picked from commit 6b51baf6a8)
2021-09-12 09:56:15 -06:00
Warner Losh
25b4b24edf lua loader: Add disable-device to disable a device.
disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by:		tsoome
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D31297

(cherry picked from commit 07c4b78d0a)
2021-09-12 09:56:15 -06:00
John Hood
3a4b9e30d4 loader: support.4th resets the read buffer incorrectly
Large nextboot.conf files (over 80 bytes) are not read correctly by the
Forth loader, causing file parsing to abort, and nextboot configuration
fails to apply.

Simple repro:

nextboot -e foo=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shutdown -r now

That will cause the bug to cause a parse failure but shouldn't otherwise
affect the boot.  Depending on your loader configuration, you may also
have to set beastie_disable and/or reduce the number of modules loaded
to see the error on a small console screen.  12.0 or CURRENT users will
also have to explicitly use the Forth loader instead of the Lua loader.
The error will look something like:

Warning: syntax error on file /boot/loader.conf.local
foo="xxxxxxxxxxxxxxnextboot_enable="YES"
                                    ^
/boot/support.4th has crude file I/O buffering, which uses a buffer
'read_buffer', defined to be 80 bytes by the 'read_buffer_size'
constant.  The loader first tastes nextboot.conf, reading and parsing
the first line in it for nextboot_enable="YES".  If this is true, then
it reopens the file and parses it like other loader .conf files.

Unfortunately, the file I/O buffering code does not fully reset the
buffer state in the reset_line_reading word.  If the last file was read
to the end, that doesn't matter; the file buffer is treated as empty
anyway.  But in the nextboot.conf case, the loader will not read to the
end of file if it is over 80 bytes, and the file buffer may be reused
when reading the next file.  When the file is reread, the corrupt text
may cause file parsing to abort on bad syntax (if the corrupt line has
<>2 quotes in it), the wrong variable to be set, no variable to be set
at all, or (if the splice happens to land at a line ending) something
approximating normal operation.

The bug is very old, dating back to at least 2000 if not before, and is
still present in 12.0 and CURRENT r345863 (though it is now hidden by
the Lua loader by default).

Suggested one-line attached.  This does change the behavior of the
reset_line_reading word, which is exported in the line-reading
dictionary (though the export is not documented in loader man pages).
But repo history shows it was probably exported for the PNP support
code, which was never included in the loader build, and was removed 5
months ago.

One thing that puzzles me: how has this bug gone unnoticed/unfixed for
nearly 2 decades?  I find it hard to believe that nobody's tried to do
something interesting with nextboot, like load a kernel and filesystem,
which is what I'm doing.

Tested by:		Gary Jennejohn
PR:			239315
MFC After:		3 weeks
Reviewed by:		imp (and correctly applied this time)
Differential Revision:	https://reviews.freebsd.org/D31328

(cherry picked from commit dbdf2b52f5)
2021-09-12 09:56:15 -06:00
Kyle Evans
8df27f0ace lualoader: use more concise verbiage for autoboot
The behavior remains the same, but lualoader now uses the more concise
verbiage that forthloader used.  This is particularly important because
the previous line would exceed the right boundary of the menu and run
straight into space that would typically be allowed for the logo.

This makes it slightly easier to port logos from forthloader to
lualoader.

(cherry picked from commit ed107537b4)
2021-09-12 00:34:28 -05:00
Kyle Evans
0c675cb9c9 lualoader: allow brands to specify a shift
Some brands will want to specify a shift to make sure they're properly
centered; let it happen.

(cherry picked from commit e19d9a9b6e)
2021-09-12 00:34:28 -05:00