forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reboot: allow to specify reboot mode via sysfs
The kernel cmdline reboot= option offers some sort of control on how the reboot is issued. We don't always know in advance what type of reboot to perform. Sometimes a warm reboot is preferred to persist certain memory regions across the reboot. Others a cold one is needed to apply a future system update that makes a memory memory model change, like changing the base page size or resizing a persistent memory region. Or simply we want to enable reboot_force because we noticed that something bad happened. Add handles in sysfs to allow setting these reboot options, so they can be changed when the system is booted, other than at boot time. The handlers are under <sysfs>/kernel/reboot, can be read to get the current configuration and written to alter it. # cd /sys/kernel/reboot/ # grep . * cpu:0 force:0 mode:cold type:acpi # echo 2 >cpu # echo yes >force # echo soft >mode # echo bios >type # grep . * cpu:2 force:1 mode:soft type:bios Before setting anything, check for CAP_SYS_BOOT capability, so it's possible to allow an unpriviledged process to change these settings simply by relaxing the handles permissions, without opening them to the world. [[email protected]: fix variable assignments in type_store] Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux#1197 Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matteo Croce <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Kees Cook <[email protected]> Cc: Tyler Hicks <[email protected]> Cc: Nathan Chancellor <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
1 parent
f9a9050
commit 2c622ed
Showing
2 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
What: /sys/kernel/reboot | ||
Date: November 2020 | ||
KernelVersion: 5.11 | ||
Contact: Matteo Croce <[email protected]> | ||
Description: Interface to set the kernel reboot behavior, similarly to | ||
what can be done via the reboot= cmdline option. | ||
(see Documentation/admin-guide/kernel-parameters.txt) | ||
|
||
What: /sys/kernel/reboot/mode | ||
Date: November 2020 | ||
KernelVersion: 5.11 | ||
Contact: Matteo Croce <[email protected]> | ||
Description: Reboot mode. Valid values are: cold warm hard soft gpio | ||
|
||
What: /sys/kernel/reboot/type | ||
Date: November 2020 | ||
KernelVersion: 5.11 | ||
Contact: Matteo Croce <[email protected]> | ||
Description: Reboot type. Valid values are: bios acpi kbd triple efi pci | ||
|
||
What: /sys/kernel/reboot/cpu | ||
Date: November 2020 | ||
KernelVersion: 5.11 | ||
Contact: Matteo Croce <[email protected]> | ||
Description: CPU number to use to reboot. | ||
|
||
What: /sys/kernel/reboot/force | ||
Date: November 2020 | ||
KernelVersion: 5.11 | ||
Contact: Matteo Croce <[email protected]> | ||
Description: Don't wait for any other CPUs on reboot and | ||
avoid anything that could hang. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters