[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200929051526.GD353@linux.intel.com>
Date: Mon, 28 Sep 2020 22:15:26 -0700
From: Sean Christopherson <sean.j.christopherson@...el.com>
To: Maxim Levitsky <mlevitsk@...hat.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 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.
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;
> }
Powered by blists - more mailing lists