]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/virtio: Fix sparse warning
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Thu, 26 Mar 2020 09:35:56 +0000 (10:35 +0100)
committerJoerg Roedel <jroedel@suse.de>
Fri, 27 Mar 2020 10:09:18 +0000 (11:09 +0100)
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 <lkp@intel.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20200326093558.2641019-2-jean-philippe@linaro.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
include/uapi/linux/virtio_iommu.h

index 237e36a280cb636fe053676438ddb80c3383af48..48e3c29223b580bba987976098c1c65992964796 100644 (file)
 #define VIRTIO_IOMMU_F_MMIO                    5
 
 struct virtio_iommu_range_64 {
-       __le64                                  start;
-       __le64                                  end;
+       __u64                                   start;
+       __u64                                   end;
 };
 
 struct virtio_iommu_range_32 {
-       __le32                                  start;
-       __le32                                  end;
+       __u32                                   start;
+       __u32                                   end;
 };
 
 struct virtio_iommu_config {
        /* Supported page sizes */
-       __le64                                  page_size_mask;
+       __u64                                   page_size_mask;
        /* Supported IOVA range */
        struct virtio_iommu_range_64            input_range;
        /* Max domain ID size */
        struct virtio_iommu_range_32            domain_range;
        /* Probe buffer size */
-       __le32                                  probe_size;
+       __u32                                   probe_size;
 };
 
 /* Request types */