* [PATCH] kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use
@ 2020-11-15 15:27 Paolo Bonzini
2020-11-16 17:19 ` Ben Gardon
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2020-11-15 15:27 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: Ben Gardon
In some cases where shadow paging is in use, the root page will
be either mmu->pae_root or vcpu->arch.mmu->lm_root. Then it will
not have an associated struct kvm_mmu_page, because it is allocated
with alloc_page instead of kvm_mmu_alloc_page.
Just return false quickly from is_tdp_mmu_root if the TDP MMU is
not in use, which also includes the case where shadow paging is
enabled.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/mmu/tdp_mmu.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 27e381c9da6c..ff28a5c6abd6 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -49,7 +49,14 @@ bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa)
{
struct kvm_mmu_page *sp;
+ if (!kvm->arch.tdp_mmu_enabled)
+ return false;
+ if (WARN_ON(!VALID_PAGE(hpa)))
+ return false;
+
sp = to_shadow_page(hpa);
+ if (WARN_ON(!sp))
+ return false;
return sp->tdp_mmu_page && sp->root_count;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use
2020-11-15 15:27 [PATCH] kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use Paolo Bonzini
@ 2020-11-16 17:19 ` Ben Gardon
0 siblings, 0 replies; 2+ messages in thread
From: Ben Gardon @ 2020-11-16 17:19 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: LKML, kvm
On Sun, Nov 15, 2020 at 7:27 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> In some cases where shadow paging is in use, the root page will
> be either mmu->pae_root or vcpu->arch.mmu->lm_root. Then it will
> not have an associated struct kvm_mmu_page, because it is allocated
> with alloc_page instead of kvm_mmu_alloc_page.
>
> Just return false quickly from is_tdp_mmu_root if the TDP MMU is
> not in use, which also includes the case where shadow paging is
> enabled.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
> ---
> arch/x86/kvm/mmu/tdp_mmu.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index 27e381c9da6c..ff28a5c6abd6 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> @@ -49,7 +49,14 @@ bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa)
> {
> struct kvm_mmu_page *sp;
>
> + if (!kvm->arch.tdp_mmu_enabled)
> + return false;
> + if (WARN_ON(!VALID_PAGE(hpa)))
> + return false;
> +
> sp = to_shadow_page(hpa);
> + if (WARN_ON(!sp))
> + return false;
>
> return sp->tdp_mmu_page && sp->root_count;
> }
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-16 17:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-15 15:27 [PATCH] kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use Paolo Bonzini
2020-11-16 17:19 ` Ben Gardon
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).