linux/Documentation
Matteo Croce 2c622ed0ea 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.

[natechancellor@gmail.com: fix variable assignments in type_store]
  Link: https://lkml.kernel.org/r/20201112035023.974748-1-natechancellor@gmail.com
  Link: https://github.com/ClangBuiltLinux/linux/issues/1197

Link: https://lkml.kernel.org/r/20201110202746.9690-1-mcroce@linux.microsoft.com
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Tyler Hicks <tyhicks@linux.microsoft.com>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-15 22:46:19 -08:00
..
ABI reboot: allow to specify reboot mode via sysfs 2020-12-15 22:46:19 -08:00
accounting
admin-guide kdump: append uts_namespace.name offset to VMCOREINFO 2020-12-15 22:46:18 -08:00
arm docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
arm64 A much quieter cycle for documentation (happily), with, one hopes, the bulk 2020-12-14 16:55:54 -08:00
block block-5.10-2020-10-24 2020-10-24 12:46:42 -07:00
bpf bpf: Migrate from patchwork.ozlabs.org to patchwork.kernel.org. 2020-10-11 22:05:47 +02:00
cdrom
core-api Generic interrupt and irqchips subsystem: 2020-12-15 15:03:31 -08:00
cpu-freq
crypto
dev-tools ubsan: remove UBSAN_MISC in favor of individual options 2020-12-15 22:46:19 -08:00
devicetree pci-v5.11-changes 2020-12-15 16:49:59 -08:00
doc-guide kernel-doc: Fix example in Nested structs/unions 2020-12-08 10:23:17 -07:00
driver-api Power management updates for 5.11-rc1 2020-12-15 16:30:31 -08:00
fault-injection A handful of late-arriving documentation fixes. 2020-10-23 17:13:53 -07:00
fb drm fixes (round two) for 5.10-rc1 2020-10-23 13:56:34 -07:00
features scripts: get_feat.pl: use its implementation for list-arch.sh 2020-12-03 15:10:14 -07:00
filesystems proc: provide details on indirect branch speculation 2020-12-15 22:46:15 -08:00
firmware_class
firmware-guide Documentation: ACPI: enumeration: add PCI hierarchy representation 2020-11-23 17:59:49 +01:00
fpga
gpu drm/docs: Fix todo.rst 2020-11-18 11:51:58 +01:00
hid
hwmon hwmon: (sbtsi) Add documentation 2020-12-12 08:34:29 -08:00
i2c
ia64 docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
ide
iio
infiniband
input Input: document inhibiting 2020-12-02 22:10:37 -08:00
isdn
kbuild kbuild: remove unused OBJSIZE 2020-11-02 11:31:00 +09:00
kernel-hacking
leds docs: leds: index.rst: add a missing file 2020-11-02 13:45:37 +01:00
litmus-tests
livepatch
locking Documentation: seqlock: s/LOCKTYPE/LOCKNAME/g 2020-12-09 17:08:49 +01:00
m68k docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
maintainer
mhi
mips docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
misc-devices Documentation: remove mic/index from misc-devices/index.rst 2020-11-04 11:38:32 +01:00
netlabel
networking Networking updates for 5.11 2020-12-15 13:22:29 -08:00
nios2 docs: nios2: add missing ReST file 2020-12-07 08:35:21 -07:00
nvdimm
openrisc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
parisc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
PCI Documentation: better locations for sysfs-pci, sysfs-tagging 2020-10-09 09:33:23 -06:00
pcmcia
power PM: EM: Update Energy Model with new flag indicating power scale 2020-11-10 20:29:28 +01:00
powerpc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
process Networking updates for 5.11 2020-12-15 13:22:29 -08:00
RCU docs/rcu: Update the call_rcu() API 2020-11-06 17:02:43 -08:00
riscv docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
s390 docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
scheduler Power management updates for 5.11-rc1 2020-12-15 16:30:31 -08:00
scsi SPDX patches for 5.10-rc1 2020-10-14 16:19:42 -07:00
security
sh docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
sound ALSA: usb-audio: Add implicit_fb module option 2020-11-23 15:17:24 +01:00
sparc docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
sphinx docs: update requirements to install six module 2020-12-09 17:27:47 -07:00
sphinx-static
spi
staging
target
timers
trace mm/lru: revise the comments of lru_lock 2020-12-15 14:48:04 -08:00
translations Networking updates for 5.11 2020-12-15 13:22:29 -08:00
usb
userspace-api "Intel SGX is new hardware functionality that can be used by 2020-12-14 13:14:57 -08:00
virt KVM: mmu: Fix SPTE encoding of MMIO generation upper half 2020-12-11 19:18:43 -05:00
vm mm/lru: revise the comments of lru_lock 2020-12-15 14:48:04 -08:00
w1 w1: w1_therm: Rename conflicting sysfs attribute 'eeprom' to 'eeprom_cmd' 2020-11-12 08:50:13 +01:00
watchdog
x86 A much quieter cycle for documentation (happily), with, one hopes, the bulk 2020-12-14 16:55:54 -08:00
xtensa A much quieter cycle for documentation (happily), with, one hopes, the bulk 2020-12-14 16:55:54 -08:00
.gitignore
asm-annotations.rst
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py docs: Note that sphinx 1.7 will be required soon 2020-12-11 13:53:38 -07:00
COPYING-logo
docutils.conf
dontdiff
index.rst docs: archis: add a per-architecture features list 2020-12-03 15:10:15 -07:00
Kconfig docs: Kconfig/Makefile: add a check for broken ABI files 2020-10-30 13:08:07 +01:00
logo.gif
Makefile A small number of fixes, plus a build tweak to respect the desire for 2020-11-03 09:57:30 -08:00
memory-barriers.txt docs/memory-barriers.txt: Fix a typo in CPU MEMORY BARRIERS section 2020-11-06 17:24:51 -08:00
SubmittingPatches
watch_queue.rst