Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030801AbcCQM50 (ORCPT ); Thu, 17 Mar 2016 08:57:26 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:36866 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936001AbcCQM5U (ORCPT ); Thu, 17 Mar 2016 08:57:20 -0400 From: Matt Fleming To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: joeyli , Matt Fleming , Ard Biesheuvel , Kweh Hock Leong , Borislav Petkov , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner Subject: [PATCH 3/4] x86/efi: Force EFI reboot to process pending capsules Date: Thu, 17 Mar 2016 12:57:10 +0000 Message-Id: <1458219431-24741-4-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1458219431-24741-1-git-send-email-matt@codeblueprint.co.uk> References: <1458219431-24741-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1721 Lines: 56 If an EFI capsule has been sent to the firmware we must match the type of EFI reset against that required by the capsule to ensure it is processed correctly. Force an EFI reboot if a capsule is pending for the next reset. Cc: Kweh Hock Leong Cc: Borislav Petkov Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Thomas Gleixner Signed-off-by: Matt Fleming --- arch/x86/kernel/reboot.c | 9 +++++++++ include/linux/efi.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index ab0adc0fa5db..a9b31eb815f2 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -535,6 +535,15 @@ static void native_machine_emergency_restart(void) mode = reboot_mode == REBOOT_WARM ? 0x1234 : 0; *((unsigned short *)__va(0x472)) = mode; + /* + * If an EFI capsule has been registered with the firmware then + * override the reboot= parameter. + */ + if (efi_capsule_pending(NULL)) { + pr_info("EFI capsule is pending, forcing EFI reboot.\n"); + reboot_type = BOOT_EFI; + } + for (;;) { /* Could also try the reset bit in the Hammer NB */ switch (reboot_type) { diff --git a/include/linux/efi.h b/include/linux/efi.h index a28053e71e99..290aa5673119 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1028,6 +1028,12 @@ static inline bool efi_enabled(int feature) } static inline void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {} + +static inline bool +efi_capsule_pending(int *reset_type) +{ + return false; +} #endif extern int efi_status_to_err(efi_status_t status); -- 2.6.2