From patchwork Wed Nov 29 13:33:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 17270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp339855vqn; Wed, 29 Nov 2023 05:34:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHB3i3ZFD7Tn1qjr0s+p7Xf6X27H/U54xPoIz+jnKHLLx99UotQ5XDb3gfREq3QXEWeVpfL X-Received: by 2002:a05:6a20:438a:b0:18a:e176:5283 with SMTP id i10-20020a056a20438a00b0018ae1765283mr18470041pzl.39.1701264870060; Wed, 29 Nov 2023 05:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701264870; cv=none; d=google.com; s=arc-20160816; b=gqgR9Du2Qf9wlrMmP6hwlauv5M5T8lWKM55a36RJIq2YJQnS+TJSXLJtDSfHin88X6 ovVlQvLi8dBcr2v69RIDECD/cuYO3z/tTeQV7ObKTBYeFbh21bs0I/8/vyJg4FRr8uEE k8C6Hu/PLFD+ydM0RaIFUtm/bvoRmZplh62h2GPj575//CZ+8UvkExNxrbVpEnVYstev fL1j332Zai8GT5x0uMnh1X/LAX+sWLitS6X6cF1Ney+sccqLJnQ+d/ij5xWyk41Z4RPT fLUkkZLBEi4vPbr7QKT51TCFoJkfrxgut3/pzUCy+OrR0tSi/TfG6NQqOiIOBWlaP8FZ zOuA== 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 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t22-20020a056a0021d600b006b69f056508si14773349pfj.149.2023.11.29.05.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:34:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; 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 2620:137:e000::3:1 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 750B2822B70B; Wed, 29 Nov 2023 05:34:25 -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 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:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783905512208064336 X-GMAIL-MSGID: 1783905512208064336 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(-)