From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 2/2] expose kvm pv features
Date: Thu, 5 Feb 2009 10:35:07 -0500 [thread overview]
Message-ID: <1233848107-9331-3-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1233848107-9331-2-git-send-email-glommer@redhat.com>
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 <glommer@redhat.com>
---
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 <linux/kvm.h>
+#include <linux/kvm_para.h>
extern int kvm_allowed;
#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);
--
1.5.6.5
next prev parent reply other threads:[~2009-02-05 15:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 15:35 [Qemu-devel] [PATCH 0/2] Expose KVM pv features Glauber Costa
2009-02-05 15:35 ` [Qemu-devel] [PATCH 1/2] Factor out common code in filling cpuid code Glauber Costa
2009-02-05 15:35 ` Glauber Costa [this message]
2009-02-06 18:46 ` [Qemu-devel] Re: [PATCH 2/2] expose kvm pv features Anthony Liguori
2009-02-06 18:53 ` Glauber Costa
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=1233848107-9331-3-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).