KVM: SVM: Add a proper field for Hyper-V VMCB enlightenments
[platform/kernel/linux-starfive.git] / arch / x86 / kvm / svm / svm_onhyperv.h
index 35d6981..51030df 100644 (file)
@@ -17,8 +17,10 @@ int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu);
 
 static inline void svm_hv_init_vmcb(struct vmcb *vmcb)
 {
-       struct hv_enlightenments *hve =
-               (struct hv_enlightenments *)vmcb->control.reserved_sw;
+       struct hv_enlightenments *hve = &vmcb->control.hv_enlightenments;
+
+       BUILD_BUG_ON(sizeof(vmcb->control.hv_enlightenments) !=
+                    sizeof(vmcb->control.reserved_sw));
 
        if (npt_enabled &&
            ms_hyperv.nested_features & HV_X64_NESTED_ENLIGHTENED_TLB)
@@ -60,18 +62,15 @@ static inline void svm_hv_vmcb_dirty_nested_enlightenments(
                struct kvm_vcpu *vcpu)
 {
        struct vmcb *vmcb = to_svm(vcpu)->vmcb;
-       struct hv_enlightenments *hve =
-               (struct hv_enlightenments *)vmcb->control.reserved_sw;
+       struct hv_enlightenments *hve = &vmcb->control.hv_enlightenments;
 
        if (hve->hv_enlightenments_control.msr_bitmap)
                vmcb_mark_dirty(vmcb, HV_VMCB_NESTED_ENLIGHTENMENTS);
 }
 
-static inline void svm_hv_update_vp_id(struct vmcb *vmcb,
-               struct kvm_vcpu *vcpu)
+static inline void svm_hv_update_vp_id(struct vmcb *vmcb, struct kvm_vcpu *vcpu)
 {
-       struct hv_enlightenments *hve =
-               (struct hv_enlightenments *)vmcb->control.reserved_sw;
+       struct hv_enlightenments *hve = &vmcb->control.hv_enlightenments;
        u32 vp_index = kvm_hv_get_vpindex(vcpu);
 
        if (hve->hv_vp_id != vp_index) {