From patchwork Wed Oct 28 02:06:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 55654 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2125279lbq; Tue, 27 Oct 2015 19:08:45 -0700 (PDT) X-Received: by 10.66.153.166 with SMTP id vh6mr31678914pab.83.1445998124928; Tue, 27 Oct 2015 19:08:44 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id y1si18350631par.57.2015.10.27.19.08.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2015 19:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrG97-0001UD-GR; Wed, 28 Oct 2015 02:07:25 +0000 Received: from mail-ig0-x230.google.com ([2607:f8b0:4001:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrG8q-0001OR-4s for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2015 02:07:10 +0000 Received: by igbkq10 with SMTP id kq10so96852176igb.0 for ; Tue, 27 Oct 2015 19:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=QXAb26usyBLYU4D8qkwvIUvNC4viA9tEkSUBnshrhmI=; b=lyZglwiAi5VWpAuYy1zUnrQR7LwENZMp3b4716T/JNelYXGlNQhxj3snHv2YIlHDyM wY2m4l/lQ4Qwf15Dea3iihazd6xL9rh4j2gEQ9+XmVNIw2Xq4nFbNhskuIWs/6uYaOhv 6K1yvL14Ihirp942VVwJiwJ2rcUuViXL7BX3+g1YYZ7uyJ7f748yJuibaynzgwZJ3cXc ZxzCf+XnQIazO7th6CYL/lNp+7LVHp1lnDIZHcpOtoooGUfdQC/uKN/0qZEc7I4k79MJ rNh3B9ur5IQXq2INgbiN+nTj0+3Sh5l/Bc/jEQZ8oS8g60eGAvX3IY41ay9Qqn9eutUM 1cow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=QXAb26usyBLYU4D8qkwvIUvNC4viA9tEkSUBnshrhmI=; b=gIS5xsrnoQfPyrLZCt/EHTtuEiNCwjbayhLRTmgF4FIu4b0i8X272aOlMm1K8CqOjk NjWoJsMpWq70sLcrgFzFEGSvFcGY7XUZU5fesdQigAZF/a68GIlMwGXwTSVfqHkYDxAU IS+LRgv4cVJB7gvvpusuhZBOreguH3z1GeLaPpZoIaVvFXDOnj2QpPAyHiRQNPFNjOvl OZSMdyhySCG1kte6xencBejyWuzlu4NKT9jeaykV6tZvjpx7HzGO/nbnJiQlk0ej/ltc WidcQQP3VqaH3k/J3wOcQCyTvoU9GPCkbilIlhPKnp76aHdbA1FfGns/C1LOW7gbN8Do dYTQ== X-Gm-Message-State: ALoCoQkahCCIkKIjiWwMOUpwM4/UEIw9Fho1ACXYalmCxjf1HIJkeTS1pibMUMqXq1Tq5dpuRheC MIME-Version: 1.0 X-Received: by 10.50.164.196 with SMTP id ys4mr312500igb.37.1445998006404; Tue, 27 Oct 2015 19:06:46 -0700 (PDT) Received: by 10.36.214.215 with HTTP; Tue, 27 Oct 2015 19:06:46 -0700 (PDT) In-Reply-To: <1445981041-8774-1-git-send-email-timur@codeaurora.org> References: <1445981041-8774-1-git-send-email-timur@codeaurora.org> Date: Wed, 28 Oct 2015 11:06:46 +0900 Message-ID: Subject: Re: [PATCH] arm64: efi: make sure vmlinux load address aligned on 2MBytes From: Ard Biesheuvel To: Timur Tabi X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151027_190708_508935_6C2CCAB8 X-CRM114-Status: GOOD ( 19.21 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c05:0:0:0:230 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "linux-efi@vger.kernel.org" , Mark Langsdorf , Jon Masters , Will Deacon , Matt Fleming , Shanker Donthineni , Mark Salter , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On 28 October 2015 at 06:24, Timur Tabi wrote: > From: Shanker Donthineni > > The vmlinux image load address must be aligned to 2MB, as documented > in Documentation/arm64/booting.txt. Otherwise, __create_page_tables > in head.S will create incorrect page table entries. > > Signed-off-by: Shanker Donthineni > Signed-off-by: Timur Tabi > --- > arch/arm64/kernel/efi-stub.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c > index 816120e..df1433d 100644 > --- a/arch/arm64/kernel/efi-stub.c > +++ b/arch/arm64/kernel/efi-stub.c > @@ -21,7 +21,7 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, > unsigned long dram_base, > efi_loaded_image_t *image) > { > - efi_status_t status; > + efi_status_t status = EFI_LOAD_ERROR; > unsigned long kernel_size, kernel_memsize = 0; > unsigned long nr_pages; > void *old_image_addr = (void *)*image_addr; > @@ -39,15 +39,18 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, > * value or a NULL pointer). It will also ensure that, on > * platforms where the [dram_base, dram_base + TEXT_OFFSET) > * interval is partially occupied by the firmware (like on APM > - * Mustang), we can still place the kernel at the address > - * 'dram_base + TEXT_OFFSET'. > + * Mustang) and dram_base is aligned on 2Mbytes, we can still > + * place the kernel at the address 'dram_base + TEXT_OFFSET'. > */ > - *image_addr = *reserve_addr = dram_base + TEXT_OFFSET; > - nr_pages = round_up(kernel_memsize, EFI_ALLOC_ALIGN) / > + if (IS_ALIGNED(dram_base, SZ_2M)) { > + *image_addr = *reserve_addr = dram_base + TEXT_OFFSET; > + nr_pages = round_up(kernel_memsize, EFI_ALLOC_ALIGN) / > EFI_PAGE_SIZE; > - status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS, > + status = efi_call_early(allocate_pages, > + EFI_ALLOCATE_ADDRESS, > EFI_LOADER_DATA, nr_pages, > (efi_physical_addr_t *)reserve_addr); > + } > if (status != EFI_SUCCESS) { > kernel_memsize += TEXT_OFFSET; > status = efi_low_alloc(sys_table_arg, kernel_memsize, I agree we should fix this, but I would prefer a oneliner such as _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Acked-by: Mark Rutland diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 816120ece6bc..a60ce249cfc0 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -42,7 +42,8 @@ * Mustang), we can still place the kernel at the address * 'dram_base + TEXT_OFFSET'. */ - *image_addr = *reserve_addr = dram_base + TEXT_OFFSET; + *image_addr = *reserve_addr = round_up(dram_base, SZ_2M) + + TEXT_OFFSET); nr_pages = round_up(kernel_memsize, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE; status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS,