[PATCH v2 0/7] KVM: nSVM: ondemand nested state allocation + smm fixes

From: Maxim Levitsky
Date: Thu Aug 20 2020 - 09:34:00 EST


Hi!

This patch series does some refactoring and implements on demand nested state area
This way at least guests that don't use nesting won't waste memory
on nested state.

Patches 1,2,3 are refactoring

Patches 4,5 are new from V1 and implement more strict SMM save state area checking
on resume from SMM to avoid guest tampering with this area.

This was done to avoid crashing if the guest enabled 'guest was interrupted'
flag there and we don't have nested state allocated.

Patches 6,7 are for ondemand nested state.

The series was tested with various nested guests, in one case even with
L3 running, but note that due to unrelated issue, migration with nested
guest running didn't work for me with or without this series.
I am investigating this currently.

Best regards,
Maxim Levitsky

Maxim Levitsky (7):
KVM: SVM: rename a variable in the svm_create_vcpu
KVM: nSVM: rename nested 'vmcb' to vmcb12_gpa in few places
KVM: SVM: refactor msr permission bitmap allocation
KVM: x86: allow kvm_x86_ops.set_efer to return a value
KVM: nSVM: more strict smm checks
KVM: emulator: more strict rsm checks.
KVM: nSVM: implement ondemand allocation of the nested state

arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/emulate.c | 22 ++++--
arch/x86/kvm/svm/nested.c | 53 +++++++++++--
arch/x86/kvm/svm/svm.c | 130 ++++++++++++++++++--------------
arch/x86/kvm/svm/svm.h | 10 ++-
arch/x86/kvm/vmx/vmx.c | 5 +-
arch/x86/kvm/x86.c | 3 +-
7 files changed, 151 insertions(+), 74 deletions(-)

--
2.26.2