<div dir="ltr">Thanks Gerd, that's very helpful!<div><br></div><div>Recently I've had a reason to get Vk to work with a non cpu accelerated guest and your steps were pretty much all there was to it (couldn't directly use the hypervisor's mapping apis w/ tcg, so the 'runtime user controlled backings' part needed to use your method: <a href="https://android-review.googlesource.com/c/platform/external/qemu/+/1310349">https://android-review.googlesource.com/c/platform/external/qemu/+/1310349</a>)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 12, 2020 at 3:41 AM Gerd Hoffmann <<a href="mailto:kraxel@redhat.com">kraxel@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"> Hi,<br>
<br>
> I was taking a look at QEMU and it's non-obvious to me how to implement<br>
> RESOURCE_MAP / RESOURCE_UNMAP.<br>
> <br>
> For GL_ARB_buffer_storage, virglrenderer can provide a page-aligned<br>
> address (seems to work even on Nvidia) for use with KVM:<br>
> <br>
> <a href="https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/374/diffs#14086999aaf57fc68a3d7d639ab280c3a2672430_603_670" rel="noreferrer" target="_blank">https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/374/diffs#14086999aaf57fc68a3d7d639ab280c3a2672430_603_670</a><br>
> <br>
> We need to figure out a way to call kvm_region_add / kvm_region_del<br>
> from virtio-gpu-3d.c with this address.<br>
<br>
Global initialization:<br>
(1) Create a memory region for the virtual pci bar,<br>
using memory_region_init() That'll be just a container.<br>
<br>
Resource initialization:<br>
(1) Create a memory region for each resource you want be able to map,<br>
using memory_region_init_ram_ptr().<br>
(2) Register the resource region as child in the container, using<br>
memory_region_add_subregion().<br>
<br>
RESOURCE_MAP:<br>
(1) Move the memory region to the place the guest asks for, using<br>
memory_region_set_address().<br>
(2) Enable the region (memory_region_set_enabled()).<br>
<br>
RESOURCE_UNMAP:<br>
(1) Disable the region (memory_region_set_enabled()).<br>
<br>
HTH,<br>
Gerd<br>
<br>
<br>
_______________________________________________<br>
virglrenderer-devel mailing list<br>
<a href="mailto:virglrenderer-devel@lists.freedesktop.org" target="_blank">virglrenderer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel</a><br>
</blockquote></div>