<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 6, 2024 at 1:15 PM Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, Aug 6, 2024 at 9:15 AM Gurchetan Singh<br>
<<a href="mailto:gurchetansingh@chromium.org" target="_blank">gurchetansingh@chromium.org</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Aug 5, 2024 at 2:14 AM Sergio Lopez Pascual <<a href="mailto:slp@redhat.com" target="_blank">slp@redhat.com</a>> wrote:<br>
>><br>
>> Dmitry Osipenko <<a href="mailto:dmitry.osipenko@collabora.com" target="_blank">dmitry.osipenko@collabora.com</a>> writes:<br>
>><br>
>> > On 7/23/24 14:49, Sergio Lopez wrote:<br>
>> >> There's an incresing number of machines supporting multiple page sizes<br>
>> >> and on these machines the host and a guest can be running, each one,<br>
>> >> with a different page size.<br>
>> >><br>
>> >> For what pertains to virtio-gpu, this is not a problem if the page size<br>
>> >> of the guest happens to be bigger or equal than the host, but will<br>
>> >> potentially lead to failures in memory allocations and/or mappings<br>
>> >> otherwise.<br>
>> ><br>
>> > Please describe concrete problem you're trying to solve. Guest memory<br>
>> > allocation consists of guest pages, I don't see how knowledge of host<br>
>> > page size helps anything in userspace.<br>
>> ><br>
>> > I suspect you want this for host blobs, but then it should be<br>
>> > virtio_gpu_vram_create() that should use max(host_page_sz,<br>
>> > guest_page_size), AFAICT. It's kernel who is responsible for memory<br>
>> > management, userspace can't be trusted for doing that.<br>
>><br>
>> Mesa's Vulkan/Venus uses CREATE_BLOB to request the host the creation<br>
>> and mapping into the guest of device-backed memory and shmem regions.<br>
>> The CREATE_BLOB ioctl doesn't update drm_virtgpu_resource_create->size,<br>
>> so the guest kernel (and, as a consequence, the host kernel) can't<br>
>> override the user's request.<br>
>><br>
>> I'd like Mesa's Vulkan/Venus in the guest to be able to obtain the host<br>
>> page size to align the size of the CREATE_BLOB requests as required.<br>
><br>
><br>
> gfxstream solves this problem by putting the relevant information in the capabilities obtained from the host:<br>
><br>
> <a href="https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/heads/main/host/virtio-gpu-gfxstream-renderer.cpp#1691" rel="noreferrer" target="_blank">https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/heads/main/host/virtio-gpu-gfxstream-renderer.cpp#1691</a><br>
><br>
> If you want to be paranoid, you can also validate the ResourceCreateBlob::size is properly host-page aligned when that request reaches the host.<br>
><br>
> So you can probably solve this problem using current interfaces. Whether it's cleaner for all context types to use the capabilities, or have all VMMs to expose VIRTIO_GPU_F_HOST_PAGE_SIZE, would be the cost/benefit tradeoff.<br>
><br>
<br>
I guess solving it in a context-type specific way is possible. But I<br>
think it is a relatively universal constraint. And maybe it makes<br>
sense for virtgpu guest kernel to enforce alignment (at least it can<br>
return an error synchronously) in addition to the host.<br></blockquote><div><br></div><div>virtio-media may have support for VIRTIO_MEDIA_CMD_MMAP too, so could run into this issue.</div><div><br></div><div><a href="https://github.com/chromeos/virtio-media?tab=readme-ov-file#shared-memory-regions">https://github.com/chromeos/virtio-media?tab=readme-ov-file#shared-memory-regions</a><br></div><div><br></div><div>virtio-fs also has the DAX window which uses the same memory mapping mechanism.</div><div><br></div><div><a href="https://virtio-fs.gitlab.io/design.html">https://virtio-fs.gitlab.io/design.html</a><br></div><div><br></div><div>Maybe this should not be a virtio-gpu thing, but a virtio thing?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
BR,<br>
-R<br>
<br>
>><br>
>><br>
>> Thanks,<br>
>> Sergio.<br>
>><br>
</blockquote></div></div>