Skip to content

Commit 3f84b96

Browse files
jpbruckerjoergroedel
authored andcommitted
iommu/virtio: Fix sparse warning
We copied the virtio_iommu_config from the virtio-iommu specification, which declares the fields using little-endian annotations (for example le32). Unfortunately this causes sparse to warn about comparison between little- and cpu-endian, because of the typecheck() in virtio_cread(): drivers/iommu/virtio-iommu.c:1024:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1024:9: sparse: restricted __le64 * drivers/iommu/virtio-iommu.c:1024:9: sparse: unsigned long long * drivers/iommu/virtio-iommu.c:1036:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1036:9: sparse: restricted __le64 * drivers/iommu/virtio-iommu.c:1036:9: sparse: unsigned long long * drivers/iommu/virtio-iommu.c:1040:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1040:9: sparse: restricted __le64 * drivers/iommu/virtio-iommu.c:1040:9: sparse: unsigned long long * drivers/iommu/virtio-iommu.c:1044:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1044:9: sparse: restricted __le32 * drivers/iommu/virtio-iommu.c:1044:9: sparse: unsigned int * drivers/iommu/virtio-iommu.c:1048:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1048:9: sparse: restricted __le32 * drivers/iommu/virtio-iommu.c:1048:9: sparse: unsigned int * drivers/iommu/virtio-iommu.c:1052:9: sparse: sparse: incompatible types in comparison expression (different base types): drivers/iommu/virtio-iommu.c:1052:9: sparse: restricted __le32 * drivers/iommu/virtio-iommu.c:1052:9: sparse: unsigned int * Although virtio_cread() does convert virtio-endian (in our case little-endian) to cpu-endian, the typecheck() needs the two arguments to have the same endianness. Do as UAPI headers of other virtio devices do, and remove the endian annotation from the device config. Even though we change the UAPI this shouldn't cause any regression since QEMU, the existing implementation of virtio-iommu that uses this header, already removes the annotations when importing headers. Reported-by: kbuild test robot <[email protected]> Signed-off-by: Jean-Philippe Brucker <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent fa4afd7 commit 3f84b96

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/uapi/linux/virtio_iommu.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818
#define VIRTIO_IOMMU_F_MMIO 5
1919

2020
struct virtio_iommu_range_64 {
21-
__le64 start;
22-
__le64 end;
21+
__u64 start;
22+
__u64 end;
2323
};
2424

2525
struct virtio_iommu_range_32 {
26-
__le32 start;
27-
__le32 end;
26+
__u32 start;
27+
__u32 end;
2828
};
2929

3030
struct virtio_iommu_config {
3131
/* Supported page sizes */
32-
__le64 page_size_mask;
32+
__u64 page_size_mask;
3333
/* Supported IOVA range */
3434
struct virtio_iommu_range_64 input_range;
3535
/* Max domain ID size */
3636
struct virtio_iommu_range_32 domain_range;
3737
/* Probe buffer size */
38-
__le32 probe_size;
38+
__u32 probe_size;
3939
};
4040

4141
/* Request types */

0 commit comments

Comments
 (0)