All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 07/12] Nested Virtualization: efer
@ 2010-12-20 16:08 Christoph Egger
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Egger @ 2010-12-20 16:08 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]


-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_nh07_efer.diff --]
[-- Type: text/x-diff, Size: 2730 bytes --]

# HG changeset patch
# User cegger
# Date 1292839437 -3600
Allow guest to enable SVM in EFER

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

diff -r 2ec7ded683f7 -r 496c029072b1 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -616,10 +616,15 @@ static int hvm_save_cpu_ctxt(struct doma
     return 0;
 }
 
-static bool_t hvm_efer_valid(uint64_t value, uint64_t efer_validbits)
+static bool_t hvm_efer_valid(struct domain *d,
+                             uint64_t value, uint64_t efer_validbits)
 {
+    if ( nestedhvm_enabled(d) && cpu_has_svm )
+        efer_validbits |= EFER_SVME;
+
     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_lmsl && (value & EFER_LMSLE)) ||
@@ -634,6 +639,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);
@@ -673,9 +679,9 @@ static int hvm_load_cpu_ctxt(struct doma
         return -EINVAL;
     }
 
-    if ( !hvm_efer_valid(
-        ctxt.msr_efer,
-        EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA
+                   | EFER_NX | EFER_SCE;
+    if ( !hvm_efer_valid(d, ctxt.msr_efer, efer_validbits) )
     {
         gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
                  ctxt.msr_efer);
@@ -1214,14 +1220,15 @@ err:
 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_LMSLE | EFER_LME | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_NX | EFER_SCE;
+    if ( !hvm_efer_valid(v->domain, value, efer_validbits) )
     {
         gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
-                 "EFER: %"PRIx64"\n", value);
+                 "EFER: 0x%"PRIx64"\n", value);
         hvm_inject_exception(TRAP_gp_fault, 0, 0);
         return X86EMUL_EXCEPTION;
     }
diff -r 2ec7ded683f7 -r 496c029072b1 xen/include/asm-x86/cpufeature.h
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -204,6 +204,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 */
 
 /* 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH 07/12] Nested Virtualization: efer
@ 2011-03-09 14:24 Christoph Egger
  2011-03-29  6:51 ` Dong, Eddie
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Egger @ 2011-03-09 14:24 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]


-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_nh07_efer.diff --]
[-- Type: text/x-diff, Size: 2729 bytes --]

# HG changeset patch
# User cegger
# Date 1298892114 -3600
Allow guest to enable SVM in EFER

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

diff -r 9707e7a215bd -r cccf815a82a7 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -627,10 +627,15 @@ static int hvm_save_cpu_ctxt(struct doma
     return 0;
 }
 
-static bool_t hvm_efer_valid(uint64_t value, uint64_t efer_validbits)
+static bool_t hvm_efer_valid(struct domain *d,
+                             uint64_t value, uint64_t efer_validbits)
 {
+    if ( nestedhvm_enabled(d) && cpu_has_svm )
+        efer_validbits |= EFER_SVME;
+
     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_lmsl && (value & EFER_LMSLE)) ||
@@ -645,6 +650,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);
@@ -684,9 +690,9 @@ static int hvm_load_cpu_ctxt(struct doma
         return -EINVAL;
     }
 
-    if ( !hvm_efer_valid(
-        ctxt.msr_efer,
-        EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA
+                   | EFER_NX | EFER_SCE;
+    if ( !hvm_efer_valid(d, ctxt.msr_efer, efer_validbits) )
     {
         gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
                  ctxt.msr_efer);
@@ -1278,14 +1284,15 @@ err:
 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_LMSLE | EFER_LME | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_NX | EFER_SCE;
+    if ( !hvm_efer_valid(v->domain, value, efer_validbits) )
     {
         gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
-                 "EFER: %"PRIx64"\n", value);
+                 "EFER: 0x%"PRIx64"\n", value);
         hvm_inject_exception(TRAP_gp_fault, 0, 0);
         return X86EMUL_EXCEPTION;
     }
diff -r 9707e7a215bd -r cccf815a82a7 xen/include/asm-x86/cpufeature.h
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -211,6 +211,8 @@
 
 #define cpu_has_rdtscp          boot_cpu_has(X86_FEATURE_RDTSCP)
 
+#define cpu_has_svm		boot_cpu_has(X86_FEATURE_SVM)
+
 #endif /* __ASM_I386_CPUFEATURE_H */
 
 /* 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-29  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-20 16:08 [PATCH 07/12] Nested Virtualization: efer Christoph Egger
  -- strict thread matches above, loose matches on Subject: below --
2011-03-09 14:24 Christoph Egger
2011-03-29  6:51 ` Dong, Eddie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.