All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] QEMU/KVM: report paravirt features on cpuid
@ 2008-02-22 17:34 Marcelo Tosatti
  0 siblings, 0 replies; only message in thread
From: Marcelo Tosatti @ 2008-02-22 17:34 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel


Report paravirt features on cpuid.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm-userspace/qemu/qemu-kvm-x86.c
===================================================================
--- kvm-userspace.orig/qemu/qemu-kvm-x86.c
+++ kvm-userspace/qemu/qemu-kvm-x86.c
@@ -20,6 +20,8 @@
 
 #define MSR_IA32_TSC		0x10
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
 static struct kvm_msr_list *kvm_msr_list;
 extern unsigned int kvm_shadow_memory;
 extern kvm_context_t kvm_context;
@@ -493,6 +495,40 @@ static void do_cpuid_ent(struct kvm_cpui
     }
 }
 
+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_MMU_WRITE
+	{ KVM_CAP_MMU_WRITE, KVM_FEATURE_MMU_WRITE },
+#endif
+#ifdef KVM_CAP_MULTICALL
+	{ KVM_CAP_MULTICALL, KVM_FEATURE_MULTICALL },
+#endif
+#ifdef KVM_CAP_CR3_CACHE
+	{ KVM_CAP_CR3_CACHE, KVM_FEATURE_CR3_CACHE },
+#endif
+	{ -1, -1 }
+};
+
+static int get_para_features(kvm_context_t kvm_context)
+{
+	int i, features = 0;
+
+	for (i = 0; i < ARRAY_SIZE(para_features)-1; i++) {
+		if (kvm_check_extension(kvm_context, para_features[i].cap))
+			features |= (1 << para_features[i].feature);
+	}
+
+	return features;
+}
+
 int kvm_arch_qemu_init_env(CPUState *cenv)
 {
     struct kvm_cpuid_entry cpuid_ent[100];
@@ -503,10 +539,6 @@ int kvm_arch_qemu_init_env(CPUState *cen
     int cpuid_nent = 0;
     CPUState copy;
     uint32_t i, limit;
-    int has_clocksource = 0;
-#ifdef KVM_CAP_CLOCKSOURCE
-    has_clocksource = kvm_check_extension(kvm_context, KVM_CAP_CLOCKSOURCE);
-#endif
 
     copy = *cenv;
 
@@ -524,7 +556,7 @@ int kvm_arch_qemu_init_env(CPUState *cen
     pv_ent = &cpuid_ent[cpuid_nent++];
     memset(pv_ent, 0, sizeof(*pv_ent));
     pv_ent->function = KVM_CPUID_FEATURES;
-    pv_ent->eax = (has_clocksource << KVM_FEATURE_CLOCKSOURCE);
+    pv_ent->eax = get_para_features(kvm_context);
 #endif
 
     copy.regs[R_EAX] = 0;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-22 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-22 17:34 [PATCH] QEMU/KVM: report paravirt features on cpuid Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.