From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 4/4] kvm pv features PART I
Date: Thu, 29 Jan 2009 12:19:29 -0500 [thread overview]
Message-ID: <1233249569-16686-5-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1233249569-16686-4-git-send-email-glommer@redhat.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
kvm.h | 5 +++++
target-i386/helper.c | 19 ++++++++++++++++++-
target-i386/kvm.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 1 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/helper.c b/target-i386/helper.c
index 1410002..6bcd94d 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1405,7 +1405,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t *ecx, uint32_t *edx)
{
/* test if maximum index reached */
- if (index & 0x80000000) {
+ if (index & 0x40000000) {
+ /* Those are KVM-specific, dodge them without messing with
+ * exposed cpuid_level */
+ } else if (index & 0x80000000) {
if (index > env->cpuid_xlevel)
index = env->cpuid_level;
} else {
@@ -1511,6 +1514,20 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
*ecx = 0;
*edx = 0;
break;
+ case 0x40000000:
+ if (kvm_enabled()) {
+ /* KVM CPUID signature */
+ *eax = 0;
+ *ebx = 0x4b4d564b; /* KVMKVMK */
+ *ecx = 0x564b4d56; /* VMKV */
+ *edx = 0x0000004d; /* M */
+ }
+ break;
+ case 0x40000001:
+ if (kvm_enabled()) {
+ *eax = kvm_get_para_features(env);
+ }
+ break;
case 0x80000000:
*eax = env->cpuid_xlevel;
*ebx = env->cpuid_vendor1;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 64b24db..c9f0272 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -56,6 +56,36 @@ static void kvm_fill_cpuid(CPUState *env, KVMCpuid *cpuid_data,
}
}
+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
+#ifdef KVM_CAP_CR3_CACHE
+ { KVM_CAP_CR3_CACHE, KVM_FEATURE_CR3_CACHE },
+#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;
+}
+
int kvm_arch_init_vcpu(CPUState *env)
{
KVMCpuid cpuid_data;
--
1.5.6.5
next prev parent reply other threads:[~2009-01-29 17:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 17:19 [Qemu-devel] [PATCH 0/4] Improve cpuid x86 code Glauber Costa
2009-01-29 17:19 ` [Qemu-devel] [PATCH 1/4] convert cpuid registration to KVM_SET_CPUID2 Glauber Costa
2009-01-29 17:19 ` [Qemu-devel] [PATCH 2/4] Factor out common code in filling cpuid code Glauber Costa
2009-01-29 17:19 ` [Qemu-devel] [PATCH 3/4] mask out forbidden cpuid features with kvm ioctl Glauber Costa
2009-01-29 17:19 ` Glauber Costa [this message]
2009-01-29 19:17 ` [Qemu-devel] [PATCH 4/4] kvm pv features PART I Glauber Costa
2009-01-29 20:50 ` [Qemu-devel] Re: [PATCH 3/4] mask out forbidden cpuid features with kvm ioctl Anthony Liguori
2009-01-30 12:37 ` Glauber Costa
2009-02-03 21:25 ` Avi Kivity
2009-02-04 6:26 ` Amit Shah
2009-02-03 21:27 ` Avi Kivity
2009-02-03 21:36 ` Anthony Liguori
2009-01-30 10:15 ` [Qemu-devel] [PATCH 0/4] Improve cpuid x86 code Amit Shah
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=1233249569-16686-5-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).