Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1562611rdb; Wed, 20 Sep 2023 12:40:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESOOit4sjWojyC1RE//o7OwzU3G2ZIHQeX8i7PIfO3ePNLBaBSXCYGLiRqMi0iuV2CbBpR X-Received: by 2002:a05:6358:52cb:b0:133:a8e:6feb with SMTP id z11-20020a05635852cb00b001330a8e6febmr5107017rwz.12.1695238851774; Wed, 20 Sep 2023 12:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695238851; cv=none; d=google.com; s=arc-20160816; b=mf9quGAneatQzjgs7LRWkqcoatUZ+dhtareEqTXdGdsokFuT0z/8Y+RFdqso5salqx dhd2ow8wZ6pxbeIgLbkWPIuxvq7ckUEniH0oSGoglW8f9+ZwtbvkHRYoWMOE13eFTS2s V/hj096J79oWi0uj5Hl2iToQyYp+P2wcW8/+Xq2eIjCcClkGtbtDv8ph5DJVEu+MJlRB KEk75sEogZXiy7WlFj2H6F+zMAD03ikcNi5+1QOkCSsxqXrIc86qnlXn/jMb2yfKIrHl GgDxbKttgmmxixiZXNG9GC9crO8SfbPhRFUYIAuQy0bv02QrHt2bOLT0ydW3Tk/0rAdv 1eww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZerJcnOhEvUGAjVvFDnt+ED8Lu+58HuQE4rkQfwGHOA=; fh=wvyVrLHluqPZl1Q5U7hoLRJJ9aj+OqoPoK/FCmnnC2g=; b=qQBREs1HIlXTw9wp8f9pSSkaZBXUzOQ1SfV6DbXf5AYC1w8Tk1a8e2K0YpQ067GLad 2pFUEAIiEkzw4x3SnFYmpoxydvw2AEnru7mGEG5MWh80CJ/NAXurLiLE7fIJwojXoVsM hCbKb5qQeDZGtoOC46WXNHeoq9ftIL404dlkhRNeLxYnmehTaNirUK64Q4Gtk9e7QREL nre5uXpOuWfsDKg/xIf+dxw2Q/+rWunbZtW2ygM/2HSuz1a8drsVKYOPUhHK/55kx1JZ Z08yyS7WObkczLBQfI1xDxKStGIfknkBgQLQUXodrMNdrhTg8XZ7uvbEgG7QS0O+0yOq uNbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=oK8vRjz6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o23-20020a63fb17000000b0056fed6fa634si3562469pgh.433.2023.09.20.12.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=oK8vRjz6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C2666829EA20; Wed, 20 Sep 2023 07:53:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjITOxO (ORCPT + 99 others); Wed, 20 Sep 2023 10:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234330AbjITOxM (ORCPT ); Wed, 20 Sep 2023 10:53:12 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888D791 for ; Wed, 20 Sep 2023 07:53:06 -0700 (PDT) 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=ZerJcnOhEvUGAjVvFDnt+ED8Lu+58HuQE4rkQfwGHOA=; b=oK8vRjz6Cd8f7av9WAZ5MrtvDW ibgh94KLBV8bt3XT/9afi1rlEMXon7JYGg022FAXhUQZjpxFY0xwx6vKCjVnzWjaj1Wf05zIekyP+ 7Tdo8to/IC62m6luX7US+MvBnpB5L+C5sRZGxmzkbD1eLLHMxatdmUuwEwjYb1jgWR+CK6y35zJk/ Jqpg71tlE334dkhfQmcvC+yZTUBqEThAiih5oPlNhMoCKZFNJgWxLQFXYYZItL9o229FD8LorfdgL PQsAN960x2p15PJgxMjFr6zjsjVxfLazY91uScz7lkmL9lJrXIg3ghzbHk6i7YEspFdVx8Fq2lCyU ooWAy3kA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qiyYv-00EfZI-0q; Wed, 20 Sep 2023 14:52:23 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 5EBD4300348; Wed, 20 Sep 2023 16:52:22 +0200 (CEST) Date: Wed, 20 Sep 2023 16:52:22 +0200 From: Peter Zijlstra To: Juergen Gross Cc: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux-foundation.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Srivatsa S. Bhat (VMware)" , Alexey Makhalov , VMware PV-Drivers Reviewers Subject: Re: [RFC PATCH 3/3] x86/paravirt: switch mixed paravirt/alternative calls to alternative_2 Message-ID: <20230920145222.GB6687@noisy.programming.kicks-ass.net> References: <20230608140333.4083-1-jgross@suse.com> <20230608140333.4083-4-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230608140333.4083-4-jgross@suse.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 07:53:16 -0700 (PDT) On Thu, Jun 08, 2023 at 04:03:33PM +0200, Juergen Gross wrote: > Instead of stacking alternative and paravirt patching, use the new > ALT_FLAG_CALL flag to switch those mixed calls to pure alternative > handling. > > This eliminates the need to be careful regarding the sequence of > alternative and paravirt patching. > > For call depth tracking callthunks_setup() needs to be adapted to patch > calls at alternative patching sites instead of paravirt calls. > > Remove the no longer needed paravirt patching and related code. I think this becomes easier if you first convert the paravirt sites to alternatives, such that .parainstructions is empty, and then in a subsequent patch remove all the paravirt infrastructure that is unused. > +#define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl;", ALT_CALL_INSTR, \ > + ALT_CALL_ALWAYS, "pushf; pop %rax;", \ > + ALT_NOT(X86_FEATURE_XENPV) I find this more readable when written as: #define SAVE_FLAGS ALTERNATIVE_2 "PARA_IRQ_save_fl;", \ ALT_CALL_INSTR, ALT_CALL_ALWAYS, \ "pushf; pop %rax;", ALT_NOT(X86_FEATURE_XENPV) (and perhaps ALT_NOT_XEN is in order, there's a ton of those) If you base this on top of the nested alternative patches, another helper might be: #define __PV_ALTERNATIVE(old) __ALTERNATIVE(old, ALT_CALL_INSTR, ALT_CALL_ALWAYS) So that you can then write: #define SAVE_FLAGS __ALTERNATIVE(__PV_ALTERNATIVE("PARA_IRQ_save_fl;"), "pushf; pop %rax;", ALT_NOT_XEN) But perhaps I'm over-cooking things now..