<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 5, 2024 at 2:14 AM Sergio Lopez Pascual <<a href="mailto:slp@redhat.com">slp@redhat.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">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></blockquote><div><br></div><div>gfxstream solves this problem by putting the relevant information in the capabilities obtained from the host:</div><div><br></div><div><a href="https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/heads/main/host/virtio-gpu-gfxstream-renderer.cpp#1691">https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/heads/main/host/virtio-gpu-gfxstream-renderer.cpp#1691</a><br></div><div><br></div><div>If you want to be paranoid, you can also validate the ResourceCreateBlob::size is properly host-page aligned when that request reaches the host.</div><div><br></div><div>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.</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>
Thanks,<br>
Sergio.<br>
<br>
</blockquote></div></div>