[PATCH v3 4/5] virtio: blk: Fix converting the vendor id to a string

Simon Glass sjg at chromium.org
Sat Apr 11 22:30:54 CEST 2026


Hi Daniel,

On 2026-04-08T22:09:23, Daniel Palmer <daniel at thingy.jp> wrote:
> virtio: blk: Fix converting the vendor id to a string
>
> Currently we are trying to work out if the vendor id is from
> a virtio-mmio device and then casting a u32 to a char* and using
> it as a C-string. By chance there is usually a zero after the u32
> and it works.
>
> Since the vendor id we are trying to convert to a string is QEMU's
> just define a value for the QEMU vendor id, check if the vendor
> id matches and then use a predefined string for "QEMU".
>
> I don't think we should have been assumming all virtio-mmio vendor
> ids are printable ASCII chars in the first place so do this special
> casing just for QEMU. If the vendor id isn't QEMU print the hex
> value of it.
>
> Signed-off-by: Daniel Palmer <daniel at thingy.jp>
>
> drivers/virtio/virtio_blk.c | 12 +++++-------
>  include/virtio_mmio.h       |  2 ++
>  2 files changed, 7 insertions(+), 7 deletions(-)

> diff --git a/include/virtio_mmio.h b/include/virtio_mmio.h
> @@ -5,6 +5,8 @@
> +#define VIRTIO_MMIO_VENDOR_QEMU      0x554d4551

This vendor ID applies to all virtio transports, not just virtio-mmio,
e.g. virtio_blk.c must include virtio_mmio.h even when built for
platforms that only have virtio-pci

Please can you move this to include/virtio.h instead? Something like
VIRTIO_VENDOR_QEMU would be more appropriate.

With that:
Reviewed-by: Simon Glass <sjg at chromium.org>

Regards,
Simon


More information about the U-Boot mailing list