[PATCH v3 00/38] virtio: config space endian-ness cleanup

Michael S. Tsirkin
2020-08-05T17:16:02Z

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.

Further, LE-only devices (e.g. modern-style) add unnecessary overhead
by using generic transitional-style config space accesses.

The following patches adding sparse tagging and then using that
to correctly access config space as either transitional or LE
are my tree.
Lightly tested.

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 there.

changes from v2:
- convert a couple of missing devices
- add APIs for accessing config space as LE, use that
in modern devices and in balloon.
- code comments in vdpa_sim explaining use of transitional APIs

Michael S. Tsirkin (38):
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 is 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
virtio_config: disallow native type fields (again)
virtio_config: LE config space accessors
virtio_caif: correct tags for config space fields
virtio_config: add virtio_cread_le_feature
virtio_balloon: use LE config space accesses
virtio_input: convert to LE accessors
virtio_fs: convert to LE accessors
virtio_crypto: convert to LE accessors
virtio_pmem: convert to LE accessors
drm/virtio: convert to LE accessors
virtio_mem: convert to LE accessors
virtio-iommu: convert to LE accessors
virtio_config: drop LE option from config space
virtio_net: use LE accessors for speed/duplex

drivers/crypto/virtio/virtio_crypto_core.c | 46 ++---
drivers/gpu/drm/virtio/virtgpu_kms.c | 16 +-
drivers/iommu/virtio-iommu.c | 34 ++--
drivers/net/virtio_net.c | 9 +-
drivers/nvdimm/virtio_pmem.c | 4 +-
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 | 33 +++-
drivers/vhost/vdpa.c | 8 +-
drivers/virtio/virtio_balloon.c | 28 ++--
drivers/virtio/virtio_input.c | 32 ++--
drivers/virtio/virtio_mem.c | 30 ++--
drivers/virtio/virtio_vdpa.c | 9 +-
fs/fuse/virtio_fs.c | 4 +-
include/linux/vdpa.h | 34 ++++
include/linux/virtio_caif.h | 6 +-
include/linux/virtio_config.h | 186 +++++++++++++++------
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 +--
32 files changed, 405 insertions(+), 271 deletions(-)

--
MST