Re: Could anybody give some description about the implement ofhyercall in kvm?

From: Stefan Hajnoczi
Date: Fri Jan 13 2012 - 05:12:06 EST


On Fri, Jan 13, 2012 at 7:45 AM, Liu ping fan <kernelfans@xxxxxxxxx> wrote:
> On Thu, Jan 12, 2012 at 5:21 PM, Stefan Hajnoczi <stefanha@xxxxxxxxx> wrote:
>> On Thu, Jan 12, 2012 at 4:38 AM, Liu ping fan <kernelfans@xxxxxxxxx> wrote:
>>> Could anybody give some description about the implement of hyercall in
>>> kvm? Or give some links about it?
>>
>> Try git grep hypercall arch/x86/kvm.
>>
>> Take a look at arch/x86/kvm/x86.c kvm_set_msr_common() and
>> kvm_emulate_hypercall().  Some of the KVM time-keeping, minimal HyperV
>> support, and async page faults live there.  Also see
>> arch/x86/include/asm/kvm_para.h.
>>
>> Hypercalls are architecture-specific so if you are interested in ppc
>> or s390, check those arch directories.
>>
> Thanks, but when I tried to start from the macro "____PVOP_VCALL", but
> lost in it. If there is some document like the hypercall in Xen, this
> will be appreciated. (And I guest Hypercall in kvm is the same as Xen
> which is very similar to syscall, right?)

You can read about paravirt_ops to understand why that layer of
indirection is present:
http://lwn.net/Articles/194543/

But that macro is not the actual hypercall instructions, just a
mechanism for runtime-patching the kernel depending on whether it's
running on bare metal, KVM, Xen, etc.

What you really should look at if you're interested in specific
paravirt features that you are interested in. For example,
arch/x86/kernel/kvmclock.c implements a paravirt clock using
"paravirt" Model Specific Registers and a shared memory region as the
guest<->host interface. So I guess you could say KVM paravirt uses
several mechanisms for host<->guest interaction.

Stefan
--
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/