From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-31.mta0.migadu.com [91.218.175.31]) (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 48906440632 for ; Thu, 24 Sep 2026 22:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.31 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289410; cv=none; b=rNMcPvGEqAadCk0yumGjKOT+yAuhuZ5weMIywBjHy78kC96zqDjMluLefGhRr11x1qQvhUqZQuD0vx2CLLvoYCH1gdtF/Z7yztcsjcHlYLqrWW8sUeG+bFl4zJWTnMF43D00KTS4s3LHXU++/5ouvNBpe/tqN2hdK9Y5RVQ8SrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289410; c=relaxed/simple; bh=kvklvMQb5bIcpXnAuNRAqEBY7d8GE0zlY/tQCrHSqxg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oc8fwEPwZKXXNGfMbOotJ3okK3Y9mDifwuHsxNDbhBhILXZ4XZL4mBSk6Hg4UyBr1JhhLiL45c/ILgPnbC+opyMhfvP55Yg4oazUd0GR1ex4OBZac9Hlyr0PRKurr3yPzLVat/K/VeMguTcXCclYxb3DdaDfN4ZG7stSf3nMba0= 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=KqrZAsZ3; arc=none smtp.client-ip=91.218.175.31 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="KqrZAsZ3" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=kvklvMQb5bIcpXnAuNRAqEBY7d8GE0zlY/tQCrHSqxg=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790289406; v=1; x=1790894206; b=KqrZAsZ3GkIUJfeBg37N2oappBHp7z1XSnGbX5m/UfSQE9Acya1iCfOm7w5+x6YXud5REi3p 35T5a6xYk1LQgdTRMgKNdzDXGc09v65ClUZkcxCh0MM4VfZT8phh6xjjsVLtA5KjWsMmR16h4zP aWrreiOHkqkOJcEa9gVtsqhM= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 2f823245de1bd7fb; Thu, 24 Sep 2026 22:36:45 +0000 X-Mizu-Trace-ID: 2f823245de1bd7fb X-Migadu-Flow: FLOW_OUT From: "Jose Fernandez (Anthropic)" Date: Thu, 24 Sep 2026 22:35:47 +0000 Subject: [PATCH v2 3/9] scripts/sorttable: Make the arm64 before_func offset configurable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260924-b4-arm64-callops-kcfi-v2-3-587865b6d991@linux.dev> References: <20260924-b4-arm64-callops-kcfi-v2-0-587865b6d991@linux.dev> In-Reply-To: <20260924-b4-arm64-callops-kcfi-v2-0-587865b6d991@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 | 4 ++++ scripts/sorttable.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile b/scripts/Makefile index 3434a82a119f0..daad9b9540b8d 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -51,6 +51,10 @@ endif ifdef CONFIG_BUILDTIME_MCOUNT_SORT HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED +# 0 or unset (no prefix NOPs) leaves sorttable's built-in default in place. +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