[PATCH RFC v3 2/4] virtio-pci: extend virtio_pci_cap with page_shift
Daniel Verkamp
dverkamp at chromium.org
Thu Feb 20 19:19:47 UTC 2025
On Thu, Feb 20, 2025 at 6:30 AM Sergio Lopez <slp at redhat.com> wrote:
[...]
> @@ -829,6 +839,7 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
> *bar = res_bar;
> *offset = res_offset;
> *len = res_length;
> + *page_size = 1 << (page_shift + 12);
Maybe this should validate that page_shift is in range to avoid any
funny business from the device; since page_size is u32, this needs
page_shift + 12 < 32. (If it's out of range, I am not sure what this
should do; maybe just warn and set it to the default 4096?)
Also shifting into the sign bit is technically undefined (or
implementation-defined? I don't recall) behavior, so perhaps make the
constant unsigned, e.g. `1U << (page_shift + 12)`.
Other than that, looks reasonable to me:
Reviewed-by: Daniel Verkamp <dverkamp at chromium.org>
Thanks,
-- Daniel
More information about the dri-devel
mailing list