[PATCH v2 00/24] virtio: config space endian-ness cleanup

Michael S. Tsirkin
Mon, 03 Aug 2020 20:58:33 -0000

Config space endian-ness is currently a mess: fields are
not tagged with the correct endian-ness so it's easy
to make mistakes like instanciating config space in
native endian-ness.

The following patches adding sparse tagging are currently in my tree.
Lightly tested.

As a follow-up, I plan to add new APIs that handle modern config space
in a more efficient way (bypassing the version check).

That is still TBD.

I also start with a version using gcc extensions, then switch
to _Generic. This is helpful for backports to older kernels/older
distros: _Generic patch can just be skipped.

Michael S. Tsirkin (24):
  virtio_balloon: fix sparse warning
  virtio_ring: sparse warning fixup
  virtio: allow __virtioXX, __leXX in config space
  virtio_9p: correct tags for config space fields
  virtio_balloon: correct tags for config space fields
  virtio_blk: correct tags for config space fields
  virtio_console: correct tags for config space fields
  virtio_crypto: correct tags for config space fields
  virtio_fs: correct tags for config space fields
  virtio_gpu: correct tags for config space fields
  virtio_input: correct tags for config space fields
  virtio_iommu: correct tags for config space fields
  virtio_mem: correct tags for config space fields
  virtio_net: correct tags for config space fields
  virtio_pmem: correct tags for config space fields
  virtio_scsi: correct tags for config space fields
  virtio_config: disallow native type fields
  mlxbf-tmfifo: sparse tags for config access
  vdpa: make sure set_features in invoked for legacy
  vhost/vdpa: switch to new helpers
  virtio_vdpa: legacy features handling
  vdpa_sim: fix endian-ness of config space
  virtio_config: cread/write cleanup
  virtio_config: rewrite using _Generic

 drivers/platform/mellanox/mlxbf-tmfifo.c |  13 +-
 drivers/scsi/virtio_scsi.c               |   4 +-
 drivers/vdpa/vdpa.c                      |   1 +
 drivers/vdpa/vdpa_sim/vdpa_sim.c         |  31 ++++-
 drivers/vhost/vdpa.c                     |   8 +-
 drivers/virtio/virtio_balloon.c          |   2 +-
 drivers/virtio/virtio_vdpa.c             |   9 +-
 include/linux/vdpa.h                     |  34 +++++
 include/linux/virtio_config.h            | 159 ++++++++++++++---------
 include/linux/virtio_ring.h              |  19 ++-
 include/uapi/linux/virtio_9p.h           |   4 +-
 include/uapi/linux/virtio_balloon.h      |  10 +-
 include/uapi/linux/virtio_blk.h          |  26 ++--
 include/uapi/linux/virtio_console.h      |   8 +-
 include/uapi/linux/virtio_crypto.h       |  26 ++--
 include/uapi/linux/virtio_fs.h           |   2 +-
 include/uapi/linux/virtio_gpu.h          |   8 +-
 include/uapi/linux/virtio_input.h        |  18 +--
 include/uapi/linux/virtio_iommu.h        |  12 +-
 include/uapi/linux/virtio_mem.h          |  14 +-
 include/uapi/linux/virtio_net.h          |   8 +-
 include/uapi/linux/virtio_pmem.h         |   4 +-
 include/uapi/linux/virtio_scsi.h         |  20 +--
 23 files changed, 270 insertions(+), 170 deletions(-)

--
MST