From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F023CC43441 for ; Mon, 12 Nov 2018 08:33:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7DA6223AE for ; Mon, 12 Nov 2018 08:33:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7DA6223AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbeKLSZI convert rfc822-to-8bit (ORCPT ); Mon, 12 Nov 2018 13:25:08 -0500 Received: from foss.arm.com ([217.140.101.70]:59902 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeKLSZI (ORCPT ); Mon, 12 Nov 2018 13:25:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9A20380D; Mon, 12 Nov 2018 00:32:59 -0800 (PST) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B06DC3F5A0; Mon, 12 Nov 2018 00:32:57 -0800 (PST) Date: Mon, 12 Nov 2018 08:32:54 +0000 Message-ID: <86muqeelvt.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Qian Cai Cc: Ard Biesheuvel , , , , linux kernel , Subject: Re: [PATCH] efi: permit calling efi_mem_reserve_persistent from atomic context In-Reply-To: References: <20181108180511.30239-1-ard.biesheuvel@linaro.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Nov 2018 02:45:48 +0000, Qian Cai wrote: > > > > > On Nov 9, 2018, at 9:45 PM, Qian Cai wrote: > > > > > > On 11/8/18 at 1:05 PM, Ard Biesheuvel wrote: > > > >> Currently, efi_mem_reserve_persistent() may not be called from atomic > >> context, since both the kmalloc() call and the memremap() call may > >> sleep. > >> > >> The kmalloc() call is easy enough to fix, but the memremap() call > >> needs to be moved into an init hook since we cannot control the > >> memory allocation behavior of memremap() at the call site. > >> > >> Signed-off-by: Ard Biesheuvel > >> --- > >> drivers/firmware/efi/efi.c | 31 +++++++++++++++++++------------ > >> 1 file changed, 19 insertions(+), 12 deletions(-) > >> > >> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > >> index 249eb70691b0..cfc876e0b67b 100644 > >> --- a/drivers/firmware/efi/efi.c > >> +++ b/drivers/firmware/efi/efi.c > >> @@ -963,36 +963,43 @@ bool efi_is_table_address(unsigned long phys_addr) > >> } > >> > >> static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock); > >> +static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init; > >> > >> int efi_mem_reserve_persistent(phys_addr_t addr, u64 size) > >> { > >> - struct linux_efi_memreserve *rsv, *parent; > >> + struct linux_efi_memreserve *rsv; > >> > >> - if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) > >> + if (!efi_memreserve_root) > >> return -ENODEV; > >> > >> - rsv = kmalloc(sizeof(*rsv), GFP_KERNEL); > >> + rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC); > >> if (!rsv) > >> return -ENOMEM; > >> > >> - parent = memremap(efi.mem_reserve, sizeof(*rsv), MEMREMAP_WB); > >> - if (!parent) { > >> - kfree(rsv); > >> - return -ENOMEM; > >> - } > >> - > >> rsv->base = addr; > >> rsv->size = size; > >> > >> spin_lock(&efi_mem_reserve_persistent_lock); > >> - rsv->next = parent->next; > >> - parent->next = __pa(rsv); > >> + rsv->next = efi_memreserve_root->next; > >> + efi_memreserve_root->next = __pa(rsv); > >> spin_unlock(&efi_mem_reserve_persistent_lock); > >> > >> - memunmap(parent); > >> + return 0; > >> +} > >> > >> +static int __init efi_memreserve_root_init(void) > >> +{ > >> + if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) > >> + return -ENODEV; > >> + > >> + efi_memreserve_root = memremap(efi.mem_reserve, > >> + sizeof(*efi_memreserve_root), > >> + MEMREMAP_WB); > >> + if (!efi_memreserve_root) > >> + return -ENOMEM; > >> return 0; > >> } > >> +early_initcall(efi_memreserve_root_init); > >> > >> #ifdef CONFIG_KEXEC > >> static int update_efi_random_seed(struct notifier_block *nb, > >> -- > >> 2.19.1 > > BTW, I won’t be able to apply this patch on top of this series [1]. After applied that series, the original BUG sleep from atomic is gone as well as two other GIC warnings. Do you think a new patch is needed here? > > > > [1] https://www.spinics.net/lists/arm-kernel/msg685751.html > OK, I was able to apply this patch on top of latest mainline (ccda4af0f4b9) > which also include one patch (1/6) from the above series, > > However, the efi-related patches from the series (4/6, 5/6, and 6/6) are no > longer able to be cleanly applied. > > As the results, the above patch did fix the original BUG: sleep from atomic, > but it introduces 2 new warnings. [...] These are the warnings you've already reported, aren't they? And we've established that if you apply the whole series, everything work as intended at least on the GIC side (the timer issue is a different story altogether). Or am I missing something? Thanks, M. -- Jazz is not dead, it just smell funny.