lkml.org 
[lkml]   [2008]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Use CPUID to communicate with the hypervisor.
  Hi,

> +unsigned long hypervisor_tsc_freq(void)
> +{
> + unsigned long tsc_khz;
> + unsigned int max_cpuid_leaf;
> +
> + if (cpu_has_hypervisor) {
> + max_cpuid_leaf = cpuid_eax(HYPERVISOR_INFO_LEAF);
> + if (max_cpuid_leaf >= HYPERVISOR_TIMING_LEAF) {
> + tsc_khz = cpuid_eax(HYPERVISOR_TIMING_LEAF);
> + printk(KERN_INFO
> + "TSC frequency read from hypervisor\n");
> + return tsc_khz;
> + }
> + }
> + return 0;
> +}

Shouldn't you check the hypervisor signature here?

> /*
> + * Intel & AMD have reserved the cpuid levels 0x40000000 - 0x400000FF for
> + * software use. Hypervisors can use these levels to provide an interface
> + * to pass information from the hypervisor to the guest. This is similar
> + * to how we extract information about a physical cpu by using cpuid.
> + */
> +
> +/*
> + * This CPUID leaf returns the information about the hypervisor.
> + * EAX : maximum input value for CPUID supported by the hypervisor.
> + * EBX, ECX, EDX : Hypervisor vendor ID signature. E.g. VMwareVMware.
> + */
> +#define HYPERVISOR_INFO_LEAF 0x40000000
> +/*
> + * This leaf gets timing information from the hypervisor.info.
> + * EAX: (Virtual) TSC frequency in kHz.
> + * EBX: (Virtual) Bus (local apic timer) frequency in kHz.
> + * ECX, EDX: RESERVED
> + */
> +#define HYPERVISOR_TIMING_LEAF 0x40000010

Likewise, I think this should be HYPERVISOR_VMWARE_TIMING_LEAF.

Or we need some way to
(a) standardize hypervisor cpuid leafes (or parts of it) and
(b) handle sparsely filled cpuid info.

Right now both kvm and xen use the first one or two leafes (after info),
but in incompatible ways, so for these the signature *must* be checked
before using the info found there.

0x40000010 doesn't clash with anything as far I know, so we could
attempt to make that standard accross hypervisors.

cheers,
Gerd


\
 
 \ /
  Last update: 2008-09-29 10:31    [W:0.159 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site