Revision 1c90ef26

b/target-i386/cpu.h
862 862
    uint64_t msr_fixed_counters[MAX_FIXED_COUNTERS];
863 863
    uint64_t msr_gp_counters[MAX_GP_COUNTERS];
864 864
    uint64_t msr_gp_evtsel[MAX_GP_COUNTERS];
865
    uint64_t msr_hv_hypercall;
866
    uint64_t msr_hv_guest_os_id;
865 867

  
866 868
    /* exception/interrupt handling */
867 869
    int error_code;
b/target-i386/kvm.c
1230 1230
                              env->msr_global_ctrl);
1231 1231
        }
1232 1232
        if (has_msr_hv_hypercall) {
1233
            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_GUEST_OS_ID, 0);
1234
            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL, 0);
1233
            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_GUEST_OS_ID,
1234
                              env->msr_hv_guest_os_id);
1235
            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL,
1236
                              env->msr_hv_hypercall);
1235 1237
        }
1236 1238
        if (has_msr_hv_vapic) {
1237 1239
            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
......
1520 1522
        }
1521 1523
    }
1522 1524

  
1525
    if (has_msr_hv_hypercall) {
1526
        msrs[n++].index = HV_X64_MSR_HYPERCALL;
1527
        msrs[n++].index = HV_X64_MSR_GUEST_OS_ID;
1528
    }
1523 1529
    msr_data.info.nmsrs = n;
1524 1530
    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
1525 1531
    if (ret < 0) {
......
1627 1633
        case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1:
1628 1634
            env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = msrs[i].data;
1629 1635
            break;
1636
        case HV_X64_MSR_HYPERCALL:
1637
            env->msr_hv_hypercall = msrs[i].data;
1638
            break;
1639
        case HV_X64_MSR_GUEST_OS_ID:
1640
            env->msr_hv_guest_os_id = msrs[i].data;
1641
            break;
1630 1642
        }
1631 1643
    }
1632 1644

  
b/target-i386/machine.c
554 554
    }
555 555
};
556 556

  
557
static bool hyperv_hypercall_enable_needed(void *opaque)
558
{
559
    X86CPU *cpu = opaque;
560
    CPUX86State *env = &cpu->env;
561

  
562
    return env->msr_hv_hypercall != 0 || env->msr_hv_guest_os_id != 0;
563
}
564

  
565
static const VMStateDescription vmstate_msr_hypercall_hypercall = {
566
    .name = "cpu/msr_hyperv_hypercall",
567
    .version_id = 1,
568
    .minimum_version_id = 1,
569
    .minimum_version_id_old = 1,
570
    .fields      = (VMStateField []) {
571
        VMSTATE_UINT64(env.msr_hv_hypercall, X86CPU),
572
        VMSTATE_UINT64(env.msr_hv_guest_os_id, X86CPU),
573
        VMSTATE_END_OF_LIST()
574
    }
575
};
576

  
557 577
const VMStateDescription vmstate_x86_cpu = {
558 578
    .name = "cpu",
559 579
    .version_id = 12,
......
688 708
        } , {
689 709
            .vmsd = &vmstate_mpx,
690 710
            .needed = mpx_needed,
711
        }, {
712
            .vmsd = &vmstate_msr_hypercall_hypercall,
713
            .needed = hyperv_hypercall_enable_needed,
691 714
        } , {
692 715
            /* empty */
693 716
        }

Also available in: Unified diff