Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfio/pci: Support 8-byte PCI loads and stores

Many PCI adapters can benefit or even require full 64bit read
and write access to their registers. In order to enable work on
user-space drivers for these devices add two new variations
vfio_pci_core_io{read|write}64 of the existing access methods
when the architecture supports 64-bit ioreads and iowrites.

Signed-off-by: Ben Segal <bpsegal@us.ibm.com>
Co-developed-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com>
Link: https://lore.kernel.org/r/20240619115847.1344875-3-gbayer@linux.ibm.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Ben Segal and committed by
Alex Williamson
4df13a68 186bfe44

+19
+16
drivers/vfio/pci/vfio_pci_rdwr.c
··· 89 89 VFIO_IOREAD(8) 90 90 VFIO_IOREAD(16) 91 91 VFIO_IOREAD(32) 92 + #ifdef ioread64 93 + VFIO_IOREAD(64) 94 + #endif 92 95 93 96 #define VFIO_IORDWR(size) \ 94 97 static int vfio_pci_iordwr##size(struct vfio_pci_core_device *vdev,\ ··· 127 124 VFIO_IORDWR(8) 128 125 VFIO_IORDWR(16) 129 126 VFIO_IORDWR(32) 127 + #if defined(ioread64) && defined(iowrite64) 128 + VFIO_IORDWR(64) 129 + #endif 130 + 130 131 /* 131 132 * Read or write from an __iomem region (MMIO or I/O port) with an excluded 132 133 * range which is inaccessible. The excluded range drops writes and fills ··· 155 148 else 156 149 fillable = 0; 157 150 151 + #if defined(ioread64) && defined(iowrite64) 152 + if (fillable >= 8 && !(off % 8)) { 153 + ret = vfio_pci_iordwr64(vdev, iswrite, test_mem, 154 + io, buf, off, &filled); 155 + if (ret) 156 + return ret; 157 + 158 + } else 159 + #endif 158 160 if (fillable >= 4 && !(off % 4)) { 159 161 ret = vfio_pci_iordwr32(vdev, iswrite, test_mem, 160 162 io, buf, off, &filled);
+3
include/linux/vfio_pci_core.h
··· 155 155 VFIO_IOREAD_DECLATION(8) 156 156 VFIO_IOREAD_DECLATION(16) 157 157 VFIO_IOREAD_DECLATION(32) 158 + #ifdef ioread64 159 + VFIO_IOREAD_DECLATION(64) 160 + #endif 158 161 159 162 #endif /* VFIO_PCI_CORE_H */