diff mbox series

[v2,5/5] IOMMU: iommu_snoop is x86-only

Message ID cde0e89a-ea2d-22f9-7145-72ed40777d21@suse.com (mailing list archive)
State New, archived
Headers show
Series IOMMU: restrict visibility/scope if certain variables | expand

Commit Message

Jan Beulich March 9, 2020, 10:44 a.m. UTC
In fact it's VT-d specific, but we don't have a way yet to build code
for just one vendor. Provide a #define for the opposite case.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: The option isn't HVM-specific, after all.

Comments

Paul Durrant March 10, 2020, 10:49 a.m. UTC | #1
> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 09 March 2020 10:45
> To: xen-devel@lists.xenproject.org
> Cc: Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>; Julien Grall
> <julien@xen.org>; Wei Liu <wl@xen.org>; Konrad Wilk <konrad.wilk@oracle.com>; George Dunlap
> <George.Dunlap@eu.citrix.com>; Andrew Cooper <andrew.cooper3@citrix.com>; Ian Jackson
> <ian.jackson@citrix.com>; Paul Durrant <paul@xen.org>
> Subject: [PATCH v2 5/5] IOMMU: iommu_snoop is x86-only
> 
> In fact it's VT-d specific, but we don't have a way yet to build code
> for just one vendor. Provide a #define for the opposite case.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Paul Durrant <paul@xen.org>

> ---
> v2: The option isn't HVM-specific, after all.
> 
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -32,7 +32,6 @@ bool_t __read_mostly iommu_enabled;
>  bool_t __read_mostly force_iommu;
>  bool_t __read_mostly iommu_verbose;
>  bool __read_mostly iommu_quarantine = true;
> -bool_t __read_mostly iommu_snoop = 1;
>  bool_t __read_mostly iommu_crash_disable;
> 
>  static bool __hwdom_initdata iommu_hwdom_none;
> @@ -79,8 +78,10 @@ static int __init parse_iommu_param(cons
>  #endif
>          else if ( (val = parse_boolean("verbose", s, ss)) >= 0 )
>              iommu_verbose = val;
> +#ifndef iommu_snoop
>          else if ( (val = parse_boolean("snoop", s, ss)) >= 0 )
>              iommu_snoop = val;
> +#endif
>  #ifndef iommu_intremap
>          else if ( (val = parse_boolean("intremap", s, ss)) >= 0 )
>              iommu_intremap = val ? iommu_intremap_full : iommu_intremap_off;
> @@ -488,7 +489,9 @@ int __init iommu_setup(void)
>      printk("I/O virtualisation %sabled\n", iommu_enabled ? "en" : "dis");
>      if ( !iommu_enabled )
>      {
> -        iommu_snoop = 0;
> +#ifndef iommu_snoop
> +        iommu_snoop = false;
> +#endif
>          iommu_hwdom_passthrough = false;
>          iommu_hwdom_strict = false;
>      }
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -52,6 +52,9 @@ bool __read_mostly untrusted_msi;
> 
>  bool __read_mostly iommu_igfx = true;
>  bool __read_mostly iommu_qinval = true;
> +#ifndef iommu_snoop
> +bool __read_mostly iommu_snoop = true;
> +#endif
> 
>  int nr_iommus;
> 
> @@ -2288,8 +2291,10 @@ static int __init vtd_setup(void)
>                 cap_sps_2mb(iommu->cap) ? ", 2MB" : "",
>                 cap_sps_1gb(iommu->cap) ? ", 1GB" : "");
> 
> +#ifndef iommu_snoop
>          if ( iommu_snoop && !ecap_snp_ctl(iommu->ecap) )
> -            iommu_snoop = 0;
> +            iommu_snoop = false;
> +#endif
> 
>          if ( iommu_hwdom_passthrough && !ecap_pass_thru(iommu->ecap) )
>              iommu_hwdom_passthrough = false;
> @@ -2331,7 +2336,9 @@ static int __init vtd_setup(void)
>      }
> 
>  #define P(p,s) printk("Intel VT-d %s %senabled.\n", s, (p)? "" : "not ")
> +#ifndef iommu_snoop
>      P(iommu_snoop, "Snoop Control");
> +#endif
>      P(iommu_hwdom_passthrough, "Dom0 DMA Passthrough");
>      P(iommu_qinval, "Queued Invalidation");
>      P(iommu_intremap, "Interrupt Remapping");
> @@ -2351,7 +2358,9 @@ static int __init vtd_setup(void)
> 
>   error:
>      iommu_enabled = 0;
> -    iommu_snoop = 0;
> +#ifndef iommu_snoop
> +    iommu_snoop = false;
> +#endif
>      iommu_hwdom_passthrough = false;
>      iommu_qinval = 0;
>      iommu_intremap = iommu_intremap_off;
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -54,7 +54,6 @@ static inline bool_t dfn_eq(dfn_t x, dfn
> 
>  extern bool_t iommu_enable, iommu_enabled;
>  extern bool force_iommu, iommu_quarantine, iommu_verbose;
> -extern bool_t iommu_snoop;
> 
>  #ifdef CONFIG_X86
>  extern enum __packed iommu_intremap {
> @@ -70,9 +69,10 @@ extern enum __packed iommu_intremap {
>     iommu_intremap_restricted,
>     iommu_intremap_full,
>  } iommu_intremap;
> -extern bool iommu_igfx, iommu_qinval;
> +extern bool iommu_igfx, iommu_qinval, iommu_snoop;
>  #else
>  # define iommu_intremap false
> +# define iommu_snoop false
>  #endif
> 
>  #if defined(CONFIG_X86) && defined(CONFIG_HVM)
diff mbox series

Patch

--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -32,7 +32,6 @@  bool_t __read_mostly iommu_enabled;
 bool_t __read_mostly force_iommu;
 bool_t __read_mostly iommu_verbose;
 bool __read_mostly iommu_quarantine = true;
-bool_t __read_mostly iommu_snoop = 1;
 bool_t __read_mostly iommu_crash_disable;
 
 static bool __hwdom_initdata iommu_hwdom_none;
@@ -79,8 +78,10 @@  static int __init parse_iommu_param(cons
 #endif
         else if ( (val = parse_boolean("verbose", s, ss)) >= 0 )
             iommu_verbose = val;
+#ifndef iommu_snoop
         else if ( (val = parse_boolean("snoop", s, ss)) >= 0 )
             iommu_snoop = val;
+#endif
 #ifndef iommu_intremap
         else if ( (val = parse_boolean("intremap", s, ss)) >= 0 )
             iommu_intremap = val ? iommu_intremap_full : iommu_intremap_off;
@@ -488,7 +489,9 @@  int __init iommu_setup(void)
     printk("I/O virtualisation %sabled\n", iommu_enabled ? "en" : "dis");
     if ( !iommu_enabled )
     {
-        iommu_snoop = 0;
+#ifndef iommu_snoop
+        iommu_snoop = false;
+#endif
         iommu_hwdom_passthrough = false;
         iommu_hwdom_strict = false;
     }
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -52,6 +52,9 @@  bool __read_mostly untrusted_msi;
 
 bool __read_mostly iommu_igfx = true;
 bool __read_mostly iommu_qinval = true;
+#ifndef iommu_snoop
+bool __read_mostly iommu_snoop = true;
+#endif
 
 int nr_iommus;
 
@@ -2288,8 +2291,10 @@  static int __init vtd_setup(void)
                cap_sps_2mb(iommu->cap) ? ", 2MB" : "",
                cap_sps_1gb(iommu->cap) ? ", 1GB" : "");
 
+#ifndef iommu_snoop
         if ( iommu_snoop && !ecap_snp_ctl(iommu->ecap) )
-            iommu_snoop = 0;
+            iommu_snoop = false;
+#endif
 
         if ( iommu_hwdom_passthrough && !ecap_pass_thru(iommu->ecap) )
             iommu_hwdom_passthrough = false;
@@ -2331,7 +2336,9 @@  static int __init vtd_setup(void)
     }
 
 #define P(p,s) printk("Intel VT-d %s %senabled.\n", s, (p)? "" : "not ")
+#ifndef iommu_snoop
     P(iommu_snoop, "Snoop Control");
+#endif
     P(iommu_hwdom_passthrough, "Dom0 DMA Passthrough");
     P(iommu_qinval, "Queued Invalidation");
     P(iommu_intremap, "Interrupt Remapping");
@@ -2351,7 +2358,9 @@  static int __init vtd_setup(void)
 
  error:
     iommu_enabled = 0;
-    iommu_snoop = 0;
+#ifndef iommu_snoop
+    iommu_snoop = false;
+#endif
     iommu_hwdom_passthrough = false;
     iommu_qinval = 0;
     iommu_intremap = iommu_intremap_off;
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -54,7 +54,6 @@  static inline bool_t dfn_eq(dfn_t x, dfn
 
 extern bool_t iommu_enable, iommu_enabled;
 extern bool force_iommu, iommu_quarantine, iommu_verbose;
-extern bool_t iommu_snoop;
 
 #ifdef CONFIG_X86
 extern enum __packed iommu_intremap {
@@ -70,9 +69,10 @@  extern enum __packed iommu_intremap {
    iommu_intremap_restricted,
    iommu_intremap_full,
 } iommu_intremap;
-extern bool iommu_igfx, iommu_qinval;
+extern bool iommu_igfx, iommu_qinval, iommu_snoop;
 #else
 # define iommu_intremap false
+# define iommu_snoop false
 #endif
 
 #if defined(CONFIG_X86) && defined(CONFIG_HVM)