From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-52.mta0.migadu.com [91.218.175.52]) (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 A6F714457B7 for ; Thu, 24 Sep 2026 22:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289422; cv=none; b=Uxls591zsQZ0XTEszklSj4ugOW74CXJYSfs7/oIYfOHRP7sk5auxWTlTG5uiIoDZJV/mHdsc5flQyvkOBgPPR0ilgQJkhf8lsGYiJVrqGxHrzjCsqBxZK1XwPXWJpYbOZXDfrK+w/4SXqdN9Jsw/vFLpufB1/tfkKRGsk37SJWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289422; c=relaxed/simple; bh=FS6X8NELcqU5nbWh3I09msuFV9zg7bXT/RgrskATLK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XUsT4h/5gX3VrMbGaA+MI1YrqSSSkXy5PVKsHoPo9oErtbhUHNqAcivttMoamr3Yroi1J/fbvwURlMI3WQgyFifZzzqzBLlPsH7ka8AGBkkY33SfXrnrJ7aeJ39VvCbI2WAbCN0fq7wCrgWfeUPOgdqlnefcfS0hfH2vX30y3oM= 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=h2vbVBmr; arc=none smtp.client-ip=91.218.175.52 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="h2vbVBmr" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=FS6X8NELcqU5nbWh3I09msuFV9zg7bXT/RgrskATLK0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790289417; v=1; x=1790894217; b=h2vbVBmrUf6CKo9+hwvLD/wWovRqY0MHNpVqWgoQNLKygQ5UcSuux6EX/2nAArXo3KC1l1E+ /16r/QUcOIQiWZFEtS/vYkflWwLGu+vy9AvVCmrNdB4/zUGT5rGcnJy5ErrUedWC2f2RFpobkz/ btvYEhubQc9RHLrFUFFpoASw= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 8b68d55e8478d9d6; Thu, 24 Sep 2026 22:36:56 +0000 X-Mizu-Trace-ID: 8b68d55e8478d9d6 X-Migadu-Flow: FLOW_OUT From: "Jose Fernandez (Anthropic)" Date: Thu, 24 Sep 2026 22:35:48 +0000 Subject: [PATCH v2 4/9] compiler_types: Let notrace keep the function prefix NOPs 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-4-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 Let notrace keep the prefix NOPs when the architecture defines CC_USING_PATCHABLE_FUNCTION_PREFIX. kCFI callers check the type hash at a fixed offset before the entry point, so a notrace function needs the same prefix NOPs as any other. Record the entry in a section the linker drops, so ftrace never sees it. Clang 21 takes a section name as a third argument of the attribute. Nothing defines the macro yet, so no functional change. Reviewed-by: Ben Cressey Reviewed-by: Florent Revest (Anthropic) Assisted-by: LLM Signed-off-by: Jose Fernandez (Anthropic) --- include/linux/compiler_types.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index c5921f1390079..43dafaa061942 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -211,6 +211,15 @@ struct ftrace_likely_data { #if defined(CC_USING_HOTPATCH) #define notrace __attribute__((hotpatch(0, 0))) +#elif defined(CC_USING_PATCHABLE_FUNCTION_PREFIX) && !defined(__BINDGEN__) +/* + * Not for bindgen: its libclang may not support the section argument + * (Clang >= 21), and leaving the attribute out does not change the ABI. + */ +#define notrace \ + __attribute__((patchable_function_entry(CC_USING_PATCHABLE_FUNCTION_PREFIX, \ + CC_USING_PATCHABLE_FUNCTION_PREFIX, \ + ".discard.patchable_function_entries"))) #elif defined(CC_USING_PATCHABLE_FUNCTION_ENTRY) #define notrace __attribute__((patchable_function_entry(0, 0))) #else -- 2.52.0