From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF7ACC4332F for ; Tue, 14 Nov 2023 12:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231826AbjKNMu7 (ORCPT ); Tue, 14 Nov 2023 07:50:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232889AbjKNMuy (ORCPT ); Tue, 14 Nov 2023 07:50:54 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFF65192 for ; Tue, 14 Nov 2023 04:50:48 -0800 (PST) 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=EtM4Wf6wmF/h9qD3ggeAeZqT/sbRValNFVYjSFWKqBY=; b=YRUoUeUbC0Q4bOQj2gm+5tuAvx TF2j+tqdYaCmxYB5MLYi0g+IGLVa1mTrAjNMEF5dyNX7ub64XTraRpz3aluajjyKRRmely0zA09qj IBCVfUVgBMNH4uRuAzZvSNYOSwFFJZfeFHCI2iqmO5GhGgOxQ+0lc3e7XdLXpxaSo8FjQCRLr70z8 rapNv+8OQFeARrFrIG9RRHOGUm9HM8tmR2bD8wQa09YutKp9Zm7aYEnViYsZBkBlhDdrg64w9sDqT 85OccAcZzN5h8azGeKx8fqugyVqK8sCcZfIjt2g40Z5XoEsKpUiWb3vauiMwSKqJxb3jGnjJTH2P3 W13c63Kg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1r2ss9-00816d-GK; Tue, 14 Nov 2023 12:50:31 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2CB963007C8; Tue, 14 Nov 2023 13:50:29 +0100 (CET) Date: Tue, 14 Nov 2023 13:50:28 +0100 From: Peter Zijlstra To: Borislav Petkov Cc: Juergen Gross , linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH v4 2/5] x86/alternative: add indirect call patching Message-ID: <20231114125028.GX3818@noisy.programming.kicks-ass.net> References: <20231030142508.1407-1-jgross@suse.com> <20231030142508.1407-3-jgross@suse.com> <20231114123737.GBZVNqEXKgt+6P1Wiv@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231114123737.GBZVNqEXKgt+6P1Wiv@fat_crate.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 14, 2023 at 01:37:37PM +0100, Borislav Petkov wrote: > > +#ifdef CONFIG_X86_64 > > + /* ff 15 00 00 00 00 call *0x0(%rip) */ > > + target = *(void **)(instr + a->instrlen + *(s32 *)(instr + 2)); > > +#else > > + /* ff 15 00 00 00 00 call *0x0 */ > > + target = *(void **)(*(s32 *)(instr + 2)); > > +#endif > > + if (!target) > > + target = bug; > > + > > + /* (BUG_func - .) + (target - BUG_func) := target - . */ > > + *(s32 *)(insn_buff + 1) += target - bug; > > If I squint hard enough, this looks like it is replacing one call with > another. We have a C macro alternative_call() which does exactly that. > Why can't you define an asm version ALTERNATIVE_CALL and use it > instead of using adding a new flag? We have 16 possible ones in total. This loads the function target from the pv_ops table. We can't otherwise do this.