From patchwork Mon Oct 30 14:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 16055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2255553vqb; Mon, 30 Oct 2023 07:25:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoKEaOR6jNBEpcyAqKC2b3bsffTS4fLHI+cyPrel4BKFbb6kjQn2IF6mfjNr2rmAFrVZRm X-Received: by 2002:a17:902:c402:b0:1c3:e2eb:f79d with SMTP id k2-20020a170902c40200b001c3e2ebf79dmr16511479plk.8.1698675929835; Mon, 30 Oct 2023 07:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698675929; cv=none; d=google.com; s=arc-20160816; b=MZo722PAZY7t7RyIGpiOPgTiiGt+IuN60ZVd6Ur19fxNZpX4FHe507/6WrIG5St2Qu 8aNTwEoHy1xMdMbVVLaRKKQtZte2ANJGD18Sb5mnbnBX2aXufTPPFV81YnbIHLfR5nWl 9jLHSXp++xbwTnNDBXBPVIRYb0g5GLFmYR2pf3RqN8WPvmgsNNHNBUKdLWyALOCEuoIB 11NthUlZK0q+UZjTWJXCOMjvEHbmDLFLkmhe+HKdb961fbYsgb6yzA/RSVxQapA/5U3E imkZBbmnp9kpwfyPWq9BTEvo9lnrD3jgpccI4NCyF9WCJdOL1WojRsmjMhGLtvhbwByi g/fQ== 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=y2ADXZuRUSMr2od9G+oNY1AaP5CziwipA6lK0SssnIw=; fh=69ERR2JGu6HwpvDweAGhMBWKjW9vTZ/OQbycZiYqWpk=; b=hcfzhw3m6PNS/QnhKMCPzipud0/hA18R2iuEmTPnJdaPvud8cQr7JKU97kw88U6mv/ zp+ljub7+zUazC+0jdv7qFgA3Uz5GRvWveEfsnrZun40CjakbMm6mVWabiNLJmI00ez0 uchyyZKfy5A56Itu5l7rOGLAMuqPTlR/Z1R553ymNgogEJw3x8+0MPPukL+1M/0uianx gRDXPu2Taun0ZybFb3VqP+tOeDQKp1YE7GnyGAeSZ59Nhg1nIDmbGG8MejioAKpYAASr Szd6PaU3CiQztEVstyoArEt/7afYFL450ohpyMMoT2fbyrEOJttNY0MdoQRi2c8TbXf8 KS9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=h4OOWOe0; 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 k4-20020a170902d58400b001b8a56b9895si5284510plh.616.2023.10.30.07.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 07:25:29 -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=h4OOWOe0; 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 CE91280C5F8F; Mon, 30 Oct 2023 07:25:28 -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 S231845AbjJ3OZR (ORCPT + 31 others); Mon, 30 Oct 2023 10:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231919AbjJ3OZQ (ORCPT ); Mon, 30 Oct 2023 10:25:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86DD1C6; Mon, 30 Oct 2023 07:25:12 -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 3DA0021CAD; Mon, 30 Oct 2023 14:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698675911; 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=y2ADXZuRUSMr2od9G+oNY1AaP5CziwipA6lK0SssnIw=; b=h4OOWOe06DQ9hnKJPsEwywmZI2lFAj/geZAZMPADqRPLqQggbHPr0WJDCOBES0ID1ErhY/ ei7JimsZMOQJkqo38O3ifbz/+A0vBIOqslQrabGE9kxAmHBtet/L6RnMg2aWqskon4wXWT OaKHVj4gP5to5B2P53gNeadd+lriP70= 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 BB99E138F8; Mon, 30 Oct 2023 14:25:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id S2xyLMa8P2W0QAAAMHmgww (envelope-from ); Mon, 30 Oct 2023 14:25:10 +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 v4 0/5] x86/paravirt: Get rid of paravirt patching Date: Mon, 30 Oct 2023 15:25:03 +0100 Message-Id: <20231030142508.1407-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 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, 30 Oct 2023 07:25:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781190812053609109 X-GMAIL-MSGID: 1781190812053609109 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 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: move some functions and defines to alternative x86/alternative: add indirect call patching x86/paravirt: introduce ALT_NOT_XEN 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 | 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 | 121 ++++++++++------------ 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, 146 insertions(+), 285 deletions(-)