Re: Use CPUID to communicate with the hypervisor.

From: Gerd Hoffmann
Date: Mon Sep 29 2008 - 14:47:14 EST


Alok Kataria wrote:
> Hi Gerd,
>
>> Shouldn't you check the hypervisor signature here?
>
> Nope the whole idea of not checking the hypervisor signature is that we
> should keep this interface generic.

Nice idea. Problem with that is that approach is that we don't have
full control here. It probably isn't that a hard to have vmware, xen
and kvm agree here, given vmware proposes this and for xen+kvm one can
send patches. But even that you can't take for granted, see the
discussion of the "tsc-may-change-on-migration" problem.

The real big problem are other closed-source hypervisors (VirtualPC /
Hyper-V / Parallels / ...). How can we be sure they don't define that
leaf to something different?

> Also one thing to remember is, that a hypervisor can decide to not
> implement this level and just return "0" the kernel can then just ignore
> that value. That's what we do currently in native_calibrate_tsc.

The fudamental issue outlined above aside: Even the "ignore 0" part
isn't in the patch right now.

>> 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.
>
> Hmm that's unfortunate, but we can have exceptions for these one of
> cases and AFAIK these are only checked in the kvm/xen code path and not
> in any generic code as of now, right ?

Yes.

> btw, i could only find the semantics for 0x40000001 leaf in KVM's header
> file but don't see Xen using that leaf, can you please point me which
> leafs are you referring to here.

pv drivers in hvm guests use that (and query very xen-specific stuff
which wouldn't make much sense in other hypervisors). It isn't in the
kernel source tree, look here instead:

http://xenbits.xensource.com/xen-3.3-testing.hg?file/19201eebab16/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c

cheers,
Gerd


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/