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 5EDE729A33E for ; Mon, 8 Dec 2025 09:51:13 +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=1765187476; cv=none; b=BG6rVTzdTpvV6y02yjaRJNqF/biFoG6vCqKROr0ybdnckpiWvIJmQ9rSbonqaUECyvNAxcCZ70S1ym4F3+F3u43EddFB6Z2tpPK4whMrRCR4SCgP+8U7PtlVt12r78jeTY2dYrJS1O5bCGbz0hYIpZgYz6IOghoyyNWYS87BRtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765187476; c=relaxed/simple; bh=kMWHE8rThydmL01zYDHJltJlu4WPwk1CiM6SmPytkuE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CrMRZWzOBjWkqwfSQ+hi7EMRAr7t7A1qKj3r+jb5FjjtxiQv2pb0Vr3OSVzAA8/kLeIGJm2VhAciwDgoR+mffEPbU2gjZT7lHTEXDRq70lPfMaP9HKToXjyVQ7DYLtMcYa3RBDm6s3b4G6o5ZK/NWkJ3QSqdW6+2hSmkyt/AT68= 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=Bv38eyPJ; 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="Bv38eyPJ" 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=GrQCu3iuL3Fuu5MgMGNgUOq1XKLRXvMcXlaywcpTdRo=; b=Bv38eyPJGzBUudMUWBBPwjPbSu SUx+ZNvC4pC7vBjM0l/JwpIpQcZmywoI5/nNZIW/JDP4G9x30BvaD7ghjzyhUO7x3CENUoDTa+bZM sd8yxZ1IsiKcn/N6hBGNQjmiA8ACDmC2UMXvxNIjzw6gz9Bfbt5VfnDM18MV1qsxS2X/ns2z47UP5 UbPO6qCLVwMxh+rzxUTY41QSYxC6nkf/dSDfdPMawtRatixltLsqrr3XooGv52Vg97OEjrHRnVxCw E2G6TXsev3zfpuTDppbqKRCjjjLl/u6crToV5W08DHV/nB3HvYCrzsXG7PBvxsY0EuTzUZHh2z2uP i0/nclFg==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vSXte-00000009c8i-28UJ; Mon, 08 Dec 2025 09:51:10 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4E02E30301A; Mon, 08 Dec 2025 10:51:09 +0100 (CET) Date: Mon, 8 Dec 2025 10:51:09 +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 8/8] x86/alternative: Convert alternatives to assembler macros Message-ID: <20251208095109.GD3707891@noisy.programming.kicks-ass.net> References: <051df5c21cbf6d9ac396c22b3ab3c51d73c0def7.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: <051df5c21cbf6d9ac396c22b3ab3c51d73c0def7.1765044697.git.jpoimboe@kernel.org> On Sat, Dec 06, 2025 at 01:41:15PM -0800, Josh Poimboeuf wrote: > Improve code generation readability by converting the alternatives into > assembler macros which are created when alternative.h is included. > > Before: > > # ./arch/x86/include/asm/smap.h:47: alternative("", "stac", X86_FEATURE_SMAP); > # 47 "./arch/x86/include/asm/smap.h" 1 > # ALT: oldinstr > 771: > > 772: > # ALT: padding > .skip -(((775f-774f)-(772b-771b)) > 0) * ((775f-774f)-(772b-771b)),0x90 > 773: > .pushsection .altinstructions, "aM", @progbits, 14 > .long 771b - . > .long 774f - . > .4byte ( 9*32+20) > .byte 773b-771b > .byte 775f-774f > .popsection > .pushsection .altinstr_replacement, "ax" > ANNOTATE_DATA_SPECIAL > # ALT: replacement > 774: > stac > 775: > .popsection > > After: > > # ./arch/x86/include/asm/smap.h:47: alternative("", "stac", X86_FEATURE_SMAP); > # 47 "./arch/x86/include/asm/smap.h" 1 > ALTERNATIVE "", "stac", "( 9*32+20)" > So the problem with the gas macro thing is that it doesn't allow for that nesting. I don't think we currently use it other than to define the ALTERNATIVE_2 and ALTERNATIVE_3 macros, but IIRC the reason I started all that was because it was fairly trivial to use things like CALL_NOSPEC in an alternative (where CALL_NOSPEC is already an alternative). Anyway, yes, the macro variant is easier to read in the .s output.