From patchwork Mon Oct 16 12:39:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 15422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3429235vqb; Mon, 16 Oct 2023 05:39:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFizzEY+5KLQ+uxLf3zPkKqwvyro7gnTmzCv7vTMGmZ7vtY7Rp/f+PppM0KL3lmLvJCFFln X-Received: by 2002:a05:6a20:a123:b0:13f:65ca:52a2 with SMTP id q35-20020a056a20a12300b0013f65ca52a2mr37871004pzk.5.1697459985668; Mon, 16 Oct 2023 05:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697459985; cv=none; d=google.com; s=arc-20160816; b=lff3fOIrcRU8wZBOS+uvMxjDxkU5L8LwfTo7z1DTQEOO+ilDniJ6fH/CzyqLshNmCZ JfYnl+yHsdmoUa4CrZNlOh1v3rSb5jBDNYG8tDT8/FVcyyD7eigPBgBxo5VyBMJJWVnp 8/kK+S9PP3Fu4WDg1qAtHOPivIRNNl5fOyKFhPkhOQFVx4bJ+xgzDRxIL5GDYOsovHKY pIbFGhLBbW2HjGtb2qNFiMOGLP1I/g7f4Be4xSXAR8Kd9mMxGAn/fe8uwDyKZIwPoV7U GQXirIkS7a1HKxtVH6fdV88K1o862IokSJzbOipzb3VrZsBmRKRfUR0ROo7AfWNPJKCR bPkA== 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=TrHQ0ELhL7iWzaPXNchammsXfJ1VpjNzr9oy6lA6Krc=; fh=69ERR2JGu6HwpvDweAGhMBWKjW9vTZ/OQbycZiYqWpk=; b=j4q5X1eOXiaaa9e43hLAJlqfqOuO5ZBFB0/f55ilVAQYebgjZSVmbHxUTZMk7bZ9hn CsMG9+t3ItX14XL9RtNaA11+DHKIQwiVQN7WAM7N6TsgjkOKjs3caIqi0vJ1jACh6/JB OCw3Di1Aj3ZPurB/Y5fHRtsa3APHzo6+zakBITX0BZ+wuIM8rlaeiecP4DGNEM3LGkOi DnB+ouuak4qYIfAgscTXId0zuarIhmZxZY79SHmuQBstXD61jwOLrB1In7WQKnvuMjEV UQSOpgO5xpPyrD7+vPsIXbfAKpSeM+Fp81dMgKrl1LdKOAmgSgty3//bbJYbdB8yevbY 3p/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YzXXQasX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 36-20020a630a24000000b00578a28df3e2si9861710pgk.816.2023.10.16.05.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 05:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YzXXQasX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 1014480BBC6B; Mon, 16 Oct 2023 05:39:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233095AbjJPMjm (ORCPT + 18 others); Mon, 16 Oct 2023 08:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232929AbjJPMji (ORCPT ); Mon, 16 Oct 2023 08:39:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DA13AB; Mon, 16 Oct 2023 05:39:37 -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-out2.suse.de (Postfix) with ESMTPS id 9FCDA1F37F; Mon, 16 Oct 2023 12:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1697459975; 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=TrHQ0ELhL7iWzaPXNchammsXfJ1VpjNzr9oy6lA6Krc=; b=YzXXQasXeVaCM4rll76gJ/cRr0gpD70UiJXXyCcxaVKzwc9L4AXNbvBrVwebwOapoEgD/V kOvKYPLYE1drK+oaVua+5/yuA0E3o3tYXm/4BGroCwxVwrDXMIXbHrdl6BnhOJf4Kxonoe BdcUCorSEAPEtsoXqKVKuI5f9GWDvX4= 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 27145133B7; Mon, 16 Oct 2023 12:39:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8jQZCAcvLWX4IgAAMHmgww (envelope-from ); Mon, 16 Oct 2023 12:39: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" , Ajay Kaher , Alexey Makhalov , VMware PV-Drivers Reviewers , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Boris Ostrovsky , xen-devel@lists.xenproject.org Subject: [PATCH v2 0/4] x86/paravirt: Get rid of paravirt patching Date: Mon, 16 Oct 2023 14:39:29 +0200 Message-Id: <20231016123933.17284-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-Score: 4.05 X-Spamd-Result: default: False [4.05 / 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)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.85)[-0.851]; NEURAL_SPAM_LONG(3.00)[1.000]; RCPT_COUNT_TWELVE(0.00)[18]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 05:39:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779915801716270326 X-GMAIL-MSGID: 1779915801716270326 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 V2: - split last patch into 2 - rebase of patch 2 as suggested by Peter - addressed Peter's comments for patch 3 Juergen Gross (4): 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 | 26 ++++- arch/x86/include/asm/paravirt.h | 79 +++++---------- arch/x86/include/asm/paravirt_types.h | 73 +++----------- arch/x86/include/asm/qspinlock_paravirt.h | 4 +- arch/x86/include/asm/text-patching.h | 12 --- arch/x86/kernel/alternative.c | 116 ++++++++++------------ 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, 137 insertions(+), 285 deletions(-)