Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4579280rdh; Wed, 29 Nov 2023 05:34:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiGjQtTV8aGjYydAGdg6r+AS7BsAl/enQRluoSOU9mEGNN8mAf6Qly4LnyuwelzrIxH9lw X-Received: by 2002:a17:902:ab84:b0:1cf:cac4:cd1e with SMTP id f4-20020a170902ab8400b001cfcac4cd1emr8630275plr.65.1701264873665; Wed, 29 Nov 2023 05:34:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701264873; cv=none; d=google.com; s=arc-20160816; b=OSC2vE1cxxIoQHrjwJdDK2To34jxRLLlV0NmRdjV59vPIx37y/rUxm9ypxzQs8+hw2 bKE4WUw7jQ6BBSd1YmAXFT5rHwQzUJmn6lUB8turoMtl5sIRJwYCIzG69ASJZEYkriG4 qnAqTmXcgDjMGEdY3NqP4yPFhUB70qE0SEOo0MiOJAvcfL+f6mr/L6/D2pJqpyVST8Xm b7CmUgtzYGWKlACGlMTyohSgcdcHtTM4c6vmLOQ+4772J6WziX3c2Rr211Xgk0pq4AmO bgUzMoO5L7TARoXOSv89XFFDNCJ5HJHI+AC7idu1iS4E2bnFdPOYAnkEaYsUkqgYgSt/ l3Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Qd/edhp+5962psCPMPy4XP3r2u443myO08oYjOHlTLA=; fh=JZ0mkxAY7JgHEGcDE+bHMXYcaAAH7riwUHOHQpZmmZA=; b=X8YCjJzD+OLmf8ARuADHAbAl7DEGVBlKPLr72AUEcXknjJY6ADvjs0J20MKDTcsLJW 3WPhnupNSexIUV3csPEn7+aui5fPH7yydMixnCvIqxzV7rVUg+v8gbKZlkSn0mo0b5Ck AxUgAawDiXIv8YBXQBfZ2uj1ukD79jhQOn0lrQGAjfYUTuPiqX7g1H4EfugwaQ/8Yd0E NXMLnme8vy/vq379fso1GdGnno761gOgejxmEdJzAuFO8L8gv59WObzpfW8sTCyJ4fmx P/ob6wZIONaJh5zZNw/p/HG/TbRn2zdb6BeJZFrCgwl7rSxRyDlKt+W+nAM7jB/YZYwc HpNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Pa0EKVY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x7-20020a170902ec8700b001c7345bc01csi9491202plg.450.2023.11.29.05.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:34:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Pa0EKVY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 32E7B822A4BD; Wed, 29 Nov 2023 05:34:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234255AbjK2Nds (ORCPT + 99 others); Wed, 29 Nov 2023 08:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233837AbjK2Ndq (ORCPT ); Wed, 29 Nov 2023 08:33:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2931DB0; Wed, 29 Nov 2023 05:33:52 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C08DD1FCF3; Wed, 29 Nov 2023 13:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701264830; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Qd/edhp+5962psCPMPy4XP3r2u443myO08oYjOHlTLA=; b=Pa0EKVY0qxxUd5ai3BkeXQ5O36LsXwze2YUAWSo+uhiqrqu+qQnOMc08tb752X/3bhkI4m zYIZAMIQnrocT+NXv0m6eFE9HhHgm/vc2JCCLVRkIuKeW6Gq8NZCOTCDWChK+a1azg+4be jXG4Qt7cAEBdPBvNbmAiVU1MYGGsVv0= Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 4D8461376F; Wed, 29 Nov 2023 13:33:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id tvlGEb49Z2V6HwAAn2gu4w (envelope-from ); Wed, 29 Nov 2023 13:33:50 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , VMware PV-Drivers Reviewers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Boris Ostrovsky , xen-devel@lists.xenproject.org Subject: [PATCH v5 0/5] 86/paravirt: Get rid of paravirt patching Date: Wed, 29 Nov 2023 14:33:27 +0100 Message-Id: <20231129133332.31043-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: 0.90 X-Spamd-Result: default: False [0.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_TWELVE(0.00)[18]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:34:31 -0800 (PST) This is a small series getting rid of paravirt patching by switching completely to alternative patching for the same functionality. The basic idea is to add the capability to switch from indirect to direct calls via a special alternative patching option. This removes _some_ of the paravirt macro maze, but most of it needs to stay due to the need of hiding the call instructions from the compiler in order to avoid needless register save/restore. What is going away is the nasty stacking of alternative and paravirt patching and (of course) the special .parainstructions linker section. I have tested the series on bare metal and as Xen PV domain to still work. Note that objtool might need some changes to cope with the new indirect call patching mechanism. Additionally some paravirt handling can probably be removed from it. Changes in V5: - addressed Boris' comments - rebased on top of the tip/master branch Changes in V4: - addressed Boris' comments in patch 1 - fixed bugs found by kernel test robot (patch 2) Changes in V3: - split v2 patch 3 into 2 patches as requested by Peter and Ingo Changes in V2: - split last patch into 2 - rebase of patch 2 as suggested by Peter - addressed Peter's comments for patch 3 Juergen Gross (5): x86/paravirt: introduce ALT_NOT_XEN x86/paravirt: move some functions and defines to alternative x86/alternative: add indirect call patching x86/paravirt: switch mixed paravirt/alternative calls to alternative_2 x86/paravirt: remove no longer needed paravirt patching code arch/x86/include/asm/alternative.h | 30 +++++- arch/x86/include/asm/paravirt.h | 77 ++++--------- arch/x86/include/asm/paravirt_types.h | 85 +++++---------- arch/x86/include/asm/qspinlock_paravirt.h | 4 +- arch/x86/include/asm/text-patching.h | 12 --- arch/x86/kernel/alternative.c | 125 ++++++++++------------ arch/x86/kernel/callthunks.c | 17 ++- arch/x86/kernel/kvm.c | 4 +- arch/x86/kernel/module.c | 20 +--- arch/x86/kernel/paravirt.c | 54 ++-------- arch/x86/kernel/vmlinux.lds.S | 13 --- arch/x86/tools/relocs.c | 2 +- arch/x86/xen/irq.c | 2 +- 13 files changed, 161 insertions(+), 284 deletions(-) -- 2.35.3