From: Sean Christopherson <seanjc@google.com>
To: David Matlack <dmatlack@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Kai Huang <kai.huang@intel.com>,
Isaku Yamahata <isaku.yamahata@gmail.com>,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH v3 01/10] KVM: x86/mmu: Change tdp_mmu to a read-only parameter
Date: Tue, 11 Oct 2022 20:12:32 +0000 [thread overview]
Message-ID: <Y0XOMOSnMq49IgRW@google.com> (raw)
In-Reply-To: <20220921173546.2674386-2-dmatlack@google.com>
On Wed, Sep 21, 2022, David Matlack wrote:
> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 6bdaacb6faa0..168c46fd8dd1 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -230,14 +230,14 @@ static inline bool kvm_shadow_root_allocated(struct kvm *kvm)
> }
>
> #ifdef CONFIG_X86_64
> -static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return kvm->arch.tdp_mmu_enabled; }
> +extern bool tdp_mmu_enabled;
> #else
> -static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return false; }
> +#define tdp_mmu_enabled false
> #endif
Rather than open code references to the variable, keep the wrappers so that the
guts can be changed without needing to churn a pile of code. I'll follow-up in
the "Split out TDP MMU page fault handling" with the reasoning.
E.g.
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index 6bdaacb6faa0..1ad6d02e103f 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -230,14 +230,21 @@ static inline bool kvm_shadow_root_allocated(struct kvm *kvm)
}
#ifdef CONFIG_X86_64
-static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return kvm->arch.tdp_mmu_enabled; }
+extern bool tdp_mmu_enabled;
+#endif
+
+static inline bool is_tdp_mmu_enabled(void)
+{
+#ifdef CONFIG_X86_64
+ return tdp_mmu_enabled;
#else
-static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return false; }
+ return false;
#endif
+}
static inline bool kvm_memslots_have_rmaps(struct kvm *kvm)
{
- return !is_tdp_mmu_enabled(kvm) || kvm_shadow_root_allocated(kvm);
+ return !is_tdp_mmu_enabled() || kvm_shadow_root_allocated(kvm);
}
static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
next prev parent reply other threads:[~2022-10-11 20:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 17:35 [PATCH v3 00/10] KVM: x86/mmu: Make tdp_mmu read-only and clean up TPD MMU fault handler David Matlack
2022-09-21 17:35 ` [PATCH v3 01/10] KVM: x86/mmu: Change tdp_mmu to a read-only parameter David Matlack
2022-09-27 9:19 ` Huang, Kai
2022-09-27 16:14 ` David Matlack
2022-09-27 21:10 ` Huang, Kai
2022-09-29 1:56 ` Huang, Kai
2022-10-03 18:58 ` Isaku Yamahata
2022-10-03 20:02 ` David Matlack
2022-10-03 21:56 ` Isaku Yamahata
2022-10-03 20:11 ` Huang, Kai
2022-10-11 20:12 ` Sean Christopherson [this message]
2022-09-21 17:35 ` [PATCH v3 02/10] KVM: x86/mmu: Move TDP MMU VM init/uninit behind tdp_mmu_enabled David Matlack
2022-10-03 19:01 ` Isaku Yamahata
2022-09-21 17:35 ` [PATCH v3 03/10] KVM: x86/mmu: Grab mmu_invalidate_seq in kvm_faultin_pfn() David Matlack
2022-10-03 19:05 ` Isaku Yamahata
2022-09-21 17:35 ` [PATCH v3 04/10] KVM: x86/mmu: Handle error PFNs " David Matlack
2022-09-21 17:35 ` [PATCH v3 05/10] KVM: x86/mmu: Avoid memslot lookup during KVM_PFN_ERR_HWPOISON handling David Matlack
2022-10-03 19:23 ` Isaku Yamahata
2022-09-21 17:35 ` [PATCH v3 06/10] KVM: x86/mmu: Handle no-slot faults in kvm_faultin_pfn() David Matlack
2022-09-21 17:35 ` [PATCH v3 07/10] KVM: x86/mmu: Initialize fault.{gfn,slot} earlier for direct MMUs David Matlack
2022-10-03 19:27 ` Isaku Yamahata
2022-09-21 17:35 ` [PATCH v3 08/10] KVM: x86/mmu: Split out TDP MMU page fault handling David Matlack
2022-10-03 19:28 ` Isaku Yamahata
2022-10-11 21:56 ` Sean Christopherson
2022-09-21 17:35 ` [PATCH v3 09/10] KVM: x86/mmu: Stop needlessly making MMU pages available for TDP MMU faults David Matlack
2022-10-03 19:28 ` Isaku Yamahata
2022-09-21 17:35 ` [PATCH v3 10/10] KVM: x86/mmu: Rename __direct_map() to direct_map() David Matlack
2022-10-03 19:29 ` Isaku Yamahata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y0XOMOSnMq49IgRW@google.com \
--to=seanjc@google.com \
--cc=dmatlack@google.com \
--cc=isaku.yamahata@gmail.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).