RE: [kvm-devel] [PATCH 2/3] Refactor hypercall infrastructure (v3)

From: Nakajima, Jun
Date: Mon Sep 17 2007 - 17:57:31 EST


Anthony Liguori wrote:
> This patch refactors the current hypercall infrastructure to better
support
> live
> migration and SMP. It eliminates the hypercall page by trapping the
UD
> exception that would occur if you used the wrong hypercall instruction
for the
> underlying architecture and replacing it with the right one lazily.
>
> It also introduces the infrastructure to probe for hypercall available
via
> CPUID leaves 0x40000000. CPUID leaf 0x40000001 should be filled out
by
> userspace.
>
> A fall-out of this patch is that the unhandled hypercalls no longer
trap to
> userspace. There is very little reason though to use a hypercall to
> communicate
> with userspace as PIO or MMIO can be used. There is no code in tree
that uses
> userspace hypercalls.
>
> Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
>
> diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
> index 3b29256..cc5dfb4 100644
> --- a/include/linux/kvm_para.h
> +++ b/include/linux/kvm_para.h
> @@ -1,73 +1,110 @@
> #ifndef __LINUX_KVM_PARA_H
> #define __LINUX_KVM_PARA_H
>
> -/*
> - * Guest OS interface for KVM paravirtualization
> - *
> - * Note: this interface is totally experimental, and is certain to
change
> - * as we make progress.
> +/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx.
It
> + * should be used to determine that a VM is running under KVM.

<snip>

> +
> +static inline int kvm_para_available(void)
> +{
> + unsigned int eax, ebx, ecx, edx;
> + char signature[13];
> +
> + cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
> + memcpy(signature + 0, &ebx, 4);
> + memcpy(signature + 4, &ecx, 4);
> + memcpy(signature + 8, &edx, 4);
> + signature[12] = 0;
> +
> + if (strcmp(signature, "KVMKVMKVM") == 0)

> + return 1;
> +
> + return 0;
> +}

I think we should compare 12 characters (not just 9, as far as my eyes
tell), and can we use some cute one, like "FantasticKVM"? ;-)

Jun
---
Intel Open Source Technology Center
-
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/