From: Marcelo Tosatti <marcelo@kvack.org>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>
Subject: [PATCH] QEMU/KVM: report paravirt features on cpuid
Date: Fri, 22 Feb 2008 14:34:37 -0300 [thread overview]
Message-ID: <20080222173437.GA11384@dmt> (raw)
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/
reply other threads:[~2008-02-22 17:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080222173437.GA11384@dmt \
--to=marcelo@kvack.org \
--cc=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox