xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 08/14] Nested Virtualization: efer
@ 2010-08-05 15:03 Christoph Egger
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Egger @ 2010-08-05 15:03 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 322 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: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

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

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

diff -r 7789f1d7d7e7 -r 8c7c597735c6 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -616,6 +616,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)) ||
@@ -630,6 +631,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);
@@ -669,9 +671,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);
@@ -1081,14 +1086,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 7789f1d7d7e7 -r 8c7c597735c6 xen/include/asm-x86/cpufeature.h
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -199,6 +199,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] 4+ messages in thread

* RE: [PATCH 08/14] Nested Virtualization: efer
@ 2010-08-19  3:33 Dong, Eddie
  2010-08-19  8:41 ` Tim Deegan
  0 siblings, 1 reply; 4+ messages in thread
From: Dong, Eddie @ 2010-08-19  3:33 UTC (permalink / raw)
  To: Christoph Egger, xen-devel@lists.xensource.com; +Cc: Dong, Eddie

> # HG changeset patch
> # User cegger
> # Date 1281003856 -7200
> Allow guest to enable SVM in EFER
> 
> diff -r 7789f1d7d7e7 -r 8c7c597735c6 xen/arch/x86/hvm/hvm.c
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -616,6 +616,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)) ||
> @@ -630,6 +631,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);
> @@ -669,9 +671,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;

Check it is running on SVM first. 

> +
> +    if ( !hvm_efer_valid(ctxt.msr_efer, efer_validbits) )
>      {
>          gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
>                   ctxt.msr_efer);
> @@ -1081,14 +1086,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;
ditto

> +
> +    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 7789f1d7d7e7 -r 8c7c597735c6 xen/include/asm-x86/cpufeature.h
> --- a/xen/include/asm-x86/cpufeature.h
> +++ b/xen/include/asm-x86/cpufeature.h
> @@ -199,6 +199,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 */
> 
>  /*

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

* Re: [PATCH 08/14] Nested Virtualization: efer
  2010-08-19  3:33 Dong, Eddie
@ 2010-08-19  8:41 ` Tim Deegan
  2010-08-19 10:18   ` Christoph Egger
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Deegan @ 2010-08-19  8:41 UTC (permalink / raw)
  To: Dong, Eddie; +Cc: Christoph Egger, xen-devel@lists.xensource.com

At 04:33 +0100 on 19 Aug (1282192384), Dong, Eddie wrote:
> > # HG changeset patch
> > # User cegger
> > # Date 1281003856 -7200
> > Allow guest to enable SVM in EFER
> > 
> > diff -r 7789f1d7d7e7 -r 8c7c597735c6 xen/arch/x86/hvm/hvm.c
> > --- a/xen/arch/x86/hvm/hvm.c
> > +++ b/xen/arch/x86/hvm/hvm.c
> > @@ -616,6 +616,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)) ||
> > @@ -630,6 +631,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);
> > @@ -669,9 +671,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;
> 
> Check it is running on SVM first. 

This check is made in hvm_efer_valid().  But it might be less confusing
to have hvm_efer_valid() check nestedhvm_enabled() as well rather than
do half the check in the caller and half in the function.

Tim.


-- 
Tim Deegan <Tim.Deegan@citrix.com>
Principal Software Engineer, XenServer Engineering
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

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

* Re: [PATCH 08/14] Nested Virtualization: efer
  2010-08-19  8:41 ` Tim Deegan
@ 2010-08-19 10:18   ` Christoph Egger
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Egger @ 2010-08-19 10:18 UTC (permalink / raw)
  To: Tim Deegan; +Cc: xen-devel@lists.xensource.com, Dong, Eddie

On Thursday 19 August 2010 10:41:03 Tim Deegan wrote:
> At 04:33 +0100 on 19 Aug (1282192384), Dong, Eddie wrote:
> > > # HG changeset patch
> > > # User cegger
> > > # Date 1281003856 -7200
> > > Allow guest to enable SVM in EFER
> > >
> > > diff -r 7789f1d7d7e7 -r 8c7c597735c6 xen/arch/x86/hvm/hvm.c
> > > --- a/xen/arch/x86/hvm/hvm.c
> > > +++ b/xen/arch/x86/hvm/hvm.c
> > > @@ -616,6 +616,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)) ||
> > > @@ -630,6 +631,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);
> > > @@ -669,9 +671,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;
> >
> > Check it is running on SVM first.
>
> This check is made in hvm_efer_valid().  But it might be less confusing
> to have hvm_efer_valid() check nestedhvm_enabled() as well rather than
> do half the check in the caller and half in the function.

Good point. Fixed in local tree.

Christoph


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

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

end of thread, other threads:[~2010-08-19 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-05 15:03 [PATCH 08/14] Nested Virtualization: efer Christoph Egger
  -- strict thread matches above, loose matches on Subject: below --
2010-08-19  3:33 Dong, Eddie
2010-08-19  8:41 ` Tim Deegan
2010-08-19 10:18   ` Christoph Egger

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