From patchwork Thu Sep 17 06:19:48 2020
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Ard Biesheuvel <ardb@kernel.org>
X-Patchwork-Id: 11781619
Return-Path: 
 <SRS0=6281=C2=lists.infradead.org=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7EA96CA
	for <patchwork-linux-arm@patchwork.kernel.org>;
 Thu, 17 Sep 2020 06:20:24 +0000 (UTC)
Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mail.kernel.org (Postfix) with ESMTPS id 758BF208E4
	for <patchwork-linux-arm@patchwork.kernel.org>;
 Thu, 17 Sep 2020 06:20:24 +0000 (UTC)
Authentication-Results: mail.kernel.org;
	dkim=pass (2048-bit key) header.d=lists.infradead.org
 header.i=@lists.infradead.org header.b="asIIUop8";
	dkim=fail reason="signature verification failed" (1024-bit key)
 header.d=kernel.org header.i=@kernel.org header.b="Dfh0zH+Q"
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 758BF208E4
Authentication-Results: mail.kernel.org;
 dmarc=fail (p=none dis=none) header.from=kernel.org
Authentication-Results: mail.kernel.org;
 spf=none
 smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
	d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding:
	Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive:
	List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:In-Reply-To:References:List-Owner;
	bh=Lo1QvkycLV/7qa6tRuaKU+043GrCtYRFDvZNpiyIHFs=; b=asIIUop8zx9VLyP8RxH3FSnpIB
	goa+Fn9zbDfPdm1XBArYJdBUQkptX0eK5ggte4+RtYnD6jtYPnDQ1atbG+LXFXdCGBPPGD7Ec0NCz
	2rf7GocaLxeNTnfrTrLiyeLitFTbrFsfog6LNatG/wbNnekF7ykhcZ7bzwvfMVNbAYwx0vMjCBUDv
	yaOUflwQYiTda6AkoJnj1IISdIYLgkCEIzyDVq3rIFW3BA+m5EhmhXKI2gcksipSVuIsbux+px9ZV
	v42wJcIXgnVA+qJct1MFfxvPN1vQBL9aLZclNOcXNmKZD8Q09LA4yNxvFkRoNLlBOPKYSN6XHmtJn
	mAF9oPSw==;
Received: from localhost ([::1] helo=merlin.infradead.org)
	by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux))
	id 1kInGx-0003LG-UJ; Thu, 17 Sep 2020 06:20:00 +0000
Received: from mail.kernel.org ([198.145.29.99])
 by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux))
 id 1kInGv-0003Kq-Ma
 for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 06:19:58 +0000
Received: from e123331-lin.nice.arm.com (unknown [91.140.120.15])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mail.kernel.org (Postfix) with ESMTPSA id 9D4CD20707;
 Thu, 17 Sep 2020 06:19:54 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
 s=default; t=1600323596;
 bh=ziD1S262d4AhvP0HlkLo4WCfu8gkBuZJo+18GfJki9c=;
 h=From:To:Cc:Subject:Date:From;
 b=Dfh0zH+QgFdYO0gLoboRtZhySJAl+bjUHgIo8kCQVGjvzCWF7i2BSPEKZiFbSIEGm
 fFSTDES62ApoJHYwFnIAtXQMpjV7DYbIoeuFScbKPT4lMxCYpo/X7ffl/+OEWMkRAK
 4Unu4CMR1SVL+8a4DZhSoF74nrvGspRqV5Nh1iTI=
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: vfp: force non-conditional encoding for external Thumb2
 tail call
Date: Thu, 17 Sep 2020 09:19:48 +0300
Message-Id: <20200917061948.12403-1-ardb@kernel.org>
X-Mailer: git-send-email 2.17.1
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
X-CRM114-CacheID: sfid-20200917_021957_811961_126E0A54 
X-CRM114-Status: GOOD (  13.51  )
X-Spam-Score: -8.2 (--------)
X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary:
 Content analysis details:   (-8.2 points)
 pts rule name              description
 ---- ----------------------
 --------------------------------------------------
 -5.0 RCVD_IN_DNSWL_HI       RBL: Sender listed at https://www.dnswl.org/,
 high trust [198.145.29.99 listed in list.dnswl.org]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.1 DKIM_SIGNED            Message has a DKIM or DK signature,
 not necessarily
 valid
 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from
 envelope-from domain
 -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from
 author's domain
 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
 -3.0 DKIMWL_WL_HIGH         DKIMwl.org - Whitelisted High sender
X-BeenThere: linux-arm-kernel@lists.infradead.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <linux-arm-kernel.lists.infradead.org>
List-Unsubscribe: 
 <http://lists.infradead.org/mailman/options/linux-arm-kernel>,
 <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>
List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
List-Post: <mailto:linux-arm-kernel@lists.infradead.org>
List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>
List-Subscribe: 
 <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,
 <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>
Cc: ndesaulniers@google.com, linux@armlinux.org.uk, stable@vger.kernel.org,
 Ard Biesheuvel <ardb@kernel.org>
MIME-Version: 1.0
Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org>
Errors-To: 
 linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org

Nick reports that the following error is produced in some cases when
using GCC+ld.bfd to build the ARM defconfig with Thumb2 enabled:

  arch/arm/vfp/vfphw.o: in function `vfp_support_entry':
  (.text+0xa): relocation truncated to fit: R_ARM_THM_JUMP19 against
  symbol `vfp_kmode_exception' defined in .text.unlikely section in
  arch/arm/vfp/vfpmodule.o

  $ arm-linux-gnueabihf-ld --version
  GNU ld (GNU Binutils for Debian) 2.34

Generally, the linker should be able to fix up out of range branches by
emitting veneers, but apparently, it fails to do so in this particular
case, i.e., a conditional 'tail call' to vfp_kmode_exception(), which
is not defined in the same object file.

So let's force the use of a non-conditional encoding of the B instruction,
which has more space for an immediate offset.

Cc: <stable@vger.kernel.org>
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/vfp/vfphw.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index 4fcff9f59947..f1468702fbc9 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -82,6 +82,7 @@ ENTRY(vfp_support_entry)
 	ldr	r3, [sp, #S_PSR]	@ Neither lazy restore nor FP exceptions
 	and	r3, r3, #MODE_MASK	@ are supported in kernel mode
 	teq	r3, #USR_MODE
+THUMB(	it	ne			)
 	bne	vfp_kmode_exception	@ Returns through lr
 
 	VFPFMRX	r1, FPEXC		@ Is the VFP enabled?