[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0518490df933d0b12b6dc4b0df2234091cd95ce7.camel@redhat.com>
Date: Wed, 30 Sep 2020 18:35:40 +0300
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: kvm@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Joerg Roedel <joro@...tes.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, Jim Mattson <jmattson@...gle.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>
Subject: Re: [PATCH v6 4/4] KVM: nSVM: implement on demand allocation of the
nested state
On Mon, 2020-09-28 at 22:15 -0700, Sean Christopherson wrote:
> On Wed, Sep 23, 2020 at 12:10:25AM +0300, Maxim Levitsky wrote:
> > This way we don't waste memory on VMs which don't use nesting
> > virtualization even when the host enabled it for them.
> >
> > Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
> > ---
> > arch/x86/kvm/svm/nested.c | 42 ++++++++++++++++++++++++++++++
> > arch/x86/kvm/svm/svm.c | 55 ++++++++++++++++++++++-----------------
> > arch/x86/kvm/svm/svm.h | 6 +++++
> > 3 files changed, 79 insertions(+), 24 deletions(-)
> >
> > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> > index 09417f5197410..dd13856818a03 100644
> > --- a/arch/x86/kvm/svm/nested.c
> > +++ b/arch/x86/kvm/svm/nested.c
> > @@ -467,6 +467,9 @@ int nested_svm_vmrun(struct vcpu_svm *svm)
> >
> > vmcb12 = map.hva;
> >
> > + if (WARN_ON(!svm->nested.initialized))
>
> Probably should use WARN_ON_ONCE, if this is somehow it, userspace could
> easily spam the kernel.
Makes sense.
>
> Side topic, do we actually need 'initialized'? Wouldn't checking for a
> valid nested.msrpm or nested.hsave suffice?
It a matter of taste - I prefer to have a single variable controlling this,
rather than two.
a WARN_ON(svm->nested.initialized && !svm->nested.msrpm || !svm->nested.hsave))
would probably be nice to have. IMHO I rather leave this like it is if you
don't object.
>
> > + return 1;
> > +
> > if (!nested_vmcb_checks(svm, vmcb12)) {
> > vmcb12->control.exit_code = SVM_EXIT_ERR;
> > vmcb12->control.exit_code_hi = 0;
> > @@ -684,6 +687,45 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
> > return 0;
> > }
Best regards,
Maxim Levitsky
Powered by blists - more mailing lists