Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp18887imm; Fri, 25 May 2018 15:07:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqRqLWsQJD190MOOd/i0v+Sa5xNXZdw6Rww/IWEbbmkqsXzDHu3GWlYt56e28eHHwA8Hd30 X-Received: by 2002:a63:9a49:: with SMTP id e9-v6mr3394171pgo.251.1527286068400; Fri, 25 May 2018 15:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527286068; cv=none; d=google.com; s=arc-20160816; b=WVtxkCn0ELRvNBZDHMrBkwud4ZaJBcffRqRLhpp12H5a89AIws32fOHgELwJK5S+0o lfxKwpBAuFNcngoNB/jB5QTGkgtnJr+8xVZnqja0KnwMgH1Yk1x5epo38zJQ2LruXIi7 eVgnHJxWMuiZqfYa7MPNciC8a7ltF3YP5Xb6f/GSJcTFuNfAv8vm2c/1EZ5mUEOnWKWD 5AmSOrm3wrcYGYztRqvfRjoFuLMhAM9BehC9pWE6+PTJCAtijUquSkPrz3NAhDz3G9g1 y+9dQpQQRU8QTTi9AiS0qDhmUGRh1X2TSmkKlRfQyascfX9ohYv6IU2cbAjRwkVomNCp a44Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=siFfZsmtQ2PguaSDLPRANh3t/n2Gd3GHNAdR8ztXMz4=; b=kQFxi6ZIuxkzIiJrdeQOifiR92Ci+ZZZfMoUALYsLnF8KduFTkbpjEA/C+qlmCIgIs UWcqbjzAtUEpCHIuitdecA93KDymj84Z6gkuM4YX/SXAGojrrNRsLsjNdft+yL0gLC87 RIUlUP4ye6nqvP5qyt70yUVB9rVQVG2MxAXu/GUPXDj7YEjSyQ0U6UTVMfZUkGruQ69K ZAUwTviIl2hRcuLN/1bCThB15Px/0a+RSjgFKzjHahvO/HNSf1U5kX5iVKwEDhW8t2AB xAqyrOhwX2kyChhxDVGpw19I08eUHFpn6QMSBD7PZ4/wGqXJ33DQtzoJfrgudScgFZRN u2iA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7-v6si24246692pfj.267.2018.05.25.15.07.33; Fri, 25 May 2018 15:07:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030686AbeEYWGD (ORCPT + 99 others); Fri, 25 May 2018 18:06:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:50944 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030513AbeEYWFL (ORCPT ); Fri, 25 May 2018 18:05:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2018 15:05:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,441,1520924400"; d="scan'208";a="231749055" Received: from sai-dev-mach.sc.intel.com ([143.183.140.145]) by fmsmga005.fm.intel.com with ESMTP; 25 May 2018 15:05:11 -0700 From: Sai Praneeth Prakhya To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sai Praneeth , Lee Chun-Yi , Borislav Petkov , Tony Luck , Will Deacon , Dave Hansen , Mark Rutland , Bhupesh Sharma , Naresh Bhat , Ricardo Neri , Peter Zijlstra , Ravi Shankar , Matt Fleming , Dan Williams , Ard Biesheuvel , Miguel Ojeda Subject: [PATCH V4 1/3] x86/efi: Call efi_delete_dummy_variable() during efi subsystem initialization Date: Fri, 25 May 2018 15:05:01 -0700 Message-Id: <1527285903-31799-2-git-send-email-sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527285903-31799-1-git-send-email-sai.praneeth.prakhya@intel.com> References: <1527285903-31799-1-git-send-email-sai.praneeth.prakhya@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sai Praneeth Invoking efi_runtime_services() through efi_rts_wq (efi runtime services workqueue) means all accesses to efi_runtime_services() should be done after efi_rts_wq has been created. efi_delete_dummy_variable() calls set_variable(), hence efi_delete_dummy_variable() should be called after efi_rts_wq has been created. Presently, efi_delete_dummy_variable() is called from efi_enter_virtual_mode() which is early in the boot phase (efi_rts_wq isn't created yet), so call efi_delete_dummy_variable() later in the boot phase. Another and the most important reason for calling efi_delete_dummy_variable() late in the boot process is, if called before rest_init(), kernel prints stack trace with a warning "bad: scheduling from the idle thread!". Hence, call from efisubsys_init() which is called during rest_init(). Signed-off-by: Sai Praneeth Prakhya Suggested-by: Andy Lutomirski Cc: Lee Chun-Yi Cc: Borislav Petkov Cc: Tony Luck Cc: Will Deacon Cc: Dave Hansen Cc: Mark Rutland Cc: Bhupesh Sharma Cc: Naresh Bhat Cc: Ricardo Neri Cc: Peter Zijlstra Cc: Ravi Shankar Cc: Matt Fleming Cc: Dan Williams Cc: Ard Biesheuvel Cc: Miguel Ojeda --- arch/x86/include/asm/efi.h | 1 - arch/x86/platform/efi/efi.c | 6 ------ drivers/firmware/efi/efi.c | 6 ++++++ include/linux/efi.h | 3 +++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index cec5fae23eb3..0e61b771b93d 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -138,7 +138,6 @@ extern void __init efi_runtime_update_mappings(void); extern void __init efi_dump_pagetable(void); extern void __init efi_apply_memmap_quirks(void); extern int __init efi_reuse_config(u64 tables, int nr_tables); -extern void efi_delete_dummy_variable(void); extern void efi_switch_mm(struct mm_struct *mm); struct efi_setup_data { diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 9061babfbc83..a3169d14583f 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -893,9 +893,6 @@ static void __init kexec_enter_virtual_mode(void) if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX)) runtime_code_page_mkexec(); - - /* clean DUMMY object */ - efi_delete_dummy_variable(); #endif } @@ -1015,9 +1012,6 @@ static void __init __efi_enter_virtual_mode(void) * necessary relocation fixups for the new virtual addresses. */ efi_runtime_update_mappings(); - - /* clean DUMMY object */ - efi_delete_dummy_variable(); } void __init efi_enter_virtual_mode(void) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 232f4915223b..1176af664013 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -337,6 +337,12 @@ static int __init efisubsys_init(void) if (!efi_enabled(EFI_BOOT)) return 0; + /* + * Clean DUMMY object calls EFI Runtime Service, set_variable(), so + * it should be invoked only after efi_rts_wq is ready. + */ + efi_delete_dummy_variable(); + /* We register the efi directory at /sys/firmware/efi */ efi_kobj = kobject_create_and_add("efi", firmware_kobj); if (!efi_kobj) { diff --git a/include/linux/efi.h b/include/linux/efi.h index 3016d8c456bc..1b79939d0b1e 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -994,6 +994,7 @@ extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size, bool nonblocking); extern void efi_find_mirror(void); +extern void efi_delete_dummy_variable(void); #else static inline void efi_late_init(void) {} static inline void efi_free_boot_services(void) {} @@ -1004,6 +1005,8 @@ static inline efi_status_t efi_query_variable_store(u32 attributes, { return EFI_SUCCESS; } + +static inline void efi_delete_dummy_variable(void) {} #endif extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); -- 2.7.4