Skip to content

KVM: nSVM: ondemand nested state allocation

Maxim Levitsky kvm lkml 7 versions – Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest4 patches 1 replyApplied
  2. v64 patches 8 repliesSuperseded
  3. v54 patches 3 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v42 patches7 repliesSuperseded
v38 patches2 repliesSuperseded
v27 patches8 repliesSuperseded
v18 patches14 repliesSuperseded

Patches in v7 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: x86: xen_hvm_config: cleanup return valuesarch/x86/kvm/x86.c+9 -140 replies
2/4KVM: x86: report negative values from wrmsr emulation to userspacearch/x86/kvm/emulate.c arch/x86/kvm/x86.c+8 -50 replies
3/4KVM: x86: allow kvm_x86_ops.set_efer to return an error valuearch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h +2 more+14 -60 replies
4/4KVM: nSVM: implement on demand allocation of the nested statearch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+83 -280 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v7 yet.

Read the v7 thread

Cover letter [PATCH v7 0/4] KVM: nSVM: ondemand nested state allocation

This is the next version of this patch series.

In V5 I adopted Sean Christopherson's suggestion to make .set_efer return a negative error (-ENOMEM in this case) which in most cases in kvm propagates to the userspace.

I noticed though that wrmsr emulation code doesn't do this and instead it injects #GP to the guest on _any_ error.

So I fixed the wrmsr code to behave in a similar way to the rest of the kvm code.
(#GP only on a positive error value, and forward the negative error to the userspace)

I had to adjust one wrmsr handler (xen_hvm_config) to stop it from returning
negative values so that new WRMSR emulation behavior doesn't break it.
This patch was only compile tested.

The memory allocation failure was tested by always returning -ENOMEM from svm_allocate_nested.

The nested allocation itself was tested by countless attempts to run nested guests, do nested migration on both my AMD and Intel machines. I wasn't able to break it.

Changes from V5: addressed Sean Christopherson's review feedback. Changes from V6: rebased the code on latest kvm/queue

Best regards,
Maxim Levitsky

Maxim Levitsky (4):
KVM: x86: xen_hvm_config: cleanup return values
KVM: x86: report negative values from wrmsr emulation to userspace
KVM: x86: allow kvm_x86_ops.set_efer to return an error value
KVM: nSVM: implement on demand allocation of the nested state

 arch/x86/include/asm/kvm_host.h |  2 +-
 arch/x86/kvm/emulate.c          |  4 +--
 arch/x86/kvm/svm/nested.c       | 42 ++++++++++++++++++++++
 arch/x86/kvm/svm/svm.c          | 64 ++++++++++++++++++---------------
 arch/x86/kvm/svm/svm.h          | 10 +++++-
 arch/x86/kvm/vmx/vmx.c          |  6 ++--
 arch/x86/kvm/x86.c              | 39 ++++++++++----------
 7 files changed, 114 insertions(+), 53 deletions(-)
Signature · 1 line
2.26.2