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 <wangmingrong1@xiaomi.com>
This commit is contained in:
wangmingrong1 2024-12-05 10:13:57 +08:00 committed by Xiang Xiao
parent 1ab1dbc0f0
commit 75fc19d729

View file

@ -32,6 +32,7 @@
#include <sys/param.h>
#include <nuttx/arch.h>
#include <nuttx/mm/kasan.h>
#include <nuttx/virtio/virtio.h>
#include <nuttx/virtio/virtio-mmio.h>
@ -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;
}