Skip to contentSkip to conversation

Revert "VMX: flush cache when vmentry back to UC guest"

PATCH In review Jan Beulich 4 participants 4 messages Dec 4, 2013 – Dec 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "VMX: flush cache when vmentry back to UC guest"

This reverts commit 86d60e85 as well as one related change from 62652c00 ("VMX: fix cr0.cd handling"), on the basis that all of this flushing is still insufficient and, while not known to fix anything, is known to negatively affect performance.

xen/arch/x86/hvm/hvm.c +0 -6
@@ -2566,9 +2566,6 @@ static enum hvm_copy_result __hvm_copy(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
@@ -2680,9 +2677,6 @@ static enum hvm_copy_result __hvm_clear(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
xen/arch/x86/hvm/vmx/vmx.c +0 -11
@@ -643,10 +643,6 @@ static void vmx_ctxt_switch_to(struct vc
             __invept(INVEPT_SINGLE_CONTEXT, ept_get_eptp(ept_data), 0);
     }
 
-    /* For guest cr0.cd setting, do not use potentially polluted cache */
-    if ( unlikely(v->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        wbinvd();
-
     vmx_restore_guest_msrs(v);
     vmx_restore_dr(v);
 }
@@ -2999,13 +2995,6 @@ void vmx_vmenter_helper(const struct cpu
     struct hvm_vcpu_asid *p_asid;
     bool_t need_flush;
 
-    /* In case hypervisor access hvm memory when guest uc mode */
-    if ( unlikely(curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory) )
-    {
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 0;
-        wbinvd();
-    }
-
     if ( !cpu_has_vmx_vpid )
         goto out;
     if ( nestedhvm_vcpu_in_guestmode(curr) )
xen/include/asm-x86/hvm/vcpu.h +0 -1
@@ -169,7 +169,6 @@ struct hvm_vcpu {
 
     /* Which cache mode is this VCPU in (CR0:CD/NW)? */
     u8                  cache_mode;
-    bool_t              hypervisor_access_uc_hvm_memory;
 
     struct hvm_vcpu_io  hvm_io;
 

Revert "VMX: flush cache when vmentry back to UC guest"

This reverts commit 86d60e85 as well as one related change from 62652c00 ("VMX: fix cr0.cd handling"), on the basis that all of this flushing is still insufficient and, while not known to fix anything, is known to negatively affect performance.

xen/arch/x86/hvm/hvm.c +0 -6
@@ -2566,9 +2566,6 @@ static enum hvm_copy_result __hvm_copy(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
@@ -2680,9 +2677,6 @@ static enum hvm_copy_result __hvm_clear(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
xen/arch/x86/hvm/vmx/vmx.c +0 -11
@@ -643,10 +643,6 @@ static void vmx_ctxt_switch_to(struct vc
             __invept(INVEPT_SINGLE_CONTEXT, ept_get_eptp(ept_data), 0);
     }
 
-    /* For guest cr0.cd setting, do not use potentially polluted cache */
-    if ( unlikely(v->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        wbinvd();
-
     vmx_restore_guest_msrs(v);
     vmx_restore_dr(v);
 }
@@ -2999,13 +2995,6 @@ void vmx_vmenter_helper(const struct cpu
     struct hvm_vcpu_asid *p_asid;
     bool_t need_flush;
 
-    /* In case hypervisor access hvm memory when guest uc mode */
-    if ( unlikely(curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory) )
-    {
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 0;
-        wbinvd();
-    }
-
     if ( !cpu_has_vmx_vpid )
         goto out;
     if ( nestedhvm_vcpu_in_guestmode(curr) )
xen/include/asm-x86/hvm/vcpu.h +0 -1
@@ -169,7 +169,6 @@ struct hvm_vcpu {
 
     /* Which cache mode is this VCPU in (CR0:CD/NW)? */
     u8                  cache_mode;
-    bool_t              hypervisor_access_uc_hvm_memory;
 
     struct hvm_vcpu_io  hvm_io;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#2 lore raw
In reply to Jan Beulich
Quoted 6 lines · Jan Beulich

This reverts commit 86d60e85 as well as one related change from 62652c00 ("VMX: fix cr0.cd handling"), on the basis that all of this flushing is still insufficient and, while not known to fix anything, is known to negatively affect performance.

Quoted 64 lines
xen/arch/x86/hvm/hvm.c +0 -3
@@ -2566,9 +2566,6 @@ static enum hvm_copy_result __hvm_copy(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode ==
 NO_FILL_CACHE_MODE) ) 
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
xen/arch/x86/hvm/hvm.c +0 -3
@@ -2680,9 +2677,6 @@ static enum hvm_copy_result __hvm_clear(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode ==
 NO_FILL_CACHE_MODE) ) 
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
xen/arch/x86/hvm/vmx/vmx.c +0 -1
@@ -643,10 +643,6 @@ static void vmx_ctxt_switch_to(struct vc
             __invept(INVEPT_SINGLE_CONTEXT, ept_get_eptp(ept_data),
     0); }
 
-    /* For guest cr0.cd setting, do not use potentially polluted

cache */
- if ( unlikely(v->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE)
)

xen/arch/x86/hvm/vmx/vmx.c +0 -9
-        wbinvd();
-
     vmx_restore_guest_msrs(v);
     vmx_restore_dr(v);
 }
@@ -2999,13 +2995,6 @@ void vmx_vmenter_helper(const struct cpu
     struct hvm_vcpu_asid *p_asid;
     bool_t need_flush;
 
-    /* In case hypervisor access hvm memory when guest uc mode */
-    if (
 unlikely(curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory) ) 
-    {
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 0;
-        wbinvd();
-    }
-
     if ( !cpu_has_vmx_vpid )
         goto out;

if ( nestedhvm_vcpu_in_guestmode(curr) )

xen/include/asm-x86/hvm/vcpu.h +0 -1
@@ -169,7 +169,6 @@ struct hvm_vcpu {
 
     /* Which cache mode is this VCPU in (CR0:CD/NW)? */
     u8                  cache_mode;
-    bool_t              hypervisor_access_uc_hvm_memory;
 
     struct hvm_vcpu_io  hvm_io;
#3 lore raw
In reply to Jan Beulich

Acked by Eddie Dong <[email protected]>

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, December 05, 2013 12:47 AM
To: xen-devel
Cc: Andrew Cooper; George Dunlap; Dong, Eddie; Liu, Jinsong; Nakajima, Jun; Keir Fraser
Subject: [PATCH] Revert "VMX: flush cache when vmentry back to UC guest"

This reverts commit 86d60e85 as well as one related change from
62652c00 ("VMX: fix cr0.cd handling"), on the basis that all of this flushing is still insufficient and, while not known to fix anything, is known to negatively affect performance.

xen/arch/x86/hvm/hvm.c +0 -3
@@ -2566,9 +2566,6 @@ static enum hvm_copy_result __hvm_copy(
         return HVMCOPY_unhandleable;
 #endif
 
-    if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo); @@ -2680,9 +2677,6 @@ static enum hvm_copy_result __hvm_clear(
         return HVMCOPY_unhandleable;

#endif

- if ( unlikely(curr->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
- curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 1;
-

     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
xen/arch/x86/hvm/vmx/vmx.c +0 -11
@@ -643,10 +643,6 @@ static void vmx_ctxt_switch_to(struct vc
             __invept(INVEPT_SINGLE_CONTEXT, ept_get_eptp(ept_data), 0);
     }
 
-    /* For guest cr0.cd setting, do not use potentially polluted cache */
-    if ( unlikely(v->arch.hvm_vcpu.cache_mode == NO_FILL_CACHE_MODE) )
-        wbinvd();
-
     vmx_restore_guest_msrs(v);
     vmx_restore_dr(v);
 }
@@ -2999,13 +2995,6 @@ void vmx_vmenter_helper(const struct cpu
     struct hvm_vcpu_asid *p_asid;
     bool_t need_flush;
 
-    /* In case hypervisor access hvm memory when guest uc mode */
-    if ( unlikely(curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory) )
-    {
-        curr->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory = 0;
-        wbinvd();
-    }
-
     if ( !cpu_has_vmx_vpid )
         goto out;
     if ( nestedhvm_vcpu_in_guestmode(curr) )
xen/include/asm-x86/hvm/vcpu.h +0 -1
@@ -169,7 +169,6 @@ struct hvm_vcpu {
 
     /* Which cache mode is this VCPU in (CR0:CD/NW)? */
     u8                  cache_mode;
-    bool_t              hypervisor_access_uc_hvm_memory;
 
     struct hvm_vcpu_io  hvm_io;