From 75fc19d7297a451e9b4dfed07211e4d127197c71 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Thu, 5 Dec 2024 10:13:57 +0800 Subject: [PATCH] virtio: Fix the problem of incorrect setting of virtio queue address under tags kasan There is also a printing error due to https://github.com/apache/nuttx/pull/15043: Configuration/Tool: rv-virt/virt_nsh In file included from virtio/virtio-mmio.c:29: virtio/virtio-mmio.c: In function 'virtio_mmio_init_device': Error: virtio/virtio-mmio.c:826:14: error: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=] 826 | vrterr("Version %d not supported!\n", vdev->id.version); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ | | | uint32_t {aka long unsigned int} virtio/virtio-mmio.c:826:24: note: format string is defined here 826 | vrterr("Version %d not supported!\n", vdev->id.version); | ~^ | | | int | %ld cc1: all warnings being treated as errors make[1]: *** [Makefile:109: virtio-mmio.o] Error 1 make[1]: Target 'libdrivers.a' not remade because of errors. Signed-off-by: wangmingrong1 --- drivers/virtio/virtio-mmio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio-mmio.c b/drivers/virtio/virtio-mmio.c index 8788885e0d1..049eff98168 100644 --- a/drivers/virtio/virtio-mmio.c +++ b/drivers/virtio/virtio-mmio.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -342,15 +343,15 @@ static int virtio_mmio_config_virtqueue(FAR struct metal_io_region *io, { metal_io_write32(io, VIRTIO_MMIO_QUEUE_NUM, vq->vq_nentries); - addr = (uint64_t)(uintptr_t)vq->vq_ring.desc; + addr = (uint64_t)kasan_reset_tag((FAR void *)vq->vq_ring.desc); metal_io_write32(io, VIRTIO_MMIO_QUEUE_DESC_LOW, addr); metal_io_write32(io, VIRTIO_MMIO_QUEUE_DESC_HIGH, addr >> 32); - addr = (uint64_t)(uintptr_t)vq->vq_ring.avail; + addr = (uint64_t)kasan_reset_tag((FAR void *)vq->vq_ring.avail); metal_io_write32(io, VIRTIO_MMIO_QUEUE_AVAIL_LOW, addr); metal_io_write32(io, VIRTIO_MMIO_QUEUE_AVAIL_HIGH, addr >> 32); - addr = (uint64_t)(uintptr_t)vq->vq_ring.used; + addr = (uint64_t)kasan_reset_tag((FAR void *)vq->vq_ring.used); metal_io_write32(io, VIRTIO_MMIO_QUEUE_USED_LOW, addr); metal_io_write32(io, VIRTIO_MMIO_QUEUE_USED_HIGH, addr >> 32); @@ -823,7 +824,7 @@ static int virtio_mmio_init_device(FAR struct virtio_mmio_device_s *vmdev, vdev->id.version = metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_VERSION); if (vdev->id.version < 1 || vdev->id.version > 2) { - vrterr("Version %d not supported!\n", vdev->id.version); + vrterr("Version %"PRIu32" not supported!\n", vdev->id.version); return -ENODEV; }