Re: [PATCH 1/3] virtio-gpu: rutabaga: Properly set stride when copying resources
On Mon, Jun 10, 2024 at 12:44 AM Marc-André Lureau < marcandre.lur...@gmail.com> wrote: > Hi > > On Wed, Jun 5, 2024 at 7:30 PM Weifeng Liu > wrote: > >> The stride is not correctly assigned when copying pixel data, causing >> images being displayed incomplete when using 2d component of rutabaga. >> >> Signed-off-by: Weifeng Liu >> --- >> hw/display/virtio-gpu-rutabaga.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/hw/display/virtio-gpu-rutabaga.c >> b/hw/display/virtio-gpu-rutabaga.c >> index 17bf701a21..2ba6869606 100644 >> --- a/hw/display/virtio-gpu-rutabaga.c >> +++ b/hw/display/virtio-gpu-rutabaga.c >> @@ -53,6 +53,7 @@ virtio_gpu_rutabaga_update_cursor(VirtIOGPU *g, struct >> virtio_gpu_scanout *s, >> transfer.z = 0; >> transfer.w = res->width; >> transfer.h = res->height; >> +transfer.stride = res->width * 4; >> > > ok, stride defined by QEMUCursor layout > > >> transfer.d = 1; >> >> transfer_iovec.iov_base = s->current_cursor->data; >> @@ -273,6 +274,7 @@ rutabaga_cmd_resource_flush(VirtIOGPU *g, struct >> virtio_gpu_ctrl_command *cmd) >> transfer.z = 0; >> transfer.w = res->width; >> transfer.h = res->height; >> +transfer.stride = pixman_image_get_stride(res->image); >> transfer.d = 1; >> > > ok (destination image stride) > > >> transfer_iovec.iov_base = pixman_image_get_data(res->image); >> @@ -382,6 +384,7 @@ rutabaga_cmd_transfer_to_host_2d(VirtIOGPU *g, >> transfer.z = 0; >> transfer.w = t2d.r.width; >> transfer.h = t2d.r.height; >> +transfer.stride = t2d.r.width * 4; >> > > here however, it's unclear to me what the stride could be, I think it > could depend on resource format (virgl doesn't set stride either). > > Gurchetan? > gfxstream does more or less the same thing internally to deal with the lack of stride. Since virtio-gpu KMS only supports 4-bpp formats, this is fine, so r-b for this particular patch. That said, we actually don't use virtio-gpu-rutabaga for 2D mode or VirGL mode, preferring to use the other more supported modes in QEMU for those use cases. I think there's actually some CI support for those in many places. So suggest just waiting until virglrenderer uprev lands in QEMU. > > > >> transfer.d = 1; >> >> result = rutabaga_resource_transfer_write(vr->rutabaga, 0, >> t2d.resource_id, >> -- >> 2.45.0 >> >> >> > > -- > Marc-André Lureau >
Re: rutabaga 0.1.3
On Sat, Mar 2, 2024 at 6:38 AM Alyssa Ross wrote: > Hi Gurchetan, > > > >> > Would this be a suitable commit for the 0.1.3 release of rutabaga? > > >> > > > >> > > https://chromium.googlesource.com/crosvm/crosvm/+/5dfd74a0680d317c6edf44138def886f47cb1c7c > > >> > > > >> > The gfxstream/AEMU commits would remain unchanged. > > >> > > >> That combination works for me. > > > > > > Just FYI, still working on it. Could take 1-2 more weeks. > > > > FYI: > > > > > https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/tags/v0.1.2-gfxstream-release > > > > > https://android.googlesource.com/platform/hardware/google/aemu/+/refs/tags/v0.1.2-aemu-release > > > > > https://chromium.googlesource.com/crosvm/crosvm/+/refs/tags/v0.1.3-rutabaga-release > > Unlike the commit I tested for you, the commit that ended up being > tagged as v0.1.3-rutabaga-release doesn't work for me: > > qemu: The errno is EBADF: Bad file number > qemu: CHECK failed in rutabaga_cmd_resource_map_blob() > ../hw/display/virtio-gpu-rutabaga.c:655 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x208, error 0x1200 > qemu: CHECK failed in rutabaga_cmd_resource_unmap_blob() > ../hw/display/virtio-gpu-rutabaga.c:723 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x209, error 0x1200 > qemu: The errno is EBADF: Bad file number > qemu: CHECK failed in rutabaga_cmd_resource_map_blob() > ../hw/display/virtio-gpu-rutabaga.c:655 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x208, error 0x1200 > qemu: CHECK failed in rutabaga_cmd_resource_unmap_blob() > ../hw/display/virtio-gpu-rutabaga.c:723 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x209, error 0x1200 > qemu: The errno is EBADF: Bad file number > qemu: CHECK failed in rutabaga_cmd_resource_map_blob() > ../hw/display/virtio-gpu-rutabaga.c:655 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x208, error 0x1200 > qemu: invalid resource id > qemu: CHECK failed in rutabaga_cmd_submit_3d() > ../hw/display/virtio-gpu-rutabaga.c:341 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x207, error 0x1200 > qemu: CHECK failed in rutabaga_cmd_resource_unmap_blob() > ../hw/display/virtio-gpu-rutabaga.c:723 > qemu: virtio_gpu_rutabaga_process_cmd: ctrl 0x209, error 0x1200 > Thank you for the bug report .. does crrev.com/c/5342655 fix this for you? I bisected it to: > > commit f3dbf20eedadb135e2fd813474fbb9731d465f3a > Author: Andrew Walbran > Date: Wed Nov 29 17:23:45 2023 + > > rutabaga_gfx: Uprev nix to 0.27.1 > > The new version of nix uses OwnedFd in various places, which > allows us > to have less unsafe code. > > TEST=CQ > BUG=b:293289578 > > Change-Id: I61aa80c4105eaf1182c5c325109b5aba11cf60de > Reviewed-on: > https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5072293 > Auto-Submit: Andrew Walbran > Reviewed-by: Gurchetan Singh > Reviewed-by: Frederick Mayle > Commit-Queue: Frederick Mayle >
Re: [PATCH v15 0/9] rutabaga_gfx + gfxstream
On Tue, Jan 30, 2024 at 7:10 PM Gurchetan Singh wrote: > > > On Fri, Jan 26, 2024 at 6:23 AM Alyssa Ross wrote: > >> Gurchetan Singh writes: >> >> > On Sat, Jan 20, 2024 at 4:19 AM Alyssa Ross wrote: >> > >> >> Gurchetan Singh writes: >> >> >> >> > On Fri, Jan 19, 2024 at 1:13 PM Alyssa Ross wrote: >> >> >> >> >> >> Hi Gurchetan, >> >> >> >> >> >> > Thanks for the reminder. I did make a request to create the >> release >> >> >> > tags, but changes were requested by Fedora packaging effort: >> >> >> > >> >> >> > https://bugzilla.redhat.com/show_bug.cgi?id=2242058 >> >> >> > https://bugzilla.redhat.com/show_bug.cgi?id=2241701 >> >> >> > >> >> >> > So the request was canceled, but never re-requested. I'll fire >> off >> >> >> > another request, with: >> >> >> > >> >> >> > gfxstream: 23d05703b94035ac045df60823fb1fc4be0fdf1c ("gfxstream: >> >> >> > manually add debug logic") >> >> >> > AEMU: dd8b929c247ce9872c775e0e5ddc4300011d0e82 ("aemu: improve >> >> licensing") >> >> >> > >> >> >> > as the commits. These match the Fedora requests, and the AEMU >> one has >> >> >> > been merged into Fedora already it seems. >> >> >> >> >> >> These revisions have the problem I mentioned in my previous message: >> >> >> >> >> >> >> The gfxstream ref mentioned here isn't compatible with >> >> >> >> v0.1.2-rutabaga-release, because it no longer provides >> >> logging_base.pc, >> >> >> >> >> >> rutabaga was not fixed to use the new AEMU package names until >> after the >> >> >> v0.1.2-rutabaga-release tag, in commit 5dfd74a06. So will there be >> a >> >> >> new Rutabaga release that's compatible with these release versions >> of >> >> >> gfxstream and AEMU? >> >> > >> >> > Good catch. >> >> > >> >> > One possible workaround is to build gfxstream as a shared library. I >> >> > think that would avoid rutabaga looking for AEMU package config >> files. >> >> > >> >> > But if another rutabaga release is desired with support for a static >> >> > library, then we can make that happen too. >> >> >> >> We're exclusively building gfxstream as a shared library. >> >> >> >> Looking at rutabaga's build.rs, it appears to me like pkg-config is >> >> always used for gfxstream unless overridden by GFXSTREAM_PATH. >> >> >> > >> > Hmm, it seems we should be checking pkg-config --static before looking >> for >> > AEMU in build.rs -- oh well. >> > >> > Would this be a suitable commit for the 0.1.3 release of rutabaga? >> > >> > >> https://chromium.googlesource.com/crosvm/crosvm/+/5dfd74a0680d317c6edf44138def886f47cb1c7c >> > >> > The gfxstream/AEMU commits would remain unchanged. >> >> That combination works for me. >> > > Just FYI, still working on it. Could take 1-2 more weeks. > FYI: https://android.googlesource.com/platform/hardware/google/gfxstream/+/refs/tags/v0.1.2-gfxstream-release https://android.googlesource.com/platform/hardware/google/aemu/+/refs/tags/v0.1.2-aemu-release https://chromium.googlesource.com/crosvm/crosvm/+/refs/tags/v0.1.3-rutabaga-release > > >
Re: Call for GSoC/Outreachy internship project ideas
On Wed, Jan 24, 2024 at 4:51 AM Stefan Hajnoczi wrote: > On Tue, 23 Jan 2024 at 22:47, Gurchetan Singh > wrote: > > Title: > > - Improve display integration for upstream virtualized graphics > > > > Summary: > > - The Rutabaga Virtual Graphics interface's UI integration upstream is > very simple, but in deployment it will be complex. This project aims to > bridge the gap between downstream consumers and upstream QEMU. > > > > Looking for someone interested in Rust + system level graphics to help > realize the next steps. > > Hi Gurchetan, > It's unclear what this project idea entails. > > Based on your email my guess is you're looking for someone to help > upstream code into QEMU, but I'm not sure. Last year there was a > project to upstream bsd-user emulation code into QEMU and I think that > type of project can work well. > > Or maybe you're looking for someone to write a QEMU UI code that uses > rutabaga_gfx. > > Can you describe the next steps in more detail? > > The project description should contain enough information for someone > who knows how to program but has no domain knowledge in Rutabaga, > virtio-gpu, or QEMU. > > > Note: developers should be willing to sign Google CLA, here: > > > > https://cla.developers.google.com/about/google-individual > > > > But everything will be FOSS. > > Which codebase will this project touch? If a CLA is required then it > sounds like it's not qemu.git? > Good points, I think we need to think about this a bit more I hereby withdraw the idea! > > > Links > > - https://crosvm.dev/book/appendix/rutabaga_gfx.html > > - > https://patchew.org/QEMU/20230421011223.718-1-gurchetansi...@chromium.org/ > > > > Skills > > - Level: Advanced > > - Rust, Vulkan, virtualization, cross-platform graphics >
Re: [PATCH v15 0/9] rutabaga_gfx + gfxstream
On Fri, Jan 26, 2024 at 6:23 AM Alyssa Ross wrote: > Gurchetan Singh writes: > > > On Sat, Jan 20, 2024 at 4:19 AM Alyssa Ross wrote: > > > >> Gurchetan Singh writes: > >> > >> > On Fri, Jan 19, 2024 at 1:13 PM Alyssa Ross wrote: > >> >> > >> >> Hi Gurchetan, > >> >> > >> >> > Thanks for the reminder. I did make a request to create the > release > >> >> > tags, but changes were requested by Fedora packaging effort: > >> >> > > >> >> > https://bugzilla.redhat.com/show_bug.cgi?id=2242058 > >> >> > https://bugzilla.redhat.com/show_bug.cgi?id=2241701 > >> >> > > >> >> > So the request was canceled, but never re-requested. I'll fire off > >> >> > another request, with: > >> >> > > >> >> > gfxstream: 23d05703b94035ac045df60823fb1fc4be0fdf1c ("gfxstream: > >> >> > manually add debug logic") > >> >> > AEMU: dd8b929c247ce9872c775e0e5ddc4300011d0e82 ("aemu: improve > >> licensing") > >> >> > > >> >> > as the commits. These match the Fedora requests, and the AEMU one > has > >> >> > been merged into Fedora already it seems. > >> >> > >> >> These revisions have the problem I mentioned in my previous message: > >> >> > >> >> >> The gfxstream ref mentioned here isn't compatible with > >> >> >> v0.1.2-rutabaga-release, because it no longer provides > >> logging_base.pc, > >> >> > >> >> rutabaga was not fixed to use the new AEMU package names until after > the > >> >> v0.1.2-rutabaga-release tag, in commit 5dfd74a06. So will there be a > >> >> new Rutabaga release that's compatible with these release versions of > >> >> gfxstream and AEMU? > >> > > >> > Good catch. > >> > > >> > One possible workaround is to build gfxstream as a shared library. I > >> > think that would avoid rutabaga looking for AEMU package config files. > >> > > >> > But if another rutabaga release is desired with support for a static > >> > library, then we can make that happen too. > >> > >> We're exclusively building gfxstream as a shared library. > >> > >> Looking at rutabaga's build.rs, it appears to me like pkg-config is > >> always used for gfxstream unless overridden by GFXSTREAM_PATH. > >> > > > > Hmm, it seems we should be checking pkg-config --static before looking > for > > AEMU in build.rs -- oh well. > > > > Would this be a suitable commit for the 0.1.3 release of rutabaga? > > > > > https://chromium.googlesource.com/crosvm/crosvm/+/5dfd74a0680d317c6edf44138def886f47cb1c7c > > > > The gfxstream/AEMU commits would remain unchanged. > > That combination works for me. > Just FYI, still working on it. Could take 1-2 more weeks.
Re: [PATCH v3 3/3] virtio-gpu-rutabaga.c: override resource_destroy method
On Tue, Jan 30, 2024 at 7:00 AM Manos Pitsidianakis < manos.pitsidiana...@linaro.org> wrote: > When the Rutabaga GPU device frees resources, it calls > rutabaga_resource_unref for that resource_id. However, when the generic > VirtIOGPU functions destroys resources, it only removes the > virtio_gpu_simple_resource from the device's VirtIOGPU->reslist list. > The rutabaga resource associated with that resource_id is then leaked. > > This commit overrides the resource_destroy class method introduced in > the previous commit to fix this. > Reviewed-by: Gurchetan Singh > > Signed-off-by: Manos Pitsidianakis > --- > hw/display/virtio-gpu-rutabaga.c | 47 > 1 file changed, 35 insertions(+), 12 deletions(-) > > diff --git a/hw/display/virtio-gpu-rutabaga.c > b/hw/display/virtio-gpu-rutabaga.c > index 9e67f9bd51..17bf701a21 100644 > --- a/hw/display/virtio-gpu-rutabaga.c > +++ b/hw/display/virtio-gpu-rutabaga.c > @@ -148,14 +148,38 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, > } > > static void > +virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, > + struct virtio_gpu_simple_resource *res, > + Error **errp) > +{ > +int32_t result; > +VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); > + > +result = rutabaga_resource_unref(vr->rutabaga, res->resource_id); > +if (result) { > +error_setg_errno(errp, > +(int)result, > +"%s: rutabaga_resource_unref returned %"PRIi32 > +" for resource_id = %"PRIu32, __func__, result, > +res->resource_id); > +} > + > +if (res->image) { > +pixman_image_unref(res->image); > +} > + > +QTAILQ_REMOVE(>reslist, res, next); > +g_free(res); > +} + > +static void > rutabaga_cmd_resource_unref(VirtIOGPU *g, > struct virtio_gpu_ctrl_command *cmd) > { > -int32_t result; > +int32_t result = 0; > struct virtio_gpu_simple_resource *res; > struct virtio_gpu_resource_unref unref; > - > -VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); > +Error *local_err = NULL; > > VIRTIO_GPU_FILL_CMD(unref); > > @@ -164,15 +188,14 @@ rutabaga_cmd_resource_unref(VirtIOGPU *g, > res = virtio_gpu_find_resource(g, unref.resource_id); > CHECK(res, cmd); > > -result = rutabaga_resource_unref(vr->rutabaga, unref.resource_id); > -CHECK(!result, cmd); > - > -if (res->image) { > -pixman_image_unref(res->image); > +virtio_gpu_rutabaga_resource_unref(g, res, _err); > +if (local_err) { > +error_report_err(local_err); > +/* local_err was freed, do not reuse it. */ > +local_err = NULL; > +result = 1; > } > - > -QTAILQ_REMOVE(>reslist, res, next); > -g_free(res); > +CHECK(!result, cmd); > } > > static void > @@ -1099,7 +1122,7 @@ static void > virtio_gpu_rutabaga_class_init(ObjectClass *klass, void *data) > vgc->handle_ctrl = virtio_gpu_rutabaga_handle_ctrl; > vgc->process_cmd = virtio_gpu_rutabaga_process_cmd; > vgc->update_cursor_data = virtio_gpu_rutabaga_update_cursor; > - > +vgc->resource_destroy = virtio_gpu_rutabaga_resource_unref; > vdc->realize = virtio_gpu_rutabaga_realize; > device_class_set_props(dc, virtio_gpu_rutabaga_properties); > } > -- > γαῖα πυρί μιχθήτω > >
Re: [PATCH v2 3/3] virtio-gpu-rutabaga.c: override resource_destroy method
On Mon, Jan 29, 2024 at 7:46 AM Manos Pitsidianakis < manos.pitsidiana...@linaro.org> wrote: > When the Rutabaga GPU device frees resources, it calls > rutabaga_resource_unref for that resource_id. However, when the generic > VirtIOGPU functions destroys resources, it only removes the > virtio_gpu_simple_resource from the device's VirtIOGPU->reslist list. > The rutabaga resource associated with that resource_id is then leaked. > > This commit overrides the resource_destroy class method introduced in > the previous commit to fix this. > > Signed-off-by: Manos Pitsidianakis > --- > hw/display/virtio-gpu-rutabaga.c | 51 > 1 file changed, 39 insertions(+), 12 deletions(-) > > diff --git a/hw/display/virtio-gpu-rutabaga.c > b/hw/display/virtio-gpu-rutabaga.c > index 9e67f9bd51..6ac0776005 100644 > --- a/hw/display/virtio-gpu-rutabaga.c > +++ b/hw/display/virtio-gpu-rutabaga.c > @@ -148,14 +148,42 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, > } > > static void > +virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, > + struct virtio_gpu_simple_resource *res, > + Error **errp) > +{ > +int32_t result; > +const char *strerror = NULL; > +VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); > + > +result = rutabaga_resource_unref(vr->rutabaga, res->resource_id); > +if (result) { > +error_setg(errp, "%s: rutabaga_resource_unref returned %"PRIi32 > + " for resource_id = %"PRIu32, __func__, result, > + res->resource_id); > +strerror = strerrorname_np((int)result); > +if (strerror != NULL) { > +error_append_hint(errp, "%s: %s\n", > + strerror, strerrordesc_np((int)result) ? : > ""); > +} > Can't we rely on virtio_gpu_rutabaga_debug_cb(..) to report an error when the resource ID is not found? > +} > + > +if (res->image) { > +pixman_image_unref(res->image); > +} > + > +QTAILQ_REMOVE(>reslist, res, next); > +g_free(res); > +} > + > +static void > rutabaga_cmd_resource_unref(VirtIOGPU *g, > struct virtio_gpu_ctrl_command *cmd) > { > -int32_t result; > +int32_t result = 0; > struct virtio_gpu_simple_resource *res; > struct virtio_gpu_resource_unref unref; > - > -VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); > +Error *local_err = NULL; > > VIRTIO_GPU_FILL_CMD(unref); > > @@ -164,15 +192,14 @@ rutabaga_cmd_resource_unref(VirtIOGPU *g, > res = virtio_gpu_find_resource(g, unref.resource_id); > CHECK(res, cmd); > > -result = rutabaga_resource_unref(vr->rutabaga, unref.resource_id); > -CHECK(!result, cmd); > - > -if (res->image) { > -pixman_image_unref(res->image); > +virtio_gpu_rutabaga_resource_unref(g, res, _err); > +if (local_err) { > +error_report_err(local_err); > +/* local_err was freed, do not reuse it. */ > +local_err = NULL; > +result = 1; > } > - > -QTAILQ_REMOVE(>reslist, res, next); > -g_free(res); > +CHECK(!result, cmd); > } > > static void > @@ -1099,7 +1126,7 @@ static void > virtio_gpu_rutabaga_class_init(ObjectClass *klass, void *data) > vgc->handle_ctrl = virtio_gpu_rutabaga_handle_ctrl; > vgc->process_cmd = virtio_gpu_rutabaga_process_cmd; > vgc->update_cursor_data = virtio_gpu_rutabaga_update_cursor; > - > +vgc->resource_destroy = virtio_gpu_rutabaga_resource_unref; > vdc->realize = virtio_gpu_rutabaga_realize; > device_class_set_props(dc, virtio_gpu_rutabaga_properties); > } > -- > γαῖα πυρί μιχθήτω > >
Re: [PATCH v15 0/9] rutabaga_gfx + gfxstream
On Sat, Jan 20, 2024 at 4:19 AM Alyssa Ross wrote: > Gurchetan Singh writes: > > > On Fri, Jan 19, 2024 at 1:13 PM Alyssa Ross wrote: > >> > >> Hi Gurchetan, > >> > >> > Thanks for the reminder. I did make a request to create the release > >> > tags, but changes were requested by Fedora packaging effort: > >> > > >> > https://bugzilla.redhat.com/show_bug.cgi?id=2242058 > >> > https://bugzilla.redhat.com/show_bug.cgi?id=2241701 > >> > > >> > So the request was canceled, but never re-requested. I'll fire off > >> > another request, with: > >> > > >> > gfxstream: 23d05703b94035ac045df60823fb1fc4be0fdf1c ("gfxstream: > >> > manually add debug logic") > >> > AEMU: dd8b929c247ce9872c775e0e5ddc4300011d0e82 ("aemu: improve > licensing") > >> > > >> > as the commits. These match the Fedora requests, and the AEMU one has > >> > been merged into Fedora already it seems. > >> > >> These revisions have the problem I mentioned in my previous message: > >> > >> >> The gfxstream ref mentioned here isn't compatible with > >> >> v0.1.2-rutabaga-release, because it no longer provides > logging_base.pc, > >> > >> rutabaga was not fixed to use the new AEMU package names until after the > >> v0.1.2-rutabaga-release tag, in commit 5dfd74a06. So will there be a > >> new Rutabaga release that's compatible with these release versions of > >> gfxstream and AEMU? > > > > Good catch. > > > > One possible workaround is to build gfxstream as a shared library. I > > think that would avoid rutabaga looking for AEMU package config files. > > > > But if another rutabaga release is desired with support for a static > > library, then we can make that happen too. > > We're exclusively building gfxstream as a shared library. > > Looking at rutabaga's build.rs, it appears to me like pkg-config is > always used for gfxstream unless overridden by GFXSTREAM_PATH. > Hmm, it seems we should be checking pkg-config --static before looking for AEMU in build.rs -- oh well. Would this be a suitable commit for the 0.1.3 release of rutabaga? https://chromium.googlesource.com/crosvm/crosvm/+/5dfd74a0680d317c6edf44138def886f47cb1c7c The gfxstream/AEMU commits would remain unchanged.
Re: [PATCH v15 0/9] rutabaga_gfx + gfxstream
On Fri, Jan 19, 2024 at 1:13 PM Alyssa Ross wrote: > > Hi Gurchetan, > > > Thanks for the reminder. I did make a request to create the release > > tags, but changes were requested by Fedora packaging effort: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=2242058 > > https://bugzilla.redhat.com/show_bug.cgi?id=2241701 > > > > So the request was canceled, but never re-requested. I'll fire off > > another request, with: > > > > gfxstream: 23d05703b94035ac045df60823fb1fc4be0fdf1c ("gfxstream: > > manually add debug logic") > > AEMU: dd8b929c247ce9872c775e0e5ddc4300011d0e82 ("aemu: improve licensing") > > > > as the commits. These match the Fedora requests, and the AEMU one has > > been merged into Fedora already it seems. > > These revisions have the problem I mentioned in my previous message: > > >> The gfxstream ref mentioned here isn't compatible with > >> v0.1.2-rutabaga-release, because it no longer provides logging_base.pc, > > rutabaga was not fixed to use the new AEMU package names until after the > v0.1.2-rutabaga-release tag, in commit 5dfd74a06. So will there be a > new Rutabaga release that's compatible with these release versions of > gfxstream and AEMU? Good catch. One possible workaround is to build gfxstream as a shared library. I think that would avoid rutabaga looking for AEMU package config files. But if another rutabaga release is desired with support for a static library, then we can make that happen too.
Re: [PATCH v15 0/9] rutabaga_gfx + gfxstream
On Tue, Jan 16, 2024 at 2:42 AM Alyssa Ross wrote: > > Hi Gurchetan, > > Gurchetan Singh writes: > > > - As mentioned in v14: > > * AEMU: d6e6b99 "Delete VpxFrameParser.cpp" > > * gfxstream: 2131f78d Merge "gfxstream: add egl & gles deps.." > > > > are the proposed v.0.1.2 release points. If those commits are sufficient > > for packaging AEMU + gfxstream, let me know and I'll have official release > > tags made. If additional changes are required for packaging, let me know > > as well. > > Were these releases ever made? Thanks for the reminder. I did make a request to create the release tags, but changes were requested by Fedora packaging effort: https://bugzilla.redhat.com/show_bug.cgi?id=2242058 https://bugzilla.redhat.com/show_bug.cgi?id=2241701 So the request was canceled, but never re-requested. I'll fire off another request, with: gfxstream: 23d05703b94035ac045df60823fb1fc4be0fdf1c ("gfxstream: manually add debug logic") AEMU: dd8b929c247ce9872c775e0e5ddc4300011d0e82 ("aemu: improve licensing") as the commits. These match the Fedora requests, and the AEMU one has been merged into Fedora already it seems. > > > The gfxstream ref mentioned here isn't compatible with > v0.1.2-rutabaga-release, because it no longer provides logging_base.pc, > and this email is the last mention I can find of these releases. > > In Nixpkgs, I've gone for packaging gfxstream and aemu with your initial > proposed release points, which works fine, but it would be great to have > this clearer upstream.
Re: [PATCH v17 0/9] gfxstream + rutabaga_gfx
On Mon, Oct 9, 2023 at 12:15 AM Marc-André Lureau < marcandre.lur...@redhat.com> wrote: > Hi > > On Fri, Oct 6, 2023 at 5:08 AM Gurchetan Singh > wrote: > > > > From: Gurchetan Singh > > > > Branch containing changes: > > > > https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v17 > > > > Changes since v16: > > > > - Fixed typo mentioned here: > > > > https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg01407.html > > > > Antonio Caggiano (2): > > virtio-gpu: CONTEXT_INIT feature > > virtio-gpu: blob prep > > > > Dr. David Alan Gilbert (1): > > virtio: Add shared memory capability > > > > Gerd Hoffmann (1): > > virtio-gpu: hostmem > > > > Gurchetan Singh (5): > > gfxstream + rutabaga prep: added need defintions, fields, and options > > gfxstream + rutabaga: add initial support for gfxstream > > gfxstream + rutabaga: meson support > > gfxstream + rutabaga: enable rutabaga > > docs/system: add basic virtio-gpu documentation > > > > Except for a few misc style issues, the series looks good to me. > > Gerd, as the virtio-gpu "odd fixes" maintainer, any chance you take a > quick look and ack the series? Even better if you send a PR :) > Ping. Branch containing latest series with the minor fixes Marc suggested is here: https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v18 > > thanks > >
Re: [PATCH v17 6/9] gfxstream + rutabaga: add initial support for gfxstream
On Mon, Oct 9, 2023 at 12:11 AM Marc-André Lureau < marcandre.lur...@redhat.com> wrote: > On Fri, Oct 6, 2023 at 5:09 AM Gurchetan Singh > wrote: > > > > This adds initial support for gfxstream and cross-domain. Both > > features rely on virtio-gpu blob resources and context types, which > > are also implemented in this patch. > > > > gfxstream has a long and illustrious history in Android graphics > > paravirtualization. It has been powering graphics in the Android > > Studio Emulator for more than a decade, which is the main developer > > platform. > > > > Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. > > The key design characteristic was a 1:1 threading model and > > auto-generation, which fit nicely with the OpenGLES spec. It also > > allowed easy layering with ANGLE on the host, which provides the GLES > > implementations on Windows or MacOS enviroments. > > > > gfxstream has traditionally been maintained by a single engineer, and > > between 2015 to 2021, the goldfish throne passed to Frank Yang. > > Historians often remark this glorious reign ("pax gfxstreama" is the > > academic term) was comparable to that of Augustus and both Queen > > Elizabeths. Just to name a few accomplishments in a resplendent > > panoply: higher versions of GLES, address space graphics, snapshot > > support and CTS compliant Vulkan [b]. > > > > One major drawback was the use of out-of-tree goldfish drivers. > > Android engineers didn't know much about DRM/KMS and especially TTM so > > a simple guest to host pipe was conceived. > > > > Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of > > the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu > > port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. > > It was a symbol compatible replacement of virglrenderer [c] and named > > "AVDVirglrenderer". This implementation forms the basis of the > > current gfxstream host implementation still in use today. > > > > cross-domain support follows a similar arc. Originally conceived by > > Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in > > 2018, it initially relied on the downstream "virtio-wl" device. > > > > In 2020 and 2021, virtio-gpu was extended to include blob resources > > and multiple timelines by yours truly, features gfxstream/cross-domain > > both require to function correctly. > > > > Right now, we stand at the precipice of a truly fantastic possibility: > > the Android Emulator powered by upstream QEMU and upstream Linux > > kernel. gfxstream will then be packaged properfully, and app > > developers can even fix gfxstream bugs on their own if they encounter > > them. > > > > It's been quite the ride, my friends. Where will gfxstream head next, > > nobody really knows. I wouldn't be surprised if it's around for > > another decade, maintained by a new generation of Android graphics > > enthusiasts. > > > > Technical details: > > - Very simple initial display integration: just used Pixman > > - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function > > calls > > > > Next steps for Android VMs: > > - The next step would be improving display integration and UI > interfaces > > with the goal of the QEMU upstream graphics being in an emulator > > release [d]. > > > > Next steps for Linux VMs for display virtualization: > > - For widespread distribution, someone needs to package Sommelier or > the > > wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer > > versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, > > which allows disabling KMS hypercalls. If anyone cares enough, it'll > > probably be possible to build a custom VM variant that uses this > display > > virtualization strategy. > > > > [a] > https://android-review.googlesource.com/c/platform/development/+/34470 > > [b] > https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 > > [c] > https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 > > [d] https://developer.android.com/studio/releases/emulator > > [e] https://github.com/talex5/wayland-proxy-virtwl > > > > Signed-off-by: Gurchetan Singh > > Tested-by: Alyssa Ross > > Tested-by: Emmanouil Pitsidianakis > > Tested-by: Akihiko Odaki > > Reviewed-by: Emmanouil Pitsidianakis > > Reviewed-by: Antonio Caggiano > &
[PATCH v17 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5585558855..be16efbd38 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 93857ad523..5585558855 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1511,6 +1511,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Antonio Caggiano Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index be16efbd38..6efd15b6ae 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1363,8 +1363,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index 98e071e63b..dd82c6eb13 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -215,6 +215,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- include/hw/virtio/virtio-gpu.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..39018377d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,27 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +uint64_t capset_mask; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 05619c6968..2b64fd9f9d 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -80,6 +80,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -96,6 +103,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -114,6 +127,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 3bb64b536c..65848a662a 100644 --- a/meson.build +++ b/meson.build @@ -1046,6 +1046,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4277,6 +4283,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index 6a17b90968..e49309dd78 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -230,6 +230,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 2a74b0275b..a28ccbcaf6 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -156,6 +156,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support'
[PATCH v17 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..cb73dd7998 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one virtio-gpu capability set ("capset") must be specified when +starting the device. The currently capsets supported are ``gfxstream-vulkan`` +and ``cross-domain`` for Linux guests. For Android guests, the experimental +``x-gfxstream-gles`` and ``x-gfxstream-composer`` capsets are also supported. + +The device will try to auto-detect the wayland socket path if the +``cross-domain`` capset name is set. The user may optionally specify +``wayland-socket-path`` for non-standard paths. + +The ``wsi`` option can be set to ``surfaceless`` or ``headless``. +Surfaceless doesn't create a native window surface, but does copy from the +render target to the Pixman buffer if a virtio-gpu 2D hypercall
[PATCH v17 0/9] gfxstream + rutabaga_gfx
From: Gurchetan Singh Branch containing changes: https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v17 Changes since v16: - Fixed typo mentioned here: https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg01407.html Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1113 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 40 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1488 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.609.gbb76f46606-goog
[PATCH v17 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-rutabaga.c | 1113 ++ hw/display/virtio-vga-rutabaga.c | 50 ++ 3 files changed, 1210 insertions(+) create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-pci-rutabaga.c new file mode 100644 index 00..c96729e198 --- /dev/null +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-gpu-pci.h" +#include "qom
[PATCH v16 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- include/hw/virtio/virtio-gpu.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..39018377d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,27 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +uint64_t capset_mask; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-rutabaga.c | 1113 ++ hw/display/virtio-vga-rutabaga.c | 50 ++ 3 files changed, 1210 insertions(+) create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-pci-rutabaga.c new file mode 100644 index 00..c96729e198 --- /dev/null +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-gpu-pci.h" +#include "qom
[PATCH v16 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 20ceeb8158..5473f6e1ad 100644 --- a/meson.build +++ b/meson.build @@ -1051,6 +1051,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4289,6 +4295,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index 57e265c871..aabc706b6d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -230,6 +230,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index e4b46d5715..8efbc9851c 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -157,6 +157,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support'
[PATCH v16 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5585558855..be16efbd38 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Branch containing changes: https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v16 Changes since v15: - Incorporated review feedback from here: https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg00800.html Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1113 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 40 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1488 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..cb73dd7998 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one virtio-gpu capability set ("capset") must be specified when +starting the device. The currently capsets supported are ``gfxstream-vulkan`` +and ``cross-domain`` for Linux guests. For Android guests, the experimental +``x-gfxstream-gles`` and ``x-gfxstream-composer`` capsets are also supported. + +The device will try to auto-detect the wayland socket path if the +``cross-domain`` capset name is set. The user may optionally specify +``wayland-socket-path`` for non-standard paths. + +The ``wsi`` option can be set to ``surfaceless`` or ``headless``. +Surfaceless doesn't create a native window surface, but does copy from the +render target to the Pixman buffer if a virtio-gpu 2D hypercall
[PATCH v16 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Antonio Caggiano Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index be16efbd38..6efd15b6ae 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1363,8 +1363,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index 98e071e63b..dd82c6eb13 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -215,6 +215,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v16 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 93857ad523..5585558855 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1511,6 +1511,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..cb73dd7998 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one virtio-gpu capability set ("capset") must be specified when +starting the device. The currently capsets supported are ``gfxstream-vulkan`` +and ``cross-domain`` for Linux guests. For Android guests, the experimental +``x-gfxstream-gles`` and ``x-gfxstream-composer`` capsets are also supported. + +The device will try to auto-detect the wayland socket path if the +``cross-domain`` capset name is set. The user may optionally specify +``wayland-socket-path`` for non-standard paths. + +The ``wsi`` option can be set to ``surfaceless`` or ``headless``. +Surfaceless doesn't create a native window surface, but does copy from the +render target to the Pixman buffer if a virtio-gpu 2D hypercall
[PATCH v15 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Antonio Caggiano Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index be16efbd38..6efd15b6ae 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1363,8 +1363,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index 98e071e63b..dd82c6eb13 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -215,6 +215,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-rutabaga.c | 1122 ++ hw/display/virtio-vga-rutabaga.c | 50 ++ 3 files changed, 1219 insertions(+) create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-pci-rutabaga.c new file mode 100644 index 00..c96729e198 --- /dev/null +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-gpu-pci.h" +#include "qom
[PATCH v15 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 93857ad523..5585558855 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1511,6 +1511,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 21a1bc03f8..1228690880 100644 --- a/meson.build +++ b/meson.build @@ -1061,6 +1061,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4299,6 +4305,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index 57e265c871..aabc706b6d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -230,6 +230,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index e4b46d5715..8efbc9851c 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -157,6 +157,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support'
[PATCH v15 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Prior version: https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg07402.html Branch containing changes: https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v15 Changes since v14: - Thomas Huth suggested the use of the "x-" prefix for experimental properties. Now, we have "x-gfxstream-gles" and "x-gfxstream-composer" since those capsets are only runnable with Android guests and we're not sure if anybody else will use them. https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg07465.html What still needs to happen: - As mentioned in v14: * AEMU: d6e6b99 "Delete VpxFrameParser.cpp" * gfxstream: 2131f78d Merge "gfxstream: add egl & gles deps.." are the proposed v.0.1.2 release points. If those commits are sufficient for packaging AEMU + gfxstream, let me know and I'll have official release tags made. If additional changes are required for packaging, let me know as well. Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1122 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 40 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1497 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5585558855..be16efbd38 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v15 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- include/hw/virtio/virtio-gpu.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..39018377d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,27 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +uint64_t capset_mask; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5585558855..be16efbd38 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Antonio Caggiano Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index be16efbd38..6efd15b6ae 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1363,8 +1363,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index 59a472a0b1..5b030e3b2e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -215,6 +215,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 93857ad523..5585558855 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1511,6 +1511,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Prior version: https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg05005.html Even though reviewed, there were a few issues that needed to be addressed. 1) Packaging/Releasing Marc-Andre Lureau pointed a few issues with packaging the AEMU library: https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg02734.html https://android-review.googlesource.com/q/topic:%22aemu-package-fix%22 https://android-review.googlesource.com/c/platform/hardware/google/aemu/+/2751077 I therefore propose the current ToT: - AEMU: d6e6b99 "Delete VpxFrameParser.cpp" - gfxstream: 2131f78d Merge "gfxstream: add egl & gles deps.." as the 0.1.2 release points. Let me know if that works for packaging and I will get release tags made. There is a rutabaga release tag already, let me know if another is desired. Thanks! 2) Command line interface The command line interface is now "gfxstream-vulkan=on,cross-domain=on" as per discussion here: https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg03038.html "wayland_socket_path" is also now "wayland-socket-path" to the command-line users. 3) Potential bug after memory unmap Akihiko Odaki pointed out a potential memory map, but it one that would only be triggered by fuzzing/malicious actors. https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg05141.html https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg05540.html I just documented the bug as suggested since I suspect for cross-platform support that code in particular will need to be refactored anyways, so avoid optimizing for now. Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1127 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 40 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1502 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- include/hw/virtio/virtio-gpu.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..39018377d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,27 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +uint64_t capset_mask; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.582.g8ccd20d70d-goog
[PATCH v14 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-rutabaga.c | 1127 ++ hw/display/virtio-vga-rutabaga.c | 50 ++ 3 files changed, 1224 insertions(+) create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-pci-rutabaga.c new file mode 100644 index 00..c96729e198 --- /dev/null +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-gpu-pci.h" +#include "qom
[PATCH v14 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..5e0b33bc74 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one virtio-gpu capability set ("capset") must be specified when +starting the device. The currently capsets supported are ``gfxstream-vulkan`` +and ``cross-domain`` for Linux guests. For Android guests, the experimental +``gfxstream-gles`` and ``gfxstream-composer`` capsets are also supported. + +The device will try to auto-detect the wayland socket path if the +``cross-domain`` capset name is set. The user may optionally specify +``wayland-socket-path`` for non-standard paths. + +The ``wsi`` option can be set to ``surfaceless`` or ``headless``. +Surfaceless doesn't create a native window surface, but does copy from the +render target to the Pixman buffer if a virtio-gpu 2D hypercall
[PATCH v14 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 5139db2ff7..1e12c2964d 100644 --- a/meson.build +++ b/meson.build @@ -1061,6 +1061,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4293,6 +4299,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index 57e265c871..aabc706b6d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -230,6 +230,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index e4b46d5715..8efbc9851c 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -157,6 +157,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support'
[PATCH v14 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Tested-by: Huang Rui Acked-by: Huang Rui Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.582.g8ccd20d70d-goog
Re: [PATCH v13 6/9] gfxstream + rutabaga: add initial support for gfxstream
On Wed, Sep 20, 2023 at 5:05 AM Mark Cave-Ayland < mark.cave-ayl...@ilande.co.uk> wrote: > On 20/09/2023 12:42, Akihiko Odaki wrote: > > > On 2023/08/29 9:36, Gurchetan Singh wrote: > >> This adds initial support for gfxstream and cross-domain. Both > >> features rely on virtio-gpu blob resources and context types, which > >> are also implemented in this patch. > >> > >> gfxstream has a long and illustrious history in Android graphics > >> paravirtualization. It has been powering graphics in the Android > >> Studio Emulator for more than a decade, which is the main developer > >> platform. > >> > >> Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. > >> The key design characteristic was a 1:1 threading model and > >> auto-generation, which fit nicely with the OpenGLES spec. It also > >> allowed easy layering with ANGLE on the host, which provides the GLES > >> implementations on Windows or MacOS enviroments. > >> > >> gfxstream has traditionally been maintained by a single engineer, and > >> between 2015 to 2021, the goldfish throne passed to Frank Yang. > >> Historians often remark this glorious reign ("pax gfxstreama" is the > >> academic term) was comparable to that of Augustus and both Queen > >> Elizabeths. Just to name a few accomplishments in a resplendent > >> panoply: higher versions of GLES, address space graphics, snapshot > >> support and CTS compliant Vulkan [b]. > >> > >> One major drawback was the use of out-of-tree goldfish drivers. > >> Android engineers didn't know much about DRM/KMS and especially TTM so > >> a simple guest to host pipe was conceived. > >> > >> Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of > >> the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu > >> port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. > >> It was a symbol compatible replacement of virglrenderer [c] and named > >> "AVDVirglrenderer". This implementation forms the basis of the > >> current gfxstream host implementation still in use today. > >> > >> cross-domain support follows a similar arc. Originally conceived by > >> Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in > >> 2018, it initially relied on the downstream "virtio-wl" device. > >> > >> In 2020 and 2021, virtio-gpu was extended to include blob resources > >> and multiple timelines by yours truly, features gfxstream/cross-domain > >> both require to function correctly. > >> > >> Right now, we stand at the precipice of a truly fantastic possibility: > >> the Android Emulator powered by upstream QEMU and upstream Linux > >> kernel. gfxstream will then be packaged properfully, and app > >> developers can even fix gfxstream bugs on their own if they encounter > >> them. > >> > >> It's been quite the ride, my friends. Where will gfxstream head next, > >> nobody really knows. I wouldn't be surprised if it's around for > >> another decade, maintained by a new generation of Android graphics > >> enthusiasts. > >> > >> Technical details: > >>- Very simple initial display integration: just used Pixman > >>- Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function > >> calls > >> > >> Next steps for Android VMs: > >>- The next step would be improving display integration and UI > interfaces > >> with the goal of the QEMU upstream graphics being in an emulator > >> release [d]. > >> > >> Next steps for Linux VMs for display virtualization: > >>- For widespread distribution, someone needs to package Sommelier or > the > >> wayland-proxy-virtwl [e] ideally into Debian main. In addition, > newer > >> versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, > >> which allows disabling KMS hypercalls. If anyone cares enough, > it'll > >> probably be possible to build a custom VM variant that uses this > display > >> virtualization strategy. > >> > >> [a] > https://android-review.googlesource.com/c/platform/development/+/34470 > >> [b] > https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 > >> [c] > https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 > >> [d] https://developer.android.c
Re: [PATCH v11 6/9] gfxstream + rutabaga: add initial support for gfxstream
On Wed, Sep 13, 2023 at 4:58 AM Bernhard Beschow wrote: > > > Am 23. August 2023 01:25:38 UTC schrieb Gurchetan Singh < > gurchetansi...@chromium.org>: > >This adds initial support for gfxstream and cross-domain. Both > >features rely on virtio-gpu blob resources and context types, which > >are also implemented in this patch. > > > >gfxstream has a long and illustrious history in Android graphics > >paravirtualization. It has been powering graphics in the Android > >Studio Emulator for more than a decade, which is the main developer > >platform. > > > >Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. > >The key design characteristic was a 1:1 threading model and > >auto-generation, which fit nicely with the OpenGLES spec. It also > >allowed easy layering with ANGLE on the host, which provides the GLES > >implementations on Windows or MacOS enviroments. > > > >gfxstream has traditionally been maintained by a single engineer, and > >between 2015 to 2021, the goldfish throne passed to Frank Yang. > >Historians often remark this glorious reign ("pax gfxstreama" is the > >academic term) was comparable to that of Augustus and both Queen > >Elizabeths. Just to name a few accomplishments in a resplendent > >panoply: higher versions of GLES, address space graphics, snapshot > >support and CTS compliant Vulkan [b]. > > > >One major drawback was the use of out-of-tree goldfish drivers. > >Android engineers didn't know much about DRM/KMS and especially TTM so > >a simple guest to host pipe was conceived. > > > >Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of > >the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu > >port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. > >It was a symbol compatible replacement of virglrenderer [c] and named > >"AVDVirglrenderer". This implementation forms the basis of the > >current gfxstream host implementation still in use today. > > > >cross-domain support follows a similar arc. Originally conceived by > >Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in > >2018, it initially relied on the downstream "virtio-wl" device. > > > >In 2020 and 2021, virtio-gpu was extended to include blob resources > >and multiple timelines by yours truly, features gfxstream/cross-domain > >both require to function correctly. > > > >Right now, we stand at the precipice of a truly fantastic possibility: > >the Android Emulator powered by upstream QEMU and upstream Linux > >kernel. gfxstream will then be packaged properfully, and app > >developers can even fix gfxstream bugs on their own if they encounter > >them. > > > >It's been quite the ride, my friends. Where will gfxstream head next, > >nobody really knows. I wouldn't be surprised if it's around for > >another decade, maintained by a new generation of Android graphics > >enthusiasts. > > > >Technical details: > > - Very simple initial display integration: just used Pixman > > - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function > >calls > > > >Next steps for Android VMs: > > - The next step would be improving display integration and UI interfaces > >with the goal of the QEMU upstream graphics being in an emulator > >release [d]. > > > >Next steps for Linux VMs for display virtualization: > > - For widespread distribution, someone needs to package Sommelier or the > >wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer > >versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, > >which allows disabling KMS hypercalls. If anyone cares enough, it'll > >probably be possible to build a custom VM variant that uses this > display > >virtualization strategy. > > > >[a] > https://android-review.googlesource.com/c/platform/development/+/34470 > >[b] > https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 > >[c] > https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 > >[d] https://developer.android.com/studio/releases/emulator > >[e] https://github.com/talex5/wayland-proxy-virtwl > > > >Signed-off-by: Gurchetan Singh > >Tested-by: Alyssa Ross > >Tested-by: Emmanouil Pitsidianakis > >Reviewed-by: Emmanouil Pitsidianakis > >--- > >v1: Incorported various suggestions by Akihiko Odaki and Bernard Berschow > >- Removed GET_VIRTIO_GPU_GL / GET_RUTABAGA ma
Re: [PATCH v13 0/9] rutabaga_gfx + gfxstream
On Wed, Sep 13, 2023 at 6:49 AM Marc-André Lureau < marcandre.lur...@gmail.com> wrote: > Hi > > On Wed, Sep 13, 2023 at 5:08 AM Gurchetan Singh > wrote: > > On Tue, Sep 12, 2023 at 6:59 AM Marc-André Lureau < > marcandre.lur...@gmail.com> wrote: > >> Packaging aemu and gfxstream is a bit problematic. I have some WIP > >> Fedora packages. >> > >> AEMU: > >> - installs files under /usr/include/host-common and > >> /usr/include/snapshot. Can this be moved under /usr/include/aemu > >> instead? > >> - builds only static versions of libaemu-host-common.a and > >> liblogging-base.a (distros don't like static libs much) > >> - could liblogging-base(.a,.so,..) also have "aemu" name in it? > >> - libaemu-base.so is not versioned > >> - I can't find a release tarball, nor the (v0.1.2) release tag > >> - could have a README file > >> > >> I am not very familiar with cmake, so it's not obvious how to make the > >> required changes. Would you like me to open an issue (where?) or try > >> to make some patches? > > > > > > I filed an internal bug with all the issues you listed: Android side > should fix this internally. > > > > I see a few options for packaging: > > > > 1) Punt on gfxstream/AEMU packaging, just do rutabaga > > > > gfxstream is mostly useful for Android guests, and I didn't expect > anyone to actually package it at this point since most here are interested > in Linux guests (where gfxstream VK is headless only right now). Plus > ioctl-fowarding > API forwarding for security and performance, so I'm not > sure if it'll have any sticking power even if everything is supported > (outside of a few niche use cases). > > > > Though, I sense interest in Wayland passthrough for dual Linux use > cases. I put up: > > > > crrev.com/c/4860836 > > > > that'll allow packaging on rutabaga_gfx and even CI testing without > gfxstream, since it is designed to function without it. We could issue > another rutabaga-release tag, or you can simply add a patch (a common > packaging practice) on the Fedora package with the "UPSTEAM label". > > > > 2) Actually package gfxstream only > > > > Probably an intermediate solution that doesn't introduce > versioning/static library issues would be just to have a copy of AEMU in > the gfxstream repo, and link it statically. Will need another release > tag/commit of gfxstream. > > > > 3) Don't package at all > > > > For my particular use case since we have to build QEMU for sources, this > is fine. If upstream breaks virtio-gpu-rutabaga.c, we'll send a patch and > fix it. Being in-tree is most important. > > > > Let me know what you prefer! > > > > I would rather have standard packaging of the various projects, so we > can test and develop easily. > Ack. Here are the requested changes: - https://android-review.googlesource.com/q/topic:%22aemu-package-fix%22 - crrev.com/c/4865171 The main change is: https://android-review.googlesource.com/c/platform/hardware/google/aemu/+/2751066 Once that's okay for packaging, I'll ping harder on v0.1.2 gfxstream/AEMU release tags. Let me know if you want another release tag for rutabaga, or if just patching in upstream changes would be acceptable. For rutabaga, I ended up having to patch a little bit the shared > library, to fix SONAME: > Landed as crrev.com/c/4863380. > > diff --git a/ffi/Makefile b/ffi/Makefile > index d2f0d38..7efc8f3 100644 > --- a/ffi/Makefile > +++ b/ffi/Makefile > @@ -47,13 +47,13 @@ build: > > install: build > ifeq ($(UNAME), Linux) > -install -D -m 755 -t $(DESTDIR)$(libdir) $(OUT)/$(LIB_NAME) > +install -D -m 755 $(OUT)/$(LIB_NAME) > $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) > endif > ifeq ($(UNAME), Darwin) > -install_name_tool -id $(DESTDIR)$(libdir)/$(LIB_NAME) > $(DESTDIR)$(libdir)/$(LIB_NAME) > +install_name_tool -id > $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) > $(DESTDIR)$(libdir)/$(LIB_NAME) > endif > -ln -sf $(DESTDIR)$(libdir)/$(LIB_NAME) > $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) > -ln -sf $(DESTDIR)$(libdir)/$(LIB_NAME) > $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION_MAJOR) > +ln -s $(LIB_NAME).$(RUTABAGA_VERSION) > $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION_MAJOR) > +ln -s $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME) > ifeq ($(UNAME), Linux) > install -D -m 0644 $(SRC)/share/rutabaga_gfx_ffi.pc > $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc > install -D -m 0644 $(SRC)
Re: [PATCH v11 0/9] rutabaga_gfx + gfxstream
On Tue, Sep 12, 2023 at 1:53 AM Alyssa Ross wrote: > Gurchetan Singh writes: > > > On Fri, Aug 25, 2023 at 12:37 PM Alyssa Ross wrote: > > > >> Alyssa Ross writes: > >> > >> > Gurchetan Singh writes: > >> > > >> >> On Fri, Aug 25, 2023 at 12:11 AM Alyssa Ross wrote: > >> >> > >> >>> Gurchetan Singh writes: > >> >>> > >> >>> > On Wed, Aug 23, 2023 at 4:07 AM Alyssa Ross wrote: > >> >>> > > >> >>> >> Gurchetan Singh writes: > >> >>> >> > >> >>> >> > - Official "release commits" issued for rutabaga_gfx_ffi, > >> >>> >> > gfxstream, aemu-base. For example, see crrev.com/c/4778941 > >> >>> >> > > >> >>> >> > - The release commits can make packaging easier, though once > >> >>> >> > again all known users will likely just build from sources > >> >>> >> > anyways > >> >>> >> > >> >>> >> It's a small thing, but could there be actual tags, rather than > just > >> >>> >> blessed commits? It'd just make them easier to find, and save a > >> bit of > >> >>> >> time in review for packages. > >> >>> >> > >> >>> > > >> >>> > I added: > >> >>> > > >> >>> > > >> >>> > >> > https://crosvm.dev/book/appendix/rutabaga_gfx.html#latest-releases-for-potential-packaging > >> >>> > > >> >>> > Tags are possible, but I want to clarify the use case before > >> packaging. > >> >>> > Where are you thinking of packaging it for (Debian??)? Are you > mostly > >> >>> > interested in Wayland passthrough (my guess) or gfxstream too? > >> Depending > >> >>> > your use case, we may be able to minimize the work involved. > >> >>> > >> >>> Packaging for Nixpkgs (where I already maintain what to my > knowledge is > >> >>> the only crosvm distro package). I'm personally mostly interested > in > >> >>> Wayland passthroug, but I wouldn't be surprised if others are > >> interested > >> >>> in gfxstream. The packaging work is already done, I've just been > >> >>> holding off actually pushing the packages waiting for the stable > >> >>> releases. > >> >>> > >> >>> The reason that tags would be useful is that it allows a reviewer of > >> the > >> >>> package to see at a glance that the package is built from a stable > >> >>> release. If it's just built from a commit hash, they have to go and > >> >>> verify that it's a stable release, which is mildly annoying and > >> >>> unconventional. > >> >>> > >> >> > >> >> Understood. Request to have gfxstream and AEMU v0.1.2 release tags > >> made. > >> >> > >> >> For rutabaga_gfx_ffi, is the crates.io upload sufficient? > >> >> > >> >> https://crates.io/crates/rutabaga_gfx_ffi > >> >> > >> >> Debian, for example, treats crates.io as the source of truth and > builds > >> >> tooling around that. I wonder if Nixpkgs as similar tooling around > >> >> crates.io. > >> > > >> > We do, and I'll use the crates.io release for the package — good > >> > suggestion, but it's still useful to also have a tag in a git repo. > It > >> > makes it easier if I need to do a bisect, for example. As a distro > >> > developer, I'm frequently jumping across codebases I am not very > >> > familiar with to try to track down regressions, etc., and it's much > >> > easier when I don't have to learn some special quirk of the package > like > >> > not having git tags. > >> > >> Aha, trying to switch my package over to it has revealed that there is > >> actually a reason not to use the crates.io release. It doesn't include > >> a Cargo.lock, which would mean we'd have to obtain one from elsewhere. > >> Either from the crosvm git repo, at which point we might just get all > >> the sources from there, or by vendoring a Cargo.lock into our own git > >> tree for packages, which we try to avoid because when you have a lot of > >> them, they become quite a large proportion of the overall size of the > >> repo. > >> > > > > Ack. Request to have a rutabaga release tag in crosvm also made, should > be > > complete in a few days. > > Thanks! I've found the rutabaga tag, but I still don't see any relevant > tags for aemu or gfxstream. Any news there? > It's harder to get the attention of the Android build team than the Chrome build team. Though, there are a few issues with AEMU/gfxstream packaging we also need to figure out -- see "[PATCH v13 0/9] rutabaga_gfx + gfxstream" for details -- interested in your opinion on the matter!
Re: [PATCH v13 0/9] rutabaga_gfx + gfxstream
On Tue, Sep 12, 2023 at 6:59 AM Marc-André Lureau < marcandre.lur...@gmail.com> wrote: > Hi Gurchetan > > On Wed, Sep 6, 2023 at 5:22 AM Gurchetan Singh > wrote: > > > > > > > > On Wed, Aug 30, 2023 at 7:26 PM Huang Rui wrote: > >> > >> On Tue, Aug 29, 2023 at 08:36:20AM +0800, Gurchetan Singh wrote: > >> > From: Gurchetan Singh > >> > > >> > Changes since v12: > >> > - Added r-b tags from Antonio Caggiano and Akihiko Odaki > >> > - Removed review version from commit messages > >> > - I think we're good to merge since we've had multiple people test > and review this series?? > >> > > >> > How to build both rutabaga and gfxstream guest/host libs: > >> > > >> > https://crosvm.dev/book/appendix/rutabaga_gfx.html > >> > > >> > Branch containing this patch series: > >> > > >> > https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v13 > >> > > >> > Antonio Caggiano (2): > >> > virtio-gpu: CONTEXT_INIT feature > >> > virtio-gpu: blob prep > >> > > >> > Dr. David Alan Gilbert (1): > >> > virtio: Add shared memory capability > >> > > >> > Gerd Hoffmann (1): > >> > virtio-gpu: hostmem > >> > >> Patch 1 -> 4 are > >> > >> Acked-and-Tested-by: Huang Rui > > > > > > Thanks Ray, I've rebased > https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v13 and > added the additional acks in the commit message. > > > > UI/gfx maintainers, since everything is reviewed and there hasn't been > any additional review comments, may we merge the gfxstream + rutabaga_gfx > series? Thank you! > > > > > > Packaging aemu and gfxstream is a bit problematic. I have some WIP > Fedora packages. > > AEMU: > - installs files under /usr/include/host-common and > /usr/include/snapshot. Can this be moved under /usr/include/aemu > instead? > - builds only static versions of libaemu-host-common.a and > liblogging-base.a (distros don't like static libs much) > - could liblogging-base(.a,.so,..) also have "aemu" name in it? > - libaemu-base.so is not versioned > - I can't find a release tarball, nor the (v0.1.2) release tag > - could have a README file > > I am not very familiar with cmake, so it's not obvious how to make the > required changes. Would you like me to open an issue (where?) or try > to make some patches? > I filed an internal bug with all the issues you listed: Android side should fix this internally. I see a few options for packaging: 1) Punt on gfxstream/AEMU packaging, just do rutabaga gfxstream is mostly useful for Android guests, and I didn't expect anyone to actually package it at this point since most here are interested in Linux guests (where gfxstream VK is headless only right now). Plus ioctl-fowarding > API forwarding for security and performance, so I'm not sure if it'll have any sticking power even if everything is supported (outside of a few niche use cases). Though, I sense interest in Wayland passthrough for dual Linux use cases. I put up: crrev.com/c/4860836 <http://crrev.com/c4860836> that'll allow packaging on rutabaga_gfx and even CI testing without gfxstream, since it is designed to function without it. We could issue another rutabaga-release tag, or you can simply add a patch (a common packaging practice) on the Fedora package with the "UPSTEAM label". 2) Actually package gfxstream only Probably an intermediate solution that doesn't introduce versioning/static library issues would be just to have a copy of AEMU in the gfxstream repo, and link it statically. Will need another release tag/commit of gfxstream. 3) Don't package at all For my particular use case since we have to build QEMU for sources, this is fine. If upstream breaks virtio-gpu-rutabaga.c, we'll send a patch and fix it. Being in-tree is most important. Let me know what you prefer! > > gfxstream: > - libgfxtream_backend.so is not versioned > - I can't find a release tarball, nor the (v0.1.2) release tag > https://android-review.googlesource.com/c/platform/hardware/google/gfxstream/+/2749095 > > > (packaging is important so we can build the new code in CI too!) > > thanks > > -- > Marc-André Lureau >
Re: [PATCH v13 0/9] rutabaga_gfx + gfxstream
On Wed, Aug 30, 2023 at 7:26 PM Huang Rui wrote: > On Tue, Aug 29, 2023 at 08:36:20AM +0800, Gurchetan Singh wrote: > > From: Gurchetan Singh > > > > Changes since v12: > > - Added r-b tags from Antonio Caggiano and Akihiko Odaki > > - Removed review version from commit messages > > - I think we're good to merge since we've had multiple people test and > review this series?? > > > > How to build both rutabaga and gfxstream guest/host libs: > > > > https://crosvm.dev/book/appendix/rutabaga_gfx.html > > > > Branch containing this patch series: > > > > https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v13 > > > > Antonio Caggiano (2): > > virtio-gpu: CONTEXT_INIT feature > > virtio-gpu: blob prep > > > > Dr. David Alan Gilbert (1): > > virtio: Add shared memory capability > > > > Gerd Hoffmann (1): > > virtio-gpu: hostmem > > Patch 1 -> 4 are > > Acked-and-Tested-by: Huang Rui > Thanks Ray, I've rebased https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v13 and added the additional acks in the commit message. UI/gfx maintainers, since everything is reviewed and there hasn't been any additional review comments, may we merge the gfxstream + rutabaga_gfx series? Thank you! > > > > > Gurchetan Singh (5): > > gfxstream + rutabaga prep: added need defintions, fields, and options > > gfxstream + rutabaga: add initial support for gfxstream > > gfxstream + rutabaga: meson support > > gfxstream + rutabaga: enable rutabaga > > docs/system: add basic virtio-gpu documentation > > > > docs/system/device-emulation.rst |1 + > > docs/system/devices/virtio-gpu.rst | 112 +++ > > hw/display/meson.build | 22 + > > hw/display/virtio-gpu-base.c |6 +- > > hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ > > hw/display/virtio-gpu-pci.c | 14 + > > hw/display/virtio-gpu-rutabaga.c | 1119 ++ > > hw/display/virtio-gpu.c | 16 +- > > hw/display/virtio-vga-rutabaga.c | 50 ++ > > hw/display/virtio-vga.c | 33 +- > > hw/virtio/virtio-pci.c | 18 + > > include/hw/virtio/virtio-gpu-bswap.h | 15 + > > include/hw/virtio/virtio-gpu.h | 41 + > > include/hw/virtio/virtio-pci.h |4 + > > meson.build |7 + > > meson_options.txt|2 + > > scripts/meson-buildoptions.sh|3 + > > softmmu/qdev-monitor.c |3 + > > softmmu/vl.c |1 + > > 19 files changed, 1495 insertions(+), 19 deletions(-) > > create mode 100644 docs/system/devices/virtio-gpu.rst > > create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c > > create mode 100644 hw/display/virtio-gpu-rutabaga.c > > create mode 100644 hw/display/virtio-vga-rutabaga.c > > > > -- > > 2.42.0.rc2.253.gd59a3bf2b4-goog > > >
Re: [PATCH v11 0/9] rutabaga_gfx + gfxstream
On Fri, Aug 25, 2023 at 12:37 PM Alyssa Ross wrote: > Alyssa Ross writes: > > > Gurchetan Singh writes: > > > >> On Fri, Aug 25, 2023 at 12:11 AM Alyssa Ross wrote: > >> > >>> Gurchetan Singh writes: > >>> > >>> > On Wed, Aug 23, 2023 at 4:07 AM Alyssa Ross wrote: > >>> > > >>> >> Gurchetan Singh writes: > >>> >> > >>> >> > - Official "release commits" issued for rutabaga_gfx_ffi, > >>> >> > gfxstream, aemu-base. For example, see crrev.com/c/4778941 > >>> >> > > >>> >> > - The release commits can make packaging easier, though once > >>> >> > again all known users will likely just build from sources > >>> >> > anyways > >>> >> > >>> >> It's a small thing, but could there be actual tags, rather than just > >>> >> blessed commits? It'd just make them easier to find, and save a > bit of > >>> >> time in review for packages. > >>> >> > >>> > > >>> > I added: > >>> > > >>> > > >>> > https://crosvm.dev/book/appendix/rutabaga_gfx.html#latest-releases-for-potential-packaging > >>> > > >>> > Tags are possible, but I want to clarify the use case before > packaging. > >>> > Where are you thinking of packaging it for (Debian??)? Are you mostly > >>> > interested in Wayland passthrough (my guess) or gfxstream too? > Depending > >>> > your use case, we may be able to minimize the work involved. > >>> > >>> Packaging for Nixpkgs (where I already maintain what to my knowledge is > >>> the only crosvm distro package). I'm personally mostly interested in > >>> Wayland passthroug, but I wouldn't be surprised if others are > interested > >>> in gfxstream. The packaging work is already done, I've just been > >>> holding off actually pushing the packages waiting for the stable > >>> releases. > >>> > >>> The reason that tags would be useful is that it allows a reviewer of > the > >>> package to see at a glance that the package is built from a stable > >>> release. If it's just built from a commit hash, they have to go and > >>> verify that it's a stable release, which is mildly annoying and > >>> unconventional. > >>> > >> > >> Understood. Request to have gfxstream and AEMU v0.1.2 release tags > made. > >> > >> For rutabaga_gfx_ffi, is the crates.io upload sufficient? > >> > >> https://crates.io/crates/rutabaga_gfx_ffi > >> > >> Debian, for example, treats crates.io as the source of truth and builds > >> tooling around that. I wonder if Nixpkgs as similar tooling around > >> crates.io. > > > > We do, and I'll use the crates.io release for the package — good > > suggestion, but it's still useful to also have a tag in a git repo. It > > makes it easier if I need to do a bisect, for example. As a distro > > developer, I'm frequently jumping across codebases I am not very > > familiar with to try to track down regressions, etc., and it's much > > easier when I don't have to learn some special quirk of the package like > > not having git tags. > > Aha, trying to switch my package over to it has revealed that there is > actually a reason not to use the crates.io release. It doesn't include > a Cargo.lock, which would mean we'd have to obtain one from elsewhere. > Either from the crosvm git repo, at which point we might just get all > the sources from there, or by vendoring a Cargo.lock into our own git > tree for packages, which we try to avoid because when you have a lot of > them, they become quite a large proportion of the overall size of the > repo. > Ack. Request to have a rutabaga release tag in crosvm also made, should be complete in a few days. > > (This probably differs from Debian, etc., because in Nixpkgs, we don't > package each crate dependency separately. We only have packages for > applications (or occasionally, C ABI libraries written in Rust), and > each of those gets to bring in whatever crate dependencies it wants as > part of its build. This means we use the upstream Cargo.lock, and > accept that different Rust packages will use lots of different versions > of dependencies, which I don't believe is the case with other distros > that take a more purist approach to Rust packaging.) >
[PATCH v13 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..21465e4ce2 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one capset (see colon separated ``capset_names`` below) must be +specified when starting the device. The currently supported +``capset_names`` are ``gfxstream-vulkan`` and ``cross-domain`` on Linux +guests. For Android guests, ``gfxstream-gles`` is also supported. + +The device will try to auto-detect the wayland socket path if the +``cross-domain`` capset name is set. The user may optionally specify +``wayland_socket_path`` for non-standard paths. + +The ``wsi`` option can be set to ``surfaceless`` or ``headless``. +Surfaceless doesn't create a native window surface, but does copy from the +render target to the Pixman buffer if a virtio-gpu 2D hypercall is issued. +Headless is like surfaceless
[PATCH v13 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-rutabaga.c | 1119 ++ hw/display/virtio-vga-rutabaga.c | 50 ++ 3 files changed, 1216 insertions(+) create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-pci-rutabaga.c new file mode 100644 index 00..c96729e198 --- /dev/null +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/pci/pci.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-gpu-pci.h" +#include "qom
[PATCH v13 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 98e68ef0b1..293f388e53 100644 --- a/meson.build +++ b/meson.build @@ -1069,6 +1069,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4272,6 +4278,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index aaea5ddd77..dea3bf7d9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -224,6 +224,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 9da3fe299b..9a95b4f782 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -154,6 +154,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support'
[PATCH v13 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bbd5c6561a..48ef0d9fad 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1509,6 +1509,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Antonio Caggiano Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3e658f1fef..fe094addef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1361,8 +1361,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index b0b96f67fa..2f98eefdf3 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -216,6 +216,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Changes since v12: - Added r-b tags from Antonio Caggiano and Akihiko Odaki - Removed review version from commit messages - I think we're good to merge since we've had multiple people test and review this series?? How to build both rutabaga and gfxstream guest/host libs: https://crosvm.dev/book/appendix/rutabaga_gfx.html Branch containing this patch series: https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v13 Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1119 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 41 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1495 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Antonio Caggiano Reviewed-by: Akihiko Odaki --- include/hw/virtio/virtio-gpu.h | 28 1 file changed, 28 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..de06bcdba4 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,28 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; + +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +char *capset_names; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v13 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.rc2.253.gd59a3bf2b4-goog
Re: [PATCH v12 0/9] rutabaga_gfx + gfxstream
On Thu, Aug 24, 2023 at 9:53 PM Akihiko Odaki wrote: > On 2023/08/25 8:40, Gurchetan Singh wrote: > > From: Gurchetan Singh > > > > Prior versions: > > > > Changes since v11: > > - Incorporated review feedback > > > > How to build both rutabaga and gfxstream guest/host libs: > > > > https://crosvm.dev/book/appendix/rutabaga_gfx.html > > > > Branch containing this patch series (now on QEMU Gitlab): > > > > https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v12 > > > > Antonio Caggiano (2): > >virtio-gpu: CONTEXT_INIT feature > >virtio-gpu: blob prep > > > > Dr. David Alan Gilbert (1): > >virtio: Add shared memory capability > > > > Gerd Hoffmann (1): > >virtio-gpu: hostmem > > > > Gurchetan Singh (5): > >gfxstream + rutabaga prep: added need defintions, fields, and options > >gfxstream + rutabaga: add initial support for gfxstream > >gfxstream + rutabaga: meson support > >gfxstream + rutabaga: enable rutabaga > >docs/system: add basic virtio-gpu documentation > > > > docs/system/device-emulation.rst |1 + > > docs/system/devices/virtio-gpu.rst | 112 +++ > > hw/display/meson.build | 22 + > > hw/display/virtio-gpu-base.c |6 +- > > hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ > > hw/display/virtio-gpu-pci.c | 14 + > > hw/display/virtio-gpu-rutabaga.c | 1119 ++ > > hw/display/virtio-gpu.c | 16 +- > > hw/display/virtio-vga-rutabaga.c | 50 ++ > > hw/display/virtio-vga.c | 33 +- > > hw/virtio/virtio-pci.c | 18 + > > include/hw/virtio/virtio-gpu-bswap.h | 15 + > > include/hw/virtio/virtio-gpu.h | 41 + > > include/hw/virtio/virtio-pci.h |4 + > > meson.build |7 + > > meson_options.txt|2 + > > scripts/meson-buildoptions.sh|3 + > > softmmu/qdev-monitor.c |3 + > > softmmu/vl.c |1 + > > 19 files changed, 1495 insertions(+), 19 deletions(-) > > create mode 100644 docs/system/devices/virtio-gpu.rst > > create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c > > create mode 100644 hw/display/virtio-gpu-rutabaga.c > > create mode 100644 hw/display/virtio-vga-rutabaga.c > > > > Thanks for keeping working on this. For the entire series: > Reviewed-by: Akihiko Odaki > Tested-by: Akihiko Odaki > Awesome, thanks. I'll wait a few days for possible additional comments, otherwise I'll send out v13 with additional r-b tags.
Re: [PATCH v12 8/9] gfxstream + rutabaga: enable rutabaga
On Fri, Aug 25, 2023 at 6:55 AM Antonio Caggiano wrote: > Hi Gurchetan, > > Thank you for this series and for including some of my patches :) > > On 25/08/2023 01:40, Gurchetan Singh wrote: > > This change enables rutabaga to receive virtio-gpu-3d hypercalls > > when it is active. > > > > Signed-off-by: Gurchetan Singh > > Tested-by: Alyssa Ross > > Tested-by: Emmanouil Pitsidianakis > > Reviewed-by: Emmanouil Pitsidianakis > > --- > > v3: Whitespace fix (Akihiko) > > v9: reorder virtio_gpu_have_udmabuf() after checking if rutabaga > > is enabled to avoid spurious warnings (Akihiko) > > > > hw/display/virtio-gpu-base.c | 3 ++- > > hw/display/virtio-gpu.c | 5 +++-- > > softmmu/qdev-monitor.c | 3 +++ > > softmmu/vl.c | 1 + > > 4 files changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c > > index 4f2b0ba1f3..50c5373b65 100644 > > --- a/hw/display/virtio-gpu-base.c > > +++ b/hw/display/virtio-gpu-base.c > > @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, > uint64_t features, > > { > > VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); > > > > -if (virtio_gpu_virgl_enabled(g->conf)) { > > +if (virtio_gpu_virgl_enabled(g->conf) || > > +virtio_gpu_rutabaga_enabled(g->conf)) { > > features |= (1 << VIRTIO_GPU_F_VIRGL); > > } > > if (virtio_gpu_edid_enabled(g->conf)) { > > diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c > > index 3e658f1fef..fe094addef 100644 > > --- a/hw/display/virtio-gpu.c > > +++ b/hw/display/virtio-gpu.c > > @@ -1361,8 +1361,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, > Error **errp) > > VirtIOGPU *g = VIRTIO_GPU(qdev); > > > > if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { > > -if (!virtio_gpu_have_udmabuf()) { > > -error_setg(errp, "cannot enable blob resources without > udmabuf"); > > +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && > > +!virtio_gpu_have_udmabuf()) { > > +error_setg(errp, "need rutabaga or udmabuf for blob > resources"); > > Does that mean udmabuf is not required at all when using rutabaga? > How does rutabaga handle blob resources? > It's not required, since it's a Linux-only thing. Some use cases do prefer to use guest memory and we do have provisional support for that (see `handle` field of `rutabaga_resource_create_blob`). Though more testing is required on the target platform, and likely virtio-gpu spec changes for a full-functional solution. > > > return; > > } > > > > diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c > > index 74f4e41338..1b8005ae55 100644 > > --- a/softmmu/qdev-monitor.c > > +++ b/softmmu/qdev-monitor.c > > @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { > > { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, > > { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, > > { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, > > +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", > > + QEMU_ARCH_VIRTIO_MMIO }, > > +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", > QEMU_ARCH_VIRTIO_PCI }, > > { "virtio-input-host-device", "virtio-input-host", > QEMU_ARCH_VIRTIO_MMIO }, > > { "virtio-input-host-ccw", "virtio-input-host", > QEMU_ARCH_VIRTIO_CCW }, > > { "virtio-input-host-pci", "virtio-input-host", > QEMU_ARCH_VIRTIO_PCI }, > > diff --git a/softmmu/vl.c b/softmmu/vl.c > > index b0b96f67fa..2f98eefdf3 100644 > > --- a/softmmu/vl.c > > +++ b/softmmu/vl.c > > @@ -216,6 +216,7 @@ static struct { > > { .driver = "ati-vga", .flag = _vga }, > > { .driver = "vhost-user-vga", .flag = _vga }, > > { .driver = "virtio-vga-gl",.flag = _vga }, > > +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, > > }; > > > > static QemuOptsList qemu_rtc_opts = { > > Patches 5 to 9: > Reviewed-by: Antonio Caggiano > > Cheers, > Antonio >
Re: [PATCH v11 0/9] rutabaga_gfx + gfxstream
On Fri, Aug 25, 2023 at 12:11 AM Alyssa Ross wrote: > Gurchetan Singh writes: > > > On Wed, Aug 23, 2023 at 4:07 AM Alyssa Ross wrote: > > > >> Gurchetan Singh writes: > >> > >> > - Official "release commits" issued for rutabaga_gfx_ffi, > >> > gfxstream, aemu-base. For example, see crrev.com/c/4778941 > >> > > >> > - The release commits can make packaging easier, though once > >> > again all known users will likely just build from sources > >> > anyways > >> > >> It's a small thing, but could there be actual tags, rather than just > >> blessed commits? It'd just make them easier to find, and save a bit of > >> time in review for packages. > >> > > > > I added: > > > > > https://crosvm.dev/book/appendix/rutabaga_gfx.html#latest-releases-for-potential-packaging > > > > Tags are possible, but I want to clarify the use case before packaging. > > Where are you thinking of packaging it for (Debian??)? Are you mostly > > interested in Wayland passthrough (my guess) or gfxstream too? Depending > > your use case, we may be able to minimize the work involved. > > Packaging for Nixpkgs (where I already maintain what to my knowledge is > the only crosvm distro package). I'm personally mostly interested in > Wayland passthroug, but I wouldn't be surprised if others are interested > in gfxstream. The packaging work is already done, I've just been > holding off actually pushing the packages waiting for the stable > releases. > > The reason that tags would be useful is that it allows a reviewer of the > package to see at a glance that the package is built from a stable > release. If it's just built from a commit hash, they have to go and > verify that it's a stable release, which is mildly annoying and > unconventional. > Understood. Request to have gfxstream and AEMU v0.1.2 release tags made. For rutabaga_gfx_ffi, is the crates.io upload sufficient? https://crates.io/crates/rutabaga_gfx_ffi Debian, for example, treats crates.io as the source of truth and builds tooling around that. I wonder if Nixpkgs as similar tooling around crates.io.
Re: [PATCH v11 0/9] rutabaga_gfx + gfxstream
On Wed, Aug 23, 2023 at 4:07 AM Alyssa Ross wrote: > Gurchetan Singh writes: > > > - Official "release commits" issued for rutabaga_gfx_ffi, > > gfxstream, aemu-base. For example, see crrev.com/c/4778941 > > > > - The release commits can make packaging easier, though once > > again all known users will likely just build from sources > > anyways > > It's a small thing, but could there be actual tags, rather than just > blessed commits? It'd just make them easier to find, and save a bit of > time in review for packages. > I added: https://crosvm.dev/book/appendix/rutabaga_gfx.html#latest-releases-for-potential-packaging Tags are possible, but I want to clarify the use case before packaging. Where are you thinking of packaging it for (Debian??)? Are you mostly interested in Wayland passthrough (my guess) or gfxstream too? Depending your use case, we may be able to minimize the work involved.
Re: [PATCH v7 6/9] gfxstream + rutabaga: add initial support for gfxstream
On Wed, Aug 23, 2023 at 8:03 AM Mark Cave-Ayland < mark.cave-ayl...@ilande.co.uk> wrote: > On 17/08/2023 03:23, Gurchetan Singh wrote: > > > From: Gurchetan Singh > > > > This adds initial support for gfxstream and cross-domain. Both > > features rely on virtio-gpu blob resources and context types, which > > are also implemented in this patch. > > > > gfxstream has a long and illustrious history in Android graphics > > paravirtualization. It has been powering graphics in the Android > > Studio Emulator for more than a decade, which is the main developer > > platform. > > > > Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. > > The key design characteristic was a 1:1 threading model and > > auto-generation, which fit nicely with the OpenGLES spec. It also > > allowed easy layering with ANGLE on the host, which provides the GLES > > implementations on Windows or MacOS enviroments. > > > > gfxstream has traditionally been maintained by a single engineer, and > > between 2015 to 2021, the goldfish throne passed to Frank Yang. > > Historians often remark this glorious reign ("pax gfxstreama" is the > > academic term) was comparable to that of Augustus and both Queen > > Elizabeths. Just to name a few accomplishments in a resplendent > > panoply: higher versions of GLES, address space graphics, snapshot > > support and CTS compliant Vulkan [b]. > > > > One major drawback was the use of out-of-tree goldfish drivers. > > Android engineers didn't know much about DRM/KMS and especially TTM so > > a simple guest to host pipe was conceived. > > > > Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of > > the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu > > port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. > > It was a symbol compatible replacement of virglrenderer [c] and named > > "AVDVirglrenderer". This implementation forms the basis of the > > current gfxstream host implementation still in use today. > > > > cross-domain support follows a similar arc. Originally conceived by > > Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in > > 2018, it initially relied on the downstream "virtio-wl" device. > > > > In 2020 and 2021, virtio-gpu was extended to include blob resources > > and multiple timelines by yours truly, features gfxstream/cross-domain > > both require to function correctly. > > > > Right now, we stand at the precipice of a truly fantastic possibility: > > the Android Emulator powered by upstream QEMU and upstream Linux > > kernel. gfxstream will then be packaged properfully, and app > > developers can even fix gfxstream bugs on their own if they encounter > > them. > > > > It's been quite the ride, my friends. Where will gfxstream head next, > > nobody really knows. I wouldn't be surprised if it's around for > > another decade, maintained by a new generation of Android graphics > > enthusiasts. > > > > Technical details: > >- Very simple initial display integration: just used Pixman > >- Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function > > calls > > > > Next steps for Android VMs: > >- The next step would be improving display integration and UI > interfaces > > with the goal of the QEMU upstream graphics being in an emulator > > release [d]. > > > > Next steps for Linux VMs for display virtualization: > >- For widespread distribution, someone needs to package Sommelier or > the > > wayland-proxy-virtwl [e] ideally into Debian main. In addition, > newer > > versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, > > which allows disabling KMS hypercalls. If anyone cares enough, > it'll > > probably be possible to build a custom VM variant that uses this > display > > virtualization strategy. > > > > [a] > https://android-review.googlesource.com/c/platform/development/+/34470 > > [b] > https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 > > [c] > https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 > > [d] https://developer.android.com/studio/releases/emulator > > [e] https://github.com/talex5/wayland-proxy-virtwl > > > > Signed-off-by: Gurchetan Singh > > Tested-by: Alyssa Ross > > Tested-by: Emmanouil Pitsidianakis > > Reviewed-by: Emmanouil Pitsidianakis > > --- > > v1
Re: [PATCH v7 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
On Wed, Aug 23, 2023 at 7:32 AM Mark Cave-Ayland < mark.cave-ayl...@ilande.co.uk> wrote: > On 17/08/2023 03:23, Gurchetan Singh wrote: > > > From: Gurchetan Singh > > > > This modifies the common virtio-gpu.h file have the fields and > > defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. > > > > Signed-off-by: Gurchetan Singh > > Tested-by: Alyssa Ross > > Tested-by: Emmanouil Pitsidianakis > > Reviewed-by: Emmanouil Pitsidianakis > > --- > > v1: void *rutabaga --> struct rutabaga *rutabaga (Akihiko) > > have a separate rutabaga device instead of using GL device (Bernard) > > > > v2: VirtioGpuRutabaga --> VirtIOGPURutabaga (Akihiko) > > move MemoryRegionInfo into VirtIOGPURutabaga (Akihiko) > > remove 'ctx' field (Akihiko) > > remove 'rutabaga_active' > > > > v6: remove command from commit message, refer to docs instead (Manos) > > > > include/hw/virtio/virtio-gpu.h | 28 > > 1 file changed, 28 insertions(+) > > > > diff --git a/include/hw/virtio/virtio-gpu.h > b/include/hw/virtio/virtio-gpu.h > > index 55973e112f..e2a07e68d9 100644 > > --- a/include/hw/virtio/virtio-gpu.h > > +++ b/include/hw/virtio/virtio-gpu.h > > @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) > > #define TYPE_VHOST_USER_GPU "vhost-user-gpu" > > OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) > > > > +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" > > +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) > > + > > struct virtio_gpu_simple_resource { > > uint32_t resource_id; > > uint32_t width; > > @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { > > VIRTIO_GPU_FLAG_DMABUF_ENABLED, > > VIRTIO_GPU_FLAG_BLOB_ENABLED, > > VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, > > +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, > > }; > > > > #define virtio_gpu_virgl_enabled(_cfg) \ > > @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { > > (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) > > #define virtio_gpu_context_init_enabled(_cfg) \ > > (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) > > +#define virtio_gpu_rutabaga_enabled(_cfg) \ > > +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) > > #define virtio_gpu_hostmem_enabled(_cfg) \ > > (_cfg.hostmem > 0) > > > > @@ -232,6 +238,28 @@ struct VhostUserGPU { > > bool backend_blocked; > > }; > > > > +#define MAX_SLOTS 4096 > > + > > +struct MemoryRegionInfo { > > +int used; > > +MemoryRegion mr; > > +uint32_t resource_id; > > +}; > > + > > +struct rutabaga; > > + > > +struct VirtIOGPURutabaga { > > +struct VirtIOGPU parent_obj; > > The QOM macro should define a typedef for you, so you can drop the > "struct" here. > > > + > > +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; > > +char *capset_names; > > +char *wayland_socket_path; > > +char *wsi; > > +bool headless; > > +uint32_t num_capsets; > > +struct rutabaga *rutabaga; > > +}; > > + > > Shouldn't the VIRTIO_GPU_RUTABAGA QOM declaration and this structure be in > a separate > virtio-gpu-rutabaga header file which also includes the header defining > struct > rutabaga? The fact that you're having to pre-declare struct rutabaga in > this header > when rutabaga support is an optional dependency doesn't seem right. > It is the prevailing style of the virtio-gpu code. For example, we do have "virtio_gpu_virgl_*" functions, vhost-user, and udmabuf stubs in the same file. So for now, I didn't add an extra header file in v12. In the future, separating out optional dependencies into constituent header files could be future refactoring/cleanup. > > > #define VIRTIO_GPU_FILL_CMD(out) do { > \ > > size_t s; > \ > > s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, > \ > > > ATB, > > Mark. > >
[PATCH v12 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v1: Incorported various suggestions by Akihiko Odaki and Bernard Berschow - Removed GET_VIRTIO_GPU_GL / GET_RUTABAGA macros - Used error_report(..) - Used g_autofree to fix leaks on error paths - Removed unnecessary casts - added virtio-gpu-pci-rutabaga.c + virtio-vga-rutabaga.c files v2: Incorported various suggestions by Akihiko Odaki, Marc-André Lureau and Bernard Berschow: - Parenthesis in CHECK macro - CHECK_RESULT(result, ..) --> CHECK(!result, ..) - delay until g->parent_obj.enable = 1 - Additional cast fixes - initialize directly in virtio_gpu_rutabaga_realize(..) - add debug callback to hook into QEMU error's APIs v3: Incorporated feedback from Akihiko Odaki and Alyssa Ross: - Autodetect Wayland socket when not explicitly specified - Fix map_blob error paths - Add comment why we need both `res` and `resource` in create blob - Cast and whitespace fixes - Big endian check comes before virtio_gpu_rutabaga_init(). - VirtIOVGARUTABAGA --> VirtIOVGARutabaga v4: Incorpo
[PATCH v12 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v1: void *rutabaga --> struct rutabaga *rutabaga (Akihiko) have a separate rutabaga device instead of using GL device (Bernard) v2: VirtioGpuRutabaga --> VirtIOGPURutabaga (Akihiko) move MemoryRegionInfo into VirtIOGPURutabaga (Akihiko) remove 'ctx' field (Akihiko) remove 'rutabaga_active' v6: remove command from commit message, refer to docs instead (Manos) v12: Drop unnecessary "struct" (Mark) include/hw/virtio/virtio-gpu.h | 28 1 file changed, 28 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..de06bcdba4 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,28 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +VirtIOGPU parent_obj; + +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +char *capset_names; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Reviewed-by: Marc-André Lureau Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v3: Whitespace fix (Akihiko) v9: reorder virtio_gpu_have_udmabuf() after checking if rutabaga is enabled to avoid spurious warnings (Akihiko) hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3e658f1fef..fe094addef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1361,8 +1361,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index b0b96f67fa..2f98eefdf3 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -216,6 +216,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v3: Fix alignment issues (Akihiko) hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 98e68ef0b1..293f388e53 100644 --- a/meson.build +++ b/meson.build @@ -1069,6 +1069,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4272,6 +4278,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index aaea5ddd77..dea3bf7d9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -224,6 +224,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 9da3fe299b..9a95b4f782 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -154,6 +154,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support' printf "%s\n" ' sdl
[PATCH v12 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Reviewed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Acked-by: Huang Rui Tested-by: Huang Rui Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Prior versions: Changes since v11: - Incorporated review feedback How to build both rutabaga and gfxstream guest/host libs: https://crosvm.dev/book/appendix/rutabaga_gfx.html Branch containing this patch series (now on QEMU Gitlab): https://gitlab.com/gurchetansingh/qemu/-/commits/qemu-gfxstream-v12 Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 47 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1119 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 50 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 15 + include/hw/virtio/virtio-gpu.h | 41 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1495 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v2: - Incorporated suggestions by Akihiko Odaki - Listed the currently supported capset_names (Bernard) v3: - Incorporated suggestions by Akihiko Odaki and Alyssa Ross v4: - Incorporated suggestions by Akihiko Odaki v5: - Removed pci suffix from examples - Verified that -device virtio-gpu-rutabaga works. Strangely enough, I don't remember changing anything, and I remember it not working. I did rebase to top of tree though. - Fixed meson examples in crosvm docs v8: - Remove different links for "rutabaga_gfx" and "gfxstream-enabled rutabaga" (Akihiko) v11: - Use GPL-2.0-or-later license (Phillippe) docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..21465e4ce2 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one capset (see colon separated ``capset_names`` below) must be +specified when starting the device. The currently suppo
[PATCH v12 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 15 +++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v12 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Acked-by: Michael S. Tsirkin --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bbd5c6561a..48ef0d9fad 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1509,6 +1509,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.rc2.253.gd59a3bf2b4-goog
[PATCH v11 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v3: Fix alignment issues (Akihiko) hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 98e68ef0b1..293f388e53 100644 --- a/meson.build +++ b/meson.build @@ -1069,6 +1069,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4272,6 +4278,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index aaea5ddd77..dea3bf7d9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -224,6 +224,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 9da3fe299b..9a95b4f782 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -154,6 +154,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support' printf "%s\n" ' sdl
[PATCH v11 8/9] gfxstream + rutabaga: enable rutabaga
This change enables rutabaga to receive virtio-gpu-3d hypercalls when it is active. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v3: Whitespace fix (Akihiko) v9: reorder virtio_gpu_have_udmabuf() after checking if rutabaga is enabled to avoid spurious warnings (Akihiko) hw/display/virtio-gpu-base.c | 3 ++- hw/display/virtio-gpu.c | 5 +++-- softmmu/qdev-monitor.c | 3 +++ softmmu/vl.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..50c5373b65 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -223,7 +223,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, { VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev); -if (virtio_gpu_virgl_enabled(g->conf)) { +if (virtio_gpu_virgl_enabled(g->conf) || +virtio_gpu_rutabaga_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_VIRGL); } if (virtio_gpu_edid_enabled(g->conf)) { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3e658f1fef..fe094addef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1361,8 +1361,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { -if (!virtio_gpu_have_udmabuf()) { -error_setg(errp, "cannot enable blob resources without udmabuf"); +if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && +!virtio_gpu_have_udmabuf()) { +error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; } diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 74f4e41338..1b8005ae55 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -86,6 +86,9 @@ static const QDevAlias qdev_alias_table[] = { { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, +{ "virtio-gpu-rutabaga-device", "virtio-gpu-rutabaga", + QEMU_ARCH_VIRTIO_MMIO }, +{ "virtio-gpu-rutabaga-pci", "virtio-gpu-rutabaga", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, diff --git a/softmmu/vl.c b/softmmu/vl.c index b0b96f67fa..2f98eefdf3 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -216,6 +216,7 @@ static struct { { .driver = "ati-vga", .flag = _vga }, { .driver = "vhost-user-vga", .flag = _vga }, { .driver = "virtio-vga-gl",.flag = _vga }, +{ .driver = "virtio-vga-rutabaga", .flag = _vga }, }; static QemuOptsList qemu_rtc_opts = { -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Reviewed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Acked-by: Huang Rui Tested-by: Huang Rui Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 9/9] docs/system: add basic virtio-gpu documentation
This adds basic documentation for virtio-gpu. Suggested-by: Akihiko Odaki Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v2: - Incorporated suggestions by Akihiko Odaki - Listed the currently supported capset_names (Bernard) v3: - Incorporated suggestions by Akihiko Odaki and Alyssa Ross v4: - Incorporated suggestions by Akihiko Odaki v5: - Removed pci suffix from examples - Verified that -device virtio-gpu-rutabaga works. Strangely enough, I don't remember changing anything, and I remember it not working. I did rebase to top of tree though. - Fixed meson examples in crosvm docs v8: - Remove different links for "rutabaga_gfx" and "gfxstream-enabled rutabaga" (Akihiko) v11: - GPL-2.0-or-later license (Phillippe) docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-gpu.rst | 112 + 2 files changed, 113 insertions(+) create mode 100644 docs/system/devices/virtio-gpu.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index 4491c4cbf7..1167f3a9f2 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -91,6 +91,7 @@ Emulated Devices devices/nvme.rst devices/usb.rst devices/vhost-user.rst + devices/virtio-gpu.rst devices/virtio-pmem.rst devices/vhost-user-rng.rst devices/canokey.rst diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst new file mode 100644 index 00..21465e4ce2 --- /dev/null +++ b/docs/system/devices/virtio-gpu.rst @@ -0,0 +1,112 @@ +.. + SPDX-License-Identifier: GPL-2.0-or-later + +virtio-gpu +== + +This document explains the setup and usage of the virtio-gpu device. +The virtio-gpu device paravirtualizes the GPU and display controller. + +Linux kernel support + + +virtio-gpu requires a guest Linux kernel built with the +``CONFIG_DRM_VIRTIO_GPU`` option. + +QEMU virtio-gpu variants + + +QEMU virtio-gpu device variants come in the following form: + + * ``virtio-vga[-BACKEND]`` + * ``virtio-gpu[-BACKEND][-INTERFACE]`` + * ``vhost-user-vga`` + * ``vhost-user-pci`` + +**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated +backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' +device label). There is a vhost-user backend that runs the graphics stack +in a separate process for improved isolation. + +**Interfaces:** QEMU further categorizes virtio-gpu device variants based +on the interface exposed to the guest. The interfaces can be classified +into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga +or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or +vhost-user-gpu. + +The VGA ones always use the PCI interface, but for the non-VGA ones, the +user can further pick between MMIO or PCI. For MMIO, the user can suffix +the device name with -device, though vhost-user-gpu does not support MMIO. +For PCI, the user can suffix it with -pci. Without these suffixes, the +platform default will be chosen. + +virtio-gpu 2d +- + +The default 2D backend only performs 2D operations. The guest needs to +employ a software renderer for 3D graphics. + +Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. +Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box +on typical modern Linux distributions. + +.. parsed-literal:: +-device virtio-gpu + +.. _Mesa: https://www.mesa3d.org/ +.. _SwiftShader: https://github.com/google/swiftshader + +virtio-gpu virglrenderer + + +When using virgl accelerated graphics mode in the guest, OpenGL API calls +are translated into an intermediate representation (see `Gallium3D`_). The +intermediate representation is communicated to the host and the +`virglrenderer`_ library on the host translates the intermediate +representation back to OpenGL API calls. + +.. parsed-literal:: +-device virtio-gpu-gl + +.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ +.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ + +virtio-gpu rutabaga +--- + +virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ +rendering and `Wayland display passthrough`_. With the gfxstream rendering +mode, GLES and Vulkan calls are forwarded to the host with minimal +modification. + +The crosvm book provides directions on how to build a `gfxstream-enabled +rutabaga`_ and launch a `guest Wayland proxy`_. + +This device does require host blob support (``hostmem`` field below). The +``hostmem`` field specifies the size of virtio-gpu host memory window. +This is typically between 256M and 8G. + +At least one capset (see colon separated ``capset_names`` below) must be +specified when starting the device. The currently suppo
[PATCH v11 3/9] virtio-gpu: hostmem
From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Acked-by: Michael S. Tsirkin --- hw/display/virtio-gpu-pci.c| 14 ++ hw/display/virtio-gpu.c| 1 + hw/display/virtio-vga.c| 33 - include/hw/virtio/virtio-gpu.h | 5 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; +if (virtio_gpu_hostmem_enabled(g->conf)) { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bbd5c6561a..48ef0d9fad 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1509,6 +1509,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), +DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, >vram); -/* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ -vpci_dev->modern_mem_bar_idx = 2; -vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; +if (!virtio_gpu_hostmem_enabled(g->conf)) { +/* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ +vpci_dev->modern_mem_bar_idx = 2; +vpci_dev->msix_bar_idx = 4; +} else { +vpci_dev->msix_bar_idx = 1; +vpci_dev->modern_mem_bar_idx = 2; +memory_region_init(>hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); +pci_register_bar(_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + >hostmem); +virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); +} + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ +(_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; +uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; +MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v1: Incorported various suggestions by Akihiko Odaki and Bernard Berschow - Removed GET_VIRTIO_GPU_GL / GET_RUTABAGA macros - Used error_report(..) - Used g_autofree to fix leaks on error paths - Removed unnecessary casts - added virtio-gpu-pci-rutabaga.c + virtio-vga-rutabaga.c files v2: Incorported various suggestions by Akihiko Odaki, Marc-André Lureau and Bernard Berschow: - Parenthesis in CHECK macro - CHECK_RESULT(result, ..) --> CHECK(!result, ..) - delay until g->parent_obj.enable = 1 - Additional cast fixes - initialize directly in virtio_gpu_rutabaga_realize(..) - add debug callback to hook into QEMU error's APIs v3: Incorporated feedback from Akihiko Odaki and Alyssa Ross: - Autodetect Wayland socket when not explicitly specified - Fix map_blob error paths - Add comment why we need both `res` and `resource` in create blob - Cast and whitespace fixes - Big endian check comes before virtio_gpu_rutabaga_init(). - VirtIOVGARUTABAGA --> VirtIOVGARutabaga v4: Incorpo
[PATCH v11 5/9] gfxstream + rutabaga prep: added need defintions, fields, and options
This modifies the common virtio-gpu.h file have the fields and defintions needed by gfxstream/rutabaga, by VirtioGpuRutabaga. Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v1: void *rutabaga --> struct rutabaga *rutabaga (Akihiko) have a separate rutabaga device instead of using GL device (Bernard) v2: VirtioGpuRutabaga --> VirtIOGPURutabaga (Akihiko) move MemoryRegionInfo into VirtIOGPURutabaga (Akihiko) remove 'ctx' field (Akihiko) remove 'rutabaga_active' v6: remove command from commit message, refer to docs instead (Manos) include/hw/virtio/virtio-gpu.h | 28 1 file changed, 28 insertions(+) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..e2a07e68d9 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -38,6 +38,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) +#define TYPE_VIRTIO_GPU_RUTABAGA "virtio-gpu-rutabaga-device" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabaga, VIRTIO_GPU_RUTABAGA) + struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; @@ -94,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, +VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -108,6 +112,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_rutabaga_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) @@ -232,6 +238,28 @@ struct VhostUserGPU { bool backend_blocked; }; +#define MAX_SLOTS 4096 + +struct MemoryRegionInfo { +int used; +MemoryRegion mr; +uint32_t resource_id; +}; + +struct rutabaga; + +struct VirtIOGPURutabaga { +struct VirtIOGPU parent_obj; + +struct MemoryRegionInfo memory_regions[MAX_SLOTS]; +char *capset_names; +char *wayland_socket_path; +char *wsi; +bool headless; +uint32_t num_capsets; +struct rutabaga *rutabaga; +}; + #define VIRTIO_GPU_FILL_CMD(out) do { \ size_t s; \ s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0, \ -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 4/9] virtio-gpu: blob prep
From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- hw/display/virtio-gpu.c | 10 +++--- include/hw/virtio/virtio-gpu-bswap.h | 18 ++ include/hw/virtio/virtio-gpu.h | 5 + 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 9124108485..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -63,10 +63,28 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) { virtio_gpu_ctrl_hdr_bswap(>hdr); le32_to_cpus(>resource_id); +le32_to_cpus(>blob_mem); le32_to_cpus(>blob_flags); +le32_to_cpus(>nr_entries); +le64_to_cpus(>blob_id); le64_to_cpus(>size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +le64_to_cpus(>offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ +virtio_gpu_ctrl_hdr_bswap(>hdr); +le32_to_cpus(>resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, +struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 0/9] rutabaga_gfx + gfxstream
From: Gurchetan Singh Changes since v10: - Licensing and comment fixes - Official "release commits" issued for rutabaga_gfx_ffi, gfxstream, aemu-base. For example, see crrev.com/c/4778941 - The release commits can make packaging easier, though once again all known users will likely just build from sources anyways How to build both rutabaga and gfxstream guest/host libs: https://crosvm.dev/book/appendix/rutabaga_gfx.html Branch containing this patch series: https://gitlab.freedesktop.org/gurchetansingh/qemu-gfxstream/-/commits/qemu-gfxstream-v11 Antonio Caggiano (2): virtio-gpu: CONTEXT_INIT feature virtio-gpu: blob prep Dr. David Alan Gilbert (1): virtio: Add shared memory capability Gerd Hoffmann (1): virtio-gpu: hostmem Gurchetan Singh (5): gfxstream + rutabaga prep: added need defintions, fields, and options gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga: meson support gfxstream + rutabaga: enable rutabaga docs/system: add basic virtio-gpu documentation docs/system/device-emulation.rst |1 + docs/system/devices/virtio-gpu.rst | 112 +++ hw/display/meson.build | 22 + hw/display/virtio-gpu-base.c |6 +- hw/display/virtio-gpu-pci-rutabaga.c | 50 ++ hw/display/virtio-gpu-pci.c | 14 + hw/display/virtio-gpu-rutabaga.c | 1121 ++ hw/display/virtio-gpu.c | 16 +- hw/display/virtio-vga-rutabaga.c | 53 ++ hw/display/virtio-vga.c | 33 +- hw/virtio/virtio-pci.c | 18 + include/hw/virtio/virtio-gpu-bswap.h | 18 + include/hw/virtio/virtio-gpu.h | 41 + include/hw/virtio/virtio-pci.h |4 + meson.build |7 + meson_options.txt|2 + scripts/meson-buildoptions.sh|3 + softmmu/qdev-monitor.c |3 + softmmu/vl.c |1 + 19 files changed, 1506 insertions(+), 19 deletions(-) create mode 100644 docs/system/devices/virtio-gpu.rst create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c create mode 100644 hw/display/virtio-gpu-rutabaga.c create mode 100644 hw/display/virtio-vga-rutabaga.c -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v11 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Reviewed-by: Marc-André Lureau Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.rc1.204.g551eb34607-goog
Re: [PATCH v7 9/9] docs/system: add basic virtio-gpu documentation
On Fri, Aug 18, 2023 at 11:13 PM Akihiko Odaki wrote: > On 2023/08/19 10:17, Gurchetan Singh wrote: > > > > > > On Fri, Aug 18, 2023 at 5:08 AM Akihiko Odaki > <mailto:akihiko.od...@gmail.com>> wrote: > > > > On 2023/08/18 8:47, Gurchetan Singh wrote: > > > > > > > > > On Wed, Aug 16, 2023 at 10:28 PM Akihiko Odaki > > mailto:akihiko.od...@gmail.com> > > > <mailto:akihiko.od...@gmail.com > > <mailto:akihiko.od...@gmail.com>>> wrote: > > > > > > On 2023/08/17 11:23, Gurchetan Singh wrote: > > > > From: Gurchetan Singh > <mailto:gurchetansi...@chromium.org> > > > <mailto:gurchetansi...@chromium.org > > <mailto:gurchetansi...@chromium.org>>> > > > > > > > > This adds basic documentation for virtio-gpu. > > > > > > > > Suggested-by: Akihiko Odaki > <mailto:akihiko.od...@daynix.com> > > > <mailto:akihiko.od...@daynix.com > > <mailto:akihiko.od...@daynix.com>>> > > > > Signed-off-by: Gurchetan Singh > > mailto:gurchetansi...@chromium.org> > > > <mailto:gurchetansi...@chromium.org > > <mailto:gurchetansi...@chromium.org>>> > > > > Tested-by: Alyssa Ross mailto:h...@alyssa.is> > > <mailto:h...@alyssa.is <mailto:h...@alyssa.is>>> > > > > Tested-by: Emmanouil Pitsidianakis > > > > <mailto:manos.pitsidiana...@linaro.org> > > <mailto:manos.pitsidiana...@linaro.org > > <mailto:manos.pitsidiana...@linaro.org>>> > > > > Reviewed-by: Emmanouil Pitsidianakis > > > > <mailto:manos.pitsidiana...@linaro.org> > > <mailto:manos.pitsidiana...@linaro.org > > <mailto:manos.pitsidiana...@linaro.org>>> > > > > --- > > > > v2: - Incorporated suggestions by Akihiko Odaki > > > > - Listed the currently supported capset_names > (Bernard) > > > > > > > > v3: - Incorporated suggestions by Akihiko Odaki and Alyssa > > Ross > > > > > > > > v4: - Incorporated suggestions by Akihiko Odaki > > > > > > > > v5: - Removed pci suffix from examples > > > > - Verified that -device virtio-gpu-rutabaga works. > > Strangely > > > >enough, I don't remember changing anything, and I > > remember > > > >it not working. I did rebase to top of tree though. > > > > - Fixed meson examples in crosvm docs > > > > > > > > docs/system/device-emulation.rst | 1 + > > > > docs/system/devices/virtio-gpu.rst | 113 > > > + > > > > 2 files changed, 114 insertions(+) > > > > create mode 100644 docs/system/devices/virtio-gpu.rst > > > > > > > > diff --git a/docs/system/device-emulation.rst > > > b/docs/system/device-emulation.rst > > > > index 4491c4cbf7..1167f3a9f2 100644 > > > > --- a/docs/system/device-emulation.rst > > > > +++ b/docs/system/device-emulation.rst > > > > @@ -91,6 +91,7 @@ Emulated Devices > > > > devices/nvme.rst > > > > devices/usb.rst > > > > devices/vhost-user.rst > > > > + devices/virtio-gpu.rst > > > > devices/virtio-pmem.rst > > > > devices/vhost-user-rng.rst > > > > devices/canokey.rst > > > > diff --git a/docs/system/devices/virtio-gpu.rst > > > b/docs/system/devices/virtio-gpu.rst > > > > new file mode 100644 > > > > index 00..8c5c708272 > > > > --- /dev/null > > > > +++ b/docs/system/devices/virtio-gpu.rst > > > > @@ -0,0 +1,113 @@ > > > > +.. > > > > + SPDX-License-Identifier: GPL-2.0 > > > > + > > > > +virtio-gpu > > > > +
[PATCH v10 6/9] gfxstream + rutabaga: add initial support for gfxstream
This adds initial support for gfxstream and cross-domain. Both features rely on virtio-gpu blob resources and context types, which are also implemented in this patch. gfxstream has a long and illustrious history in Android graphics paravirtualization. It has been powering graphics in the Android Studio Emulator for more than a decade, which is the main developer platform. Originally conceived by Jesse Hall, it was first known as "EmuGL" [a]. The key design characteristic was a 1:1 threading model and auto-generation, which fit nicely with the OpenGLES spec. It also allowed easy layering with ANGLE on the host, which provides the GLES implementations on Windows or MacOS enviroments. gfxstream has traditionally been maintained by a single engineer, and between 2015 to 2021, the goldfish throne passed to Frank Yang. Historians often remark this glorious reign ("pax gfxstreama" is the academic term) was comparable to that of Augustus and both Queen Elizabeths. Just to name a few accomplishments in a resplendent panoply: higher versions of GLES, address space graphics, snapshot support and CTS compliant Vulkan [b]. One major drawback was the use of out-of-tree goldfish drivers. Android engineers didn't know much about DRM/KMS and especially TTM so a simple guest to host pipe was conceived. Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of the Mesa/virglrenderer communities. In 2018, the initial virtio-gpu port of gfxstream was done by Cuttlefish enthusiast Alistair Delva. It was a symbol compatible replacement of virglrenderer [c] and named "AVDVirglrenderer". This implementation forms the basis of the current gfxstream host implementation still in use today. cross-domain support follows a similar arc. Originally conceived by Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in 2018, it initially relied on the downstream "virtio-wl" device. In 2020 and 2021, virtio-gpu was extended to include blob resources and multiple timelines by yours truly, features gfxstream/cross-domain both require to function correctly. Right now, we stand at the precipice of a truly fantastic possibility: the Android Emulator powered by upstream QEMU and upstream Linux kernel. gfxstream will then be packaged properfully, and app developers can even fix gfxstream bugs on their own if they encounter them. It's been quite the ride, my friends. Where will gfxstream head next, nobody really knows. I wouldn't be surprised if it's around for another decade, maintained by a new generation of Android graphics enthusiasts. Technical details: - Very simple initial display integration: just used Pixman - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function calls Next steps for Android VMs: - The next step would be improving display integration and UI interfaces with the goal of the QEMU upstream graphics being in an emulator release [d]. Next steps for Linux VMs for display virtualization: - For widespread distribution, someone needs to package Sommelier or the wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option, which allows disabling KMS hypercalls. If anyone cares enough, it'll probably be possible to build a custom VM variant that uses this display virtualization strategy. [a] https://android-review.googlesource.com/c/platform/development/+/34470 [b] https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22 [c] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927 [d] https://developer.android.com/studio/releases/emulator [e] https://github.com/talex5/wayland-proxy-virtwl Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v1: Incorported various suggestions by Akihiko Odaki and Bernard Berschow - Removed GET_VIRTIO_GPU_GL / GET_RUTABAGA macros - Used error_report(..) - Used g_autofree to fix leaks on error paths - Removed unnecessary casts - added virtio-gpu-pci-rutabaga.c + virtio-vga-rutabaga.c files v2: Incorported various suggestions by Akihiko Odaki, Marc-André Lureau and Bernard Berschow: - Parenthesis in CHECK macro - CHECK_RESULT(result, ..) --> CHECK(!result, ..) - delay until g->parent_obj.enable = 1 - Additional cast fixes - initialize directly in virtio_gpu_rutabaga_realize(..) - add debug callback to hook into QEMU error's APIs v3: Incorporated feedback from Akihiko Odaki and Alyssa Ross: - Autodetect Wayland socket when not explicitly specified - Fix map_blob error paths - Add comment why we need both `res` and `resource` in create blob - Cast and whitespace fixes - Big endian check comes before virtio_gpu_rutabaga_init(). - VirtIOVGARUTABAGA --> VirtIOVGARutabaga v4: Incorpo
[PATCH v10 2/9] virtio-gpu: CONTEXT_INIT feature
From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Reviewed-by: Marc-André Lureau Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } +if (virtio_gpu_context_init_enabled(g->conf)) { +features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); +} return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, +VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ +(_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v10 1/9] virtio: Add shared memory capability
From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Reviewed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Acked-by: Huang Rui Tested-by: Huang Rui Reviewed-by: Akihiko Odaki --- hw/virtio/virtio-pci.c | 18 ++ include/hw/virtio/virtio-pci.h | 4 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ +struct virtio_pci_cap64 cap = { +.cap.cap_len = sizeof cap, +.cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, +}; + +cap.cap.bar = bar; +cap.cap.length = cpu_to_le32(length); +cap.length_hi = cpu_to_le32(length >> 32); +cap.cap.offset = cpu_to_le32(offset); +cap.offset_hi = cpu_to_le32(offset >> 32); +cap.cap.id = id; +return virtio_pci_add_mem_cap(proxy, ); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif -- 2.42.0.rc1.204.g551eb34607-goog
[PATCH v10 7/9] gfxstream + rutabaga: meson support
- Add meson detection of rutabaga_gfx - Build virtio-gpu-rutabaga.c + associated vga/pci files when present Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Reviewed-by: Emmanouil Pitsidianakis --- v3: Fix alignment issues (Akihiko) hw/display/meson.build| 22 ++ meson.build | 7 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 34 insertions(+) diff --git a/hw/display/meson.build b/hw/display/meson.build index 413ba4ab24..e362d625dd 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -79,6 +79,13 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU') if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl]) hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss} endif + + if rutabaga.found() +virtio_gpu_rutabaga_ss = ss.source_set() +virtio_gpu_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', rutabaga], + if_true: [files('virtio-gpu-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-rutabaga': virtio_gpu_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_PCI') @@ -95,6 +102,12 @@ if config_all_devices.has_key('CONFIG_VIRTIO_PCI') if_true: [files('virtio-gpu-pci-gl.c'), pixman]) hw_display_modules += {'virtio-gpu-pci-gl': virtio_gpu_pci_gl_ss} endif + if rutabaga.found() +virtio_gpu_pci_rutabaga_ss = ss.source_set() +virtio_gpu_pci_rutabaga_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI', rutabaga], + if_true: [files('virtio-gpu-pci-rutabaga.c'), pixman]) +hw_display_modules += {'virtio-gpu-pci-rutabaga': virtio_gpu_pci_rutabaga_ss} + endif endif if config_all_devices.has_key('CONFIG_VIRTIO_VGA') @@ -113,6 +126,15 @@ if config_all_devices.has_key('CONFIG_VIRTIO_VGA') virtio_vga_gl_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), if_false: files('acpi-vga-stub.c')) hw_display_modules += {'virtio-vga-gl': virtio_vga_gl_ss} + + if rutabaga.found() +virtio_vga_rutabaga_ss = ss.source_set() +virtio_vga_rutabaga_ss.add(when: ['CONFIG_VIRTIO_VGA', rutabaga], + if_true: [files('virtio-vga-rutabaga.c'), pixman]) +virtio_vga_rutabaga_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-vga.c'), +if_false: files('acpi-vga-stub.c')) +hw_display_modules += {'virtio-vga-rutabaga': virtio_vga_rutabaga_ss} + endif endif system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c')) diff --git a/meson.build b/meson.build index 98e68ef0b1..293f388e53 100644 --- a/meson.build +++ b/meson.build @@ -1069,6 +1069,12 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu dependencies: virgl)) endif endif +rutabaga = not_found +if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu + rutabaga = dependency('rutabaga_gfx_ffi', + method: 'pkg-config', + required: get_option('rutabaga_gfx')) +endif blkio = not_found if not get_option('blkio').auto() or have_block blkio = dependency('blkio', @@ -4272,6 +4278,7 @@ summary_info += {'libtasn1': tasn1} summary_info += {'PAM': pam} summary_info += {'iconv support': iconv} summary_info += {'virgl support': virgl} +summary_info += {'rutabaga support': rutabaga} summary_info += {'blkio support': blkio} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} diff --git a/meson_options.txt b/meson_options.txt index aaea5ddd77..dea3bf7d9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -224,6 +224,8 @@ option('vmnet', type : 'feature', value : 'auto', description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('rutabaga_gfx', type : 'feature', value : 'auto', + description: 'rutabaga_gfx support') option('png', type : 'feature', value : 'auto', description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 9da3fe299b..9a95b4f782 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -154,6 +154,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdmaEnable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rutabaga-gfxrutabaga_gfx support' printf "%s\n" ' sdl