From patchwork Wed Mar 30 15:43:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 8699061 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EAFB99FC5B for ; Wed, 30 Mar 2016 15:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8A3420383 for ; Wed, 30 Mar 2016 15:50:05 +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 D448220376 for ; Wed, 30 Mar 2016 15:50:04 +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 1alILv-0002YP-H8; Wed, 30 Mar 2016 15:48:15 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alIHW-0005ZN-GJ for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 15:44:02 +0000 Received: by mail-wm0-x22d.google.com with SMTP id 191so94725687wmq.0 for ; Wed, 30 Mar 2016 08:43:22 -0700 (PDT) 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=XDytqye9yW0LCquA2OMMSdCTr1v64/R2jJBdMb9IrJ0=; b=bo7Gyv67hhk537c2nuH9je/tuCqjQqCC630qTxlqU1a0pNbodTmNT2R/6K6yQ/QwHS cg+2I0RqF1S97KCU6nJ/LYn42bwtylIKX9FSXyJoi4U+oqFiFg5Dp/zoCzb29EJkqlac GZSx7AsZs9W/Ezv8vd1ceRKBQf/IR4yKObfl4= 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=XDytqye9yW0LCquA2OMMSdCTr1v64/R2jJBdMb9IrJ0=; b=PIhd7UrKjzE/uP1QgaDDRhdfbYz5oGK7cDunV6MzDjYQxDaktPXo7QWOSJ/eLa2g3G +4kHciv+0nLVj4QFbhCweVpGJrYtxSFp0gfXrzQKaPsGu5PsoKaEbpSZCzDiJOy8vTLq OZmv+/91W8yNRuW5Njhm33+yh+TF5L0OBbB1oxOpGzVbLAd3pyilfP4jAM/iCD18Z98r rXWnKAK6tMhHcMz75H96R55mQHyz84NoN4RVxnhRrIz73mWshtmE4Lv80yMO5T5w5tSg qp5Ys3XurDIvwUPgF943ZK1Hkxf+7bhy/8hNPLWjIZ75gL3Ig8N9SqdqXWtgVJfH0ytZ iTOg== X-Gm-Message-State: AD7BkJJ4GaxNk9yix1A1wiT+KVDd9EnoOnOVYnyKgykc/ZI/8zXhZi+OcWYwC7OTiKm7sbum X-Received: by 10.194.185.108 with SMTP id fb12mr10572749wjc.89.1459352601111; Wed, 30 Mar 2016 08:43:21 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id h7sm20330403wmf.9.2016.03.30.08.43.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 08:43:20 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, jeremy.linton@arm.com Subject: [PATCH v2 4/4] arm64: simplify kernel segment mapping granularity Date: Wed, 30 Mar 2016 17:43:09 +0200 Message-Id: <1459352589-28721-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459352589-28721-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459352589-28721-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_084343_439918_DF2F9E84 X-CRM114-Status: GOOD ( 16.27 ) X-Spam-Score: -2.7 (--) 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: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The mapping of the kernel consist of four segments, each of which is mapped with different permission attributes and/or lifetimes. To optimize the TLB and translation table footprint, we define various opaque constants in the linker script that resolve to different aligment values depending on the page size and whether CONFIG_DEBUG_ALIGN_RODATA is set. Considering that - a 4 KB granule kernel benefits from a 64 KB segment alignment (due to the fact that it allows the use of the contiguous bit), - the minimum alignment of the .data segment is THREAD_SIZE already, not PAGE_SIZE (i.e., we already have padding between _data and the start of the .data payload in many cases), - 2 MB is a suitable alignment value on all granule sizes, either for mapping directly (level 2 on 4 KB), or via the contiguous bit (level 3 on 16 KB and 64 KB), - anything beyond 2 MB exceeds the minimum alignment mandated by the boot protocol, and can only be mapped efficiently if the physical alignment happens to be the same, we can simplify this by standardizing on 64 KB (or 2 MB) explicitly, i.e., regardless of granule size, all segments are aligned either to 64 KB, or to 2 MB if CONFIG_DEBUG_ALIGN_RODATA=y. This also means we can drop the Kconfig dependency of CONFIG_DEBUG_ALIGN_RODATA on CONFIG_ARM64_4K_PAGES. Signed-off-by: Ard Biesheuvel --- arch/arm64/Kconfig.debug | 2 +- arch/arm64/kernel/vmlinux.lds.S | 25 ++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index 7e76845a0434..710fde4ad0f0 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -59,7 +59,7 @@ config DEBUG_RODATA If in doubt, say Y config DEBUG_ALIGN_RODATA - depends on DEBUG_RODATA && ARM64_4K_PAGES + depends on DEBUG_RODATA bool "Align linker sections up to SECTION_SIZE" help If this option is enabled, sections that may potentially be marked as diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 61a1075b9c30..77d86c976abd 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -63,14 +63,19 @@ PECOFF_FILE_ALIGNMENT = 0x200; #endif #if defined(CONFIG_DEBUG_ALIGN_RODATA) -#define ALIGN_DEBUG_RO . = ALIGN(1<