From patchwork Thu Mar 3 18:44:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63490 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp65351lbc; Thu, 3 Mar 2016 10:46:08 -0800 (PST) X-Received: by 10.66.164.39 with SMTP id yn7mr5750887pab.107.1457030766183; Thu, 03 Mar 2016 10:46:06 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id p21si39254005pfi.248.2016.03.03.10.46.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Mar 2016 10:46:06 -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 1abYFH-0001Oa-Qn; Thu, 03 Mar 2016 18:45:07 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abYEw-00019Z-SK for linux-arm-kernel@lists.infradead.org; Thu, 03 Mar 2016 18:44:47 +0000 Received: by mail-wm0-x22f.google.com with SMTP id p65so47789992wmp.1 for ; Thu, 03 Mar 2016 10:44:26 -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=fZPHyxDTBDMUiKBgR+Kzqgu7qnUWFPaDW01bQXr4Gr4=; b=gM3EEGstPx5m+sl2O5S/rHcHoJipeByjUWM6hH7QSLIDlRTBvG/WHc1kMgtZOfR6MH 1k+3NZQmyfkUtRwi+WxnDzXCzfi46wb0WNYuRQdz6Gl4/QYku3DG3m5U7n6TmtzgG0rW sDf8Lg4VZdjluLd+KFlaHnWRq1WJFWurEEVDs= 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=fZPHyxDTBDMUiKBgR+Kzqgu7qnUWFPaDW01bQXr4Gr4=; b=T0QKrkiRJSGrRs3O6rQ0Ep3kkxA3QpCKoPWUuJYIOdI7q8B0WrMi+Wad7s/2lsDo4K CBBrxt0lg/yiONksUwqQcdPv1LRHBKPotvzvu7xo87wbb1X7yPPNmgjJTxhsc1/RZUHd fT2KGYMRlxzQCwxxVIIMNXoMyul8mn6MvZ4VJ4Rry+qj4Py5Jiy4wY2FrN4Bpse3dYFQ xxs27ehSvgDEMjMPwcNxdSaJ97K6tBvt4bv7FlxGvoVAAIyInpc3BVAZLyZDa/40RhO3 a6fN52PIvlsOdRm7wvPWoPR4jWcNnBfd+M4Rhv6CdIljUDypkjVW00xZPMtrsQJ4U5IH Vj2A== X-Gm-Message-State: AD7BkJKgc/o1DalWdj+7241bP6rlMMMv7elznLsP6UOLVqBRbQMq3xbMfGnkrWq1p4yCORq6 X-Received: by 10.194.92.107 with SMTP id cl11mr5257837wjb.21.1457030665301; Thu, 03 Mar 2016 10:44:25 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id l132sm10115534wmf.7.2016.03.03.10.44.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 10:44:24 -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 v2 1/3] arm64: don't map TEXT_OFFSET bytes below the kernel if we can avoid it Date: Thu, 3 Mar 2016 19:44:14 +0100 Message-Id: <1457030656-29584-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457030656-29584-1-git-send-email-ard.biesheuvel@linaro.org> References: <1457030656-29584-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160303_104447_154241_DC0C8F7D X-CRM114-Status: GOOD ( 13.43 ) 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:22f 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 | 4 ++-- arch/arm64/kernel/image.h | 2 +- 2 files 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 af522c853b7f..ca8ba19df786 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -394,12 +394,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 /* diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h index 5ff892f40a0a..803dc57acd72 100644 --- a/arch/arm64/kernel/image.h +++ b/arch/arm64/kernel/image.h @@ -71,7 +71,7 @@ DEFINE_IMAGE_LE64(_kernel_offset_le, TEXT_OFFSET); \ DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS); -kernel_img_size = _end - (_text - TEXT_OFFSET); +kernel_img_size = _end - _text; #ifdef CONFIG_EFI