Skip to contentSkip to conversation

qemu-kvm.git uq/master queue

GIT PULL New Marcelo Tosatti 2 participants 4 messages Jun 1, 2011 – Jun 15, 2011 KVM

lore
Share & tools
lore
#0 lore raw

The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e:

audio: fix integer overflow expression (2011-06-01 00:14:07 +0400)

are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Yang, Wei Y (1):
kvm: Enable CPU SMEP feature

[email protected] (1):
kvm: Add CPUID support for VIA CPU

 target-i386/cpu.h   |    9 ++++++-
 target-i386/cpuid.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/kvm.c   |   15 +++++++++++
 3 files changed, 87 insertions(+), 3 deletions(-)
#2 lore raw

PATCH 2/2 kvm: Enable CPU SMEP feature

From: "Yang, Wei Y" <[email protected]>

This patchset enables a new CPU feature SMEP (Supervisor Mode Execution Protection) in QEMU-KVM. SMEP prevents kernel from executing code in application. Updated Intel SDM describes this CPU feature. The document will be published soon.

SMEP is identified by CPUID leaf 7 EBX[7], which is 0 before. Get the right value by query KVM kernel module, so that guest can get SMEP through CPUID.

---
 target-i386/cpuid.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
target-i386/cpuid.c +13 -0
index 40a73c7..79e7580 100644
@@ -1142,6 +1142,19 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ecx = 0;
         *edx = 0;
         break;
+    case 7:
+        if (kvm_enabled()) {
+            *eax = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EAX);
+            *ebx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EBX);
+            *ecx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_ECX);
+            *edx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EDX);
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
+        break;
     case 9:
         /* Direct Cache Access Information Leaf */
         *eax = 0; /* Bits 0-31 in DCA_CAP MSR */
Signature · 1 line
1.7.5.2
#1 lore raw

PATCH 1/2 kvm: Add CPUID support for VIA CPU

In reply to Marcelo Tosatti

From: "[email protected]" <[email protected]>

When KVM is running on VIA CPU with host cpu's model, the feautures of VIA CPU will be passed into kvm guest by calling the CPUID instruction for Centaur.

---
 target-i386/cpu.h   |    9 +++++++-
 target-i386/cpuid.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/kvm.c   |   15 ++++++++++++++
 3 files changed, 74 insertions(+), 3 deletions(-)
target-i386/cpu.h +8 -1
index 715828f..0b039d4 100644
@@ -438,9 +438,13 @@
 #define CPUID_VENDOR_INTEL_3 0x6c65746e /* "ntel" */
 
 #define CPUID_VENDOR_AMD_1   0x68747541 /* "Auth" */
-#define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */ 
+#define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */
 #define CPUID_VENDOR_AMD_3   0x444d4163 /* "cAMD" */
 
+#define CPUID_VENDOR_VIA_1   0x746e6543 /* "Cent" */
+#define CPUID_VENDOR_VIA_2   0x48727561 /* "aurH" */
+#define CPUID_VENDOR_VIA_3   0x736c7561 /* "auls" */
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */
 
@@ -730,6 +734,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     int cpuid_vendor_override;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t cpuid_xlevel2;
+    uint32_t cpuid_ext4_features;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
target-i386/cpuid.c +51 -2

83 lines not on this page · raw message

target-i386/kvm.c +15 -0
index faedc6c..1ae2d61 100644
@@ -482,6 +482,21 @@ int kvm_arch_init_vcpu(CPUState *env)
         cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
     }
 
+    /* Call Centaur's CPUID instructions they are supported. */
+    if (env->cpuid_xlevel2 > 0) {
+        env->cpuid_ext4_features &=
+            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+        cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
+
+        for (i = 0xC0000000; i <= limit; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+
+            c->function = i;
+            c->flags = 0;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+        }
+    }
+
     cpuid_data.cpuid.nent = cpuid_i;
 
 #ifdef KVM_CAP_MCE
Signature · 1 line
1.7.5.2
#3 lore raw
In reply to Marcelo Tosatti
Quoted 3 lines · Marcelo Tosatti

The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e:

audio: fix integer overflow expression (2011-06-01 00:14:07 +0400)

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 16 lines

are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Yang, Wei Y (1):
kvm: Enable CPU SMEP feature

[email protected] (1):
kvm: Add CPUID support for VIA CPU

  target-i386/cpu.h   |    9 ++++++-
  target-i386/cpuid.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++++-
  target-i386/kvm.c   |   15 +++++++++++
  3 files changed, 87 insertions(+), 3 deletions(-)