"Michael S. Tsirkin" <mst@xxxxxxxxxx> writes: > On Thu, Feb 13, 2025 at 04:49:14PM +0100, Sergio Lopez wrote: >> There's an incresing number of machines supporting multiple page sizes >> and, on these machines, the host and a guest can be running with >> different pages sizes. >> >> In addition to this, there might be devices that have a required and/or >> preferred page size for mapping memory. >> >> In this series, we extend virtio_shm_region with a field to hold the >> page size. This field has a 16-bit size to accommodate into the existing >> padding virtio_pci_cap, simplifying the introduction of this additional >> data into the structure. The device will provide the page size in format >> PAGE_SIZE >> 12. >> >> The series also extends the PCI and MMIO transports to obtain the >> corresponding value from the device. For the PCI one, it should be safe >> since we're using an existing 16-bit padding in the virtio_pci_cap >> struct. For MMIO, we need to access a new register, so there's a risk >> the VMM may overreact and crash the VM. I've checked libkrun, >> firecracker, cloud-hypervisor and crosvm, and all of them should deal >> with the unexpected MMIO read gracefully. QEMU doesn't support SHM for >> the MMIO transport, so that isn't a concern either. >> >> How the SHM page size information is used depends on each device. Some >> may silently round up allocations, some may expose this information to >> userspace. This series includes a patch that extends virtio-gpu to >> expose the information via the VIRTGPU_GETPARAM ioctl, as an example of >> the second approach. >> >> This patch series is an RFC because it requires changes to the VIRTIO >> specifications. This patch series will be used as a reference to >> propose such changes. >> >> Signed-off-by: Sergio Lopez <slp@xxxxxxxxxx> > > > don't you want to negotiate the page size with the > driver then? It's not really a negotiation. If the device presents the feature, the driver must honor the page size, either directly by rejecting or rounding up allocations, indirectly by informing userspace, or both. If the driver can't accomodate to the page size, it must refrain from using the Shared Memory Region. Thanks, Sergio.