Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp618869ybl; Wed, 21 Aug 2019 02:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBv9yHK9U2ELXAs95BxNA/wajWmw539x8guvGnxaxF4FghDTAoA0u5xkld38fhCEP9AQRf X-Received: by 2002:a65:52ca:: with SMTP id z10mr29163166pgp.424.1566381593345; Wed, 21 Aug 2019 02:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566381593; cv=none; d=google.com; s=arc-20160816; b=t000kIWThfBbUfp/ixL9uCW6ssBTkHS/cgyGjziAk0P5cESamyTnnZkFNzB1x5CjFY k6bF8OepPHC2dRvft599N2GKg11d0xPNfn8ln18bAmp+7RQpsCQ6a4+e8cupZU03NIzF QjZUhGfhpBXuQJVrKnnSbcQoLoUVP2e9neqdTZvMFp0ofozlQBQeysNXBsRLoRPg/U2T w2u1YhD19tSaFxTB1EX4sTH+M5JBFsNWVhjiSd6h4iYVABH8fCWEpDPBdP9gTNsvwTSu wzaVPSpuR7vcSxtC2yYX4TMWbDJWVN6gsP4BUlldUxNPjAzF9dhC+xJ+de2YwIe0Vg3B 3+Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yhh05Lx1Wiyqwc4CFdoUHwTxVsPR0zakJwfwav/HC18=; b=wtK7L0VvnJm9nsGy6yXjJY/wLVMyB9BHVDLxkQRW4ls5QPjJg1lYJDtuNtJqLYDKCj rRsGdL2f5VR73XOdC1TTX+bLRA1QEMszNPGWmMua8kCL1OxsHG0p/i3nrNB4jDlBIUWY hPzYrf0xSCohS2EA2QnR4Ume1jr7abRmjb3xgn8pJv7JlVG0xqtn+jpfDrbnoiUY49g0 5sO6NnZmAyBdeBDBLnoJ4WYvTxtM3/fHXRUcpm0Bjkc56+iLrmA/I9mHoJV5k/hkYNnX vow0gbxZH2H3YVd2BPqkykz20Okg2IdfsN3lJo5RLWZSllq4ob1WWLa4lr0ZjtcLA8t/ 3mWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PVj+qa4N; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si14491943plc.428.2019.08.21.02.59.37; Wed, 21 Aug 2019 02:59:53 -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; dkim=pass header.i=@linaro.org header.s=google header.b=PVj+qa4N; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbfHUJnK (ORCPT + 99 others); Wed, 21 Aug 2019 05:43:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41203 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbfHUJnK (ORCPT ); Wed, 21 Aug 2019 05:43:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id j16so1369752wrr.8 for ; Wed, 21 Aug 2019 02:43:08 -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=qfCS+P213jwXQOeqblpXAdTO3qq7WnKiiOVgXq9cv9lnz3vm7/zTnOz/EySoRORvdE mRuSfJdNIQ+yCnB4fcpsDcTqZMZW6Y+3/KyWhrILIurXWDL9ytzFWzkwRq+8v5oDjFzW bNCamk3VbujpTFchFkADw83M5nxnHkRFdOVmH4XWGUMUb1wOUQ1ubDWCZIYT5bfGXMb9 7BX7Lrwn/9pqhhVgvgw51ajRFAIo/v0YtIx6OXtnDt8+bumHZCQYYus+5SR2aPsiLbd6 5k06p4/InHEjkx8gGjOKzzDxAzq9pPdOlgTSPGfOGe3XR80CY7MlatxULi25fbueC7Sb ROjA== X-Gm-Message-State: APjAAAXrX5ztxELvbWWiSwYwzm6L2wOtKbNLbVx0Do0CtDQ/dGy12frB FBfA/ft7eIL69YXat44nCG0emHB+6iWR+OfQbZvlgw== 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 Cc: Chester Lin , Juergen Gross , Joey Lee , "linux-efi@vger.kernel.org" , "guillaume.gardet@arm.com" , "linux-kernel@vger.kernel.org" , Russell King - ARM Linux admin , "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="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.