From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033444AbdAEJOO (ORCPT ); Thu, 5 Jan 2017 04:14:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39880 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762106AbdAEJMt (ORCPT ); Thu, 5 Jan 2017 04:12:49 -0500 Date: Thu, 5 Jan 2017 17:12:42 +0800 From: Dave Young To: Nicolai Stange Cc: Matt Fleming , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mika =?iso-8859-1?Q?Penttil=E4?= Subject: Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Message-ID: <20170105091242.GA11021@dhcp-128-65.nay.redhat.com> References: <20161222102340.2689-1-nicstange@gmail.com> <20161222102340.2689-2-nicstange@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161222102340.2689-2-nicstange@gmail.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Jan 2017 09:12:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/22/16 at 11:23am, Nicolai Stange wrote: > Before invoking the arch specific handler, efi_mem_reserve() reserves > the given memory region through memblock. > > efi_mem_reserve() can get called after mm_init() though -- through > efi_bgrt_init(), for example. After mm_init(), memblock is dead and should > not be used anymore. It did not fail during previous test so we did not catch this bug, if memblock can not be used after mm_init(), IMHO it should fail instead of silently succeed. Matt, can we move the efi_mem_reserve to earlier code for example in efi_memblock_x86_reserve_range just after reserving the memmap? > > Let efi_mem_reserve() check whether memblock is dead and not do the > reservation if so. Emit a warning from the generic efi_arch mem_reserve() > in this case: if the architecture doesn't provide any other means of > registering the region as reserved, the operation would be a nop. > > Fixes: 4bc9f92e64c8 ("x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data") > Signed-off-by: Nicolai Stange > --- > Changes to v1: > Change the if condition from slab_is_available() to !slab_is_available > as pointed out by Mika Penttilä at > http://lkml.kernel.org/r/c7bf34ba-56f0-8346-36d1-7069f2115dcf@nextfour.com > > drivers/firmware/efi/efi.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index 92914801e388..158a8df2f4af 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -403,7 +403,10 @@ u64 __init efi_mem_desc_end(efi_memory_desc_t *md) > return end; > } > > -void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {} > +void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) > +{ > + WARN(slab_is_available(), "efi_mem_reserve() has no effect"); > +} > > /** > * efi_mem_reserve - Reserve an EFI memory region > @@ -419,7 +422,7 @@ void __init __weak efi_arch_mem_reserve(phys_addr_t addr, u64 size) {} > */ > void __init efi_mem_reserve(phys_addr_t addr, u64 size) > { > - if (!memblock_is_region_reserved(addr, size)) > + if (!slab_is_available() && !memblock_is_region_reserved(addr, size)) > memblock_reserve(addr, size); > > /* > -- > 2.11.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-efi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Thanks Dave