From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LVViu-0006WN-GY for qemu-devel@nongnu.org; Fri, 06 Feb 2009 13:46:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LVVir-0006TK-Il for qemu-devel@nongnu.org; Fri, 06 Feb 2009 13:46:43 -0500 Received: from [199.232.76.173] (port=60466 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVVir-0006T3-DL for qemu-devel@nongnu.org; Fri, 06 Feb 2009 13:46:41 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:51422) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LVViq-0002f3-Tk for qemu-devel@nongnu.org; Fri, 06 Feb 2009 13:46:41 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e35.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n16IhP2l024403 for ; Fri, 6 Feb 2009 11:43:25 -0700 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n16Ikc0G206444 for ; Fri, 6 Feb 2009 11:46:38 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n16IkcLr012137 for ; Fri, 6 Feb 2009 11:46:38 -0700 Message-ID: <498C857A.5040000@us.ibm.com> Date: Fri, 06 Feb 2009 12:46:18 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1233848107-9331-1-git-send-email-glommer@redhat.com> <1233848107-9331-2-git-send-email-glommer@redhat.com> <1233848107-9331-3-git-send-email-glommer@redhat.com> In-Reply-To: <1233848107-9331-3-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/2] expose kvm pv features Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: qemu-devel@nongnu.org Glauber Costa wrote: > expose kvm paravirtual features into cpuid. This enables > the use of kvmclock in qemu guests. (and all the other > features too). > > Signed-off-by: Glauber Costa > --- > kvm.h | 5 +++++ > target-i386/kvm.c | 29 +++++++++++++++++++++++++++++ > 2 files changed, 34 insertions(+), 0 deletions(-) > > diff --git a/kvm.h b/kvm.h > index efce145..49a2653 100644 > --- a/kvm.h > +++ b/kvm.h > @@ -17,6 +17,8 @@ > #include "config.h" > > #ifdef CONFIG_KVM > +#include > +#include > extern int kvm_allowed; > This breaks the build in an admittedly subtle way. kvm.h is included in various c files throughout QEMU. However, in Makefile.target, we have: kvm.o: CFLAGS+=$(KVM_CFLAGS) kvm-all.o: CFLAGS+=$(KVM_CFLAGS) And KVM_CFLAGS contains flags derived from --kerneldir. But now you're relying on all C files being able to pull in kernel headers. Looking at the patch, why put this includes in kvm.h at all? Regards, Anthony Liguori > #define kvm_enabled() (kvm_allowed) > @@ -76,4 +78,7 @@ int kvm_arch_init(KVMState *s, int smp_cpus); > > int kvm_arch_init_vcpu(CPUState *env); > > +/* x86 specific */ > +uint32_t kvm_get_para_features(CPUState *env); > + > #endif > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 4a55931..736ee38 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -33,6 +33,33 @@ > do { } while (0) > #endif > > +static struct kvm_para_features { > + int cap; > + int feature; > +} para_features[] = { > +#ifdef KVM_CAP_CLOCKSOURCE > + { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE }, > +#endif > +#ifdef KVM_CAP_NOP_IO_DELAY > + { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY }, > +#endif > +#ifdef KVM_CAP_PV_MMU > + { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP }, > +#endif > +}; > + > +uint32_t kvm_get_para_features(CPUState *env) > + { > + uint32_t i, features = 0; > + > + for (i = 0; i < ARRAY_SIZE(para_features); i++) { > + if (kvm_ioctl(env->kvm_state, KVM_CHECK_EXTENSION, para_features[i].cap)) > + features |= (1 << para_features[i].feature); > + } > + > + return features; > +} > + > typedef struct { > struct kvm_cpuid cpuid; > struct kvm_cpuid_entry entries[100]; > @@ -69,6 +96,8 @@ int kvm_arch_init_vcpu(CPUState *env) > > kvm_fill_cpuid(env, &cpuid_data, 0, limit); > > + kvm_fill_cpuid(env, &cpuid_data, KVM_CPUID_SIGNATURE, KVM_CPUID_FEATURES); > + > cpu_x86_cpuid(env, 0x80000000, &eax, &ebx, &ecx, &edx); > limit = eax; > kvm_fill_cpuid(env, &cpuid_data, 0x80000000, limit); >