From f28558d3d37ad3bc4e35e8ac93f7bf81a0d5622c Mon Sep 17 00:00:00 2001 From: Will Auld Date: Mon, 26 Nov 2012 21:32:18 -0800 Subject: target-i386: Enabling IA32_TSC_ADJUST for QEMU KVM guest VMs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CPUID.7.0.EBX[1]=1 indicates IA32_TSC_ADJUST MSR 0x3b is supported Basic design is to emulate the MSR by allowing reads and writes to the hypervisor vcpu specific locations to store the value of the emulated MSRs. In this way the IA32_TSC_ADJUST value will be included in all reads to the TSC MSR whether through rdmsr or rdtsc. As this is a new MSR that the guest may access and modify its value needs to be migrated along with the other MRSs. The changes here are specifically for recognizing when IA32_TSC_ADJUST is enabled in CPUID and code added for migrating its value. Signed-off-by: Will Auld Reviewed-by: Andreas Färber Signed-off-by: Marcelo Tosatti --- target-i386/machine.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'target-i386/machine.c') diff --git a/target-i386/machine.c b/target-i386/machine.c index 477150887b..4229ddeac8 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -328,6 +328,24 @@ static const VMStateDescription vmstate_fpop_ip_dp = { } }; +static bool tsc_adjust_needed(void *opaque) +{ + CPUX86State *env = opaque; + + return env->tsc_adjust != 0; +} + +static const VMStateDescription vmstate_msr_tsc_adjust = { + .name = "cpu/msr_tsc_adjust", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT64(tsc_adjust, CPUX86State), + VMSTATE_END_OF_LIST() + } +}; + static bool tscdeadline_needed(void *opaque) { CPUX86State *env = opaque; @@ -477,6 +495,9 @@ static const VMStateDescription vmstate_cpu = { } , { .vmsd = &vmstate_fpop_ip_dp, .needed = fpop_ip_dp_needed, + }, { + .vmsd = &vmstate_msr_tsc_adjust, + .needed = tsc_adjust_needed, }, { .vmsd = &vmstate_msr_tscdeadline, .needed = tscdeadline_needed, -- cgit 1.4.1