From patchwork Sun Dec 10 06:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 17797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6385318vqy; Sat, 9 Dec 2023 22:22:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqZ3be2O9ZMTIiwj7rInynkww4cu9hccM6cTunW/+p81I+leBNWK5g6OuN1HMe59lW3dC4 X-Received: by 2002:a17:902:d2c5:b0:1d0:476f:b2ba with SMTP id n5-20020a170902d2c500b001d0476fb2bamr3125147plc.50.1702189321549; Sat, 09 Dec 2023 22:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702189321; cv=none; d=google.com; s=arc-20160816; b=JmH4NtJJczlTnwr0Wsquxi4ZX8GqkkonLo5rnwtKUErA1EGqHFL2/WvamRfDwi0exw kqpwjmknO4F7Xnfgy6FJL3z5wHDAGthxjybi2D3cpRMkjnopjg9J19yNmFdu6UZXfYB0 gUJ8V57Li9BHprk/hKurXcfcnmRP45w7prZUMR0zFg5vAJkqwVgBCozC3LiEoPEsVVYu iviSq1LtQwukRACoFJrBDXZRyLN6YRdnRw0eBK7Cn+xJyKkyBSY85XocrWbKCFks2fe/ JN1csQ55o+pnndtzF3vXMS4DOT7PW9pNzjQnqTnnUX83k2wBWCnx0ppL+48Pc87Cv2zr BpbA== 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:dkim-signature; bh=eMbINGogkyxk7Eq7pz90fULe5xNfa98e3nj/JUFDdnE=; fh=JZ0mkxAY7JgHEGcDE+bHMXYcaAAH7riwUHOHQpZmmZA=; b=Xwzgxk+6aRKEQTKXZy47qqHkEKKXpBPYWf6QffdNX/OFp9sB1xsdBTGCwvqYCCPSiu o2R12PneWG/DseyBnvvTxqRfV2zcM8ShQHw2/ctBCoXFxEzmUYG/eke1rhKXMcg7E09M cKV+ZepFY0qiV0+8VvXGdJmlZcIBfl45emNDyBGOgzDNRAmuTedtBj0/Ek3HP2Gk6MEj VdrgRH/NjswhDPpbM7RKY1S7W5SN3EWzLG2zk4BH7FIiz6NAWdfOOdB5atYcz1jaBEqW Sg4NtQszjjw8rrklJ48bXC41N/2osmRcBA8lffhAAe23X9BEnAsU5R9KEue0v/gBaQDS tZSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Sa5kv9s/"; dkim=pass header.i=@suse.com header.s=susede1 header.b="Sa5kv9s/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t4-20020a170902e84400b001d09c96ba02si4222994plg.124.2023.12.09.22.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 22:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Sa5kv9s/"; dkim=pass header.i=@suse.com header.s=susede1 header.b="Sa5kv9s/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id EF53C805FD55; Sat, 9 Dec 2023 22:21:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjLJGVi (ORCPT + 99 others); Sun, 10 Dec 2023 01:21:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjLJGVh (ORCPT ); Sun, 10 Dec 2023 01:21:37 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5907102; Sat, 9 Dec 2023 22:21:43 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 0EFA421FB5; Sun, 10 Dec 2023 06:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1702189301; 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=eMbINGogkyxk7Eq7pz90fULe5xNfa98e3nj/JUFDdnE=; b=Sa5kv9s/RLfuNkHAGfZA47cCUM3t1TguXEd4UUr8PBVXwVuxvRUrGvbSmcMM82986I9yEJ N5Hd6l3hgU0llsK4NZE7q74PIPMoL5IEl2SSvd1WyPQ49Ii3T+9azPmY0E7SmSLO24kM0j dnrZ2iAYVmtgxX4miD6yeSQn9kytD2M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1702189301; 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=eMbINGogkyxk7Eq7pz90fULe5xNfa98e3nj/JUFDdnE=; b=Sa5kv9s/RLfuNkHAGfZA47cCUM3t1TguXEd4UUr8PBVXwVuxvRUrGvbSmcMM82986I9yEJ N5Hd6l3hgU0llsK4NZE7q74PIPMoL5IEl2SSvd1WyPQ49Ii3T+9azPmY0E7SmSLO24kM0j dnrZ2iAYVmtgxX4miD6yeSQn9kytD2M= 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 8B5AC13240; Sun, 10 Dec 2023 06:21:40 +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 JTVQIPRYdWUFewAAn2gu4w (envelope-from ); Sun, 10 Dec 2023 06:21:40 +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 v6 0/5] 86/paravirt: Get rid of paravirt patching Date: Sun, 10 Dec 2023 07:21:33 +0100 Message-Id: <20231210062138.2417-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Level: **************** X-Spam-Score: 16.72 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="Sa5kv9s/"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=fail (smtp-out1.suse.de: domain of jgross@suse.com does not designate 2a07:de40:b281:104:10:150:64:98 as permitted sender) smtp.mailfrom=jgross@suse.com X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [-3.91 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.com:+]; MX_GOOD(-0.01)[]; DMARC_POLICY_ALLOW(0.00)[suse.com,quarantine]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; R_SPF_FAIL(0.00)[-all]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(2.90)[0.968]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; WHITELIST_DMARC(-7.00)[suse.com:D:+]; RCPT_COUNT_TWELVE(0.00)[18]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -3.91 X-Rspamd-Queue-Id: 0EFA421FB5 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 howler.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 (howler.vger.email [0.0.0.0]); Sat, 09 Dec 2023 22:21:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784874869926935064 X-GMAIL-MSGID: 1784874869926935064 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 V6: - addressed Boris' comments 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 | 136 +++++++++++----------- 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, 169 insertions(+), 287 deletions(-)