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

[Xen-devel] [PATCH] remove CSTAR save/restore on VMX

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] remove CSTAR save/restore on VMX
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Mon, 14 May 2007 17:43:30 +0200
Delivery-date: Mon, 14 May 2007 08:41:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
CSTAR is an unused MSR in 64-bit mode on Intel's EM64T, hence there's no need
to save/restore this MSR during context switches. Mimic real hardware by
retaining the value written for eventual guest OS reads.

(Patch won't apply without the EFER adjustment patch.)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: 2007-05-14/xen/arch/x86/hvm/vmx/vmx.c
===================================================================
--- 2007-05-14.orig/xen/arch/x86/hvm/vmx/vmx.c  2007-05-14 14:28:19.000000000 
+0200
+++ 2007-05-14/xen/arch/x86/hvm/vmx/vmx.c       2007-05-14 14:33:24.000000000 
+0200
@@ -88,8 +88,7 @@ static DEFINE_PER_CPU(struct vmx_msr_sta
 
 static u32 msr_index[VMX_MSR_COUNT] =
 {
-    MSR_LSTAR, MSR_STAR, MSR_CSTAR,
-    MSR_SYSCALL_MASK
+    MSR_LSTAR, MSR_STAR, MSR_SYSCALL_MASK
 };
 
 static void vmx_save_host_msrs(void)
@@ -147,7 +146,7 @@ static inline int long_mode_do_msr_read(
         break;
 
     case MSR_CSTAR:
-        msr_content = guest_msr_state->msrs[VMX_INDEX_MSR_CSTAR];
+        msr_content = v->arch.hvm_vmx.cstar;
         break;
 
     case MSR_SYSCALL_MASK:
@@ -250,7 +249,8 @@ static inline int long_mode_do_msr_write
     case MSR_CSTAR:
         if ( !is_canonical_address(msr_content) )
             goto uncanonical_address;
-        WRITE_MSR(CSTAR);
+        v->arch.hvm_vmx.cstar = msr_content;
+        break;
 
     case MSR_SYSCALL_MASK:
         WRITE_MSR(SYSCALL_MASK);
@@ -730,12 +730,12 @@ static void vmx_save_cpu_state(struct vc
     unsigned long guest_flags = guest_state->flags;
 
     data->shadow_gs = v->arch.hvm_vmx.shadow_gs;
+    data->msr_cstar = v->arch.hvm_vmx.cstar;
 
     /* save msrs */
     data->msr_flags        = guest_flags;
     data->msr_lstar        = guest_state->msrs[VMX_INDEX_MSR_LSTAR];
     data->msr_star         = guest_state->msrs[VMX_INDEX_MSR_STAR];
-    data->msr_cstar        = guest_state->msrs[VMX_INDEX_MSR_CSTAR];
     data->msr_syscall_mask = guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK];
 #endif
 
@@ -755,9 +755,9 @@ static void vmx_load_cpu_state(struct vc
     guest_state->flags = data->msr_flags;
     guest_state->msrs[VMX_INDEX_MSR_LSTAR]        = data->msr_lstar;
     guest_state->msrs[VMX_INDEX_MSR_STAR]         = data->msr_star;
-    guest_state->msrs[VMX_INDEX_MSR_CSTAR]        = data->msr_cstar;
     guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK] = data->msr_syscall_mask;
 
+    v->arch.hvm_vmx.cstar     = data->msr_cstar;
     v->arch.hvm_vmx.shadow_gs = data->shadow_gs;
 #endif
 
Index: 2007-05-14/xen/include/asm-x86/hvm/vmx/vmcs.h
===================================================================
--- 2007-05-14.orig/xen/include/asm-x86/hvm/vmx/vmcs.h  2007-05-14 
14:28:19.000000000 +0200
+++ 2007-05-14/xen/include/asm-x86/hvm/vmx/vmcs.h       2007-05-14 
14:33:24.000000000 +0200
@@ -37,7 +37,6 @@ struct vmcs_struct {
 enum {
     VMX_INDEX_MSR_LSTAR = 0,
     VMX_INDEX_MSR_STAR,
-    VMX_INDEX_MSR_CSTAR,
     VMX_INDEX_MSR_SYSCALL_MASK,
 
     VMX_MSR_COUNT
@@ -77,6 +76,7 @@ struct arch_vmx_struct {
 #ifdef __x86_64__
     struct vmx_msr_state msr_state;
     unsigned long        shadow_gs;
+    unsigned long        cstar;
 #endif
     unsigned long        efer;
     unsigned long        vmxassist_enabled:1;




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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] remove CSTAR save/restore on VMX, Jan Beulich <=