From patchwork Thu Jun 8 14:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 10487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp304019vqr; Thu, 8 Jun 2023 07:10:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zCFpO36csbOmZE2RXb8mqrVw4p3cliWsrTntkyVIWgYOy5mzhKi5cDRdCuCh3unB4skO9 X-Received: by 2002:a05:6a00:1a05:b0:659:4b77:51e8 with SMTP id g5-20020a056a001a0500b006594b7751e8mr11411328pfv.15.1686233285779; Thu, 08 Jun 2023 07:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686233285; cv=none; d=google.com; s=arc-20160816; b=FTf9RHjDf5IC3GQh1w1QM/3bjWyVG04cfj3vc3BVgmnhrZ5vJUMA6GmILkgR+YJTph iImR7mTY6IZcFw4MgqIHjHRX24JTXpTfkTRmIopKhAT5FXqb7mKOaNhhtQt4dQCEXk4k 6N1Oky3TXQWpFcQAX7bs4UCG0U4sShL863R4HJEvJ8NK0hFMUgmxJ+eObOynZw2mS6u+ FCLWKkgK2SwG3nB4CrOeNAXnVgkI+29k+e3grgWUn9ya7r32P+d8dA58i64fIQJi0ZBk atJRRkeGOGbNDzW1/FqcAeXJwnH3GZPwPDLPi5idunu1U5yXfItFcCOU7fEaSVZkpYNE 3IDg== 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=xLZHfs84yXjkQpWBr2AnjtulNIQynm+15xDEC6bGzuQ=; b=HOc3d9c3e8yEH4cUtLKvyFe0hxbRsOVDTUsPa/xFf5GyQAdV9oZIdDJzkymQb7fNPw 11+GXP6P2vjE2eoQbyjKMY8kxOurU+nMvRI2dR7mgLZ5+QWOmZeMyAsl69Y4ZCJ1kYD5 yRrPzGi8YFQ7OWDpsfXfwa0+Uh0KppvVbZ2EdP1xQZrRlZzVGgQ4HzO79XS2BNal2p4X WLcpnj8VUxxIZ8ncelUweMenG56Zh/kgHBibZ5T8AOvI/xFYQhRCx9GaZM6pQb5Zy06S ih8aEqpUZeJG/RBQOYq6ctHR+iyM9JKHDqFltc7i9o5KL3hL4Kp5Z9KXXwQqszuJwTbX v4bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=B1BzVMJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a639312000000b0053ef31be221si973280pge.841.2023.06.08.07.07.46; Thu, 08 Jun 2023 07:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=B1BzVMJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236610AbjFHODk (ORCPT + 99 others); Thu, 8 Jun 2023 10:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236555AbjFHODj (ORCPT ); Thu, 8 Jun 2023 10:03:39 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E92F6198C; Thu, 8 Jun 2023 07:03:36 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 921EA21A14; Thu, 8 Jun 2023 14:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1686233015; 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=xLZHfs84yXjkQpWBr2AnjtulNIQynm+15xDEC6bGzuQ=; b=B1BzVMJKO7TeqDYmcc2zaHSMN6eIb/lygNZttFSrSJoMUQLDWuQmBUvxa3GM+u6Ar6tK8D fxHuEZv/8kO6nBmS7dq40Wp9OJc49L42sD6N3s2LIzcNQx7M1ECOJ0ObJASujCtaIrUlpM 8COeN5AFtNL1FH3j3PVvtFzlinSONV0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1B625138E6; Thu, 8 Jun 2023 14:03:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 21U+BbffgWRCbwAAMHmgww (envelope-from ); Thu, 08 Jun 2023 14:03:35 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Srivatsa S. Bhat (VMware)" , Alexey Makhalov , VMware PV-Drivers Reviewers , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Boris Ostrovsky , xen-devel@lists.xenproject.org Subject: [RFC PATCH 0/3] x86/paravirt: Get rid of paravirt patching Date: Thu, 8 Jun 2023 16:03:30 +0200 Message-Id: <20230608140333.4083-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768143754005161209?= X-GMAIL-MSGID: =?utf-8?q?1768143754005161209?= 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. RFC because I'm quite sure there will be some objtool work needed (at least removing the specific paravirt handling). Juergen Gross (3): 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 arch/x86/include/asm/alternative.h | 26 +++++- arch/x86/include/asm/paravirt.h | 39 ++------- arch/x86/include/asm/paravirt_types.h | 68 +++------------- arch/x86/include/asm/qspinlock_paravirt.h | 4 +- arch/x86/include/asm/text-patching.h | 12 --- arch/x86/kernel/alternative.c | 99 +++++++++++------------ 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, 111 insertions(+), 249 deletions(-)