loader: set boot_safe when safe mode is selected

This may be used to disable or limit functionality of some services
when safe mode is selected. The particular value of boot_safe should not
be considered significant, only its presence in the environment.

Reviewed by:	imp, tsoome
Differential Revision:	https://reviews.freebsd.org/D32172
This commit is contained in:
Kyle Evans 2024-12-13 22:31:22 -06:00
parent 212d7f439a
commit 48b05b8fc2
3 changed files with 20 additions and 1 deletions

View file

@ -128,6 +128,7 @@ also menu-namespace also menu-command-helpers
s" set hw.ata.atapi_dma=0" evaluate
s" set kern.eventtimer.periodic=1" evaluate
s" set kern.geom.part.check_integrity=0" evaluate
s" set boot_safe=YES" evaluate
;
: safemode_disable ( -- )
@ -136,6 +137,7 @@ also menu-namespace also menu-command-helpers
s" hw.ata.atapi_dma" unsetenv
s" kern.eventtimer.periodic" unsetenv
s" kern.geom.part.check_integrity" unsetenv
s" boot_safe" unsetenv
;
: init_safemode ( N -- N )

View file

@ -179,12 +179,14 @@ function core.setSafeMode(safe_mode)
loader.setenv("hw.ata.atapi_dma", "0")
loader.setenv("kern.eventtimer.periodic", "1")
loader.setenv("kern.geom.part.check_integrity", "0")
loader.setenv("boot_safe", "YES")
else
loader.unsetenv("kern.smp.disabled")
loader.unsetenv("hw.ata.ata_dma")
loader.unsetenv("hw.ata.atapi_dma")
loader.unsetenv("kern.eventtimer.periodic")
loader.unsetenv("kern.geom.part.check_integrity")
loader.unsetenv("boot_safe")
end
core.sm = safe_mode
end

View file

@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 29, 2021
.Dd September 30, 2021
.Dt LOADER_SIMP 8
.Os
.Sh NAME
@ -339,6 +339,21 @@ In a running system, the state of console muting can be manipulated by the
utility.
.It Va boot_pause
During the device probe, pause after each line is printed.
.It Va boot_safe
Force userland to boot in
.Dq safe mode ,
which may disable or limit the functionality of some services that may not be
desired in safe mode.
This is typically set by selecting
.Dq safe mode
in the loader menu, which also sets some other hints for the kernel.
Applications wishing to respect safe mode should
.Sy only
test for the presence of
.Va boot_safe
in
.Xr kenv 1 ,
not for any particular value.
.It Va boot_serial
Force the use of a serial console even when an internal console
is present.