Re: [PATCH RFC v3 2/4] virtio-pci: extend virtio_pci_cap with page_shift

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 20, 2025 at 6:30 AM Sergio Lopez <slp@xxxxxxxxxx> 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@xxxxxxxxxxxx>

Thanks,
-- Daniel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux