[PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-17 Thread Maxim Levitsky
This way we don't waste memory on VMs which don't use nesting virtualization even if it is available to them. If allocation of nested state fails (which should happen, only when host is about to OOM anyway), use new KVM_REQ_OUT_OF_MEMORY request to shut down the guest Signed-off-by: Maxim Levitsk

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-19 Thread Paolo Bonzini
On 17/09/20 18:29, Sean Christopherson wrote: >> +vcpu->arch.efer = old_efer; >> +kvm_make_request(KVM_REQ_OUT_OF_MEMORY, vcpu); > I really dislike KVM_REQ_OUT_OF_MEMORY. It's redundant with -ENOMEM and > creates a huge discrepancy with respe

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-20 Thread Sean Christopherson
On Sat, Sep 19, 2020 at 05:09:09PM +0200, Paolo Bonzini wrote: > On 17/09/20 18:29, Sean Christopherson wrote: > >> + vcpu->arch.efer = old_efer; > >> + kvm_make_request(KVM_REQ_OUT_OF_MEMORY, vcpu); > > I really dislike KVM_REQ_OUT_OF_MEMORY. It's

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-20 Thread Paolo Bonzini
On 20/09/20 18:16, Sean Christopherson wrote: >> Maxim, your previous version was adding some error handling to >> kvm_x86_ops.set_efer. I don't remember what was the issue; did you have >> any problems propagating all the errors up to KVM_SET_SREGS (easy), >> kvm_set_msr (harder) etc.? > I object

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-21 Thread Maxim Levitsky
On Sun, 2020-09-20 at 18:42 +0200, Paolo Bonzini wrote: > On 20/09/20 18:16, Sean Christopherson wrote: > > > Maxim, your previous version was adding some error handling to > > > kvm_x86_ops.set_efer. I don't remember what was the issue; did you have > > > any problems propagating all the errors u

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-21 Thread Maxim Levitsky
On Mon, 2020-09-21 at 10:53 +0300, Maxim Levitsky wrote: > On Sun, 2020-09-20 at 18:42 +0200, Paolo Bonzini wrote: > > On 20/09/20 18:16, Sean Christopherson wrote: > > > > Maxim, your previous version was adding some error handling to > > > > kvm_x86_ops.set_efer. I don't remember what was the is

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-21 Thread Maxim Levitsky
On Thu, 2020-09-17 at 09:29 -0700, Sean Christopherson wrote: > On Thu, Sep 17, 2020 at 01:10:48PM +0300, Maxim Levitsky wrote: > > This way we don't waste memory on VMs which don't use > > nesting virtualization even if it is available to them. > > > > If allocation of nested state fails (which s

Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state

2020-09-17 Thread Sean Christopherson
On Thu, Sep 17, 2020 at 01:10:48PM +0300, Maxim Levitsky wrote: > This way we don't waste memory on VMs which don't use > nesting virtualization even if it is available to them. > > If allocation of nested state fails (which should happen, > only when host is about to OOM anyway), use new KVM_REQ_