From patchwork Mon Mar 16 15:23:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45857 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E3D621523 for ; Mon, 16 Mar 2015 15:28:54 +0000 (UTC) Received: by lbvn10 with SMTP id n10sf27354786lbv.1 for ; Mon, 16 Mar 2015 08:28:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=LX9jO8dgrK5KqWEyrw/ne0BQqVURcOuY7gOZc/Yl8gE=; b=WI8Gojd54HNe+Fa9KJVvW5ONdnbqIBAgzTOubRLmCwSfhVSy3zSENXckfnGjU7h/ga gPTXMUmNMna1f9Q7ziqWBjL3fU5eoiL3Yqc+10rgArQkaz32TpEzAwLuyWTih21LvRot MCq6mNydjxXHwdyk5Jlli8rlS8cH54u/c50tAEq55+33c9Y99kXp0yYon2oNgPEiv7jR mEFfnaH7/UPBcveq4VqAbSmXS98gGozb5cFNvrJXYFasnJIOEUf44NykE1mwTtP33liu mBbd5gossZOT8VKi9d8lVcggIC+iwGvI7Zpow00A9DQC93Crzt1aBrlwiB4aD11kvtxi CK7g== X-Gm-Message-State: ALoCoQlmr32hODAsMQi9jyGv7Nirnr/oEpJ9Jydq2Ohve5DCsv23ssU0D1hL9GGJ8RgBrXKqBYmc X-Received: by 10.180.182.201 with SMTP id eg9mr5445113wic.3.1426519733144; Mon, 16 Mar 2015 08:28:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.14 with SMTP id t14ls695316laz.61.gmail; Mon, 16 Mar 2015 08:28:52 -0700 (PDT) X-Received: by 10.112.149.10 with SMTP id tw10mr15222632lbb.78.1426519732629; Mon, 16 Mar 2015 08:28:52 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id yd8si8392549lbb.144.2015.03.16.08.28.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2015 08:28:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labjg1 with SMTP id jg1so43058480lab.2 for ; Mon, 16 Mar 2015 08:28:52 -0700 (PDT) X-Received: by 10.152.120.134 with SMTP id lc6mr54962250lab.72.1426519732536; Mon, 16 Mar 2015 08:28:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2659078lbj; Mon, 16 Mar 2015 08:28:51 -0700 (PDT) X-Received: by 10.50.254.99 with SMTP id ah3mr26045017igd.12.1426519731063; Mon, 16 Mar 2015 08:28:51 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id hf1si23215170pac.201.2015.03.16.08.28.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2015 08:28:51 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1YXWvV-0007IY-Dl; Mon, 16 Mar 2015 15:27:33 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YXWuy-0006nF-4U for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2015 15:27:01 +0000 Received: by wibdy8 with SMTP id dy8so40639781wib.0 for ; Mon, 16 Mar 2015 08:26:38 -0700 (PDT) X-Received: by 10.180.207.200 with SMTP id ly8mr39538490wic.58.1426519598014; Mon, 16 Mar 2015 08:26:38 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.4.220]) by mx.google.com with ESMTPSA id u16sm15876983wjr.5.2015.03.16.08.26.35 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Mar 2015 08:26:37 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, lkml@vger.kernel.org, keescook@chromium.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com Subject: [RFC PATCH 3/3] arm64/efi: use relocated kernel Date: Mon, 16 Mar 2015 16:23:43 +0100 Message-Id: <1426519423-28263-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1426519423-28263-1-git-send-email-ard.biesheuvel@linaro.org> References: <1426519423-28263-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150316_082700_354539_574350C6 X-CRM114-Status: GOOD ( 11.37 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.181 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: joakim.bech@linaro.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 PoC for relocated kernel code. This puts the kernel at the top of the lowest naturally aligned 1 GB region of memory, and relocates the kernel so that the relative alignment of physical and virtual memory is at least 1 GB as well. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi-entry.S | 4 +++- arch/arm64/kernel/efi-stub.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S index f78e6a1de825..89ba42191e59 100644 --- a/arch/arm64/kernel/efi-entry.S +++ b/arch/arm64/kernel/efi-entry.S @@ -11,6 +11,7 @@ */ #include #include +#include #include @@ -110,7 +111,8 @@ ENTRY(efi_stub_entry) 2: /* Jump to kernel entry point */ mov x0, x20 - mov x1, xzr + and x1, x21, #~(SZ_2M - 1) + and x1, x1, #(SZ_1G - 1) mov x2, xzr mov x3, xzr br x21 diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 3b67ca4e2f2e..ba95d9d69884 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -38,8 +38,9 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table, if (*image_addr != preferred_offset) { const unsigned long alloc_size = kernel_memsize + TEXT_OFFSET; - status = efi_low_alloc(sys_table, alloc_size, SZ_2M, - reserve_addr); + status = efi_high_alloc(sys_table, alloc_size, SZ_2M, + reserve_addr, + (dram_base | (SZ_1G - 1)) + 1); /* * Check whether the new allocation crosses a 512 MB alignment