lkml.org 
[lkml]   [2020]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v6 4/4] KVM: nSVM: implement on demand allocation of the nested state
    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@redhat.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.

    Side topic, do we actually need 'initialized'? Wouldn't checking for a
    valid nested.msrpm or nested.hsave suffice?

    > + 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;
    > }

    \
     
     \ /
      Last update: 2020-09-29 07:15    [W:2.696 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site