From: Joerg Roedel<joro@xxxxxxxxxx>
Move torwards emulation of VMCB-clean-bits by using a
seperate VMCB when running L2 guests.
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f81e35e..6dacf59 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -105,6 +105,8 @@ struct nested_state {
/* Nested Paging related state */
u64 nested_cr3;
+
+ struct vmcb *n_vmcb;
};
#define MSRPM_OFFSETS 16
@@ -974,6 +976,26 @@ static u64 svm_compute_tsc_offset(struct kvm_vcpu *vcpu, u64 target_tsc)
return target_tsc - tsc;
}
+static bool init_nested_vmcb(struct vcpu_svm *svm)
+{
+ struct vmcb_control_area *hc, *nc;
+
+ svm->nested.n_vmcb = (void *)get_zeroed_page(GFP_KERNEL);
+ if (svm->nested.n_vmcb == NULL)
+ return false;
+
+ nc =&svm->nested.n_vmcb->control;
+ hc =&svm->host_vmcb->control;
+
+ nc->iopm_base_pa = hc->iopm_base_pa;
+ nc->msrpm_base_pa = hc->msrpm_base_pa;
+ nc->nested_ctl = hc->nested_ctl;
+ nc->pause_filter_count = hc->pause_filter_count;
+ svm->nested.n_vmcb->save.g_pat = svm->host_vmcb->save.g_pat;
+
+ return true;
+}
+