public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
@ 2026-01-22 21:42 Nathan Chancellor
  2026-01-22 23:37 ` Jason Gunthorpe
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nathan Chancellor @ 2026-01-22 21:42 UTC (permalink / raw)
  To: Joerg Roedel, Suravee Suthikulpanit
  Cc: Will Deacon, Robin Murphy, Vasant Hegde, Jason Gunthorpe,
	Nicolin Chen, iommu, linux-kernel, Nathan Chancellor

When building with -Wincompatible-function-pointer-types-strict, a
warning designed to catch kernel control flow integrity (kCFI) issues at
build time, there is an instance around amd_iommufd_hw_info():

  drivers/iommu/amd/iommu.c:3141:13: error: incompatible function pointer types initializing 'void *(*)(struct device *, u32 *, enum iommu_hw_info_type *)' (aka 'void *(*)(struct device *, unsigned int *, enum iommu_hw_info_type *)') with an expression of type 'void *(struct device *, u32 *, u32 *)' (aka 'void *(struct device *, unsigned int *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
   3141 |         .hw_info = amd_iommufd_hw_info,
        |                    ^~~~~~~~~~~~~~~~~~~

While 'u32 *' and 'enum iommu_hw_info_type *' are ABI compatible, hence
no regular warning from -Wincompatible-function-pointer-types, the
mismatch will trigger a kCFI violation when amd_iommufd_hw_info() is
called indirectly.

Update the type parameter of amd_iommufd_hw_info() to be
'enum iommu_hw_info_type *' to match the prototype in
'struct iommu_ops', clearing up the warning and kCFI violation.

Fixes: 7d8b06ecc45b ("iommu/amd: Add support for hw_info for iommu capability query")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/iommu/amd/iommufd.c | 2 +-
 drivers/iommu/amd/iommufd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd/iommufd.c b/drivers/iommu/amd/iommufd.c
index ad627fd5ccc7..96ec6a4a760d 100644
--- a/drivers/iommu/amd/iommufd.c
+++ b/drivers/iommu/amd/iommufd.c
@@ -11,7 +11,7 @@
 
 static const struct iommufd_viommu_ops amd_viommu_ops;
 
-void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
+void *amd_iommufd_hw_info(struct device *dev, u32 *length, enum iommu_hw_info_type *type)
 {
 	struct iommu_hw_info_amd *hwinfo;
 
diff --git a/drivers/iommu/amd/iommufd.h b/drivers/iommu/amd/iommufd.h
index f05aad495b5b..62e9e1bebfbe 100644
--- a/drivers/iommu/amd/iommufd.h
+++ b/drivers/iommu/amd/iommufd.h
@@ -7,7 +7,7 @@
 #define AMD_IOMMUFD_H
 
 #if IS_ENABLED(CONFIG_AMD_IOMMU_IOMMUFD)
-void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type);
+void *amd_iommufd_hw_info(struct device *dev, u32 *length, enum iommu_hw_info_type *type);
 size_t amd_iommufd_get_viommu_size(struct device *dev, enum iommu_viommu_type viommu_type);
 int amd_iommufd_viommu_init(struct iommufd_viommu *viommu, struct iommu_domain *parent,
 			    const struct iommu_user_data *user_data);

---
base-commit: c0a652a3d1970caa0023632ae3a4ea21991d2f1a
change-id: 20260122-amd-iommufd-fix-wifpts-dfd944cbc17e

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


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

* Re: [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
  2026-01-22 21:42 [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info() Nathan Chancellor
@ 2026-01-22 23:37 ` Jason Gunthorpe
  2026-01-23  0:37 ` Nicolin Chen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2026-01-22 23:37 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
	Vasant Hegde, Nicolin Chen, iommu, linux-kernel

On Thu, Jan 22, 2026 at 02:42:38PM -0700, Nathan Chancellor wrote:
> When building with -Wincompatible-function-pointer-types-strict, a
> warning designed to catch kernel control flow integrity (kCFI) issues at
> build time, there is an instance around amd_iommufd_hw_info():
> 
>   drivers/iommu/amd/iommu.c:3141:13: error: incompatible function pointer types initializing 'void *(*)(struct device *, u32 *, enum iommu_hw_info_type *)' (aka 'void *(*)(struct device *, unsigned int *, enum iommu_hw_info_type *)') with an expression of type 'void *(struct device *, u32 *, u32 *)' (aka 'void *(struct device *, unsigned int *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>    3141 |         .hw_info = amd_iommufd_hw_info,
>         |                    ^~~~~~~~~~~~~~~~~~~
> 
> While 'u32 *' and 'enum iommu_hw_info_type *' are ABI compatible, hence
> no regular warning from -Wincompatible-function-pointer-types, the
> mismatch will trigger a kCFI violation when amd_iommufd_hw_info() is
> called indirectly.
> 
> Update the type parameter of amd_iommufd_hw_info() to be
> 'enum iommu_hw_info_type *' to match the prototype in
> 'struct iommu_ops', clearing up the warning and kCFI violation.
> 
> Fixes: 7d8b06ecc45b ("iommu/amd: Add support for hw_info for iommu capability query")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/iommu/amd/iommufd.c | 2 +-
>  drivers/iommu/amd/iommufd.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com

Jason

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

* Re: [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
  2026-01-22 21:42 [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info() Nathan Chancellor
  2026-01-22 23:37 ` Jason Gunthorpe
@ 2026-01-23  0:37 ` Nicolin Chen
  2026-01-23  4:12 ` Vasant Hegde
  2026-01-28 14:13 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2026-01-23  0:37 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
	Vasant Hegde, Jason Gunthorpe, iommu, linux-kernel

On Thu, Jan 22, 2026 at 02:42:38PM -0700, Nathan Chancellor wrote:
> When building with -Wincompatible-function-pointer-types-strict, a
> warning designed to catch kernel control flow integrity (kCFI) issues at
> build time, there is an instance around amd_iommufd_hw_info():
> 
>   drivers/iommu/amd/iommu.c:3141:13: error: incompatible function pointer types initializing 'void *(*)(struct device *, u32 *, enum iommu_hw_info_type *)' (aka 'void *(*)(struct device *, unsigned int *, enum iommu_hw_info_type *)') with an expression of type 'void *(struct device *, u32 *, u32 *)' (aka 'void *(struct device *, unsigned int *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>    3141 |         .hw_info = amd_iommufd_hw_info,
>         |                    ^~~~~~~~~~~~~~~~~~~
> 
> While 'u32 *' and 'enum iommu_hw_info_type *' are ABI compatible, hence
> no regular warning from -Wincompatible-function-pointer-types, the
> mismatch will trigger a kCFI violation when amd_iommufd_hw_info() is
> called indirectly.
> 
> Update the type parameter of amd_iommufd_hw_info() to be
> 'enum iommu_hw_info_type *' to match the prototype in
> 'struct iommu_ops', clearing up the warning and kCFI violation.
> 
> Fixes: 7d8b06ecc45b ("iommu/amd: Add support for hw_info for iommu capability query")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
 
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>

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

* Re: [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
  2026-01-22 21:42 [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info() Nathan Chancellor
  2026-01-22 23:37 ` Jason Gunthorpe
  2026-01-23  0:37 ` Nicolin Chen
@ 2026-01-23  4:12 ` Vasant Hegde
  2026-01-28 14:13 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: Vasant Hegde @ 2026-01-23  4:12 UTC (permalink / raw)
  To: Nathan Chancellor, Joerg Roedel, Suravee Suthikulpanit
  Cc: Will Deacon, Robin Murphy, Jason Gunthorpe, Nicolin Chen, iommu,
	linux-kernel



On 1/23/2026 3:12 AM, Nathan Chancellor wrote:
> When building with -Wincompatible-function-pointer-types-strict, a
> warning designed to catch kernel control flow integrity (kCFI) issues at
> build time, there is an instance around amd_iommufd_hw_info():
> 
>   drivers/iommu/amd/iommu.c:3141:13: error: incompatible function pointer types initializing 'void *(*)(struct device *, u32 *, enum iommu_hw_info_type *)' (aka 'void *(*)(struct device *, unsigned int *, enum iommu_hw_info_type *)') with an expression of type 'void *(struct device *, u32 *, u32 *)' (aka 'void *(struct device *, unsigned int *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>    3141 |         .hw_info = amd_iommufd_hw_info,
>         |                    ^~~~~~~~~~~~~~~~~~~
> 
> While 'u32 *' and 'enum iommu_hw_info_type *' are ABI compatible, hence
> no regular warning from -Wincompatible-function-pointer-types, the
> mismatch will trigger a kCFI violation when amd_iommufd_hw_info() is
> called indirectly.
> 
> Update the type parameter of amd_iommufd_hw_info() to be
> 'enum iommu_hw_info_type *' to match the prototype in
> 'struct iommu_ops', clearing up the warning and kCFI violation.
> 
> Fixes: 7d8b06ecc45b ("iommu/amd: Add support for hw_info for iommu capability query")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks Nathan!

Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>


-Vasant



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

* Re: [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
  2026-01-22 21:42 [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info() Nathan Chancellor
                   ` (2 preceding siblings ...)
  2026-01-23  4:12 ` Vasant Hegde
@ 2026-01-28 14:13 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2026-01-28 14:13 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, Vasant Hegde,
	Jason Gunthorpe, Nicolin Chen, iommu, linux-kernel

On Thu, Jan 22, 2026 at 02:42:38PM -0700, Nathan Chancellor wrote:
>  drivers/iommu/amd/iommufd.c | 2 +-
>  drivers/iommu/amd/iommufd.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

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

end of thread, other threads:[~2026-01-28 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 21:42 [PATCH] iommu/amd: Fix type of type parameter to amd_iommufd_hw_info() Nathan Chancellor
2026-01-22 23:37 ` Jason Gunthorpe
2026-01-23  0:37 ` Nicolin Chen
2026-01-23  4:12 ` Vasant Hegde
2026-01-28 14:13 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox