From ff99aa64b13ea85ee35ec09c3fe720ad8bc83154 Mon Sep 17 00:00:00 2001 From: Andrey Smetanin Date: Wed, 25 Nov 2015 18:21:25 +0300 Subject: target-i386/kvm: Hyper-V SynIC timers MSR's support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hyper-V SynIC timers are host timers that are configurable by guest through corresponding MSR's (HV_X64_MSR_STIMER*). Guest setup and use fired by host events(SynIC interrupt and appropriate timer expiration message) as guest clock events. The state of Hyper-V SynIC timers are stored in corresponding MSR's. This patch seria implements such MSR's support and migration. Signed-off-by: Andrey Smetanin CC: Paolo Bonzini CC: Richard Henderson CC: Eduardo Habkost CC: "Andreas Färber" CC: Marcelo Tosatti CC: Denis V. Lunev CC: Roman Kagan CC: kvm@vger.kernel.org Message-Id: <1448464885-8300-3-git-send-email-asmetanin@virtuozzo.com> Signed-off-by: Paolo Bonzini --- target-i386/machine.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'target-i386/machine.c') diff --git a/target-i386/machine.c b/target-i386/machine.c index d41e286ba4..6126d96d7f 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -746,6 +746,34 @@ static const VMStateDescription vmstate_msr_hyperv_synic = { } }; +static bool hyperv_stimer_enable_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + int i; + + for (i = 0; i < ARRAY_SIZE(env->msr_hv_stimer_config); i++) { + if (env->msr_hv_stimer_config[i] || env->msr_hv_stimer_count[i]) { + return true; + } + } + return false; +} + +static const VMStateDescription vmstate_msr_hyperv_stimer = { + .name = "cpu/msr_hyperv_stimer", + .version_id = 1, + .minimum_version_id = 1, + .needed = hyperv_stimer_enable_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT64_ARRAY(env.msr_hv_stimer_config, + X86CPU, HV_SYNIC_STIMER_COUNT), + VMSTATE_UINT64_ARRAY(env.msr_hv_stimer_count, + X86CPU, HV_SYNIC_STIMER_COUNT), + VMSTATE_END_OF_LIST() + } +}; + static bool avx512_needed(void *opaque) { X86CPU *cpu = opaque; @@ -930,6 +958,7 @@ VMStateDescription vmstate_x86_cpu = { &vmstate_msr_hyperv_crash, &vmstate_msr_hyperv_runtime, &vmstate_msr_hyperv_synic, + &vmstate_msr_hyperv_stimer, &vmstate_avx512, &vmstate_xss, NULL -- cgit 1.4.1