From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D39B86331 for ; Mon, 8 Dec 2025 09:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186639; cv=none; b=Zd2wDRsl4Nf8UalyyaHdbnxlgqq3n7iDlibOGeZmfAmovSlobtfxRc3E+6ZQMCKuqMjgywKhPr64sLxeYzxZEVQYAYVQNXmrsialNPq5rvxmXEFc/G/NQQJtLwKsrF+52gsNjDs4CBJMrZFvzLwPt+DhH/dtm6XRkzsFicpje94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186639; c=relaxed/simple; bh=F6EWPqLyve5SGYIyRzOXsmTyu/vrvOX6Cj6TLDF9aS8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=npkzt3mQ2tl8whe7m8iEEHyjkQ3aJZJHdIkf5ecY5cnmZNGjmPbqap9LgqF3WcXDPoRiJgwCM3O8K3Fkx7zUzdmNSLgZaJbhiT99QfPC7N54uOnOnDU5WX6z5dV1vLHYvV3sGM9dz2rP5MKgxXLTxq4IgbkO+hosL0LkMsXYGHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=duhgefgP; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="duhgefgP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=D9P6f5QGGNoKv+iUSXzs2JsKe4qGrWgRyNPe3DEP1Fo=; b=duhgefgPzZ/jMH0PuQQtT1IVEK uULOdLWJPGVuGOoaQY0BcPZHKIQ6SOyGNaIb3oeIPZNs5McFFMzW8f1nUB64Bh1qoUoh4zATv/EHm NTMpEyaSkG7Uqft8Cer4oX0/nzrrkdtm37hoV894r1KiDtxafDKj4OwLjPXfXXx9jPEqxH0onhAL3 gROsWrCHyRsOw/uqQ24E6N1q+ovYLbrzt76RZ8+By+5MEBfuUlPyo462a/2cfSl3P1qF3DcdftrO5 vpUeq7b5Bj0BAjtQkfQojHpGG5IddEXVDyWHKyPuKe6lCnd7L8eBCz2NdvGwx9hRSt95j3B4ubDsu jGck6cSQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vSXgA-00000009bC8-01rf; Mon, 08 Dec 2025 09:37:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0A6E430301A; Mon, 08 Dec 2025 10:37:13 +0100 (CET) Date: Mon, 8 Dec 2025 10:37:12 +0100 From: Peter Zijlstra To: Josh Poimboeuf Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Ingo Molnar , Borislav Petkov , Thomas Gleixner Subject: Re: [PATCH 5/8] objtool: Convert annotations to assembler macros Message-ID: <20251208093712.GC3707891@noisy.programming.kicks-ass.net> References: <28e63e2c890661dc9bcdbe172eba06b26220d455.1765044697.git.jpoimboe@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <28e63e2c890661dc9bcdbe172eba06b26220d455.1765044697.git.jpoimboe@kernel.org> On Sat, Dec 06, 2025 at 01:41:12PM -0800, Josh Poimboeuf wrote: > Improve code generation readability by converting the objtool > annotations into assembler macros which are created when annotate.h is > included. > > Before: > > .pushsection .discard.annotate_insn, "M", @progbits, 8; .long 1b - ., 8; .popsection > > After: > > ANNOTATE_REACHABLE loc=1b > > Signed-off-by: Josh Poimboeuf > diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h > index 0e8c611bc9e2..770321c908e5 100644 > --- a/arch/x86/include/asm/asm.h > +++ b/arch/x86/include/asm/asm.h > @@ -2,15 +2,15 @@ > #ifndef _ASM_X86_ASM_H > #define _ASM_X86_ASM_H > > -#include > - > #ifdef __ASSEMBLER__ > +# define __ASM_C(a,b) a > # define __ASM_FORM(x, ...) x,## __VA_ARGS__ > # define __ASM_FORM_RAW(x, ...) x,## __VA_ARGS__ > # define __ASM_FORM_COMMA(x, ...) x,## __VA_ARGS__, > # define __ASM_REGPFX % > #else > #include > +# define __ASM_C(a,b) b > # define __ASM_FORM(x, ...) " " __stringify(x,##__VA_ARGS__) " " > # define __ASM_FORM_RAW(x, ...) __stringify(x,##__VA_ARGS__) > # define __ASM_FORM_COMMA(x, ...) " " __stringify(x,##__VA_ARGS__) "," > @@ -115,6 +115,10 @@ > > #endif > > +#define DEFINE_MACRO(name) \ > + __ASM_C(DEFINE_ ## name, \ > + asm(__stringify(DEFINE_ ## name))) > + > #ifndef __ASSEMBLER__ > static __always_inline __pure void *rip_rel_ptr(void *p) > { > diff --git a/include/linux/annotate.h b/include/linux/annotate.h > index 1678410efa1b..8b28f1a81ec4 100644 > --- a/include/linux/annotate.h > +++ b/include/linux/annotate.h > @@ -3,53 +3,43 @@ > #define _LINUX_ANNOTATE_H > > #include > +#include > +#include > + > +#define DEFINE___ANNOTATE \ > + .macro __ANNOTATE sec, type, loc; \ > + .pushsection __ASM_C(\sec, \\sec), "M", @progbits, 8; \ > + .long __ASM_C(\loc, \\loc) - .; \ > + .long __ASM_C(\type, \\type); \ > + .popsection; \ > + .endm > + > +#define __DEFINE_ANNOTATE(sec, name, type) \ > + .macro name loc=910b; \ > + 910: __ANNOTATE sec, type, __ASM_C(\loc, \\loc); \ > + .endm > + > +#define DEFINE_ANNOTATE(type) \ > + __DEFINE_ANNOTATE(.discard.annotate_insn, \ > + ANNOTATE_ ## type, ANNOTYPE_ ## type) > + > +#define DEFINE_ANNOTATE_DATA(type) \ > + __DEFINE_ANNOTATE(.discard.annotate_data, \ > + ANNOTATE_ ## type, ANNOTYPE_ ## type) > > #ifdef CONFIG_OBJTOOL > > +DEFINE_MACRO(__ANNOTATE); > +DEFINE_MACRO(ANNOTATE(NOENDBR)); > +DEFINE_MACRO(ANNOTATE(RETPOLINE_SAFE)); > +DEFINE_MACRO(ANNOTATE(INSTR_BEGIN)); > +DEFINE_MACRO(ANNOTATE(INSTR_END)); > +DEFINE_MACRO(ANNOTATE(IGNORE_ALTERNATIVE)); > +DEFINE_MACRO(ANNOTATE(INTRA_FUNCTION_CALL)); > +DEFINE_MACRO(ANNOTATE(UNRET_BEGIN)); > +DEFINE_MACRO(ANNOTATE(REACHABLE)); > +DEFINE_MACRO(ANNOTATE(NOCFI)); > +DEFINE_MACRO(ANNOTATE_DATA(DATA_SPECIAL)); Well, that took a bit this Monday morning... :-) Clever.