All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: compile out TDP MMU on 32-bit systems
Date: Mon, 8 Feb 2021 11:26:13 -0800	[thread overview]
Message-ID: <YCGQVdPio+LSNWGi@google.com> (raw)
In-Reply-To: <20210206145333.47314-1-pbonzini@redhat.com>

On Sat, Feb 06, 2021, Paolo Bonzini wrote:
> The TDP MMU assumes that it can do atomic accesses to 64-bit PTEs.
> Rather than just disabling it, compile it out completely so that it
> is possible to use for example 64-bit xchg.
> 
> To limit the number of stubs, wrap all accesses to tdp_mmu_enabled
> or tdp_mmu_page with a function.  Calls to all other functions in
> tdp_mmu.c are eliminated and do not even reach the linker.

Aha!  I always forget how smart the compiler can (sometimes) be.  I agree this
isn't at all painful.

This can/should also expand the #ifdef to the TDP-only fields in kvm_mmu_page.
I also vote to #ifdef out all of tdp_iter.h, and probably the TDP-only fields in
struct kvm_arch.

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e0171f7176c5..84499aad01a4 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1033,6 +1033,7 @@ struct kvm_arch {
        struct kvm_pmu_event_filter *pmu_event_filter;
        struct task_struct *nx_lpage_recovery_thread;

+#ifdef CONFIG_X86_64
        /*
         * Whether the TDP MMU is enabled for this VM. This contains a
         * snapshot of the TDP MMU module parameter from when the VM was
@@ -1071,6 +1072,7 @@ struct kvm_arch {
         * the thread holds the MMU lock in write mode.
         */
        spinlock_t tdp_mmu_pages_lock;
+#endif /* CONFIG_X86_64 */
 };

 struct kvm_vm_stat {
diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h
index 98db78a26957..9e38d3c5daad 100644
--- a/arch/x86/kvm/mmu/mmu_internal.h
+++ b/arch/x86/kvm/mmu/mmu_internal.h
@@ -56,10 +56,12 @@ struct kvm_mmu_page {
        /* Number of writes since the last time traversal visited this page.  */
        atomic_t write_flooding_count;

+#ifdef CONFIG_X86_64
        bool tdp_mmu_page;

        /* Used for freeing the page asyncronously if it is a TDP MMU page. */
        struct rcu_head rcu_head;
+#endif
 };

 extern struct kmem_cache *mmu_page_header_cache;
diff --git a/arch/x86/kvm/mmu/tdp_iter.h b/arch/x86/kvm/mmu/tdp_iter.h
index 4cc177d75c4a..5f60c1b1a1b4 100644
--- a/arch/x86/kvm/mmu/tdp_iter.h
+++ b/arch/x86/kvm/mmu/tdp_iter.h
@@ -7,6 +7,8 @@

 #include "mmu.h"

+#ifdef CONFIG_X86_64
+
 typedef u64 __rcu *tdp_ptep_t;

 /*
@@ -64,4 +66,6 @@ void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
 void tdp_iter_next(struct tdp_iter *iter);
 tdp_ptep_t tdp_iter_root_pt(struct tdp_iter *iter);

+#endif /* CONFIG_X86_64 */
+
 #endif /* __KVM_X86_MMU_TDP_ITER_H */



With the above:

Reviewed-and-tested-by: Sean Christopherson <seanjc@google.com>

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2021-02-08 19:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06 14:53 [PATCH] KVM: x86: compile out TDP MMU on 32-bit systems Paolo Bonzini
2021-02-08 19:26 ` Sean Christopherson [this message]
2021-02-08 19:41   ` Paolo Bonzini

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=YCGQVdPio+LSNWGi@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.