WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] [PATCH 08/14] Nested Virtualization: efer

To: "Dong, Eddie" <eddie.dong@xxxxxxxxx>, Christoph Egger <Christoph.Egger@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH 08/14] Nested Virtualization: efer
From: "Dong, Eddie" <eddie.dong@xxxxxxxxx>
Date: Thu, 19 Aug 2010 11:33:04 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "Dong, Eddie" <eddie.dong@xxxxxxxxx>
Delivery-date: Wed, 18 Aug 2010 20:38:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acs/TaJa4asovOyaQ+SYgBhKKdcR2wAADlWQ
Thread-topic: [Xen-devel] [PATCH 08/14] Nested Virtualization: efer
> # 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 */
> 
>  /*


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

<Prev in Thread] Current Thread [Next in Thread>