|
@@ -185,6 +185,28 @@ static int nested_svm_vmexit(struct vcpu_svm *svm);
|
|
|
static int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr,
|
|
|
bool has_error_code, u32 error_code);
|
|
|
|
|
|
+enum {
|
|
|
+ VMCB_DIRTY_MAX,
|
|
|
+};
|
|
|
+
|
|
|
+#define VMCB_ALWAYS_DIRTY_MASK 0U
|
|
|
+
|
|
|
+static inline void mark_all_dirty(struct vmcb *vmcb)
|
|
|
+{
|
|
|
+ vmcb->control.clean = 0;
|
|
|
+}
|
|
|
+
|
|
|
+static inline void mark_all_clean(struct vmcb *vmcb)
|
|
|
+{
|
|
|
+ vmcb->control.clean = ((1 << VMCB_DIRTY_MAX) - 1)
|
|
|
+ & ~VMCB_ALWAYS_DIRTY_MASK;
|
|
|
+}
|
|
|
+
|
|
|
+static inline void mark_dirty(struct vmcb *vmcb, int bit)
|
|
|
+{
|
|
|
+ vmcb->control.clean &= ~(1 << bit);
|
|
|
+}
|
|
|
+
|
|
|
static inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
return container_of(vcpu, struct vcpu_svm, vcpu);
|
|
@@ -973,6 +995,8 @@ static void init_vmcb(struct vcpu_svm *svm)
|
|
|
set_intercept(svm, INTERCEPT_PAUSE);
|
|
|
}
|
|
|
|
|
|
+ mark_all_dirty(svm->vmcb);
|
|
|
+
|
|
|
enable_gif(svm);
|
|
|
}
|
|
|
|
|
@@ -1089,6 +1113,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
|
|
|
|
|
|
if (unlikely(cpu != vcpu->cpu)) {
|
|
|
svm->asid_generation = 0;
|
|
|
+ mark_all_dirty(svm->vmcb);
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
@@ -2140,6 +2165,8 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
|
|
|
svm->vmcb->save.cpl = 0;
|
|
|
svm->vmcb->control.exit_int_info = 0;
|
|
|
|
|
|
+ mark_all_dirty(svm->vmcb);
|
|
|
+
|
|
|
nested_svm_unmap(page);
|
|
|
|
|
|
nested_svm_uninit_mmu_context(&svm->vcpu);
|
|
@@ -2351,6 +2378,8 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
|
|
|
|
|
|
enable_gif(svm);
|
|
|
|
|
|
+ mark_all_dirty(svm->vmcb);
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3490,6 +3519,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
|
|
|
if (unlikely(svm->vmcb->control.exit_code ==
|
|
|
SVM_EXIT_EXCP_BASE + MC_VECTOR))
|
|
|
svm_handle_mce(svm);
|
|
|
+
|
|
|
+ mark_all_clean(svm->vmcb);
|
|
|
}
|
|
|
|
|
|
#undef R
|