From patchwork Tue Oct 27 21:24:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 7503181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 935F1BEEA4 for ; Tue, 27 Oct 2015 21:26:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4062205B3 for ; Tue, 27 Oct 2015 21:26:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6E2B204A0 for ; Tue, 27 Oct 2015 21:25:59 +0000 (UTC) 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 1ZrBjM-0007CJ-5w; Tue, 27 Oct 2015 21:24:32 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrBjE-0006qw-Rr for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2015 21:24:25 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 62021140941; Tue, 27 Oct 2015 21:24:04 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 487B3140944; Tue, 27 Oct 2015 21:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from timur-ubuntu.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B2C99140941; Tue, 27 Oct 2015 21:24:02 +0000 (UTC) From: Timur Tabi To: mark.rutland@arm.com, ard.biesheuvel@linaro.org, msalter@redhat.com, linux-efi@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org, matt.fleming@intel.com, Shanker Donthineni , Mark Langsdorf , jcm@redhat.com Subject: [PATCH] arm64: efi: make sure vmlinux load address aligned on 2MBytes Date: Tue, 27 Oct 2015 16:24:01 -0500 Message-Id: <1445981041-8774-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151027_142425_012860_1D821ABA X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -2.6 (--) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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,