Skip to content

Commit 5b0530b

Browse files
nathanchancejoergroedel
authored andcommitted
iommu/amd: Fix type of type parameter to amd_iommufd_hw_info()
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: 7d8b06e ("iommu/amd: Add support for hw_info for iommu capability query") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent c0a652a commit 5b0530b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iommu/amd/iommufd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
static const struct iommufd_viommu_ops amd_viommu_ops;
1313

14-
void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
14+
void *amd_iommufd_hw_info(struct device *dev, u32 *length, enum iommu_hw_info_type *type)
1515
{
1616
struct iommu_hw_info_amd *hwinfo;
1717

drivers/iommu/amd/iommufd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define AMD_IOMMUFD_H
88

99
#if IS_ENABLED(CONFIG_AMD_IOMMU_IOMMUFD)
10-
void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type);
10+
void *amd_iommufd_hw_info(struct device *dev, u32 *length, enum iommu_hw_info_type *type);
1111
size_t amd_iommufd_get_viommu_size(struct device *dev, enum iommu_viommu_type viommu_type);
1212
int amd_iommufd_viommu_init(struct iommufd_viommu *viommu, struct iommu_domain *parent,
1313
const struct iommu_user_data *user_data);

0 commit comments

Comments
 (0)