21 Jun, 2021

1 commit

  • There can be few cases when we need to shut-down the system in order to
    protect the hardware. Currently this is done at least by the thermal core
    when temperature raises over certain limit.

    Some PMICs can also generate interrupts for example for over-current or
    over-voltage, voltage drops, short-circuit, ... etc. On some systems
    these are a sign of hardware failure and only thing to do is try to
    protect the rest of the hardware by shutting down the system.

    Add shut-down logic which can be used by all subsystems instead of
    implementing the shutdown in each subsystem. The logic is stolen from
    thermal_core with difference of using atomic_t instead of a mutex in
    order to allow calls directly from IRQ context and changing the WARN()
    to pr_emerg() as discussed here:
    https://lore.kernel.org/lkml/YJuPwAZroVZ%2Fw633@alley/
    and here:
    https://lore.kernel.org/linux-iommu/20210331093104.383705-4-geert+renesas@glider.be/

    Signed-off-by: Matti Vaittinen
    Acked-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/e83ec1ca9408f90c857ea9dcdc57b14d9037b03f.1622628333.git.matti.vaittinen@fi.rohmeurope.com
    Signed-off-by: Mark Brown

    Matti Vaittinen
     

18 Mar, 2021

1 commit

  • This reverts commit d60cd06331a3566d3305b3c7b566e79edf4e2095.

    This patch causes a panic when rebooting my Dell Poweredge r440. I do
    not have the full panic log as it's lost at that stage of the reboot and
    I do not have a serial console. Reverting this patch makes my system
    able to reboot again.

    Signed-off-by: Josef Bacik
    Signed-off-by: Rafael J. Wysocki

    Josef Bacik
     

16 Dec, 2020

5 commits

  • Not all the reboot settings from both the kernel command line or sysfs
    interface are available to all platforms.

    Filter out reboot_type and reboot_force which are x86 only, and also
    remove reboot_cpu on kernels without SMP support.

    This saves some space, and avoid confusing the user with settings which
    will have no effect.

    Link: https://lkml.kernel.org/r/20201130173717.198952-3-mcroce@linux.microsoft.com
    Signed-off-by: Matteo Croce
    Reviewed-by: Petr Mladek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     
  • Patch series "reboot: sysfs improvements".

    Some improvements to the sysfs reboot interface: hide not working settings
    and support machines with known reboot quirks.

    This patch (of 2):

    On some machines a quirk can force a specific reboot type. Quirks are
    found during a DMI scan, the list of machines which need special reboot
    handling is defined in reboot_dmi_table.

    The kernel command line reboot= option overrides this via a global
    variable `reboot_default`, so that the reboot type requested in the
    command line is really performed.

    This was not true when setting the reboot type via the new sysfs
    interface. Fix this by setting reboot_default upon the first change, like
    reboot_setup() does for the command line.

    Link: https://lkml.kernel.org/r/20201130173717.198952-1-mcroce@linux.microsoft.com
    Link: https://lkml.kernel.org/r/20201130173717.198952-2-mcroce@linux.microsoft.com
    Signed-off-by: Matteo Croce
    Reviewed-by: Petr Mladek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     
  • BOOT_CF9_SAFE_STR is an internal value used only by the x86 code and it's
    not possible to set it from userspace.

    Remove it, and rename 'cf9_force' to 'pci', so to make it coherent with
    the kernel command line reboot= option.

    Tested with this script:

    cd /sys/kernel/reboot/

    for i in cold warm hard soft gpio; do
    echo $i >mode
    read j type
    read j cpu
    read j force
    read j
    Cc: Arnd Bergmann
    Cc: Guenter Roeck
    Cc: Kees Cook
    Cc: Mike Rapoport
    Cc: Nathan Chancellor
    Cc: Pavel Tatashin
    Cc: Petr Mladek
    Cc: Tyler Hicks
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     
  • 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 /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
    Signed-off-by: Nathan Chancellor
    Reviewed-by: Petr Mladek
    Cc: Mike Rapoport
    Cc: Guenter Roeck
    Cc: Arnd Bergmann
    Cc: Pavel Tatashin
    Cc: Kees Cook
    Cc: Tyler Hicks
    Cc: Nathan Chancellor
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     
  • Small improvements to the code, without changing the way it works:

    - use a local variable, to avoid a small time lapse where reboot_cpu
    can have an invalid value

    - comment the code which is not easy to understand at a glance

    - merge two identical code blocks into one

    - replace pointer arithmetics with equivalent array syntax

    Link: https://lkml.kernel.org/r/20201103214025.116799-4-mcroce@linux.microsoft.com
    Signed-off-by: Matteo Croce
    Cc: Arnd Bergmann
    Cc: Fabian Frederick
    Cc: Greg Kroah-Hartman
    Cc: Guenter Roeck
    Cc: Kees Cook
    Cc: Mike Rapoport
    Cc: Pavel Tatashin
    Cc: Petr Mladek
    Cc: Robin Holt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     

15 Dec, 2020

1 commit

  • * pm-sleep:
    PM: sleep: Add dev_wakeup_path() helper
    PM / suspend: fix kernel-doc markup
    PM: sleep: Print driver flags for all devices during suspend/resume

    * pm-acpi:
    PM: ACPI: Refresh wakeup device power configuration every time
    PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup()
    PM: ACPI: reboot: Use S5 for reboot

    * pm-domains:
    PM: domains: create debugfs nodes when adding power domains
    PM: domains: replace -ENOTSUPP with -EOPNOTSUPP

    * powercap:
    powercap: Adjust printing the constraint name with new line
    powercap: RAPL: Add AMD Fam19h RAPL support
    powercap: Add AMD Fam17h RAPL support
    powercap/intel_rapl_msr: Convert rapl_msr_priv into pointer
    x86/msr-index: sort AMD RAPL MSRs by address

    Rafael J. Wysocki
     

15 Nov, 2020

2 commits

  • Limit the CPU number to num_possible_cpus(), because setting it to a
    value lower than INT_MAX but higher than NR_CPUS produces the following
    error on reboot and shutdown:

    BUG: unable to handle page fault for address: ffffffff90ab1bb0
    #PF: supervisor read access in kernel mode
    #PF: error_code(0x0000) - not-present page
    PGD 1c09067 P4D 1c09067 PUD 1c0a063 PMD 0
    Oops: 0000 [#1] SMP
    CPU: 1 PID: 1 Comm: systemd-shutdow Not tainted 5.9.0-rc8-kvm #110
    Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
    RIP: 0010:migrate_to_reboot_cpu+0xe/0x60
    Code: ea ea 00 48 89 fa 48 c7 c7 30 57 f1 81 e9 fa ef ff ff 66 2e 0f 1f 84 00 00 00 00 00 53 8b 1d d5 ea ea 00 e8 14 33 fe ff 89 da 0f a3 15 ea fc bd 00 48 89 d0 73 29 89 c2 c1 e8 06 65 48 8b 3c
    RSP: 0018:ffffc90000013e08 EFLAGS: 00010246
    RAX: ffff88801f0a0000 RBX: 0000000077359400 RCX: 0000000000000000
    RDX: 0000000077359400 RSI: 0000000000000002 RDI: ffffffff81c199e0
    RBP: ffffffff81c1e3c0 R08: ffff88801f41f000 R09: ffffffff81c1e348
    R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
    R13: 00007f32bedf8830 R14: 00000000fee1dead R15: 0000000000000000
    FS: 00007f32bedf8980(0000) GS:ffff88801f480000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffff90ab1bb0 CR3: 000000001d057000 CR4: 00000000000006a0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    __do_sys_reboot.cold+0x34/0x5b
    do_syscall_64+0x2d/0x40

    Fixes: 1b3a5d02ee07 ("reboot: move arch/x86 reboot= handling to generic kernel")
    Signed-off-by: Matteo Croce
    Signed-off-by: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Fabian Frederick
    Cc: Greg Kroah-Hartman
    Cc: Guenter Roeck
    Cc: Kees Cook
    Cc: Mike Rapoport
    Cc: Pavel Tatashin
    Cc: Petr Mladek
    Cc: Robin Holt
    Cc:
    Link: https://lkml.kernel.org/r/20201103214025.116799-3-mcroce@linux.microsoft.com
    Signed-off-by: Linus Torvalds

    Matteo Croce
     
  • Patch series "fix parsing of reboot= cmdline", v3.

    The parsing of the reboot= cmdline has two major errors:

    - a missing bound check can crash the system on reboot

    - parsing of the cpu number only works if specified last

    Fix both.

    This patch (of 2):

    This reverts commit 616feab753972b97.

    kstrtoint() and simple_strtoul() have a subtle difference which makes
    them non interchangeable: if a non digit character is found amid the
    parsing, the former will return an error, while the latter will just
    stop parsing, e.g. simple_strtoul("123xyx") = 123.

    The kernel cmdline reboot= argument allows to specify the CPU used for
    rebooting, with the syntax `s####` among the other flags, e.g.
    "reboot=warm,s31,force", so if this flag is not the last given, it's
    silently ignored as well as the subsequent ones.

    Fixes: 616feab75397 ("kernel/reboot.c: convert simple_strtoul to kstrtoint")
    Signed-off-by: Matteo Croce
    Signed-off-by: Andrew Morton
    Cc: Guenter Roeck
    Cc: Petr Mladek
    Cc: Arnd Bergmann
    Cc: Mike Rapoport
    Cc: Kees Cook
    Cc: Pavel Tatashin
    Cc: Robin Holt
    Cc: Fabian Frederick
    Cc: Greg Kroah-Hartman
    Cc:
    Link: https://lkml.kernel.org/r/20201103214025.116799-2-mcroce@linux.microsoft.com
    Signed-off-by: Linus Torvalds

    Matteo Croce
     

11 Nov, 2020

1 commit

  • After reboot, it's not possible to use hotkeys to enter BIOS setup
    and boot menu on some HP laptops.

    BIOS folks identified the root cause is the missing _PTS call, and
    BIOS is expecting _PTS to do proper reset.

    Using S5 for reboot is default behavior under Windows, "A full
    shutdown (S5) occurs when a system restart is requested" [1], so
    let's do the same here.

    [1] https://docs.microsoft.com/en-us/windows/win32/power/system-power-states

    Signed-off-by: Kai-Heng Feng
    [ rjw: Subject edit ]
    Signed-off-by: Rafael J. Wysocki

    Kai-Heng Feng
     

01 Jul, 2020

1 commit

  • The unicore32 port do not seem maintained for a long time now, there is no
    upstream toolchain that can create unicore32 binaries and all the links to
    prebuilt toolchains for unicore32 are dead. Even compilers that were
    available are not supported by the kernel anymore.

    Guenter Roeck says:

    I have stopped building unicore32 images since v4.19 since there is no
    available compiler that is still supported by the kernel. I am surprised
    that support for it has not been removed from the kernel.

    Remove unicore32 port.

    Signed-off-by: Mike Rapoport
    Acked-by: Arnd Bergmann
    Acked-by: Guenter Roeck

    Mike Rapoport
     

31 May, 2020

1 commit

  • To turn the KMSG_DUMP_* reasons into a more ordered list, collapse
    the redundant KMSG_DUMP_(RESTART|HALT|POWEROFF) reasons into
    KMSG_DUMP_SHUTDOWN. The current users already don't meaningfully
    distinguish between them, so there's no need to, as discussed here:
    https://lore.kernel.org/lkml/CA+CK2bAPv5u1ih5y9t5FUnTyximtFCtDYXJCpuyjOyHNOkRdqw@mail.gmail.com/

    Link: https://lore.kernel.org/lkml/20200515184434.8470-2-keescook@chromium.org/
    Reviewed-by: Pavel Tatashin
    Reviewed-by: Petr Mladek
    Acked-by: Michael Ellerman (powerpc)
    Signed-off-by: Kees Cook

    Kees Cook
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
    initial scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

15 May, 2019

1 commit

  • Allow specifying reboot_mode for panic only. This is needed on systems
    where ramoops is used to store panic logs, and user wants to use warm
    reset to preserve those, while still having cold reset on normal
    reboots.

    Link: http://lkml.kernel.org/r/20190322004735.27702-1-aaro.koskinen@iki.fi
    Signed-off-by: Aaro Koskinen
    Reviewed-by: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aaro Koskinen
     

11 Sep, 2018

1 commit


06 Aug, 2018

1 commit

  • At present, "systemctl suspend" and "shutdown" can run in parrallel. A
    system can suspend after devices_shutdown(), and resume. Then the shutdown
    task goes on to power off. This causes many devices are not really shut
    off. Hence replacing reboot_mutex with system_transition_mutex (renamed
    from pm_mutex) to achieve the exclusion. The renaming of pm_mutex as
    system_transition_mutex can be better to reflect the purpose of the mutex.

    Signed-off-by: Pingfan Liu
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Pingfan Liu
     

18 Nov, 2017

1 commit

  • Add devm_* wrapper around register_reboot_notifier to simplify device
    specific reboot notifier registration/unregistration.

    [akpm@linux-foundation.org: move `struct device' forward decl to top-of-file]
    Link: http://lkml.kernel.org/r/20170320171753.1705-1-andrew.smirnov@gmail.com
    Signed-off-by: Andrey Smirnov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Smirnov
     

11 Sep, 2015

1 commit

  • There are two kexec load syscalls, kexec_load another and kexec_file_load.
    kexec_file_load has been splited as kernel/kexec_file.c. In this patch I
    split kexec_load syscall code to kernel/kexec.c.

    And add a new kconfig option KEXEC_CORE, so we can disable kexec_load and
    use kexec_file_load only, or vice verse.

    The original requirement is from Ted Ts'o, he want kexec kernel signature
    being checked with CONFIG_KEXEC_VERIFY_SIG enabled. But kexec-tools use
    kexec_load syscall can bypass the checking.

    Vivek Goyal proposed to create a common kconfig option so user can compile
    in only one syscall for loading kexec kernel. KEXEC/KEXEC_FILE selects
    KEXEC_CORE so that old config files still work.

    Because there's general code need CONFIG_KEXEC_CORE, so I updated all the
    architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects
    KEXEC_CORE in arch Kconfig. Also updated general kernel code with to
    kexec_load syscall.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Dave Young
    Cc: Eric W. Biederman
    Cc: Vivek Goyal
    Cc: Petr Tesarik
    Cc: Theodore Ts'o
    Cc: Josh Boyer
    Cc: David Howells
    Cc: Geert Uytterhoeven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dave Young
     

16 Apr, 2015

1 commit

  • The kernel has orderly_poweroff which allows the kernel to initiate a
    graceful shutdown of userspace, by running /sbin/poweroff. This adds
    orderly_reboot that will cause userspace to shut itself down by calling
    /sbin/reboot.

    This will be used for shutdown initiated by a system controller on
    platforms that do not use ACPI.

    orderly_reboot() should be used when the system wants to allow userspace
    to gracefully shut itself down. For cases where the system may imminently
    catch on fire, the existing emergency_restart() provides an immediate
    reboot without involving userspace.

    Signed-off-by: Joel Stanley
    Cc: Fabian Frederick
    Cc: Benjamin Herrenschmidt
    Cc: Michael Ellerman
    Cc: Rusty Russell
    Cc: Jeremy Kerr
    Cc: David S. Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joel Stanley
     

26 Sep, 2014

1 commit

  • Various drivers implement architecture and/or device specific means to
    restart (reset) the system. Various mechanisms have been implemented to
    support those schemes. The best known mechanism is arm_pm_restart, which
    is a function pointer to be set either from platform specific code or from
    drivers. Another mechanism is to use hardware watchdogs to issue a reset;
    this mechanism is used if there is no other method available to reset a
    board or system. Two examples are alim7101_wdt, which currently uses the
    reboot notifier to trigger a reset, and moxart_wdt, which registers the
    arm_pm_restart function.

    The existing mechanisms have a number of drawbacks. Typically only one
    scheme to restart the system is supported (at least if arm_pm_restart is
    used). At least in theory there can be multiple means to restart the
    system, some of which may be less desirable (for example one mechanism may
    only reset the CPU, while another may reset the entire system). Using
    arm_pm_restart can also be racy if the function pointer is set from a
    driver, as the driver may be in the process of being unloaded when
    arm_pm_restart is called. Using the reboot notifier is always racy, as it
    is unknown if and when other functions using the reboot notifier have
    completed execution by the time the watchdog fires.

    Introduce a system restart handler call chain to solve the described
    problems. This call chain is expected to be executed from the
    architecture specific machine_restart() function. Drivers providing
    system restart functionality (such as the watchdog drivers mentioned
    above) are expected to register with this call chain. By using the
    priority field in the notifier block, callers can control restart handler
    execution sequence and thus ensure that the restart handler with the
    optimal restart capabilities for a given system is called first.

    Signed-off-by: Guenter Roeck
    Acked-by: Catalin Marinas
    Acked-by: Heiko Stuebner
    Cc: Russell King
    Cc: Wim Van Sebroeck
    Cc: Maxime Ripard
    Cc: Will Deacon
    Cc: Arnd Bergmann
    Cc: Jonas Jensen
    Cc: Randy Dunlap
    Cc: Steven Rostedt
    Cc: Ingo Molnar
    Cc: Dmitry Eremin-Solenikov
    Cc: David Woodhouse
    Cc: Tomasz Figa
    Signed-off-by: Andrew Morton

    Guenter Roeck
     

05 Jun, 2014

1 commit


19 Dec, 2013

1 commit

  • Commit 1b3a5d02ee07 ("reboot: move arch/x86 reboot= handling to generic
    kernel") moved reboot= handling to generic code. In the process it also
    removed the code in native_machine_shutdown() which are moving reboot
    process to reboot_cpu/cpu0.

    I guess that thought must have been that all reboot paths are calling
    migrate_to_reboot_cpu(), so we don't need this special handling. But
    kexec reboot path (kernel_kexec()) is not calling
    migrate_to_reboot_cpu() so above change broke kexec. Now reboot can
    happen on non-boot cpu and when INIT is sent in second kerneo to bring
    up BP, it brings down the machine.

    So start calling migrate_to_reboot_cpu() in kexec reboot path to avoid
    this problem.

    Bisected by WANG Chao.

    Reported-by: Matthew Whitehead
    Reported-by: Dave Young
    Signed-off-by: Vivek Goyal
    Tested-by: Baoquan He
    Tested-by: WANG Chao
    Acked-by: H. Peter Anvin
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vivek Goyal
     

25 Sep, 2013

1 commit

  • Commit 1b3a5d02ee07 ("reboot: move arch/x86 reboot= handling to generic
    kernel") did some cleanup for reboot= command line, but it made the
    reboot_default inoperative.

    The default value of variable reboot_default should be 1, and if command
    line reboot= is not set, system will use the default reboot mode.

    [akpm@linux-foundation.org: fix comment layout]
    Signed-off-by: Li Fei
    Signed-off-by: liu chuansheng
    Acked-by: Robin Holt
    Cc: [3.11.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chuansheng Liu
     

10 Jul, 2013

3 commits