xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] xen: merge efer check
Date: Wed, 31 Mar 2010 15:22:13 +0100	[thread overview]
Message-ID: <201003311622.13360.Christoph.Egger@amd.com> (raw)

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


Hi!

Attached patch merges the efer check done in hvm_load_cpu_ctxt and 
hvm_set_efer. No functional changes.

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


-- 
---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

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

diff -r fa1ad484bf0b xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c	Wed Mar 31 14:28:31 2010 +0200
+++ b/xen/arch/x86/hvm/hvm.c	Wed Mar 31 16:13:59 2010 +0200
@@ -583,6 +583,24 @@ static int hvm_save_cpu_ctxt(struct doma
     return 0;
 }
 
+static int hvm_validate_efer(uint64_t value, uint64_t efer_validbits)
+{
+    if ( (value & ~efer_validbits) ||
+         ((sizeof(long) != 8) && (value & EFER_LME)) ||
+         (!cpu_has_nx && (value & EFER_NX)) ||
+         (!cpu_has_syscall && (value & EFER_SCE)) ||
+         (!cpu_has_ffxsr && (value & EFER_FFXSE)) )
+    {
+        return 1;
+    }
+
+    if ( efer_validbits & EFER_LMA )
+        if (( value & (EFER_LME|EFER_LMA)) == EFER_LMA )
+            return 1;
+
+    return 0;
+}
+
 static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
 {
     int vcpuid, rc;
@@ -629,13 +647,8 @@ static int hvm_load_cpu_ctxt(struct doma
         return -EINVAL;
     }
 
-    if ( (ctxt.msr_efer & ~(EFER_FFXSE | EFER_LME | EFER_LMA |
-                            EFER_NX | EFER_SCE)) ||
-         ((sizeof(long) != 8) && (ctxt.msr_efer & EFER_LME)) ||
-         (!cpu_has_nx && (ctxt.msr_efer & EFER_NX)) ||
-         (!cpu_has_syscall && (ctxt.msr_efer & EFER_SCE)) ||
-         (!cpu_has_ffxsr && (ctxt.msr_efer & EFER_FFXSE)) ||
-         ((ctxt.msr_efer & (EFER_LME|EFER_LMA)) == EFER_LMA) )
+    if ( hvm_validate_efer(ctxt.msr_efer,
+             EFER_FFXSE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
     {
         gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
                  ctxt.msr_efer);
@@ -984,11 +997,7 @@ int hvm_set_efer(uint64_t value)
 
     value &= ~EFER_LMA;
 
-    if ( (value & ~(EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE)) ||
-         ((sizeof(long) != 8) && (value & EFER_LME)) ||
-         (!cpu_has_nx && (value & EFER_NX)) ||
-         (!cpu_has_syscall && (value & EFER_SCE)) ||
-         (!cpu_has_ffxsr && (value & EFER_FFXSE)) )
+    if ( hvm_validate_efer(value, EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE) )
     {
         gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
                  "EFER: %"PRIx64"\n", value);

[-- 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-03-31 14:22 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=201003311622.13360.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).