[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YD+9gwhfFCS7Xghe@google.com>
Date: Wed, 3 Mar 2021 08:46:59 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Ben Gardon <bgardon@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Brijesh Singh <brijesh.singh@....com>,
Tom Lendacky <thomas.lendacky@....com>
Subject: Re: [PATCH 03/15] KVM: x86/mmu: Ensure MMU pages are available when
allocating roots
On Tue, Mar 02, 2021, Ben Gardon wrote:
> > @@ -3241,16 +3237,10 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
> >
> > if (is_tdp_mmu_enabled(vcpu->kvm)) {
> > root = kvm_tdp_mmu_get_vcpu_root_hpa(vcpu);
> > -
> > - if (!VALID_PAGE(root))
> > - return -ENOSPC;
> > vcpu->arch.mmu->root_hpa = root;
> > } else if (shadow_root_level >= PT64_ROOT_4LEVEL) {
> > root = mmu_alloc_root(vcpu, 0, 0, shadow_root_level,
> > true);
> > -
> > - if (!VALID_PAGE(root))
> > - return -ENOSPC;
>
> There's so much going on in mmu_alloc_root that removing this check
> makes me nervous, but I think it should be safe.
Just think of it as a variant of kvm_mmu_get_page(), then all your fears will
melt away. ;-)
> I checked though the function because I was worried it might yield
> somewhere in there, which could result in the page cache being emptied
> and the allocation failing, but I don't think mmu_alloc_root this
> function will yield.
Ugh, mmu_alloc_root() won't yield, but get_zeroed_page() used to allocate pae_root
and lm_root on-demand in mmu_alloc_shadow_roots() will. The two options are
(a) allocate the fake roots before taking the lock and (b) allocate them from
vcpu->arch.mmu_shadow_page_cache. I probably prefer (a). (b) will slide
directly into the existing code, but would require bumping the min number of
objects for mmu_shadow_page_cache in mmu_topup_memory_caches(). I'd prefer not
to have yet more code that has to deal with this insanity.
Powered by blists - more mailing lists