On Thu, Feb 20, 2025 at 6:30 AM Sergio Lopez <s...@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 <dverk...@chromium.org>

Thanks,
-- Daniel

Reply via email to