xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] No need to emulate WBINVD when VT-d force snooping feature available
@ 2010-07-05  3:46 Sheng Yang
  2010-07-05  9:36 ` Ian Pratt
  0 siblings, 1 reply; 3+ messages in thread
From: Sheng Yang @ 2010-07-05  3:46 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel@lists.xensource.com

[-- Attachment #1: Type: Text/Plain, Size: 1195 bytes --]

There is no cache coherency issue if VT-d engine's force snooping feature 
available.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -1064,8 +1064,10 @@
          *  1: flushing cache (wbinvd) when the guest is scheduled out if
          *     there is no wbinvd exit, or
          *  2: execute wbinvd on all dirty pCPUs when guest wbinvd exits.
+         * If VT-d engine can force snooping, we don't need to do these.
          */
-        if ( has_arch_pdevs(v->domain) && !cpu_has_wbinvd_exiting )
+        if ( has_arch_pdevs(v->domain) && !iommu_snoop
+                && !cpu_has_wbinvd_exiting )
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2089,6 +2089,9 @@
     if ( !has_arch_mmios(current->domain) )
         return;

+    if ( iommu_snoop )
+        return;
+
     if ( cpu_has_wbinvd_exiting )
         on_each_cpu(wbinvd_ipi, NULL, 1);
     else

[-- Attachment #2: iommu_snp_wbinvd.patch --]
[-- Type: text/x-patch, Size: 1058 bytes --]

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -1064,8 +1064,10 @@
          *  1: flushing cache (wbinvd) when the guest is scheduled out if
          *     there is no wbinvd exit, or
          *  2: execute wbinvd on all dirty pCPUs when guest wbinvd exits.
+         * If VT-d engine can force snooping, we don't need to do these.
          */
-        if ( has_arch_pdevs(v->domain) && !cpu_has_wbinvd_exiting )
+        if ( has_arch_pdevs(v->domain) && !iommu_snoop
+                && !cpu_has_wbinvd_exiting )
         {
             int cpu = v->arch.hvm_vmx.active_cpu;
             if ( cpu != -1 )
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2089,6 +2089,9 @@
     if ( !has_arch_mmios(current->domain) )
         return;
 
+    if ( iommu_snoop )
+        return;
+
     if ( cpu_has_wbinvd_exiting )
         on_each_cpu(wbinvd_ipi, NULL, 1);
     else

[-- 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] 3+ messages in thread

* RE: [PATCH] No need to emulate WBINVD when VT-d force snooping feature available
  2010-07-05  3:46 [PATCH] No need to emulate WBINVD when VT-d force snooping feature available Sheng Yang
@ 2010-07-05  9:36 ` Ian Pratt
  2010-07-05 10:09   ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Pratt @ 2010-07-05  9:36 UTC (permalink / raw)
  To: Sheng Yang, Keir Fraser; +Cc: Ian Pratt, xen-devel@lists.xensource.com

> There is no cache coherency issue if VT-d engine's force snooping feature
> available.

Isn't it also necessary to explicitly set the SNP bit in each VTd PTE to force snooping? I don't believe we do this today, but since we ignore guest PAT settings on RAM we should do so.

Thanks,
Ian

 
> Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
> --- a/xen/arch/x86/hvm/vmx/vmcs.c
> +++ b/xen/arch/x86/hvm/vmx/vmcs.c
> @@ -1064,8 +1064,10 @@
>           *  1: flushing cache (wbinvd) when the guest is scheduled out if
>           *     there is no wbinvd exit, or
>           *  2: execute wbinvd on all dirty pCPUs when guest wbinvd exits.
> +         * If VT-d engine can force snooping, we don't need to do these.
>           */
> -        if ( has_arch_pdevs(v->domain) && !cpu_has_wbinvd_exiting )
> +        if ( has_arch_pdevs(v->domain) && !iommu_snoop
> +                && !cpu_has_wbinvd_exiting )
>          {
>              int cpu = v->arch.hvm_vmx.active_cpu;
>              if ( cpu != -1 )
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -2089,6 +2089,9 @@
>      if ( !has_arch_mmios(current->domain) )
>          return;
> 
> +    if ( iommu_snoop )
> +        return;
> +
>      if ( cpu_has_wbinvd_exiting )
>          on_each_cpu(wbinvd_ipi, NULL, 1);
>      else

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

* Re: [PATCH] No need to emulate WBINVD when VT-d force snooping feature available
  2010-07-05  9:36 ` Ian Pratt
@ 2010-07-05 10:09   ` Keir Fraser
  0 siblings, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2010-07-05 10:09 UTC (permalink / raw)
  To: Ian Pratt, Sheng Yang; +Cc: xen-devel@lists.xensource.com

On 05/07/2010 10:36, "Ian Pratt" <Ian.Pratt@eu.citrix.com> wrote:

>> There is no cache coherency issue if VT-d engine's force snooping feature
>> available.
> 
> Isn't it also necessary to explicitly set the SNP bit in each VTd PTE to force
> snooping? I don't believe we do this today, but since we ignore guest PAT
> settings on RAM we should do so.

In drivers/passthrough/vtd/iommu.c:intel_iommu_map_page() ---
   /* Set the SNP on leaf page table if Snoop Control available */
    if ( iommu_snoop )
        dma_set_pte_snp(*pte);

 -- Keir

> Thanks,
> Ian
> 
>  
>> Signed-off-by: Sheng Yang <sheng@linux.intel.com>
>> 
>> diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
>> --- a/xen/arch/x86/hvm/vmx/vmcs.c
>> +++ b/xen/arch/x86/hvm/vmx/vmcs.c
>> @@ -1064,8 +1064,10 @@
>>           *  1: flushing cache (wbinvd) when the guest is scheduled out if
>>           *     there is no wbinvd exit, or
>>           *  2: execute wbinvd on all dirty pCPUs when guest wbinvd exits.
>> +         * If VT-d engine can force snooping, we don't need to do these.
>>           */
>> -        if ( has_arch_pdevs(v->domain) && !cpu_has_wbinvd_exiting )
>> +        if ( has_arch_pdevs(v->domain) && !iommu_snoop
>> +                && !cpu_has_wbinvd_exiting )
>>          {
>>              int cpu = v->arch.hvm_vmx.active_cpu;
>>              if ( cpu != -1 )
>> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> @@ -2089,6 +2089,9 @@
>>      if ( !has_arch_mmios(current->domain) )
>>          return;
>> 
>> +    if ( iommu_snoop )
>> +        return;
>> +
>>      if ( cpu_has_wbinvd_exiting )
>>          on_each_cpu(wbinvd_ipi, NULL, 1);
>>      else

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

end of thread, other threads:[~2010-07-05 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-05  3:46 [PATCH] No need to emulate WBINVD when VT-d force snooping feature available Sheng Yang
2010-07-05  9:36 ` Ian Pratt
2010-07-05 10:09   ` Keir Fraser

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