From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 089DA267729 for ; Wed, 10 Dec 2025 09:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765358212; cv=none; b=YLGWLFjnVXgW4KQLE9bLvgRgqwW0d9Jth1li1r/gFW7J4fzWnJCDplg/g1j95SXT3qOdAyI7/H0MAGfMPiOfKix4VMQsyTFCGdLG2v+snFvuGCGcCUUoxgzj4ivcZcIJVJ1KHiUV4VfA0AG9sq0UNhC30zVMRscI210RweOAnzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765358212; c=relaxed/simple; bh=yO2li+6reCLJUgbIkLQFxsfFqLumHJ6fYkadlo+05Bw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IPM3PSN9HFE3VpwK+kSRj1JpNSUHLh8RYzCGDIFNDmT9x+U7EaUT9JMZ7ZLZ98MCVJSuX0dPfYFKn9lHJ9VR1h0RKOOsgSN4YQ25vj5I6YdN6PlB9BuoWIUHhSrEjvbLt2FV8I4rXn+915rD1KruV1L0ICXqY6Dpyph2V0vZwAU= 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=NzYotAOz; arc=none smtp.client-ip=90.155.92.199 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="NzYotAOz" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=2Mh3zjV4Vwm+0x35++R/S/KNiiN9R8mT1eMcTF1RaVc=; b=NzYotAOzwvmWiI6nSPLUvFKZ8m uHl7KMWXk6N//1T5LfZJCmFVz0ZRS4sNw1FCCGk454UX+gfv+Wct+6rX3OnwjYJiQVVoXxJR7T766 HFcvuEYe7QuuauWO4FpDVMji+PFRIzXJbZlAK2rWkYSlGBC8WES+3+q4/MwZD+Jce5/UDJza1XK/l i/GLUNyiOq8e+MEtUz469hd47phLf4p+8Q+586nEceRi7yxLr81QsMMEnRco7GiY06ong1WPdJuaN aJKToRIDoePhs/uH/nRwtWXMdjFWxAnT/qrNwdXGnyIbNXon6x5/yvaMZBcPlZdeoHzsYtL3EMbor QLCFJKtA==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTFRx-0000000D5b3-063i; Wed, 10 Dec 2025 08:21:29 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 9D3D0303045; Wed, 10 Dec 2025 10:16:45 +0100 (CET) Date: Wed, 10 Dec 2025 10:16:45 +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: <20251210091645.GJ3707837@noisy.programming.kicks-ass.net> References: <051df5c21cbf6d9ac396c22b3ab3c51d73c0def7.1765044697.git.jpoimboe@kernel.org> <20251208095109.GD3707891@noisy.programming.kicks-ass.net> <20251209092419.GD3707837@noisy.programming.kicks-ass.net> 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: On Tue, Dec 09, 2025 at 05:15:06PM -0800, Josh Poimboeuf wrote: > Ok, so while the syntax itself is nested, the underlying behavior is > just stacking alternatives together, like ALTERNATIVE_2 and _3 already > do, correct? Yup. > While it's clever that the current implementation allows that kind of > nested syntax, it seems dangerous. I don't see anything preventing the > inner ALTERNATIVE from being placed in the middle of the outer > ALTERNATIVE's original instructions, or anywhere in the outer's > replacement code. > > It would be really easy to introduce CALL_NOSPEC in the middle of a > group of instructions in an ALTERNATIVE without realizing that you're > likely introducing some subtle or not-so-subtle bug on x86-32, which > just happens to hide an ALTERNATIVE_2 inside the CALL_NOSPEC... I think I made objtool complain in that case, but I'm not sure. > The gas macro doesn't give you the leeway to make that mistake, so you'd > have to restructure the code slightly to make it fit into a proper > ALTERNATIVE_3. Which is less magical and more clear, so that seems like > a good thing. Perhaps, I'm not really a fan of the ALTERNATIVE_n() macros much. I think writing the nested ALTERNATIVE() form is actually more readable. But perhaps I'm the crazy one -- wouldn't be the first time :-) Anyway, seeing how its not actually used, and I've since solved the case that gave rise to all this completely differently, perhaps I should just shut up and let you do the conversion. I mean, we will have to do ALTERNATIVE_4() at some point, and it will be glorious... *sigh*