Re: [PATCH 6/7] KVM: SVM: hyper-v: Enlightened MSR-Bitmap support

From: Paolo Bonzini
Date: Thu Apr 08 2021 - 11:47:25 EST


On 07/04/21 16:41, Vineeth Pillai wrote:
+#if IS_ENABLED(CONFIG_HYPERV)
+static inline void hv_vmcb_dirty_nested_enlightenments(struct kvm_vcpu *vcpu)
+{
+ struct vmcb *vmcb = to_svm(vcpu)->vmcb;
+
+ /*
+ * vmcb can be NULL if called during early vcpu init.
+ * And its okay not to mark vmcb dirty during vcpu init
+ * as we mark it dirty unconditionally towards end of vcpu
+ * init phase.
+ */
+ if (vmcb && vmcb_is_clean(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS) &&
+ vmcb->hv_enlightenments.hv_enlightenments_control.msr_bitmap)
+ vmcb_mark_dirty(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS);
+}

In addition to what Vitaly said, can svm->vmcb really be NULL? If so it might be better to reorder initializations and skip the NULL check.

Paolo