From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Alexander Graf <agraf@suse.de>,
kvm@vger.kernel.org, Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 2/2] QEMU-KVM: Ask kernel about supported svm features
Date: Wed, 3 Mar 2010 20:15:42 +0100 [thread overview]
Message-ID: <1267643742-616-3-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1267643742-616-1-git-send-email-joerg.roedel@amd.com>
This patch adds code to ask the kernel about the svm
features it supports for its guests and propagates them to
the guest. The new capability is necessary because the old
behavior of the kernel was to just return the host svm
features but every svm-feature needs emulation in the nested
svm kernel code. The new capability indicates that the
kernel is aware of that when returning svm cpuid
information.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
kvm/include/linux/kvm.h | 2 ++
qemu-kvm-x86.c | 15 +++++++++++++--
target-i386/cpu.h | 2 ++
target-i386/helper.c | 2 +-
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/kvm/include/linux/kvm.h b/kvm/include/linux/kvm.h
index 6485981..aeb2c9b 100644
--- a/kvm/include/linux/kvm.h
+++ b/kvm/include/linux/kvm.h
@@ -500,6 +500,8 @@ struct kvm_ioeventfd {
#define KVM_CAP_PCI_SEGMENT 47
+#define KVM_CAP_SVM_CPUID_FIXED 52
+
#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing_irqchip {
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 7a5925a..60e6d26 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1291,8 +1291,19 @@ int kvm_arch_init_vcpu(CPUState *cenv)
qemu_kvm_cpuid_on_env(©);
limit = copy.regs[R_EAX];
- for (i = 0x80000000; i <= limit; ++i)
- do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, ©);
+ for (i = 0x80000000; i <= limit; ++i) {
+ do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, ©);
+ switch (i) {
+ case 0x8000000a:
+ if (!kvm_check_extension(kvm_state, KVM_CAP_SVM_CPUID_FIXED))
+ break;
+ cpuid_ent[cpuid_nent].eax = kvm_arch_get_supported_cpuid(cenv, 0x8000000a, R_EAX);
+ cpuid_ent[cpuid_nent].ebx = kvm_arch_get_supported_cpuid(cenv, 0x8000000a, R_EBX);
+ cpuid_ent[cpuid_nent].edx = kvm_arch_get_supported_cpuid(cenv, 0x8000000a, R_EDX);
+ break;
+ }
+ cpuid_nent += 1;
+ }
kvm_setup_cpuid2(cenv, cpuid_nent, cpuid_ent);
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index b64bd02..adcc19f 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -421,6 +421,8 @@
#define CPUID_EXT3_IBS (1 << 10)
#define CPUID_EXT3_SKINIT (1 << 12)
+#define CPUID_SVM_NPT (1 << 0)
+
#define CPUID_VENDOR_INTEL_1 0x756e6547 /* "Genu" */
#define CPUID_VENDOR_INTEL_2 0x49656e69 /* "ineI" */
#define CPUID_VENDOR_INTEL_3 0x6c65746e /* "ntel" */
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 73d8389..109f656 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -2220,7 +2220,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
*eax = 0x00000001; /* SVM Revision */
*ebx = 0x00000010; /* nr of ASIDs */
*ecx = 0;
- *edx = 0; /* optional features */
+ *edx = 0;
break;
default:
/* reserved values: zero */
--
1.7.0
next prev parent reply other threads:[~2010-03-03 19:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 19:15 [PATCH 0/2][RFC] Nested Paging support for Nested SVM (userspace part) Joerg Roedel
2010-03-03 19:15 ` [PATCH 1/2] QEMU-KVM: Fix ext3_feature propagation Joerg Roedel
2010-03-03 19:15 ` Joerg Roedel [this message]
2010-03-03 22:58 ` [PATCH 2/2] QEMU-KVM: Ask kernel about supported svm features Alexander Graf
2010-03-04 11:40 ` Joerg Roedel
2010-03-04 11:44 ` Alexander Graf
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=1267643742-616-3-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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