mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-22 17:42:10 -06:00
target-i386: Enabling IA32_TSC_ADJUST for QEMU KVM guest VMs
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 <will.auld@intel.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
parent
e376a788ae
commit
f28558d3d3
3 changed files with 37 additions and 0 deletions
|
@ -62,6 +62,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
|||
|
||||
static bool has_msr_star;
|
||||
static bool has_msr_hsave_pa;
|
||||
static bool has_msr_tsc_adjust;
|
||||
static bool has_msr_tsc_deadline;
|
||||
static bool has_msr_async_pf_en;
|
||||
static bool has_msr_pv_eoi_en;
|
||||
|
@ -676,6 +677,10 @@ static int kvm_get_supported_msrs(KVMState *s)
|
|||
has_msr_hsave_pa = true;
|
||||
continue;
|
||||
}
|
||||
if (kvm_msr_list->indices[i] == MSR_TSC_ADJUST) {
|
||||
has_msr_tsc_adjust = true;
|
||||
continue;
|
||||
}
|
||||
if (kvm_msr_list->indices[i] == MSR_IA32_TSCDEADLINE) {
|
||||
has_msr_tsc_deadline = true;
|
||||
continue;
|
||||
|
@ -1013,6 +1018,9 @@ static int kvm_put_msrs(CPUX86State *env, int level)
|
|||
if (has_msr_hsave_pa) {
|
||||
kvm_msr_entry_set(&msrs[n++], MSR_VM_HSAVE_PA, env->vm_hsave);
|
||||
}
|
||||
if (has_msr_tsc_adjust) {
|
||||
kvm_msr_entry_set(&msrs[n++], MSR_TSC_ADJUST, env->tsc_adjust);
|
||||
}
|
||||
if (has_msr_tsc_deadline) {
|
||||
kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
|
||||
}
|
||||
|
@ -1273,6 +1281,9 @@ static int kvm_get_msrs(CPUX86State *env)
|
|||
if (has_msr_hsave_pa) {
|
||||
msrs[n++].index = MSR_VM_HSAVE_PA;
|
||||
}
|
||||
if (has_msr_tsc_adjust) {
|
||||
msrs[n++].index = MSR_TSC_ADJUST;
|
||||
}
|
||||
if (has_msr_tsc_deadline) {
|
||||
msrs[n++].index = MSR_IA32_TSCDEADLINE;
|
||||
}
|
||||
|
@ -1350,6 +1361,9 @@ static int kvm_get_msrs(CPUX86State *env)
|
|||
case MSR_IA32_TSC:
|
||||
env->tsc = msrs[i].data;
|
||||
break;
|
||||
case MSR_TSC_ADJUST:
|
||||
env->tsc_adjust = msrs[i].data;
|
||||
break;
|
||||
case MSR_IA32_TSCDEADLINE:
|
||||
env->tsc_deadline = msrs[i].data;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue