[PATCH v2 2/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific

Xenia Ragiadakou posted 8 patches 3 years, 1 month ago
There is a newer version of this series
[PATCH v2 2/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific
Posted by Xenia Ragiadakou 3 years, 1 month ago
Move its definition to the AMD-Vi driver and use CONFIG_AMD_IOMMU
to guard its usage in common code.

Take the opportunity to replace bool_t with bool, __read_mostly with
__ro_after_init and 1 with true.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---

Changes in v2:
  - declare amd_iommu_perdev_intremap __ro_after_init
  - use no_config_param() to print a warning when the user sets an AMD_IOMMU
    specific string in the iommu boot parameter and AMD_IOMMU is disabled
  - remove the #ifdef CONFIG_AMD_IOMMU guard from the declaration of
    amd_iommu_perdev_intremap in xen/iommu.h

 xen/drivers/passthrough/amd/iommu_init.c | 2 ++
 xen/drivers/passthrough/iommu.c          | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 1f14aaf49e..9773ccfcb4 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -36,6 +36,8 @@ static struct radix_tree_root ivrs_maps;
 LIST_HEAD_READ_MOSTLY(amd_iommu_head);
 bool_t iommuv2_enabled;
 
+bool __ro_after_init amd_iommu_perdev_intremap = true;
+
 static bool iommu_has_ht_flag(struct amd_iommu *iommu, u8 mask)
 {
     return iommu->ht_flags & mask;
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 5e2a720d29..998dfaf20d 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -58,7 +58,6 @@ bool __read_mostly iommu_hap_pt_share = true;
 #endif
 
 bool_t __read_mostly iommu_debug;
-bool_t __read_mostly amd_iommu_perdev_intremap = 1;
 
 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 
@@ -116,7 +115,11 @@ static int __init cf_check parse_iommu_param(const char *s)
                 iommu_verbose = 1;
         }
         else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
+#ifdef CONFIG_AMD_IOMMU
             amd_iommu_perdev_intremap = val;
+#else
+            no_config_param("AMD_IOMMU", "amd-iommu-perdev-intremap", s, ss);
+#endif
         else if ( (val = parse_boolean("dom0-passthrough", s, ss)) >= 0 )
             iommu_hwdom_passthrough = val;
         else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
-- 
2.37.2
Re: [PATCH v2 2/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific
Posted by Jan Beulich 3 years ago
On 04.01.2023 09:44, Xenia Ragiadakou wrote:
> @@ -116,7 +115,11 @@ static int __init cf_check parse_iommu_param(const char *s)
>                  iommu_verbose = 1;
>          }
>          else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
> +#ifdef CONFIG_AMD_IOMMU
>              amd_iommu_perdev_intremap = val;
> +#else
> +            no_config_param("AMD_IOMMU", "amd-iommu-perdev-intremap", s, ss);

The string literal wants to be "iommu", I think. Please see other uses of
no_config_param().

Jan
Re: [PATCH v2 2/8] x86/iommu: amd_iommu_perdev_intremap is AMD-Vi specific
Posted by Xenia Ragiadakou 3 years ago
On 1/11/23 17:03, Jan Beulich wrote:
> On 04.01.2023 09:44, Xenia Ragiadakou wrote:
>> @@ -116,7 +115,11 @@ static int __init cf_check parse_iommu_param(const char *s)
>>                   iommu_verbose = 1;
>>           }
>>           else if ( (val = parse_boolean("amd-iommu-perdev-intremap", s, ss)) >= 0 )
>> +#ifdef CONFIG_AMD_IOMMU
>>               amd_iommu_perdev_intremap = val;
>> +#else
>> +            no_config_param("AMD_IOMMU", "amd-iommu-perdev-intremap", s, ss);
> 
> The string literal wants to be "iommu", I think. Please see other uses of
> no_config_param().

Thanks for reviewing this. You are right. I will fix it.

-- 
Xenia