On Tue, Mar 10, 2020 at 01:54:09AM +0200, Liran Alon wrote: > No functional change. > This information will be used by following patches. > > Reviewed-by: Nikita Leshenko <nikita.leshche...@oracle.com> > Signed-off-by: Liran Alon <liran.a...@oracle.com> > --- > linux-headers/asm-x86/kvm.h | 4 ++++ > target/i386/cpu.h | 1 + > target/i386/kvm.c | 6 +++--- > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h > index 503d3f42da16..99eeaaf2f0b4 100644 > --- a/linux-headers/asm-x86/kvm.h > +++ b/linux-headers/asm-x86/kvm.h > @@ -446,4 +446,8 @@ struct kvm_pmu_event_filter { > #define KVM_PMU_EVENT_ALLOW 0 > #define KVM_PMU_EVENT_DENY 1 > > +/* From arch/x86/kvm/lapic.h */ > +#define KVM_APIC_BUS_CYCLE_NS 1 > +#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) > + > #endif /* _ASM_X86_KVM_H */
This header is auto-generated from UAPI - you can't add your own stuff here. > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > index 576f309bbfc8..9c7cd7cde107 100644 > --- a/target/i386/cpu.h > +++ b/target/i386/cpu.h > @@ -1580,6 +1580,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 69eb43d796e6..00917196dffb 100644 > --- a/target/i386/kvm.c > +++ b/target/i386/kvm.c > @@ -1496,6 +1496,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) { > @@ -1800,9 +1802,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); > -- > 2.20.1