Message ID | 20221102231911.3107438-5-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp199214wru; Wed, 2 Nov 2022 16:21:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BfNe0rPQsfyk+9uI+L8ExFnCl7gVjh3PbgwJBboNydk0PRQNpL/C4njaUhH849z67TxT9 X-Received: by 2002:a17:902:ab15:b0:187:734:96a1 with SMTP id ik21-20020a170902ab1500b00187073496a1mr25319269plb.4.1667431264114; Wed, 02 Nov 2022 16:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431264; cv=none; d=google.com; s=arc-20160816; b=muty7JaRf/s0PmtbEO9qFU2w+CRw6ljNcmpjLtrH5HvQ7lTfyfZZekXMfTO/ifxac3 5N+LnIE4Z+oZQiEdWPSf9DMPo3BJ/CEfaxhQRqou5yHbFBSbPCWdIbrstktvq7W/fe2z EwMJppVay37PI2nRvosR5xX0LmWGJ1TZdA5NE9Z/Euv8lMwS3xM4sVUNdzP1jx+qG7YD DDbeh9gsGQ/UsD1zQRUjsTp60trT85EMWOi9WaJy3AzmEKsWyL7G8uL1g9R+TfRvZtFv kAdIOFhyKo9r9s+NuTJWXMPvAAqNdYC5kreHX8/Gq2/Fo1KIv5TFDIU3P7CZLoPBJ3lf VvDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=c745/GhVAupZOShsaNtc5Y0Jm7uB9ydr3S2itBPefjM=; b=xnHCQIxLUa5FaPg0r4ZofKnWqLocrO/AOZV6VySsz9o8A8UImtWzLOT9DXmJbH7nJ3 d91Vl649RFRU+nZGdymsbSD21BEP82SdKha/WGzp5KvXRV7xezjgp9Z/xNMmoVjeQLYV Ezcf3lbsiHHPQ46BEEalmI8CxeRQmp5dwaXxu8y76mJC2SJGq+njLKmvzszUUhhZmwmy kX7u9u375X9lIoM4a0xVfYm5dmi+xJM4t4oiwuOx8KPx2vuKT6EE/I4vjZ+zIba7Dqy4 Ja63TKV3Z+DADd9Q/K1Lfk+Tf1MMLe0gucvlmt7Rp7IeBOY7fbCbKJzlKqKSbhk7wK8H MCXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pj8ZAUMz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a655b0e000000b0044af51e7d4bsi18283090pgq.75.2022.11.02.16.20.49; Wed, 02 Nov 2022 16:21:04 -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=@google.com header.s=20210112 header.b=pj8ZAUMz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbiKBXUT (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 19:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbiKBXT1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 19:19:27 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D523825E7 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 16:19:21 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 7-20020a630007000000b0045bb8a49ae6so90948pga.9 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 16:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=c745/GhVAupZOShsaNtc5Y0Jm7uB9ydr3S2itBPefjM=; b=pj8ZAUMzpQAWjfpeZGv/CFSzOSSwAiDNlmMCeDtMJXA3Ia6uRvLVcV16Cymca0aHXC PM6wRe31jjgcVPugCvX2WsyNtqvMLIJF0v+Ys/n5Nq2k4svZOYnhn3INYaYp+USpd+G1 514pS4WDUrP9flgT5BLdl+/qUHO2eNFQZVTslZCWnmYA53yd76i4Ah4L5OS7bjh89Kxd agD1FqGzCkHp/1xQ5FePUye1+JugXCV19Z37h3h0SVTeBVE4gWePoOlMN/4jX90JcqtQ h9Xz7vnqCR6lnYHkhGhaSKxff5kFMXnt6v8GUJMP6nlzvcT1qM4okUu+0Q4ETJu9vS+7 8iTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c745/GhVAupZOShsaNtc5Y0Jm7uB9ydr3S2itBPefjM=; b=iXxKuYJWQkzLhPVWS0ULzx2iWgtOMRux2YJVGSd7Hlinn458p/VaeqEK3WIX3ene3f pwW08iqRGSnbg8ltBje41c8AYdQP0JPSqYGrDBNW1SzH3oVtBJiK2E8dAnLnUy+k4t2b fHa8BA9eaWtldxFE3l/7ZPEmD65/4p3+jdj0hqXTXhjBbsqks+KBcN+lNW+Q27EROea3 lwozP6pXwIIeAq9iQIq/Gy/cc++/jteobvyiqMXKklu7qMaIag43RDmk/p9OzV/Aud8A rAYgUxTODyR2Lcrd1dI6R3iPPumdX7cMUlFgxA6oujMB4cpvMICf5hdOl91c77ySqFLP aPHg== X-Gm-Message-State: ACrzQf0N/EICpSkpdIT7SCpdCYQ6oPkoumtcg/mH2pquXFq0liyHUkbM +wqH5NDq6TLU2TpMrIvSxoIRU5rUxQw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:8a97:b0:178:1939:c721 with SMTP id p23-20020a1709028a9700b001781939c721mr27564226plo.108.1667431161027; Wed, 02 Nov 2022 16:19:21 -0700 (PDT) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 2 Nov 2022 23:18:31 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-5-seanjc@google.com> Subject: [PATCH 04/44] KVM: Teardown VFIO ops earlier in kvm_exit() From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Huacai Chen <chenhuacai@kernel.org>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com> Cc: James Morse <james.morse@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Atish Patra <atishp@atishpatra.org>, David Hildenbrand <david@redhat.com>, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Isaku Yamahata <isaku.yamahata@intel.com>, Fabiano Rosas <farosas@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Chao Gao <chao.gao@intel.com>, Thomas Gleixner <tglx@linutronix.de>, Yuan Yao <yuan.yao@intel.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428405249265506?= X-GMAIL-MSGID: =?utf-8?q?1748428405249265506?= |
Series |
KVM: Rework kvm_init() and hardware enabling
|
|
Commit Message
Sean Christopherson
Nov. 2, 2022, 11:18 p.m. UTC
Move the call to kvm_vfio_ops_exit() further up kvm_exit() to try and
bring some amount of symmetry to the setup order in kvm_init(), and more
importantly so that the arch hooks are invoked dead last by kvm_exit().
This will allow arch code to move away from the arch hooks without any
change in ordering between arch code and common code in kvm_exit().
That kvm_vfio_ops_exit() is called last appears to be 100% arbitrary. It
was bolted on after the fact by commit 571ee1b68598 ("kvm: vfio: fix
unregister kvm_device_ops of vfio"). The nullified kvm_device_ops_table
is also local to kvm_main.c and is used only when there are active VMs,
so unless arch code is doing something truly bizarre, nullifying the
table earlier in kvm_exit() is little more than a nop.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, Nov 02 2022, Sean Christopherson <seanjc@google.com> wrote: > Move the call to kvm_vfio_ops_exit() further up kvm_exit() to try and > bring some amount of symmetry to the setup order in kvm_init(), and more > importantly so that the arch hooks are invoked dead last by kvm_exit(). > This will allow arch code to move away from the arch hooks without any > change in ordering between arch code and common code in kvm_exit(). > > That kvm_vfio_ops_exit() is called last appears to be 100% arbitrary. It > was bolted on after the fact by commit 571ee1b68598 ("kvm: vfio: fix > unregister kvm_device_ops of vfio"). The nullified kvm_device_ops_table > is also local to kvm_main.c and is used only when there are active VMs, > so unless arch code is doing something truly bizarre, nullifying the > table earlier in kvm_exit() is little more than a nop. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Looks safe to me. Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On Wed, 2022-11-02 at 23:18 +0000, Sean Christopherson wrote: > Move the call to kvm_vfio_ops_exit() further up kvm_exit() to try and > bring some amount of symmetry to the setup order in kvm_init(), and > more > importantly so that the arch hooks are invoked dead last by > kvm_exit(). > This will allow arch code to move away from the arch hooks without > any > change in ordering between arch code and common code in kvm_exit(). > > That kvm_vfio_ops_exit() is called last appears to be 100% > arbitrary. It > was bolted on after the fact by commit 571ee1b68598 ("kvm: vfio: fix > unregister kvm_device_ops of vfio"). The nullified > kvm_device_ops_table > is also local to kvm_main.c and is used only when there are active > VMs, > so unless arch code is doing something truly bizarre, nullifying the > table earlier in kvm_exit() is little more than a nop. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Eric Farman <farman@linux.ibm.com>
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8b7534cc953b..f592dd4ce8f2 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5961,6 +5961,7 @@ void kvm_exit(void) for_each_possible_cpu(cpu) free_cpumask_var(per_cpu(cpu_kick_mask, cpu)); kmem_cache_destroy(kvm_vcpu_cache); + kvm_vfio_ops_exit(); kvm_async_pf_deinit(); unregister_syscore_ops(&kvm_syscore_ops); unregister_reboot_notifier(&kvm_reboot_notifier); @@ -5970,7 +5971,6 @@ void kvm_exit(void) free_cpumask_var(cpus_hardware_enabled); kvm_arch_hardware_unsetup(); kvm_arch_exit(); - kvm_vfio_ops_exit(); } EXPORT_SYMBOL_GPL(kvm_exit);