Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp221531pxj; Thu, 3 Jun 2021 05:12:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaHfK/nke0ko4ZCmA9MRutMQ5LVoFt77tumF6JurW2lA24dyZ46e2aEWoCtnsO0SDEs/CP X-Received: by 2002:aa7:c445:: with SMTP id n5mr24205128edr.64.1622722371434; Thu, 03 Jun 2021 05:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622722371; cv=none; d=google.com; s=arc-20160816; b=x4zy075turCRYRi5cQ4Q9OQcWWY0XtK3kTpLsp8Kue0iagQ/IgV6bKxd032A3Z6778 hE0X0yMFhtJ3kyB6X4VyhLCYqBdUZd4bLo+/l65hVcJDcW7lxiCBa9QcAy/MiPVXwFCC 5xe2kNI1TKtu3FNkeJmggVZRGIezbZXFW1TtGZEIMLPz+lIcjc6LjCA7SKDbTBX2YR78 RgB1D+iVBC+WrOapH/C3XhDZuA7j4LW8mqfDNosoIJqahgOSsWD/bevpHMbcuR58vUgg cvR0QSY2LdPRBnfmEGH4pxi+Jm6xbh3YGmtRXGki5kleEXyT88faxuC6F9DfHgh3LqEK VGsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ysNTrejwlKPqC9c78xgT0f2pGLkh+oJrfBx6OmmV91s=; b=tm7vgFlgtigzoHjjfVAJao7waJ38DjTz9BCppE8+MhPEqdwWo1hJO9rkH+F/Rq6yAM 0Fm7wVdUu7hwjkegpqUwzSSMcqZzm4UQo5FsdZ1ueFneMwnh3OBV33PRprCI6srNKjd/ LQSrlue/WvOgExe9YeTzm/HFToEMXWsLbOH9jb7AS47AeGcj3dDiT1BQP6pXhSDbsANb jiZdMu178zQLCxsZ07PYNkttOdgX/U46mPsoXaT9GbUerhn3N2SkQtK6TNGWBqSD/OB1 y0wL1pI9wGj2/fpU4BUPKQqGUYgdJSBe9ZSDzAXXL2zEaJpO3DbX9h4m89Pr8Vqgj49y YWtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si2391353ejd.407.2021.06.03.05.12.28; Thu, 03 Jun 2021 05:12:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbhFCMJI (ORCPT + 99 others); Thu, 3 Jun 2021 08:09:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:56428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbhFCMJH (ORCPT ); Thu, 3 Jun 2021 08:09:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84AB261001; Thu, 3 Jun 2021 12:07:21 +0000 (UTC) Date: Thu, 3 Jun 2021 13:07:19 +0100 From: Catalin Marinas To: Kees Cook Cc: Arnd Bergmann , Fangrui Song , Will Deacon , Ard Biesheuvel , Mark Rutland , Marc Zyngier , David Brazdil , Linux ARM , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section Message-ID: <20210603120718.GA20338@arm.com> References: <20210226140352.3477860-1-arnd@kernel.org> <202102261256.AF256702@keescook> <20210227043257.k3aernmnzsvitp7c@google.com> <20210316104530.GA7309@arm.com> <20210316162745.GA20565@arm.com> <20210316190921.GB28565@arm.com> <202106021231.A1B7A10@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202106021231.A1B7A10@keescook> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 02, 2021 at 12:32:40PM -0700, Kees Cook wrote: > On Tue, Mar 16, 2021 at 07:09:23PM +0000, Catalin Marinas wrote: > > On Tue, Mar 16, 2021 at 05:39:27PM +0100, Arnd Bergmann wrote: > > > On Tue, Mar 16, 2021 at 5:27 PM Catalin Marinas wrote: > > > > On Tue, Mar 16, 2021 at 10:45:32AM +0000, Catalin Marinas wrote: > > > > > On Fri, Feb 26, 2021 at 08:32:57PM -0800, Fangrui Song wrote: > > > > > > On 2021-02-26, Kees Cook wrote: > > > > > > > On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote: > > > > > > > > From: Arnd Bergmann > > > > > > > > > > > > > > > > When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, > > > > > > > > I sometimes see an assertion > > > > > > > > > > > > > > > > ld.lld: error: Entry trampoline text too big > > > > > > > > > > > > > > Heh, "too big" seems a weird report for having it discarded. :) > > > > > > > > > > > > > > Any idea on this Fangrui? > > > > > > > > > > > > > > ( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 ) > > > > > > > > > > > > This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds > > > > > > > > > > > > ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16), > > > > > > "Entry trampoline text too big") > > > > > > > > > > Can we not change the ASSERT to be <= PAGE_SIZE instead? > > > > > > > > Ah, that won't work as I suspect we still need the trampoline section. > > > > > > > > Arnd, do you know why this section disappears? I did a simple test with > > > > defconfig + LD_DEAD_CODE_DATA_ELIMINATION and the trampoline section is > > > > still around. > > > > > > If I remember correctly, this showed up when CONFIG_ARM_SDE_INTERFACE > > > is disabled, which dropped the only reference into this section. > > > If that doesn't make sense, I can try digging through the old build logs to > > > reproduce the problem. > > > > I suspected this as well but still worked for me when disabling it. > > > > Anyway, I don't think identifying the exact option is necessary. With > > CONFIG_UNMAP_KERNEL_AT_EL0=y we need this section around even if only > > __entry_tramp_text_start/end are referenced. > > > > In this case we happened to detect this issue because of the ASSERT in > > vmlinux.lds.S but I wonder what else the linker drops with this dead > > code elimination that we may not notice (it seems to remove about 500KB > > from the resulting image in my test). > > > > I'll push these two patches to -next for wider coverage before deciding > > on mainline (though the option may not get much testing as it's hidden > > behind EXPERT and default n). > > I don't see this in -next? Catalin, do you want me to pick it up as part > of my collecting various linker fixes? IIRC this patch only makes sense if we also enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION on arm64. Last time I looked at Arnd's RFC it still had some issues: https://lore.kernel.org/r/20210319122506.GA6832@arm.com So I decided against queuing that for now (and this patch on top was not necessary). -- Catalin