linux/drivers/firmware/efi
Matt Fleming 62075e5818 efi/capsule: Make efi_capsule_pending() lockless
Taking a mutex in the reboot path is bogus because we cannot sleep
with interrupts disabled, such as when rebooting due to panic(),

  BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97
  in_atomic(): 0, irqs_disabled(): 1, pid: 7, name: rcu_sched
  Call Trace:
    dump_stack+0x63/0x89
    ___might_sleep+0xd8/0x120
    __might_sleep+0x49/0x80
    mutex_lock+0x20/0x50
    efi_capsule_pending+0x1d/0x60
    native_machine_emergency_restart+0x59/0x280
    machine_emergency_restart+0x19/0x20
    emergency_restart+0x18/0x20
    panic+0x1ba/0x217

In this case all other CPUs will have been stopped by the time we
execute the platform reboot code, so 'capsule_pending' cannot change
under our feet. We wouldn't care even if it could since we cannot wait
for it complete.

Also, instead of relying on the external 'system_state' variable just
use a reboot notifier, so we can set 'stop_capsules' while holding
'capsule_mutex', thereby avoiding a race where system_state is updated
while we're in the middle of efi_capsule_update_locked() (since CPUs
won't have been stopped at that point).

Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kweh Hock Leong <hock.leong.kweh@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: joeyli <jlee@suse.com>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1462570771-13324-2-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-05-07 07:06:13 +02:00
..
libstub efi/arm*/libstub: Wire up GOP protocol to 'struct screen_info' 2016-04-28 11:34:00 +02:00
arm-init.c efi/arm-init: Reserve rather than unmap the memory map for ARM as well 2016-04-28 11:34:05 +02:00
arm-runtime.c efi/arm*: Take the Memory Attributes table into account 2016-04-28 11:33:55 +02:00
capsule-loader.c efi: Add misc char driver interface to update EFI firmware 2016-04-28 11:34:05 +02:00
capsule.c efi/capsule: Make efi_capsule_pending() lockless 2016-05-07 07:06:13 +02:00
cper.c efi: Handle memory error structures produced based on old versions of standard 2015-07-15 13:30:38 +01:00
efi-pstore.c Half dozen small cleanups plus change to allow pstore 2015-11-05 11:51:18 -08:00
efi.c efi: Move efi_status_to_err() to drivers/firmware/efi/ 2016-04-28 11:34:03 +02:00
efibc.c efibc: Add EFI Bootloader Control module 2016-04-28 11:34:02 +02:00
efivars.c drivers/firmware/efi/efivars.c: use in_compat_syscall() to check for compat callers 2016-03-22 15:36:02 -07:00
esrt.c efi/esrt: Don't preformat name 2015-12-14 15:24:03 +00:00
fake_mem.c efi: Remove global 'memmap' EFI memory map 2016-04-28 11:33:51 +02:00
Kconfig efi: Add misc char driver interface to update EFI firmware 2016-04-28 11:34:05 +02:00
Makefile efi: Add misc char driver interface to update EFI firmware 2016-04-28 11:34:05 +02:00
memattr.c efi: Implement generic support for the Memory Attributes table 2016-04-28 11:33:54 +02:00
reboot.c efi: Add 'capsule' update support 2016-04-28 11:34:03 +02:00
runtime-map.c efi: Fix error handling in add_sysfs_runtime_map_entry() 2015-05-05 16:20:13 +01:00
runtime-wrappers.c efi/runtime-wrappers: Remove ARCH_EFI_IRQ_FLAGS_MASK #ifdef 2016-04-28 11:34:13 +02:00
vars.c efi: Move efi_status_to_err() to drivers/firmware/efi/ 2016-04-28 11:34:03 +02:00