aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorLiran Alon <liran.alon@oracle.com>2020-03-12 18:54:29 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-10 12:09:52 -0400
commit73b994f6d74ec00a1d78daf4145096ff9f0e2982 (patch)
tree8ba6cb0144dc11c0091ce8bca56eababdbf46fb0 /target
parent7f9114b77c285016cb5ac28604b9923cbac43ddf (diff)
downloadqemu-73b994f6d74ec00a1d78daf4145096ff9f0e2982.zip
qemu-73b994f6d74ec00a1d78daf4145096ff9f0e2982.tar.gz
qemu-73b994f6d74ec00a1d78daf4145096ff9f0e2982.tar.bz2
i386/cpu: Store LAPIC bus frequency in CPU structure
No functional change. This information will be used by following patches. Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Message-Id: <20200312165431.82118-15-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target')
-rw-r--r--target/i386/cpu.h1
-rw-r--r--target/i386/kvm.c10
2 files changed, 8 insertions, 3 deletions
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 408392d..00d1f4f 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1584,6 +1584,7 @@ typedef struct CPUX86State {
bool tsc_valid;
int64_t tsc_khz;
int64_t user_tsc_khz; /* for sanity check only */
+ uint64_t apic_bus_freq;
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
void *xsave_buf;
#endif
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 34f8387..95bbeb4 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -59,6 +59,10 @@
do { } while (0)
#endif
+/* From arch/x86/kvm/lapic.h */
+#define KVM_APIC_BUS_CYCLE_NS 1
+#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS)
+
#define MSR_KVM_WALL_CLOCK 0x11
#define MSR_KVM_SYSTEM_TIME 0x12
@@ -1469,6 +1473,8 @@ int kvm_arch_init_vcpu(CPUState *cs)
}
}
+ env->apic_bus_freq = KVM_APIC_BUS_FREQUENCY;
+
/* Paravirtualization CPUIDs */
r = hyperv_handle_properties(cs, cpuid_data.entries);
if (r < 0) {
@@ -1773,9 +1779,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
c = &cpuid_data.entries[cpuid_i++];
c->function = KVM_CPUID_SIGNATURE | 0x10;
c->eax = env->tsc_khz;
- /* LAPIC resolution of 1ns (freq: 1GHz) is hardcoded in KVM's
- * APIC_BUS_CYCLE_NS */
- c->ebx = 1000000;
+ c->ebx = env->apic_bus_freq / 1000; /* Hz to KHz */
c->ecx = c->edx = 0;
c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0);