From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-112.mta1.migadu.com [95.215.58.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F388B35DA79 for ; Fri, 4 Sep 2026 01:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788484756; cv=none; b=X0bufUMwva5aUXEP0bP/EXHw8LprYxKapKaNaoJizNcAr6taN01bujxo0p7Wkwa8vgqcMfJFeEPlhvfmykRVopoBJHnALuGu3xBtvh008Szqdf7bQKuFGJPH+SVhIc/bYEornpBRP8CijcTfs2DoiTZZ+1grqrSgYUUtv/T3c/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788484756; c=relaxed/simple; bh=uVjDr7dZL7yoKSrQjhePnAihc0cTtyYDH0m68MNyVco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lZeHMJf4x7xlYC1OFo1x82GmCaH14NgAGT9JQkFXFnaS2ZB9PmP7bCSe9uEdLJmg+93UPcwLOr4G6VHvRn0XjEmCrbGKo5HX5tRqvO1JKajX/rwM71vBZfCPtnvO1iO/gv/L/BOmqQW4mgy19WvDqQ97fApqldrEFcyY+ydxy0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TCM+NeT2; arc=none smtp.client-ip=95.215.58.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="TCM+NeT2" X-Envelope-To: llvm@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=uVjDr7dZL7yoKSrQjhePnAihc0cTtyYDH0m68MNyVco=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1788484752; v=1; x=1789089552; b=TCM+NeT2+KyWgDd/U4By2gfp/3/qVfWDnP4DWVbRhS66XX7GA2k28Pgk1DEHru8egdLQLPU+ 0omXg/e6u16phqDsmNLUKV8PegxjXZNq3M6OjXo/8yxFBvz+WrOhGwkBnMWpUjCvEvGi9Rplc+G +ICdQGlY1HecaonN+0RHIxEs= X-Envelope-To: llvm@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id ce60cf1ee74e60ff; Fri, 04 Sep 2026 01:19:12 +0000 X-Mizu-Trace-ID: ce60cf1ee74e60ff X-Migadu-Flow: FLOW_OUT From: "Jose Fernandez (Anthropic)" Date: Fri, 04 Sep 2026 01:18:34 +0000 Subject: [PATCH RFC 2/8] scripts/sorttable: Make the arm64 before_func offset configurable Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260904-b4-arm64-callops-kcfi-v1-2-ce6687739b0c@linux.dev> References: <20260904-b4-arm64-callops-kcfi-v1-0-ce6687739b0c@linux.dev> In-Reply-To: <20260904-b4-arm64-callops-kcfi-v1-0-ce6687739b0c@linux.dev> To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Catalin Marinas , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Puranjay Mohan , Xu Kuohai , Ard Biesheuvel , Ilias Apalodimas , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= , Sami Tolvanen , Kees Cook Cc: Leon Hwang , Ihor Solodrai , Josh Poimboeuf , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org, linux-efi@vger.kernel.org, rust-for-linux@vger.kernel.org, Ben Cressey , "Florent Revest (Anthropic)" , "Jose Fernandez (Anthropic)" X-Mailer: b4 0.15.2 sorttable hardcodes before_func to 8 bytes on arm64 (two prefix NOPs). Make it configurable from CONFIG_ARM64_FUNCTION_PREFIX_NOPS instead. kCFI kernels with CALL_OPS need three NOPs. The symbol does not exist yet, so no functional change. Reviewed-by: Ben Cressey Reviewed-by: Florent Revest (Anthropic) Assisted-by: LLM Signed-off-by: Jose Fernandez (Anthropic) --- scripts/Makefile | 3 +++ scripts/sorttable.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile b/scripts/Makefile index 3434a82a119f0..366c6a35141a6 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -51,6 +51,9 @@ endif ifdef CONFIG_BUILDTIME_MCOUNT_SORT HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED +ifneq ($(filter-out 0,$(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)),) +HOSTCFLAGS_sorttable.o += -DFUNCTION_PREFIX_BYTES=$(shell expr 4 \* $(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)) +endif endif # The following programs are only built on demand diff --git a/scripts/sorttable.c b/scripts/sorttable.c index d8dc2a1b7c312..925382bb23dcc 100644 --- a/scripts/sorttable.c +++ b/scripts/sorttable.c @@ -281,6 +281,11 @@ static int add_field(uint64_t addr, uint64_t size) /* Used for when mcount/fentry is before the function entry */ static int before_func; +/* How far before the function entry a patchable entry may be recorded */ +#ifndef FUNCTION_PREFIX_BYTES +#define FUNCTION_PREFIX_BYTES 8 +#endif + /* Only return match if the address lies inside the function size */ static int cmp_func_addr(const void *K, const void *A) { @@ -899,7 +904,7 @@ static int do_file(char const *const fname, void *addr) /* fallthrough */ case EM_RISCV: /* arm64 and RISC-V place patchable entries before the function. */ - before_func = 8; + before_func = FUNCTION_PREFIX_BYTES; #else case EM_AARCH64: case EM_RISCV: -- 2.52.0