Skip to contentSkip to conversation

Nested Virtualization: efer

PATCH In review Christoph Egger 1 participant 1 message Apr 15, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 10/18 Nested Virtualization: efer

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

# HG changeset patch
# User cegger
# Date 1271330303 -7200
Allow guest to enable SVM in EFER

xen/arch/x86/hvm/hvm.c +14 -3
diff -r c7f560bcc31f -r e905f1d81e63 xen/arch/x86/hvm/hvm.c
@@ -52,6 +52,7 @@
 #include <asm/hvm/support.h>
 #include <asm/hvm/cacheattr.h>
 #include <asm/hvm/trace.h>
+#include <asm/hvm/nestedhvm.h>
 #include <asm/mtrr.h>
 #include <public/sched.h>
 #include <public/hvm/ioreq.h>
@@ -587,6 +588,7 @@ static bool_t hvm_efer_valid(uint64_t va
 {
     return !((value & ~efer_validbits) ||
              ((sizeof(long) != 8) && (value & EFER_LME)) ||
+             (!cpu_has_svm && (value & EFER_SVME)) ||
              (!cpu_has_nx && (value & EFER_NX)) ||
              (!cpu_has_syscall && (value & EFER_SCE)) ||
              (!cpu_has_ffxsr && (value & EFER_FFXSE)) ||
@@ -600,6 +602,7 @@ static int hvm_load_cpu_ctxt(struct doma
     struct hvm_hw_cpu ctxt;
     struct segment_register seg;
     struct vcpu_guest_context *vc;
+    uint64_t efer_validbits;
 
     /* Which vcpu is this? */
     vcpuid = hvm_load_instance(h);
@@ -639,8 +642,11 @@ static int hvm_load_cpu_ctxt(struct doma
         return -EINVAL;
     }
 
-    if ( !hvm_efer_valid(
-        ctxt.msr_efer, EFER_FFXSE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE;
+    if ( nestedhvm_enabled(v->domain) )
+        efer_validbits |= EFER_SVME;
+
+    if ( !hvm_efer_valid(ctxt.msr_efer, efer_validbits) )
     {
         gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
                  ctxt.msr_efer);
@@ -992,10 +998,15 @@ bool_t hvm_hap_nested_page_fault(unsigne
 int hvm_set_efer(uint64_t value)
 {
     struct vcpu *v = current;
+    uint64_t efer_validbits;
 
     value &= ~EFER_LMA;
 
-    if ( !hvm_efer_valid(value, EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE;
+    if ( nestedhvm_enabled(v->domain) )
+        efer_validbits |= EFER_SVME;
+
+    if ( !hvm_efer_valid(value, efer_validbits) )
     {
         gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
                  "EFER: %"PRIx64"\n", value);
xen/include/asm-x86/cpufeature.h +2 -0
diff -r c7f560bcc31f -r e905f1d81e63 xen/include/asm-x86/cpufeature.h
@@ -198,6 +198,8 @@
 
 #define cpu_has_rdtscp          boot_cpu_has(X86_FEATURE_RDTSCP)
 
+#define cpu_has_svm             boot_cpu_has(X86_FEATURE_SVME)
+
 #endif /* __ASM_I386_CPUFEATURE_H */
 
 /* 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel