All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 7/15] Nested Virtualization: efer
Date: Thu, 3 Jun 2010 18:13:45 +0200	[thread overview]
Message-ID: <201006031813.45559.Christoph.Egger@amd.com> (raw)

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


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

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

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

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

diff -r b009d9b7b708 -r 06a332fd936d xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -615,6 +615,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_lmsl && (value & EFER_LMSLE)) ||
@@ -629,6 +630,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);
@@ -668,9 +670,12 @@ 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 ( 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);
@@ -1021,14 +1026,18 @@ 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_LMSLE | EFER_LME | EFER_NX | EFER_SCE) )
+    efer_validbits = EFER_FFXSE | EFER_LMSLE | 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);
+                 "EFER: 0x%"PRIx64"\n", value);
         hvm_inject_exception(TRAP_gp_fault, 0, 0);
         return X86EMUL_EXCEPTION;
     }
diff -r b009d9b7b708 -r 06a332fd936d xen/include/asm-x86/cpufeature.h
--- a/xen/include/asm-x86/cpufeature.h
+++ b/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 */
 
 /* 

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

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

                 reply	other threads:[~2010-06-03 16:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201006031813.45559.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=xen-devel@lists.xensource.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 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.