From patchwork Wed Mar 2 17:11:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63405 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2497789lbc; Wed, 2 Mar 2016 09:13:34 -0800 (PST) X-Received: by 10.98.31.21 with SMTP id f21mr38994430pff.134.1456938814347; Wed, 02 Mar 2016 09:13:34 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 66si19667111pfm.92.2016.03.02.09.13.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 09:13:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for 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: best guess record for 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 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 1abAKF-0001y8-Mk; Wed, 02 Mar 2016 17:12:39 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abAJy-0001kA-G9 for linux-arm-kernel@lists.infradead.org; Wed, 02 Mar 2016 17:12:24 +0000 Received: by mail-wm0-x22b.google.com with SMTP id p65so87160109wmp.0 for ; Wed, 02 Mar 2016 09:12:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b+c3AuBSZNXIK+AvklWQjG3om2pISiP+c4T+hv2Wsg0=; b=SPWyflg5WjEhh9pD7cJ+GDd3a4+c0WpPoBL6k0qL/lBwDwMKYyXuxtCDS4tMRuJVuE UhXTiKz0RLSuQoJF/eDBUEQf6BKO7ix8G8E+rtfJ2m6Ldlcd93Uxl5TMabpWq9eapAmv KkpnjaC9wBViKG/C/4XVXX3eRN/PDFE06X0nw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b+c3AuBSZNXIK+AvklWQjG3om2pISiP+c4T+hv2Wsg0=; b=IKcJ7Y3q3YHLpxMML09ixxaJyIxvGuC2kIr7HsP6X3+NJ56zIGGXZYczSR/Y2eX9l+ ZTN6WyYRluJ4rM0o3uP6MuXUKbM3O3736hmMBqw4/O9RVCiUNp0h8zymTfIaC90lbG05 HzSnN7ntmjxaYyXFZ09N9u1CpbAFoNQwP4ZsWjA7iWmofMTVt7YCRKXIdRTnvTKaAX6C ho2crz3rnJ66jFjLIuoF169sMfT0aYD85VsYl9geH0iZjcDiogRRRGoH5puEZHZENHGt sI5VqW5IuEpcEs8DttC8sxxHTtGfdI8PKscEh7/C57oabBiiPZrFWh4AyXx/9EaFCu3H aW3Q== X-Gm-Message-State: AD7BkJI1/k7TLBjU2epkb7YUK60Sagy/Eex60MQfJ+qvo5oOE0O7SQBBfZoR2j/AA7aRnDwy X-Received: by 10.28.23.196 with SMTP id 187mr977689wmx.17.1456938720877; Wed, 02 Mar 2016 09:12:00 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id gk4sm18023317wjd.7.2016.03.02.09.11.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 09:12:00 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, keescook@chromium.org, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [PATCH 1/3] arm64: don't map TEXT_OFFSET bytes below the kernel if we can avoid it Date: Wed, 2 Mar 2016 18:11:50 +0100 Message-Id: <1456938712-11089-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456938712-11089-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456938712-11089-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160302_091222_889440_0012D25C X-CRM114-Status: GOOD ( 12.79 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22b 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_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: matt@codeblueprint.co.uk, david.brown@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org For historical reasons, there is a 512 KB hole called TEXT_OFFSET below the kernel image in memory. Since this hole is part of the kernel footprint in the early mapping when running with 4 KB pages, we cannot avoid mapping it, but in other cases, e.g., when running with larger page sizes, or in the future, with more granular KASLR, there is no reason to map it explicitly like we do currently. So update the logic so that the hole is mapped only if it occurs as a result of rounding the start address of the kernel to swapper block size, and leave it unmapped otherwise. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 50c2134a4aaf..1d4ae36db0bb 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -393,12 +393,12 @@ __create_page_tables: * Map the kernel image (starting with PHYS_OFFSET). */ mov x0, x26 // swapper_pg_dir - ldr x5, =KIMAGE_VADDR + ldr x5, =KIMAGE_VADDR + TEXT_OFFSET // compile time virt addr of _text add x5, x5, x23 // add KASLR displacement create_pgd_entry x0, x5, x3, x6 ldr w6, kernel_img_size add x6, x6, x5 - mov x3, x24 // phys offset + adrp x3, KERNEL_START // runtime phys addr of _text create_block_map x0, x7, x3, x5, x6 /* @@ -415,7 +415,7 @@ __create_page_tables: ENDPROC(__create_page_tables) kernel_img_size: - .long _end - (_head - TEXT_OFFSET) + .long _end - _head .ltorg /*