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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 6F904C3A59E for ; Wed, 21 Aug 2019 09:43:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 41CCE22DD3 for ; Wed, 21 Aug 2019 09:43:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YUKJm26w"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PVj+qa4N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41CCE22DD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4+mg2P3X7/uC8Dvu3+PIB18sQBlz+LQqa1YYZ1TEzZs=; b=YUKJm26w2PvAe+ 8nhFLsiNQtIM8y2WlhEclvDsffDvvLurt/rKl2iZvaPIXIUqlIE3qJsdBTKlo5NJ7KS067xpYQtFg /M+UiT9oADpoonFHFdidONNZWVTp5NOsK7GVFyALTG6gUC2UTgmf5aEFjc5A34zGaohivPMLJWTCd YfTB06qvtfnb/I2rMQBAb5hk20rAyUkh9x5PaDRGD5b/qUFDSHoTa0F8rD81RPZ5eW0jnuLep+nlw Ov7tmvMWxLRHCEaegMp9b0QcePmfWaLF7c1GYT2t/n/gmOPoOHxYSHsFhPD0LU1mcPG36LrmyF04x pyuYkiERZvO3EHrBXr7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i0N99-0006He-Mf; Wed, 21 Aug 2019 09:43:16 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i0N94-0006Gr-2X for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2019 09:43:13 +0000 Received: by mail-wr1-x442.google.com with SMTP id p17so1356844wrf.11 for ; Wed, 21 Aug 2019 02:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yhh05Lx1Wiyqwc4CFdoUHwTxVsPR0zakJwfwav/HC18=; b=PVj+qa4NJnbMWOZAIx9AAkNEG1Iyewb7tu5yt41xycqGFxGRF/KX2EdJ/JIMt2leC0 1p3aNbchhOtqTj/x+g6Cl2hRsTJUOHVLXriQ4dwCM/RUs/qHip/w6b+E77BnytnFDc0Z 19J9nubVPao7e85KC72Y+R3kBJOfQq6DVgrlhoNwpjerPNZh1HiRZx4AxRoYN2Kh2vHU VQK2F3nYhu5dCJ8vRwOiQ8AnmUzk+qwJZBdjJsWrIepI8jzIUOhULXD8wiSQOKERyK8D IJKJSQoIOvU/a/iP5cLohN82Uc+pfTj05bz5ma/MyknX60t3Lkp8+8LuG1uw24UbfDTl cSnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yhh05Lx1Wiyqwc4CFdoUHwTxVsPR0zakJwfwav/HC18=; b=dMiohiInFkv2lUy21JXQl7eevpQtNcs2YNOf1O0+PCIhyeMLExnAPDqRn/Tfznadhc jZX+eFazDP6dwYSbXV9zwV9j3TucmFnUOG8RS3LoKWgTidU0Q21J4AciA1bSe5+K+QwH BpceHNIRW7ALZlNyX+s5czp2OopjIxygBzdfVXLKqyNZhdQaBYybPfMC+zrE/Xh5utM+ o2Xnv1GUq5HOomstPn/vwXThI2lBkIibeYOFUvcMl9BjKe2y30/mYzHpOkDtG4hCqzk5 Yo+QpXHmc2S8uRwuYNFelSJJGXlGAHkn53clJrpiSu2PbZTJqwzSKrp45mNeMXF1TV4Q ywBQ== X-Gm-Message-State: APjAAAVM3/hs8xoHJRj+fZ63XApHd5h4PkbqGE7OtPnhBFJb9dokBJcW Io3iz0VN66/iFWnl1Bu+5H7gtmmX9F80gQkm/Dpbjw== X-Google-Smtp-Source: APXvYqzgLiqDBoUMfrN5PU/uJb8XTsDfE3cVqCi/aYLhYzZuK+GnS16Vxrx3MfmlOp214llXnxta9V24a17Yg3La7Gw= X-Received: by 2002:adf:9e09:: with SMTP id u9mr7516435wre.169.1566380588039; Wed, 21 Aug 2019 02:43:08 -0700 (PDT) MIME-Version: 1.0 References: <20190802053744.5519-1-clin@suse.com> <20190820115645.GP13294@shell.armlinux.org.uk> <20190821061027.GA2828@linux-8mug> <20190821071100.GA26713@rapoport-lnx> <20190821082927.GC26713@rapoport-lnx> In-Reply-To: <20190821082927.GC26713@rapoport-lnx> From: Ard Biesheuvel Date: Wed, 21 Aug 2019 12:42:56 +0300 Message-ID: Subject: Re: [PATCH] efi/arm: fix allocation failure when reserving the kernel base To: Mike Rapoport X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190821_024310_155658_DB0809DF X-CRM114-Status: GOOD ( 19.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Joey Lee , "linux-efi@vger.kernel.org" , "guillaume.gardet@arm.com" , "linux-kernel@vger.kernel.org" , Russell King - ARM Linux admin , Chester Lin , "geert@linux-m68k.org" , "ren_guo@c-sky.com" , Gary Lin , "akpm@linux-foundation.org" , "mingo@kernel.org" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 21 Aug 2019 at 11:29, Mike Rapoport wrote: > > On Wed, Aug 21, 2019 at 10:29:37AM +0300, Ard Biesheuvel wrote: > > On Wed, 21 Aug 2019 at 10:11, Mike Rapoport wrote: > > > ... > > > I think the only missing part here is to ensure that non-reserved memory in > > > bank 0 starts from a PMD-aligned address. I believe this could be done if > > > EFI stub, but I'm not really familiar with it so this just a semi-educated > > > guess :) > > > > > > > Given that it is the ARM arch code that imposes this requirement, how > > about adding something like this to adjust_lowmem_bounds(): > > > > if (memblock_start_of_DRAM() % PMD_SIZE) > > memblock_mark_nomap(memblock_start_of_DRAM(), > > PMD_SIZE - (memblock_start_of_DRAM() % PMD_SIZE)); > > memblock_start_of_DRAM() won't work here, as it returns the actual start of > the DRAM including NOMAP regions. Moreover, as we cannot mark a region > NOMAP inside for_each_memblock() this should be done beforehand. > > I think something like this could work: > > diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c > index 2f0f07e..f2b635b 100644 > --- a/arch/arm/mm/mmu.c > +++ b/arch/arm/mm/mmu.c > @@ -1178,6 +1178,19 @@ void __init adjust_lowmem_bounds(void) > */ > vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET; > > + /* > + * The first usable region must be PMD aligned. Mark its start > + * as MEMBLOCK_NOMAP if it isn't > + */ > + for_each_memblock(memory, reg) { > + if (!memblock_is_nomap(reg) && (reg->base % PMD_SIZE)) { > + phys_addr_t size = PMD_SIZE - (reg->base % PMD_SIZE); > + > + memblock_mark_nomap(reg->base, size); > + break; We should break on the first !NOMAP memblock, even if it is already PMD aligned, but beyond that, this looks ok to me. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel