From patchwork Mon Oct 26 20:16:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 55576 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1401660lbq; Mon, 26 Oct 2015 13:18:01 -0700 (PDT) X-Received: by 10.66.167.101 with SMTP id zn5mr24122218pab.48.1445890681614; Mon, 26 Oct 2015 13:18:01 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id i16si55524476pbq.81.2015.10.26.13.18.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2015 13:18:01 -0700 (PDT) Received-SPF: pass (google.com: 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: 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 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 1ZqoCE-00013H-GG; Mon, 26 Oct 2015 20:16:46 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZqoCB-0000zW-0Q for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2015 20:16:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85D914A; Mon, 26 Oct 2015 13:16:13 -0700 (PDT) Received: from leverpostej (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F40E3F2E5; Mon, 26 Oct 2015 13:16:18 -0700 (PDT) Date: Mon, 26 Oct 2015 20:16:11 +0000 From: Mark Rutland To: Jeremy Linton Subject: Re: [PATCH v2] arm64: Align .text section to PAGE_SIZE Message-ID: <20151026201611.GI12277@leverpostej> References: <1445882989-10618-1-git-send-email-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1445882989-10618-1-git-send-email-jeremy.linton@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151026_131643_072307_87DEA327 X-CRM114-Status: GOOD ( 21.27 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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@linaro.org, catalin.marinas@arm.com, suzuki.poulose@arm.com, will.deacon@arm.com, laura@labbott.name, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Hi, On Mon, Oct 26, 2015 at 01:09:49PM -0500, Jeremy Linton wrote: > v2: > Use ALIGN_DEBUG_RO_MIN() instead of ALIGN() directly. > > v1: Move the v* stuff below the ---, there's no need for that in the permanent commit message. > It appears that 64k page kernel's die early, in a somewhat random set > of locations when built without KVM. Most likely during memblock > manipulations (depending on kernel debug options). > > Normally when KVM is built into the kernel it has an explicit > PAGE_SIZE alignment requirement and that forces the text section to be > aligned to PAGE_SIZE. Without it, the alignment granularity is likely to > be 4k. Please replace these with a description of the issue as an effect of CONFIG_DEBUG_RO_DATA && !CONFIG_DEBUG_ALIGN_RODATA, now that Ard figured that out for us, so we don't have to figure it out again in future. e.g. A kernel built with DEBUG_RO_DATA && !CONFIG_DEBUG_ALIGN_RODATA doesn't have .text aligned to a page boundary, though fixup_executable works at page-genularity thanks to its use of create_mapping. If .text is not page-aligned, the first page it exists in may be marked non-executable, leading to failures when an attempt is made to execute code in said page. > This updates the linker script to assure that the the text section is Nit: s/assure/ensure/ > aligned to a minimum of PAGE_SIZE regardless of build options. > > Signed-off-by: Jeremy Linton > --- > arch/arm64/kernel/vmlinux.lds.S | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > index 8a5d97b..f3fc966 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -91,7 +91,7 @@ SECTIONS > _text = .; > HEAD_TEXT > } > - ALIGN_DEBUG_RO > + ALIGN_DEBUG_RO_MIN(PAGE_SIZE) I'm in two minds about having a separate macro, as you suggested to save space when !DEBUG_RO_DATA. I won't strongly push for it, though it would be nice to not waste memory here if we don't have to. Also, couldn't the same issue happen for other sections (e.g. rodata)? Perhaps it would be better to have something like the following (with PAGE_SHIFT sorted out to be includable in a linker script), so any ALIGN_DEBUG_RO* correctly aligns things to whatever boundary is required, and we don't need to over-align things in the !DEBUG_RO_DATA case. Thanks, Mark. ---->8---- _______________________________________________ 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/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 9807333..4d77757 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -60,9 +60,12 @@ PECOFF_FILE_ALIGNMENT = 0x200; #define PECOFF_EDATA_PADDING #endif -#ifdef CONFIG_DEBUG_ALIGN_RODATA +#if defined(CONFIG_DEBUG_ALIGN_RODATA) #define ALIGN_DEBUG_RO . = ALIGN(1<