From patchwork Wed Jun 24 11:22:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 11622931 Return-Path: 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 102DF618 for ; Wed, 24 Jun 2020 11:30:53 +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 DCB7B2088E for ; Wed, 24 Jun 2020 11:30:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wy3yRuEK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k+U/wSIg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCB7B2088E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=7Vlazn8TkuhqBSmc3wf2yeDn+djvYAEwlrYf94vFGv8=; b=wy3yRuEKXRIMkdRldWlpAIKxiK mkA91uwntUsC8L6GlD8kPAqmv2Hzf53POVy8HIj+RofvHL6SPYOjHYVbOyyVUk+/z4c6XIL9AHB0Y Si/07gq/ZvDgeNgQZQuTzvhYIG8TkozZXeupvbWuNy3rS+p2P8RPA/lTm5tnl3WRiVD7mlCeEqOXi Io87ia82CC/hknC3fXADU8KJ9x/k+urCaqfPNUnKm3SOSu83//nZD7FFKZ/HYAs9zDozKuvewkiHl hsA604ivvOu0WXF/UW5hkXitGpYa1oT5nOSOoHWmHAmLU7zK5H2g3mZ/wD0ba8nZbh6dagz6XEvVf KjxXdObA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3aY-0002Z8-AV; Wed, 24 Jun 2020 11:29:10 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3aS-0002WN-No for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 11:29:07 +0000 Received: by mail-ed1-x542.google.com with SMTP id d15so1202573edm.10 for ; Wed, 24 Jun 2020 04:29:02 -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:mime-version :content-transfer-encoding; bh=GwanT4h3W0AsKF95D3hHEX3Xwp0giD+dURJev+7NRbU=; b=k+U/wSIgsrzUIM+Hw39Hh4B9AvyuiaKb3Jutbb94ISBr3cs5laf+9WEC6WjJ5Po/MR bnB/lAPQL7BdPOIKfumhidzpFuv0zhsjnjY1ZeADrWZjTOSIrHRW6oy0tksP7192B/wZ gU7/cY5jiSv7J3jvsoj/BIm2tCbAB5GUlCn/ONqQX4RPuuvhm+Elc6tKeIxU+xeKFBHw StxWQcLsGa+O1yCEICVsv7Xpp8nnkd/eSRDcM2AEKy2eQcFtLjxDyRNPbrtj+yeUad1i od99ImK4tqPrArzo7Sp3jXXR+JgDeIJmO9bClZdhbgcgdCttz1Rb8g3OeULyUXaUyyEs 0GgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GwanT4h3W0AsKF95D3hHEX3Xwp0giD+dURJev+7NRbU=; b=ttyCjoo4Ssat50I9dSRVQCXRnXCWVCRgTS0mQGO0QzHNE988SfnGSrUhu03gkre9Fd 3JX6qFfH6fEO8I1BEbqoki76I9bKgZN+A5rtCFIFkfSKftLwhjuym87ZsL0nxfLxpjMC TC3uKitMVR2LM5rhLVJP4Wb/3W6Ivitb9YOEr1trHLg1FfJCLcW/A2gvXkJBmJ9mAfzp tetlzpbe5IbxQACVOvTA8x84WhSDf5Xv5kGW2jp0Y0XhYz0N8S2+b/eBWCTa/xWt8+oQ u9Gww0G4Ol+6DCFKtoag/kP4d3D45VNmSGCi6liNuujESudZgJfN/cGGku1eawIhqx7B YNZQ== X-Gm-Message-State: AOAM531V9zPURUgpE65Yd2KFkg3FvUPz+jWgiD2jUetvo9tT+M8xpXgX KtyvTrjC1PMEw/x0Knsxbj2ZEw== X-Google-Smtp-Source: ABdhPJzfgNkrlVMkP46E6Puuc5M7tIUUYUCMzm6S2mYKMBh2WBiGXofvwdQHn1Mk7tcaZOT3NOTERw== X-Received: by 2002:aa7:c38f:: with SMTP id k15mr27288705edq.342.1592998141618; Wed, 24 Jun 2020 04:29:01 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id q14sm16671427edj.47.2020.06.24.04.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 04:29:01 -0700 (PDT) From: Jean-Philippe Brucker To: catalin.marinas@arm.com, will@kernel.org Subject: [PATCH] arm64: Don't insert a BTI instruction at inner labels Date: Wed, 24 Jun 2020 13:22:54 +0200 Message-Id: <20200624112253.1602786-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:542 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_VALID Message has at least one valid DKIM or DK signature 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, broonie@kernel.org, dave.martin@arm.com, linux-arm-kernel@lists.infradead.org, Jean-Philippe Brucker Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Some ftrace features are broken since commit 714a8d02ca4d ("arm64: asm: Override SYM_FUNC_START when building the kernel with BTI"). For example the function_graph tracer: $ echo function_graph > /sys/kernel/debug/tracing/current_tracer [ 36.107016] WARNING: CPU: 0 PID: 115 at kernel/trace/ftrace.c:2691 ftrace_modify_all_code+0xc8/0x14c When ftrace_modify_graph_caller() attempts to write a branch at ftrace_graph_call, it finds the "BTI J" instruction inserted by SYM_INNER_LABEL() instead of a NOP, and aborts. It turns out we don't currently need the BTI landing pads inserted by SYM_INNER_LABEL: * ftrace_call and ftrace_graph_call are only used for runtime patching of the active tracer. The patched code is not reached from a branch. * install_el2_stub is reached from a CBZ instruction, which doesn't change PSTATE.BTYPE. * __guest_exit is reached from B instructions in the hyp-entry vectors, which aren't subject to BTI checks either. Remove the BTI annotation from SYM_INNER_LABEL. Fixes: 714a8d02ca4d ("arm64: asm: Override SYM_FUNC_START when building the kernel with BTI") Signed-off-by: Jean-Philippe Brucker Reviewed-by: Mark Brown --- Tested on QEMU with and without BTI, but only ftrace not KVM. --- arch/arm64/include/asm/linkage.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h index 81fefd2a1d023..ba89a9af820ab 100644 --- a/arch/arm64/include/asm/linkage.h +++ b/arch/arm64/include/asm/linkage.h @@ -12,7 +12,6 @@ * instead. */ #define BTI_C hint 34 ; -#define BTI_J hint 36 ; /* * When using in-kernel BTI we need to ensure that PCS-conformant assembly @@ -43,11 +42,6 @@ SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \ BTI_C -#define SYM_INNER_LABEL(name, linkage) \ - .type name SYM_T_NONE ASM_NL \ - SYM_ENTRY(name, linkage, SYM_A_NONE) \ - BTI_J - #endif /*