
* Run docker probe only if docker or podman are available The docker probe uses "sudo -n" which can cause an e-mail with a security warning each time when configure is run. Therefore run docker probe only if either docker or podman are available. That avoids the problematic "sudo -n" on build environments which have neither docker nor podman installed. Fixes: c4575b59155e2e00 ("configure: store container engine in config-host.mak") Signed-off-by: Stefan Weil <sw@weilnetz.de> Message-Id: <20221030083510.310584-1-sw@weilnetz.de> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20221117172532.538149-2-alex.bennee@linaro.org> * tests/avocado/machine_aspeed.py: Reduce noise on the console for SDK tests The Aspeed SDK images are based on OpenBMC which starts a lot of services. The output noise on the console can break from time to time the test waiting for the logging prompt. Change the U-Boot bootargs variable to add "quiet" to the kernel command line and reduce the output volume. This also drops the test on the CPU id which was nice to have but not essential. Signed-off-by: Cédric Le Goater <clg@kaod.org> Message-Id: <20221104075347.370503-1-clg@kaod.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20221117172532.538149-3-alex.bennee@linaro.org> * tests/docker: allow user to override check target This is useful when trying to bisect a particular failing test behind a docker run. For example: make docker-test-clang@fedora \ TARGET_LIST=arm-softmmu \ TEST_COMMAND="meson test qtest-arm/qos-test" \ J=9 V=1 Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-4-alex.bennee@linaro.org> * docs/devel: add a maintainers section to development process We don't currently have a clear place in the documentation to describe the roles and responsibilities of a maintainer. Lets create one so we can. I've moved a few small bits out of other files to try and keep everything in one place. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-5-alex.bennee@linaro.org> * docs/devel: make language a little less code centric We welcome all sorts of patches. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-6-alex.bennee@linaro.org> * docs/devel: simplify the minimal checklist The bullet points are quite long and contain process tips. Move those bits of the bullet to the relevant sections and link to them. Use a table for nicer formatting of the checklist. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-7-alex.bennee@linaro.org> * docs/devel: try and improve the language around patch review It is important that contributors take the review process seriously and we collaborate in a respectful way while avoiding personal attacks. Try and make this clear in the language. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-8-alex.bennee@linaro.org> * tests/avocado: Raise timeout for boot_linux.py:BootLinuxPPC64.test_pseries_tcg On my machine, a debug build of QEMU takes about 260 seconds to complete this test, so with the current timeout value of 180 seconds it always times out. Double the timeout value to 360 so the test definitely has enough time to complete. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20221110142901.3832318-1-peter.maydell@linaro.org> Message-Id: <20221117172532.538149-9-alex.bennee@linaro.org> * tests/avocado: introduce alpine virt test for CI The boot_linux tests download and run a full cloud image boot and start a full distro. While the ability to test the full boot chain is worthwhile it is perhaps a little too heavy weight and causes issues in CI. Fix this by introducing a new alpine linux ISO boot in machine_aarch64_virt. This boots a fully loaded -cpu max with all the bells and whistles in 31s on my machine. A full debug build takes around 180s on my machine so we set a more generous timeout to cover that. We don't add a test for lesser GIC versions although there is some coverage for that already in the boot_xen.py tests. If we want to introduce more comprehensive testing we can do it with a custom kernel and initrd rather than a full distro boot. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-10-alex.bennee@linaro.org> * tests/avocado: skip aarch64 cloud TCG tests in CI We now have a much lighter weight test in machine_aarch64_virt which tests the full boot chain in less time. Rename the tests while we are at it to make it clear it is a Fedora cloud image. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221117172532.538149-11-alex.bennee@linaro.org> * gitlab: integrate coverage report This should hopefully give is nice coverage information about what our tests (or at least the subset we are running) have hit. Ideally we would want a way to trigger coverage on tests likely to be affected by the current commit. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221117172532.538149-12-alex.bennee@linaro.org> * vhost: mask VIRTIO_F_RING_RESET for vhost and vhost-user devices Commit 69e1c14aa2 ("virtio: core: vq reset feature negotation support") enabled VIRTIO_F_RING_RESET by default for all virtio devices. This feature is not currently emulated by QEMU, so for vhost and vhost-user devices we need to make sure it is supported by the offloaded device emulation (in-kernel or in another process). To do this we need to add VIRTIO_F_RING_RESET to the features bitmap passed to vhost_get_features(). This way it will be masked if the device does not support it. This issue was initially discovered with vhost-vsock and vhost-user-vsock, and then also tested with vhost-user-rng which confirmed the same issue. They fail when sending features through VHOST_SET_FEATURES ioctl or VHOST_USER_SET_FEATURES message, since VIRTIO_F_RING_RESET is negotiated by the guest (Linux >= v6.0), but not supported by the device. Fixes: 69e1c14aa2 ("virtio: core: vq reset feature negotation support") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1318 Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-Id: <20221121101101.29400-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Acked-by: Jason Wang <jasowang@redhat.com> * tests: acpi: whitelist DSDT before moving PRQx to _SB scope Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20221121153613.3972225-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * acpi: x86: move RPQx field back to _SB scope Commit 47a373faa6b2 (acpi: pc/q35: drop ad-hoc PCI-ISA bridge AML routines and let bus ennumeration generate AML) moved ISA bridge AML generation to respective devices and was using aml_alias() to provide PRQx fields in _SB. scope. However, it turned out that SeaBIOS was not able to process Alias opcode when parsing DSDT, resulting in lack of keyboard during boot (SeaBIOS console, grub, FreeDOS). While fix for SeaBIOS is posted https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/RGPL7HESH5U5JRLEO6FP77CZVHZK5J65/ fixed SeaBIOS might not make into QEMU-7.2 in time. Hence this workaround that puts PRQx back into _SB scope and gets rid of aliases in ISA bridge description, so DSDT will be parsable by broken SeaBIOS. That brings back hardcoded references to ISA bridge PCI0.S08.P40C/PCI0.SF8.PIRQ where middle part now is auto generated based on slot it's plugged in, but it should be fine as bridge initialization also hardcodes PCI address of the bridge so it can't ever move. Once QEMU tree has fixed SeaBIOS blob, we should be able to drop this part and revert back to alias based approach Reported-by: Volker Rümelin <vr_qemu@t-online.de> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20221121153613.3972225-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * tests: acpi: x86: update expected DSDT after moving PRQx fields in _SB scope Expected DSDT changes, pc: - Field (P40C, ByteAcc, NoLock, Preserve) + Scope (\_SB) { - PRQ0, 8, - PRQ1, 8, - PRQ2, 8, - PRQ3, 8 + Field (PCI0.S08.P40C, ByteAcc, NoLock, Preserve) + { + PRQ0, 8, + PRQ1, 8, + PRQ2, 8, + PRQ3, 8 + } } - Alias (PRQ0, \_SB.PRQ0) - Alias (PRQ1, \_SB.PRQ1) - Alias (PRQ2, \_SB.PRQ2) - Alias (PRQ3, \_SB.PRQ3) q35: - Field (PIRQ, ByteAcc, NoLock, Preserve) - { - PRQA, 8, - PRQB, 8, - PRQC, 8, - PRQD, 8, - Offset (0x08), - PRQE, 8, - PRQF, 8, - PRQG, 8, - PRQH, 8 + Scope (\_SB) + { + Field (PCI0.SF8.PIRQ, ByteAcc, NoLock, Preserve) + { + PRQA, 8, + PRQB, 8, + PRQC, 8, + PRQD, 8, + Offset (0x08), + PRQE, 8, + PRQF, 8, + PRQG, 8, + PRQH, 8 + } } - Alias (PRQA, \_SB.PRQA) - Alias (PRQB, \_SB.PRQB) - Alias (PRQC, \_SB.PRQC) - Alias (PRQD, \_SB.PRQD) - Alias (PRQE, \_SB.PRQE) - Alias (PRQF, \_SB.PRQF) - Alias (PRQG, \_SB.PRQG) - Alias (PRQH, \_SB.PRQH) Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20221121153613.3972225-4-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * MAINTAINERS: add mst to list of biosbits maintainers Adding Michael's name to the list of bios bits maintainers so that all changes and fixes into biosbits framework can go through his tree and he is notified. Suggested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Ani Sinha <ani@anisinha.ca> Message-Id: <20221111151138.36988-1-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * tests/avocado: configure acpi-bits to use avocado timeout Instead of using a hardcoded timeout, just rely on Avocado's built-in test case timeout. This helps avoid timeout issues on machines where 60 seconds is not sufficient. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20221115212759.3095751-1-jsnow@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Ani Sinha <ani@anisinha.ca> * acpi/tests/avocado/bits: keep the work directory when BITS_DEBUG is set in env Debugging bits issue often involves running the QEMU command line manually outside of the avocado environment with the generated ISO. Hence, its inconvenient if the iso gets cleaned up after the test has finished. This change makes sure that the work directory is kept after the test finishes if the test is run with BITS_DEBUG=1 in the environment so that the iso is available for use with the QEMU command line. CC: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Ani Sinha <ani@anisinha.ca> Message-Id: <20221117113630.543495-1-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * virtio: disable error for out of spec queue-enable Virtio 1.0 is pretty clear that features have to be negotiated before enabling VQs. Unfortunately Seabios ignored this ever since gaining 1.0 support (UEFI is ok). Comment the error out for now, and add a TODO. Fixes: 3c37f8b8d1 ("virtio: introduce virtio_queue_enable()") Cc: "Kangjie Xu" <kangjie.xu@linux.alibaba.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20221121200339.362452-1-mst@redhat.com> * hw/loongarch: Add default stdout uart in fdt Add "chosen" subnode into LoongArch fdt, and set it's "stdout-path" prop to uart node. Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20221115114923.3372414-1-yangxiaojuan@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> * hw/loongarch: Fix setprop_sized method in fdt rtc node. Fix setprop_sized method in fdt rtc node. Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20221116040300.3459818-1-yangxiaojuan@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> * hw/loongarch: Replace the value of uart info with macro Using macro to replace the value of uart info such as addr, size in acpi_build method. Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20221115115008.3372489-1-yangxiaojuan@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> * target/arm: Don't do two-stage lookup if stage 2 is disabled In get_phys_addr_with_struct(), we call get_phys_addr_twostage() if the CPU supports EL2. However, we don't check here that stage 2 is actually enabled. Instead we only check that inside get_phys_addr_twostage() to skip stage 2 translation. This means that even if stage 2 is disabled we still tell the stage 1 lookup to do its page table walks via stage 2. This works by luck for normal CPU accesses, but it breaks for debug accesses, which are used by the disassembler and also by semihosting file reads and writes, because the debug case takes a different code path inside S1_ptw_translate(). This means that setups that use semihosting for file loads are broken (a regression since 7.1, introduced in recent ptw refactoring), and that sometimes disassembly in debug logs reports "unable to read memory" rather than showing the guest insns. Fix the bug by hoisting the "is stage 2 enabled?" check up to get_phys_addr_with_struct(), so that we handle S2 disabled the same way we do the "no EL2" case, with a simple single stage lookup. Reported-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20221121212404.1450382-1-peter.maydell@linaro.org * target/arm: Use signed quantity to represent VMSAv8-64 translation level The LPA2 extension implements 52-bit virtual addressing for 4k and 16k translation granules, and for the former, this means an additional level of translation is needed. This means we start counting at -1 instead of 0 when doing a walk, and so 'level' is now a signed quantity, and should be typed as such. So turn it from uint32_t into int32_t. This avoids a level of -1 getting misinterpreted as being >= 3, and terminating a page table walk prematurely with a bogus output address. Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> Cc: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> * Update VERSION for v7.2.0-rc2 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> * tests/avocado: Update the URLs of the advent calendar images The qemu-advent-calendar.org server will be decommissioned soon. I've mirrored the images that we use for the QEMU CI to gitlab, so update their URLs to point to the new location. Message-Id: <20221121102436.78635-1-thuth@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> * tests/qtest: Decrease the amount of output from the qom-test The logs in the gitlab-CI have a size constraint, and sometimes we already hit this limit. The biggest part of the log then seems to be filled by the qom-test, so we should decrease the size of the output - which can be done easily by not printing the path for each property, since the path has already been logged at the beginning of each node that we handle here. However, if we omit the path, we should make sure to not recurse into child nodes in between, so that it is clear to which node each property belongs. Thus store the children and links in a temporary list and recurse only at the end of each node, when all properties have already been printed. Message-Id: <20221121194240.149268-1-thuth@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> * tests/avocado: use new rootfs for orangepi test The old URL wasn't stable. I suspect the current URL will only be stable for a few months so maybe we need another strategy for hosting rootfs snapshots? Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20221118113309.1057790-1-alex.bennee@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> * Revert "usbredir: avoid queuing hello packet on snapshot restore" Run state is also in RUN_STATE_PRELAUNCH while "-S" is used. This reverts commit 0631d4b448454ae8a1ab091c447e3f71ab6e088a Signed-off-by: Joelle van Dyne <j@getutm.app> Reviewed-by: Ján Tomko <jtomko@redhat.com> The original commit broke the usage of usbredir with libvirt, which starts every domain with "-S". This workaround is no longer needed because the usbredir behavior has been fixed in the meantime: https://gitlab.freedesktop.org/spice/usbredir/-/merge_requests/61 Signed-off-by: Ján Tomko <jtomko@redhat.com> Message-Id: <1689cec3eadcea87255e390cb236033aca72e168.1669193161.git.jtomko@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * gtk: disable GTK Clipboard with a new meson option The GTK Clipboard implementation may cause guest hangs. Therefore implement new configure switch: --enable-gtk-clipboard, as a meson option disabled by default, which warns in the help text about the experimental nature of the feature. Regenerate the meson build options to include it. The initialization of the clipboard is gtk.c, as well as the compilation of gtk-clipboard.c are now conditional on this new option to be set. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1150 Signed-off-by: Claudio Fontana <cfontana@suse.de> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Message-Id: <20221121135538.14625-1-cfontana@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * hw/usb/hcd-xhci.c: spelling: tranfer Fixes: effaf5a240e03020f4ae953e10b764622c3e87cc Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Message-Id: <20221105114851.306206-1-mjt@msgid.tls.msk.ru> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * ui/gtk: prevent ui lock up when dpy_gl_update called again before current draw event occurs A warning, "qemu: warning: console: no gl-unblock within" followed by guest scanout lockup can happen if dpy_gl_update is called in a row and the second call is made before gd_draw_event scheduled by the first call is taking place. This is because draw call returns without decrementing gl_block ref count if the dmabuf was already submitted as shown below. (gd_gl_area_draw/gd_egl_draw) if (dmabuf) { if (!dmabuf->draw_submitted) { return; } else { dmabuf->draw_submitted = false; } } So it should not schedule any redundant draw event in case draw_submitted is already set in gd_egl_fluch/gd_gl_area_scanout_flush. Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20221021192315.9110-1-dongwon.kim@intel.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * hw/usb/hcd-xhci: Reset the XHCIState with device_cold_reset() Currently the hcd-xhci-pci and hcd-xhci-sysbus devices, which are mostly wrappers around the TYPE_XHCI device, which is a direct subclass of TYPE_DEVICE. Since TYPE_DEVICE devices are not on any qbus and do not get automatically reset, the wrapper devices both reset the TYPE_XHCI device in their own reset functions. However, they do this using device_legacy_reset(), which will reset the device itself but not any bus it has. Switch to device_cold_reset(), which avoids using a deprecated function and also propagates reset along any child buses. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20221014145423.2102706-1-peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * hw/audio/intel-hda: don't reset codecs twice Currently the intel-hda device has a reset method which manually resets all the codecs by calling device_legacy_reset() on them. This means they get reset twice, once because child devices on a qbus get reset before the parent device's reset method is called, and then again because we're manually resetting them. Drop the manual reset call, and ensure that codecs are still reset when the guest does a reset via ICH6_GCTL_RESET by using device_cold_reset() (which resets all the devices on the qbus as well as the device itself) instead of a direct call to the reset function. This is a slight ordering change because the (only) codec reset now happens before the controller registers etc are reset, rather than once before and then once after, but the codec reset function hda_audio_reset() doesn't care. This lets us drop a use of device_legacy_reset(), which is deprecated. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221014142632.2092404-2-peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * hw/audio/intel-hda: Drop unnecessary prototype The only use of intel_hda_reset() is after its definition, so we don't need to separately declare its prototype at the top of the file; drop the unnecessary line. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221014142632.2092404-3-peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * add syx snapshot extras * it compiles! * virtiofsd: Add `sigreturn` to the seccomp whitelist The virtiofsd currently crashes on s390x. This is because of a `sigreturn` system call. See audit log below: type=SECCOMP msg=audit(1669382477.611:459): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 pid=6649 comm="virtiofsd" exe="/usr/libexec/virtiofsd" sig=31 arch=80000016 syscall=119 compat=0 ip=0x3fff15f748a code=0x80000000AUID="unset" UID="root" GID="root" ARCH=s390x SYSCALL=sigreturn Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: German Maglione <gmaglione@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221125143946.27717-1-mhartmay@linux.ibm.com> * libvhost-user: Fix wrong type of argument to formatting function (reported by LGTM) Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Message-Id: <20220422070144.1043697-2-sw@weilnetz.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-2-sw@weilnetz.de> * libvhost-user: Fix format strings Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220422070144.1043697-3-sw@weilnetz.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-3-sw@weilnetz.de> * libvhost-user: Fix two more format strings This fix is required for 32 bit hosts. The bug was detected by CI for arm-linux, but is also relevant for i386-linux. Reported-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-4-sw@weilnetz.de> * libvhost-user: Add format attribute to local function vu_panic Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220422070144.1043697-4-sw@weilnetz.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-5-sw@weilnetz.de> * MAINTAINERS: Add subprojects/libvhost-user to section "vhost" Signed-off-by: Stefan Weil <sw@weilnetz.de> [Michael agreed to act as maintainer for libvhost-user via email in https://lore.kernel.org/qemu-devel/20221123015218-mutt-send-email-mst@kernel.org/. --Stefan] Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-6-sw@weilnetz.de> * Add G_GNUC_PRINTF to function qemu_set_info_str and fix related issues With the G_GNUC_PRINTF function attribute the compiler detects two potential insecure format strings: ../../../net/stream.c:248:31: warning: format string is not a string literal (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ ../../../net/stream.c:322:31: warning: format string is not a string literal (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ There are also two other warnings: ../../../net/socket.c:182:35: warning: zero-length gnu_printf format string [-Wformat-zero-length] 182 | qemu_set_info_str(&s->nc, ""); | ^~ ../../../net/stream.c:170:35: warning: zero-length gnu_printf format string [-Wformat-zero-length] 170 | qemu_set_info_str(&s->nc, ""); Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-7-sw@weilnetz.de> * del ramfile * update seabios source from 1.16.0 to 1.16.1 git shortlog rel-1.16.0..rel-1.16.1 =================================== Gerd Hoffmann (3): malloc: use variable for ZoneHigh size malloc: use large ZoneHigh when there is enough memory virtio-blk: use larger default request size Igor Mammedov (1): acpi: parse Alias object Volker Rümelin (2): pci: refactor the pci_config_*() functions reset: force standard PCI configuration access Xiaofei Lee (1): virtio-blk: Fix incorrect type conversion in virtio_blk_op() Xuan Zhuo (2): virtio-mmio: read/write the hi 32 features for mmio virtio: finalize features before using device Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * update seabios binaries to 1.16.1 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> * fix for non i386 archs * replay: Fix declaration of replay_read_next_clock Fixes the build with gcc 13: replay/replay-time.c:34:6: error: conflicting types for \ 'replay_read_next_clock' due to enum/integer mismatch; \ have 'void(ReplayClockKind)' [-Werror=enum-int-mismatch] 34 | void replay_read_next_clock(ReplayClockKind kind) | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ../qemu/replay/replay-time.c:14: replay/replay-internal.h:139:6: note: previous declaration of \ 'replay_read_next_clock' with type 'void(unsigned int)' 139 | void replay_read_next_clock(unsigned int kind); | ^~~~~~~~~~~~~~~~~~~~~~ Fixes: 8eda206e090 ("replay: recording and replaying clock ticks") Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com> Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221129010547.284051-1-richard.henderson@linaro.org> * hw/display/qxl: Have qxl_log_command Return early if no log_cmd handler Only 3 command types are logged: no need to call qxl_phys2virt() for the other types. Using different cases will help to pass different structure sizes to qxl_phys2virt() in a pair of commits. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221128202741.4945-2-philmd@linaro.org> * hw/display/qxl: Document qxl_phys2virt() Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221128202741.4945-3-philmd@linaro.org> * hw/display/qxl: Pass requested buffer size to qxl_phys2virt() Currently qxl_phys2virt() doesn't check for buffer overrun. In order to do so in the next commit, pass the buffer size as argument. For QXLCursor in qxl_render_cursor() -> qxl_cursor() we verify the size of the chunked data ahead, checking we can access 'sizeof(QXLCursor) + chunk->data_size' bytes. Since in the SPICE_CURSOR_TYPE_MONO case the cursor is assumed to fit in one chunk, no change are required. In SPICE_CURSOR_TYPE_ALPHA the ahead read is handled in qxl_unpack_chunks(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221128202741.4945-4-philmd@linaro.org> * hw/display/qxl: Avoid buffer overrun in qxl_phys2virt (CVE-2022-4144) Have qxl_get_check_slot_offset() return false if the requested buffer size does not fit within the slot memory region. Similarly qxl_phys2virt() now returns NULL in such case, and qxl_dirty_one_surface() aborts. This avoids buffer overrun in the host pointer returned by memory_region_get_ram_ptr(). Fixes: CVE-2022-4144 (out-of-bounds read) Reported-by: Wenxu Yin (@awxylitol) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1336 Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221128202741.4945-5-philmd@linaro.org> * hw/display/qxl: Assert memory slot fits in preallocated MemoryRegion Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221128202741.4945-6-philmd@linaro.org> * block-backend: avoid bdrv_unregister_buf() NULL pointer deref bdrv_*() APIs expect a valid BlockDriverState. Calling them with bs=NULL leads to undefined behavior. Jonathan Cameron reported this following NULL pointer dereference when a VM with a virtio-blk device and a memory-backend-file object is terminated: 1. qemu_cleanup() closes all drives, setting blk->root to NULL 2. qemu_cleanup() calls user_creatable_cleanup(), which results in a RAM block notifier callback because the memory-backend-file is destroyed. 3. blk_unregister_buf() is called by virtio-blk's BlockRamRegistrar notifier callback and undefined behavior occurs. Fixes: baf422684d73 ("virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint") Co-authored-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221121211923.1993171-1-stefanha@redhat.com> * target/arm: Set TCGCPUOps.restore_state_to_opc for v7m This setting got missed, breaking v7m. Fixes: 56c6c98df85c ("target/arm: Convert to tcg_ops restore_state_to_opc") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1347 Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Evgeny Ermakov <evgeny.v.ermakov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221129204146.550394-1-richard.henderson@linaro.org> * Update VERSION for v7.2.0-rc3 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> * hooks are now post mem access * tests/qtests: override "force-legacy" for gpio virtio-mmio tests The GPIO device is a VIRTIO_F_VERSION_1 devices but running with a legacy MMIO interface we miss out that feature bit causing confusion. For the GPIO test force the mmio bus to support non-legacy so we can properly test it. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1333 Message-Id: <20221130112439.2527228-2-alex.bennee@linaro.org> Acked-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * vhost: enable vrings in vhost_dev_start() for vhost-user devices Commit 02b61f38d3 ("hw/virtio: incorporate backend features in features") properly negotiates VHOST_USER_F_PROTOCOL_FEATURES with the vhost-user backend, but we forgot to enable vrings as specified in docs/interop/vhost-user.rst: If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the ring starts directly in the enabled state. If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is initialized in a disabled state and is enabled by ``VHOST_USER_SET_VRING_ENABLE`` with parameter 1. Some vhost-user front-ends already did this by calling vhost_ops.vhost_set_vring_enable() directly: - backends/cryptodev-vhost.c - hw/net/virtio-net.c - hw/virtio/vhost-user-gpio.c But most didn't do that, so we would leave the vrings disabled and some backends would not work. We observed this issue with the rust version of virtiofsd [1], which uses the event loop [2] provided by the vhost-user-backend crate where requests are not processed if vring is not enabled. Let's fix this issue by enabling the vrings in vhost_dev_start() for vhost-user front-ends that don't already do this directly. Same thing also in vhost_dev_stop() where we disable vrings. [1] https://gitlab.com/virtio-fs/virtiofsd [2] https://github.com/rust-vmm/vhost/blob/240fc2966/crates/vhost-user-backend/src/event_loop.rs#L217 Fixes: 02b61f38d3 ("hw/virtio: incorporate backend features in features") Reported-by: German Maglione <gmaglione@redhat.com> Tested-by: German Maglione <gmaglione@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Message-Id: <20221123131630.52020-1-sgarzare@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20221130112439.2527228-3-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * hw/virtio: add started_vu status field to vhost-user-gpio As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine) we really should track the connection and starting separately. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20221130112439.2527228-4-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * hw/virtio: generalise CHR_EVENT_CLOSED handling ..and use for both virtio-user-blk and virtio-user-gpio. This avoids the circular close by deferring shutdown due to disconnection until a later point. virtio-user-blk already had this mechanism in place so generalise it as a vhost-user helper function and use for both blk and gpio devices. While we are at it we also fix up vhost-user-gpio to re-establish the event handler after close down so we can reconnect later. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Message-Id: <20221130112439.2527228-5-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * include/hw: VM state takes precedence in virtio_device_should_start The VM status should always preempt the device status for these checks. This ensures the device is in the correct state when we suspend the VM prior to migrations. This restores the checks to the order they where in before the refactoring moved things around. While we are at it lets improve our documentation of the various fields involved and document the two functions. Fixes: 9f6bcfd99f (hw/virtio: move vm_running check to virtio_device_started) Fixes: 259d69c00b (hw/virtio: introduce virtio_device_should_start) Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Christian Borntraeger <borntraeger@linux.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20221130112439.2527228-6-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> * hw/nvme: fix aio cancel in format There are several bugs in the async cancel code for the Format command. Firstly, cancelling a format operation neglects to set iocb->ret as well as clearing the iocb->aiocb after cancelling the underlying aiocb which causes the aio callback to ignore the cancellation. Trivial fix. Secondly, and worse, because the request is queued up for posting to the CQ in a bottom half, if the cancellation is due to the submission queue being deleted (which calls blk_aio_cancel), the req structure is deallocated in nvme_del_sq prior to the bottom half being schedulued. Fix this by simply removing the bottom half, there is no reason to defer it anyway. Fixes: 3bcf26d3d619 ("hw/nvme: reimplement format nvm to allow cancellation") Reported-by: Jonathan Derrick <jonathan.derrick@linux.dev> Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> * hw/nvme: fix aio cancel in flush Make sure that iocb->aiocb is NULL'ed when cancelling. Fix a potential use-after-free by removing the bottom half and enqueuing the completion directly. Fixes: 38f4ac65ac88 ("hw/nvme: reimplement flush to allow cancellation") Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> * hw/nvme: fix aio cancel in zone reset If the zone reset operation is cancelled but the block unmap operation completes normally, the callback will continue resetting the next zone since it neglects to check iocb->ret which will have been set to -ECANCELED. Make sure that this is checked and bail out if an error is present. Secondly, fix a potential use-after-free by removing the bottom half and enqueuing the completion directly. Fixes: 63d96e4ffd71 ("hw/nvme: reimplement zone reset to allow cancellation") Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> * hw/nvme: fix aio cancel in dsm When the DSM operation is cancelled asynchronously, we set iocb->ret to -ECANCELED. However, the callback function only checks the return value of the completed aio, which may have completed succesfully prior to the cancellation and thus the callback ends up continuing the dsm operation instead of bailing out. Fix this. Secondly, fix a potential use-after-free by removing the bottom half and enqueuing the completion directly. Fixes: d7d1474fd85d ("hw/nvme: reimplement dsm to allow cancellation") Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> * hw/nvme: remove copy bh scheduling Fix a potential use-after-free by removing the bottom half and enqueuing the completion directly. Fixes: 796d20681d9b ("hw/nvme: reimplement the copy command to allow aio cancellation") Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> * target/i386: allow MMX instructions with CR4.OSFXSR=0 MMX state is saved/restored by FSAVE/FRSTOR so the instructions are not illegal opcodes even if CR4.OSFXSR=0. Make sure that validate_vex takes into account the prefix and only checks HF_OSFXSR_MASK in the presence of an SSE instruction. Fixes: 20581aadec5e ("target/i386: validate VEX prefixes via the instructions' exception classes", 2022-10-18) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1350 Reported-by: Helge Konetzka (@hejko on gitlab.com) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> * target/i386: Always completely initialize TranslateFault In get_physical_address, the canonical address check failed to set TranslateFault.stage2, which resulted in an uninitialized read from the struct when reporting the fault in x86_cpu_tlb_fill. Adjust all error paths to use structure assignment so that the entire struct is always initialized. Reported-by: Daniel Hoffman <dhoff749@gmail.com> Fixes: 9bbcf372193a ("target/i386: Reorg GET_HPHYS") Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20221201074522.178498-1-richard.henderson@linaro.org> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1324 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> * hw/loongarch/virt: Add cfi01 pflash device Add cfi01 pflash device for LoongArch virt machine Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221130100647.398565-1-yangxiaojuan@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> * Sync pc on breakpoints * tests/qtest/migration-test: Fix unlink error and memory leaks When running the migration test compiled with Clang from Fedora 37 and sanitizers enabled, there is an error complaining about unlink(): ../tests/qtest/migration-test.c:1072:12: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/unistd.h:858:48: note: nonnull attribute specified here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../tests/qtest/migration-test.c:1072:12 in (test program exited with status code 1) TAP parsing error: Too few tests run (expected 33, got 20) The data->clientcert and data->clientkey pointers can indeed be unset in some tests, so we have to check them before calling unlink() with those. While we're at it, I also noticed that the code is only freeing some but not all of the allocated strings in this function, and indeed, valgrind is also complaining about memory leaks here. So let's call g_free() on all allocated strings to avoid leaking memory here. Message-Id: <20221125083054.117504-1-thuth@redhat.com> Tested-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> * target/s390x/tcg: Fix and improve the SACF instruction The SET ADDRESS SPACE CONTROL FAST instruction is not privileged, it can be used from problem space, too. Just the switching to the home address space is privileged and should still generate a privilege exception. This bug is e.g. causing programs like Java that use the "getcpu" vdso kernel function to crash (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990417#26 ). While we're at it, also check if DAT is not enabled. In that case the instruction is supposed to generate a special operation exception. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/655 Message-Id: <20221201184443.136355-1-thuth@redhat.com> Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> * hw/display/next-fb: Fix comment typo Signed-off-by: Evgeny Ermakov <evgeny.v.ermakov@gmail.com> Message-Id: <20221125160849.23711-1-evgeny.v.ermakov@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> * fix dev snapshots * working syx snaps * Revert "hw/loongarch/virt: Add cfi01 pflash device" This reverts commit 14dccc8ea6ece7ee63273144fb55e4770a05e0fd. Signed-off-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221205113007.683505-1-gaosong@loongson.cn> * Update VERSION for v7.2.0-rc4 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Ani Sinha <ani@anisinha.ca> Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Claudio Fontana <cfontana@suse.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Evgeny Ermakov <evgeny.v.ermakov@gmail.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Cédric Le Goater <clg@kaod.org> Co-authored-by: Alex Bennée <alex.bennee@linaro.org> Co-authored-by: Peter Maydell <peter.maydell@linaro.org> Co-authored-by: Stefano Garzarella <sgarzare@redhat.com> Co-authored-by: Igor Mammedov <imammedo@redhat.com> Co-authored-by: Ani Sinha <ani@anisinha.ca> Co-authored-by: John Snow <jsnow@redhat.com> Co-authored-by: Michael S. Tsirkin <mst@redhat.com> Co-authored-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Co-authored-by: Stefan Hajnoczi <stefanha@redhat.com> Co-authored-by: Ard Biesheuvel <ardb@kernel.org> Co-authored-by: Thomas Huth <thuth@redhat.com> Co-authored-by: Joelle van Dyne <j@getutm.app> Co-authored-by: Claudio Fontana <cfontana@suse.de> Co-authored-by: Michael Tokarev <mjt@tls.msk.ru> Co-authored-by: Dongwon Kim <dongwon.kim@intel.com> Co-authored-by: Marc Hartmayer <mhartmay@linux.ibm.com> Co-authored-by: Stefan Weil via <qemu-devel@nongnu.org> Co-authored-by: Gerd Hoffmann <kraxel@redhat.com> Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Co-authored-by: Philippe Mathieu-Daudé <philmd@linaro.org> Co-authored-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Co-authored-by: Evgeny Ermakov <evgeny.v.ermakov@gmail.com> Co-authored-by: Klaus Jensen <k.jensen@samsung.com> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Song Gao <gaosong@loongson.cn>
2571 lines
84 KiB
C
2571 lines
84 KiB
C
/*
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
*
|
|
* written by Yaniv Kamay, Izik Eidus, Gerd Hoffmann
|
|
* maintained by Gerd Hoffmann <kraxel@redhat.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 or
|
|
* (at your option) version 3 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/units.h"
|
|
#include <zlib.h>
|
|
|
|
#include "qapi/error.h"
|
|
#include "qemu/timer.h"
|
|
#include "qemu/queue.h"
|
|
#include "qemu/atomic.h"
|
|
#include "qemu/main-loop.h"
|
|
#include "qemu/module.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "sysemu/runstate.h"
|
|
#include "migration/vmstate.h"
|
|
#include "trace.h"
|
|
|
|
#include "qxl.h"
|
|
|
|
#undef SPICE_RING_CONS_ITEM
|
|
#define SPICE_RING_CONS_ITEM(qxl, r, ret) { \
|
|
uint32_t cons = (r)->cons & SPICE_RING_INDEX_MASK(r); \
|
|
if (cons >= ARRAY_SIZE((r)->items)) { \
|
|
qxl_set_guest_bug(qxl, "SPICE_RING_CONS_ITEM indices mismatch " \
|
|
"%u >= %zu", cons, ARRAY_SIZE((r)->items)); \
|
|
ret = NULL; \
|
|
} else { \
|
|
ret = &(r)->items[cons].el; \
|
|
} \
|
|
}
|
|
|
|
#undef ALIGN
|
|
#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
|
|
|
|
#define PIXEL_SIZE 0.2936875 //1280x1024 is 14.8" x 11.9"
|
|
|
|
#define QXL_MODE(_x, _y, _b, _o) \
|
|
{ .x_res = _x, \
|
|
.y_res = _y, \
|
|
.bits = _b, \
|
|
.stride = (_x) * (_b) / 8, \
|
|
.x_mili = PIXEL_SIZE * (_x), \
|
|
.y_mili = PIXEL_SIZE * (_y), \
|
|
.orientation = _o, \
|
|
}
|
|
|
|
#define QXL_MODE_16_32(x_res, y_res, orientation) \
|
|
QXL_MODE(x_res, y_res, 16, orientation), \
|
|
QXL_MODE(x_res, y_res, 32, orientation)
|
|
|
|
#define QXL_MODE_EX(x_res, y_res) \
|
|
QXL_MODE_16_32(x_res, y_res, 0), \
|
|
QXL_MODE_16_32(x_res, y_res, 1)
|
|
|
|
static QXLMode qxl_modes[] = {
|
|
QXL_MODE_EX(640, 480),
|
|
QXL_MODE_EX(800, 480),
|
|
QXL_MODE_EX(800, 600),
|
|
QXL_MODE_EX(832, 624),
|
|
QXL_MODE_EX(960, 640),
|
|
QXL_MODE_EX(1024, 600),
|
|
QXL_MODE_EX(1024, 768),
|
|
QXL_MODE_EX(1152, 864),
|
|
QXL_MODE_EX(1152, 870),
|
|
QXL_MODE_EX(1280, 720),
|
|
QXL_MODE_EX(1280, 760),
|
|
QXL_MODE_EX(1280, 768),
|
|
QXL_MODE_EX(1280, 800),
|
|
QXL_MODE_EX(1280, 960),
|
|
QXL_MODE_EX(1280, 1024),
|
|
QXL_MODE_EX(1360, 768),
|
|
QXL_MODE_EX(1366, 768),
|
|
QXL_MODE_EX(1400, 1050),
|
|
QXL_MODE_EX(1440, 900),
|
|
QXL_MODE_EX(1600, 900),
|
|
QXL_MODE_EX(1600, 1200),
|
|
QXL_MODE_EX(1680, 1050),
|
|
QXL_MODE_EX(1920, 1080),
|
|
/* these modes need more than 8 MB video memory */
|
|
QXL_MODE_EX(1920, 1200),
|
|
QXL_MODE_EX(1920, 1440),
|
|
QXL_MODE_EX(2000, 2000),
|
|
QXL_MODE_EX(2048, 1536),
|
|
QXL_MODE_EX(2048, 2048),
|
|
QXL_MODE_EX(2560, 1440),
|
|
QXL_MODE_EX(2560, 1600),
|
|
/* these modes need more than 16 MB video memory */
|
|
QXL_MODE_EX(2560, 2048),
|
|
QXL_MODE_EX(2800, 2100),
|
|
QXL_MODE_EX(3200, 2400),
|
|
/* these modes need more than 32 MB video memory */
|
|
QXL_MODE_EX(3840, 2160), /* 4k mainstream */
|
|
QXL_MODE_EX(4096, 2160), /* 4k */
|
|
/* these modes need more than 64 MB video memory */
|
|
QXL_MODE_EX(7680, 4320), /* 8k mainstream */
|
|
/* these modes need more than 128 MB video memory */
|
|
QXL_MODE_EX(8192, 4320), /* 8k */
|
|
};
|
|
|
|
static void qxl_send_events(PCIQXLDevice *d, uint32_t events);
|
|
static int qxl_destroy_primary(PCIQXLDevice *d, qxl_async_io async);
|
|
static void qxl_reset_memslots(PCIQXLDevice *d);
|
|
static void qxl_reset_surfaces(PCIQXLDevice *d);
|
|
static void qxl_ring_set_dirty(PCIQXLDevice *qxl);
|
|
|
|
static void qxl_hw_update(void *opaque);
|
|
|
|
void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
|
|
{
|
|
trace_qxl_set_guest_bug(qxl->id);
|
|
qxl_send_events(qxl, QXL_INTERRUPT_ERROR);
|
|
qxl->guest_bug = 1;
|
|
if (qxl->guestdebug) {
|
|
va_list ap;
|
|
va_start(ap, msg);
|
|
fprintf(stderr, "qxl-%d: guest bug: ", qxl->id);
|
|
vfprintf(stderr, msg, ap);
|
|
fprintf(stderr, "\n");
|
|
va_end(ap);
|
|
}
|
|
}
|
|
|
|
static void qxl_clear_guest_bug(PCIQXLDevice *qxl)
|
|
{
|
|
qxl->guest_bug = 0;
|
|
}
|
|
|
|
void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
|
|
struct QXLRect *area, struct QXLRect *dirty_rects,
|
|
uint32_t num_dirty_rects,
|
|
uint32_t clear_dirty_region,
|
|
qxl_async_io async, struct QXLCookie *cookie)
|
|
{
|
|
trace_qxl_spice_update_area(qxl->id, surface_id, area->left, area->right,
|
|
area->top, area->bottom);
|
|
trace_qxl_spice_update_area_rest(qxl->id, num_dirty_rects,
|
|
clear_dirty_region);
|
|
if (async == QXL_SYNC) {
|
|
spice_qxl_update_area(&qxl->ssd.qxl, surface_id, area,
|
|
dirty_rects, num_dirty_rects, clear_dirty_region);
|
|
} else {
|
|
assert(cookie != NULL);
|
|
spice_qxl_update_area_async(&qxl->ssd.qxl, surface_id, area,
|
|
clear_dirty_region, (uintptr_t)cookie);
|
|
}
|
|
}
|
|
|
|
static void qxl_spice_destroy_surface_wait_complete(PCIQXLDevice *qxl,
|
|
uint32_t id)
|
|
{
|
|
trace_qxl_spice_destroy_surface_wait_complete(qxl->id, id);
|
|
qemu_mutex_lock(&qxl->track_lock);
|
|
qxl->guest_surfaces.cmds[id] = 0;
|
|
qxl->guest_surfaces.count--;
|
|
qemu_mutex_unlock(&qxl->track_lock);
|
|
}
|
|
|
|
static void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id,
|
|
qxl_async_io async)
|
|
{
|
|
QXLCookie *cookie;
|
|
|
|
trace_qxl_spice_destroy_surface_wait(qxl->id, id, async);
|
|
if (async) {
|
|
cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
QXL_IO_DESTROY_SURFACE_ASYNC);
|
|
cookie->u.surface_id = id;
|
|
spice_qxl_destroy_surface_async(&qxl->ssd.qxl, id, (uintptr_t)cookie);
|
|
} else {
|
|
spice_qxl_destroy_surface_wait(&qxl->ssd.qxl, id);
|
|
qxl_spice_destroy_surface_wait_complete(qxl, id);
|
|
}
|
|
}
|
|
|
|
static void qxl_spice_flush_surfaces_async(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_flush_surfaces_async(qxl->id, qxl->guest_surfaces.count,
|
|
qxl->num_free_res);
|
|
spice_qxl_flush_surfaces_async(&qxl->ssd.qxl,
|
|
(uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
QXL_IO_FLUSH_SURFACES_ASYNC));
|
|
}
|
|
|
|
void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
|
|
uint32_t count)
|
|
{
|
|
trace_qxl_spice_loadvm_commands(qxl->id, ext, count);
|
|
spice_qxl_loadvm_commands(&qxl->ssd.qxl, ext, count);
|
|
}
|
|
|
|
void qxl_spice_oom(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_oom(qxl->id);
|
|
spice_qxl_oom(&qxl->ssd.qxl);
|
|
}
|
|
|
|
void qxl_spice_reset_memslots(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_reset_memslots(qxl->id);
|
|
spice_qxl_reset_memslots(&qxl->ssd.qxl);
|
|
}
|
|
|
|
static void qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_destroy_surfaces_complete(qxl->id);
|
|
qemu_mutex_lock(&qxl->track_lock);
|
|
memset(qxl->guest_surfaces.cmds, 0,
|
|
sizeof(qxl->guest_surfaces.cmds[0]) * qxl->ssd.num_surfaces);
|
|
qxl->guest_surfaces.count = 0;
|
|
qemu_mutex_unlock(&qxl->track_lock);
|
|
}
|
|
|
|
static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl, qxl_async_io async)
|
|
{
|
|
trace_qxl_spice_destroy_surfaces(qxl->id, async);
|
|
if (async) {
|
|
spice_qxl_destroy_surfaces_async(&qxl->ssd.qxl,
|
|
(uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
QXL_IO_DESTROY_ALL_SURFACES_ASYNC));
|
|
} else {
|
|
spice_qxl_destroy_surfaces(&qxl->ssd.qxl);
|
|
qxl_spice_destroy_surfaces_complete(qxl);
|
|
}
|
|
}
|
|
|
|
static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
|
|
{
|
|
QXLMonitorsConfig *cfg;
|
|
|
|
trace_qxl_spice_monitors_config(qxl->id);
|
|
if (replay) {
|
|
/*
|
|
* don't use QXL_COOKIE_TYPE_IO:
|
|
* - we are not running yet (post_load), we will assert
|
|
* in send_events
|
|
* - this is not a guest io, but a reply, so async_io isn't set.
|
|
*/
|
|
spice_qxl_monitors_config_async(&qxl->ssd.qxl,
|
|
qxl->guest_monitors_config,
|
|
MEMSLOT_GROUP_GUEST,
|
|
(uintptr_t)qxl_cookie_new(
|
|
QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
|
|
0));
|
|
} else {
|
|
/* >= release 0.12.6, < release 0.14.2 */
|
|
#if SPICE_SERVER_VERSION >= 0x000c06 && SPICE_SERVER_VERSION < 0x000e02
|
|
if (qxl->max_outputs) {
|
|
spice_qxl_set_max_monitors(&qxl->ssd.qxl, qxl->max_outputs);
|
|
}
|
|
#endif
|
|
qxl->guest_monitors_config = qxl->ram->monitors_config;
|
|
spice_qxl_monitors_config_async(&qxl->ssd.qxl,
|
|
qxl->ram->monitors_config,
|
|
MEMSLOT_GROUP_GUEST,
|
|
(uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
QXL_IO_MONITORS_CONFIG_ASYNC));
|
|
}
|
|
|
|
cfg = qxl_phys2virt(qxl, qxl->guest_monitors_config, MEMSLOT_GROUP_GUEST,
|
|
sizeof(QXLMonitorsConfig));
|
|
if (cfg != NULL && cfg->count == 1) {
|
|
qxl->guest_primary.resized = 1;
|
|
qxl->guest_head0_width = cfg->heads[0].width;
|
|
qxl->guest_head0_height = cfg->heads[0].height;
|
|
} else {
|
|
qxl->guest_head0_width = 0;
|
|
qxl->guest_head0_height = 0;
|
|
}
|
|
}
|
|
|
|
void qxl_spice_reset_image_cache(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_reset_image_cache(qxl->id);
|
|
spice_qxl_reset_image_cache(&qxl->ssd.qxl);
|
|
}
|
|
|
|
void qxl_spice_reset_cursor(PCIQXLDevice *qxl)
|
|
{
|
|
trace_qxl_spice_reset_cursor(qxl->id);
|
|
spice_qxl_reset_cursor(&qxl->ssd.qxl);
|
|
qemu_mutex_lock(&qxl->track_lock);
|
|
qxl->guest_cursor = 0;
|
|
qemu_mutex_unlock(&qxl->track_lock);
|
|
if (qxl->ssd.cursor) {
|
|
cursor_put(qxl->ssd.cursor);
|
|
}
|
|
qxl->ssd.cursor = cursor_builtin_hidden();
|
|
}
|
|
|
|
static uint32_t qxl_crc32(const uint8_t *p, unsigned len)
|
|
{
|
|
/*
|
|
* zlib xors the seed with 0xffffffff, and xors the result
|
|
* again with 0xffffffff; Both are not done with linux's crc32,
|
|
* which we want to be compatible with, so undo that.
|
|
*/
|
|
return crc32(0xffffffff, p, len) ^ 0xffffffff;
|
|
}
|
|
|
|
static ram_addr_t qxl_rom_size(void)
|
|
{
|
|
#define QXL_REQUIRED_SZ (sizeof(QXLRom) + sizeof(QXLModes) + sizeof(qxl_modes))
|
|
#define QXL_ROM_SZ 8192
|
|
|
|
QEMU_BUILD_BUG_ON(QXL_REQUIRED_SZ > QXL_ROM_SZ);
|
|
return QEMU_ALIGN_UP(QXL_REQUIRED_SZ, qemu_real_host_page_size());
|
|
}
|
|
|
|
static void init_qxl_rom(PCIQXLDevice *d)
|
|
{
|
|
QXLRom *rom = memory_region_get_ram_ptr(&d->rom_bar);
|
|
QXLModes *modes = (QXLModes *)(rom + 1);
|
|
uint32_t ram_header_size;
|
|
uint32_t surface0_area_size;
|
|
uint32_t num_pages;
|
|
uint32_t fb;
|
|
int i, n;
|
|
|
|
memset(rom, 0, d->rom_size);
|
|
|
|
rom->magic = cpu_to_le32(QXL_ROM_MAGIC);
|
|
rom->id = cpu_to_le32(d->id);
|
|
rom->log_level = cpu_to_le32(d->guestdebug);
|
|
rom->modes_offset = cpu_to_le32(sizeof(QXLRom));
|
|
|
|
rom->slot_gen_bits = MEMSLOT_GENERATION_BITS;
|
|
rom->slot_id_bits = MEMSLOT_SLOT_BITS;
|
|
rom->slots_start = 1;
|
|
rom->slots_end = NUM_MEMSLOTS - 1;
|
|
rom->n_surfaces = cpu_to_le32(d->ssd.num_surfaces);
|
|
|
|
for (i = 0, n = 0; i < ARRAY_SIZE(qxl_modes); i++) {
|
|
fb = qxl_modes[i].y_res * qxl_modes[i].stride;
|
|
if (fb > d->vgamem_size) {
|
|
continue;
|
|
}
|
|
modes->modes[n].id = cpu_to_le32(i);
|
|
modes->modes[n].x_res = cpu_to_le32(qxl_modes[i].x_res);
|
|
modes->modes[n].y_res = cpu_to_le32(qxl_modes[i].y_res);
|
|
modes->modes[n].bits = cpu_to_le32(qxl_modes[i].bits);
|
|
modes->modes[n].stride = cpu_to_le32(qxl_modes[i].stride);
|
|
modes->modes[n].x_mili = cpu_to_le32(qxl_modes[i].x_mili);
|
|
modes->modes[n].y_mili = cpu_to_le32(qxl_modes[i].y_mili);
|
|
modes->modes[n].orientation = cpu_to_le32(qxl_modes[i].orientation);
|
|
n++;
|
|
}
|
|
modes->n_modes = cpu_to_le32(n);
|
|
|
|
ram_header_size = ALIGN(sizeof(QXLRam), 4096);
|
|
surface0_area_size = ALIGN(d->vgamem_size, 4096);
|
|
num_pages = d->vga.vram_size;
|
|
num_pages -= ram_header_size;
|
|
num_pages -= surface0_area_size;
|
|
num_pages = num_pages / QXL_PAGE_SIZE;
|
|
|
|
assert(ram_header_size + surface0_area_size <= d->vga.vram_size);
|
|
|
|
rom->draw_area_offset = cpu_to_le32(0);
|
|
rom->surface0_area_size = cpu_to_le32(surface0_area_size);
|
|
rom->pages_offset = cpu_to_le32(surface0_area_size);
|
|
rom->num_pages = cpu_to_le32(num_pages);
|
|
rom->ram_header_offset = cpu_to_le32(d->vga.vram_size - ram_header_size);
|
|
|
|
if (d->xres && d->yres) {
|
|
/* needs linux kernel 4.12+ to work */
|
|
rom->client_monitors_config.count = 1;
|
|
rom->client_monitors_config.heads[0].left = 0;
|
|
rom->client_monitors_config.heads[0].top = 0;
|
|
rom->client_monitors_config.heads[0].right = cpu_to_le32(d->xres);
|
|
rom->client_monitors_config.heads[0].bottom = cpu_to_le32(d->yres);
|
|
rom->client_monitors_config_crc = qxl_crc32(
|
|
(const uint8_t *)&rom->client_monitors_config,
|
|
sizeof(rom->client_monitors_config));
|
|
}
|
|
|
|
d->shadow_rom = *rom;
|
|
d->rom = rom;
|
|
d->modes = modes;
|
|
}
|
|
|
|
static void init_qxl_ram(PCIQXLDevice *d)
|
|
{
|
|
uint8_t *buf;
|
|
uint32_t prod;
|
|
QXLReleaseRing *ring;
|
|
|
|
buf = d->vga.vram_ptr;
|
|
d->ram = (QXLRam *)(buf + le32_to_cpu(d->shadow_rom.ram_header_offset));
|
|
d->ram->magic = cpu_to_le32(QXL_RAM_MAGIC);
|
|
d->ram->int_pending = cpu_to_le32(0);
|
|
d->ram->int_mask = cpu_to_le32(0);
|
|
d->ram->update_surface = 0;
|
|
d->ram->monitors_config = 0;
|
|
SPICE_RING_INIT(&d->ram->cmd_ring);
|
|
SPICE_RING_INIT(&d->ram->cursor_ring);
|
|
SPICE_RING_INIT(&d->ram->release_ring);
|
|
|
|
ring = &d->ram->release_ring;
|
|
prod = ring->prod & SPICE_RING_INDEX_MASK(ring);
|
|
assert(prod < ARRAY_SIZE(ring->items));
|
|
ring->items[prod].el = 0;
|
|
|
|
qxl_ring_set_dirty(d);
|
|
}
|
|
|
|
/* can be called from spice server thread context */
|
|
static void qxl_set_dirty(MemoryRegion *mr, ram_addr_t addr, ram_addr_t end)
|
|
{
|
|
memory_region_set_dirty(mr, addr, end - addr);
|
|
}
|
|
|
|
static void qxl_rom_set_dirty(PCIQXLDevice *qxl)
|
|
{
|
|
qxl_set_dirty(&qxl->rom_bar, 0, qxl->rom_size);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static void qxl_ram_set_dirty(PCIQXLDevice *qxl, void *ptr)
|
|
{
|
|
void *base = qxl->vga.vram_ptr;
|
|
intptr_t offset;
|
|
|
|
offset = ptr - base;
|
|
assert(offset < qxl->vga.vram_size);
|
|
qxl_set_dirty(&qxl->vga.vram, offset, offset + 3);
|
|
}
|
|
|
|
/* can be called from spice server thread context */
|
|
static void qxl_ring_set_dirty(PCIQXLDevice *qxl)
|
|
{
|
|
ram_addr_t addr = qxl->shadow_rom.ram_header_offset;
|
|
ram_addr_t end = qxl->vga.vram_size;
|
|
qxl_set_dirty(&qxl->vga.vram, addr, end);
|
|
}
|
|
|
|
/*
|
|
* keep track of some command state, for savevm/loadvm.
|
|
* called from spice server thread context only
|
|
*/
|
|
static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
|
|
{
|
|
switch (le32_to_cpu(ext->cmd.type)) {
|
|
case QXL_CMD_SURFACE:
|
|
{
|
|
QXLSurfaceCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id,
|
|
sizeof(QXLSurfaceCmd));
|
|
|
|
if (!cmd) {
|
|
return 1;
|
|
}
|
|
uint32_t id = le32_to_cpu(cmd->surface_id);
|
|
|
|
if (id >= qxl->ssd.num_surfaces) {
|
|
qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE id %d >= %d", id,
|
|
qxl->ssd.num_surfaces);
|
|
return 1;
|
|
}
|
|
if (cmd->type == QXL_SURFACE_CMD_CREATE &&
|
|
(cmd->u.surface_create.stride & 0x03) != 0) {
|
|
qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE stride = %d %% 4 != 0\n",
|
|
cmd->u.surface_create.stride);
|
|
return 1;
|
|
}
|
|
WITH_QEMU_LOCK_GUARD(&qxl->track_lock) {
|
|
if (cmd->type == QXL_SURFACE_CMD_CREATE) {
|
|
qxl->guest_surfaces.cmds[id] = ext->cmd.data;
|
|
qxl->guest_surfaces.count++;
|
|
if (qxl->guest_surfaces.max < qxl->guest_surfaces.count) {
|
|
qxl->guest_surfaces.max = qxl->guest_surfaces.count;
|
|
}
|
|
}
|
|
if (cmd->type == QXL_SURFACE_CMD_DESTROY) {
|
|
qxl->guest_surfaces.cmds[id] = 0;
|
|
qxl->guest_surfaces.count--;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case QXL_CMD_CURSOR:
|
|
{
|
|
QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id,
|
|
sizeof(QXLCursorCmd));
|
|
|
|
if (!cmd) {
|
|
return 1;
|
|
}
|
|
if (cmd->type == QXL_CURSOR_SET) {
|
|
qemu_mutex_lock(&qxl->track_lock);
|
|
qxl->guest_cursor = ext->cmd.data;
|
|
qemu_mutex_unlock(&qxl->track_lock);
|
|
}
|
|
if (cmd->type == QXL_CURSOR_HIDE) {
|
|
qemu_mutex_lock(&qxl->track_lock);
|
|
qxl->guest_cursor = 0;
|
|
qemu_mutex_unlock(&qxl->track_lock);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* spice display interface callbacks */
|
|
|
|
static void interface_attached_worker(QXLInstance *sin)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
|
|
trace_qxl_interface_attach_worker(qxl->id);
|
|
}
|
|
|
|
#if !(SPICE_HAS_ATTACHED_WORKER)
|
|
static void interface_attach_worker(QXLInstance *sin, QXLWorker *qxl_worker)
|
|
{
|
|
interface_attached_worker(sin);
|
|
}
|
|
#endif
|
|
|
|
static void interface_set_compression_level(QXLInstance *sin, int level)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
|
|
trace_qxl_interface_set_compression_level(qxl->id, level);
|
|
qxl->shadow_rom.compression_level = cpu_to_le32(level);
|
|
qxl->rom->compression_level = cpu_to_le32(level);
|
|
qxl_rom_set_dirty(qxl);
|
|
}
|
|
|
|
#if SPICE_NEEDS_SET_MM_TIME
|
|
static void interface_set_mm_time(QXLInstance *sin, uint32_t mm_time)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
|
|
if (!qemu_spice_display_is_running(&qxl->ssd)) {
|
|
return;
|
|
}
|
|
|
|
trace_qxl_interface_set_mm_time(qxl->id, mm_time);
|
|
qxl->shadow_rom.mm_clock = cpu_to_le32(mm_time);
|
|
qxl->rom->mm_clock = cpu_to_le32(mm_time);
|
|
qxl_rom_set_dirty(qxl);
|
|
}
|
|
#endif
|
|
|
|
static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
|
|
trace_qxl_interface_get_init_info(qxl->id);
|
|
info->memslot_gen_bits = MEMSLOT_GENERATION_BITS;
|
|
info->memslot_id_bits = MEMSLOT_SLOT_BITS;
|
|
info->num_memslots = NUM_MEMSLOTS;
|
|
info->num_memslots_groups = NUM_MEMSLOTS_GROUPS;
|
|
info->internal_groupslot_id = 0;
|
|
info->qxl_ram_size =
|
|
le32_to_cpu(qxl->shadow_rom.num_pages) << QXL_PAGE_BITS;
|
|
info->n_surfaces = qxl->ssd.num_surfaces;
|
|
}
|
|
|
|
static const char *qxl_mode_to_string(int mode)
|
|
{
|
|
switch (mode) {
|
|
case QXL_MODE_COMPAT:
|
|
return "compat";
|
|
case QXL_MODE_NATIVE:
|
|
return "native";
|
|
case QXL_MODE_UNDEFINED:
|
|
return "undefined";
|
|
case QXL_MODE_VGA:
|
|
return "vga";
|
|
}
|
|
return "INVALID";
|
|
}
|
|
|
|
static const char *io_port_to_string(uint32_t io_port)
|
|
{
|
|
if (io_port >= QXL_IO_RANGE_SIZE) {
|
|
return "out of range";
|
|
}
|
|
static const char *io_port_to_string[QXL_IO_RANGE_SIZE + 1] = {
|
|
[QXL_IO_NOTIFY_CMD] = "QXL_IO_NOTIFY_CMD",
|
|
[QXL_IO_NOTIFY_CURSOR] = "QXL_IO_NOTIFY_CURSOR",
|
|
[QXL_IO_UPDATE_AREA] = "QXL_IO_UPDATE_AREA",
|
|
[QXL_IO_UPDATE_IRQ] = "QXL_IO_UPDATE_IRQ",
|
|
[QXL_IO_NOTIFY_OOM] = "QXL_IO_NOTIFY_OOM",
|
|
[QXL_IO_RESET] = "QXL_IO_RESET",
|
|
[QXL_IO_SET_MODE] = "QXL_IO_SET_MODE",
|
|
[QXL_IO_LOG] = "QXL_IO_LOG",
|
|
[QXL_IO_MEMSLOT_ADD] = "QXL_IO_MEMSLOT_ADD",
|
|
[QXL_IO_MEMSLOT_DEL] = "QXL_IO_MEMSLOT_DEL",
|
|
[QXL_IO_DETACH_PRIMARY] = "QXL_IO_DETACH_PRIMARY",
|
|
[QXL_IO_ATTACH_PRIMARY] = "QXL_IO_ATTACH_PRIMARY",
|
|
[QXL_IO_CREATE_PRIMARY] = "QXL_IO_CREATE_PRIMARY",
|
|
[QXL_IO_DESTROY_PRIMARY] = "QXL_IO_DESTROY_PRIMARY",
|
|
[QXL_IO_DESTROY_SURFACE_WAIT] = "QXL_IO_DESTROY_SURFACE_WAIT",
|
|
[QXL_IO_DESTROY_ALL_SURFACES] = "QXL_IO_DESTROY_ALL_SURFACES",
|
|
[QXL_IO_UPDATE_AREA_ASYNC] = "QXL_IO_UPDATE_AREA_ASYNC",
|
|
[QXL_IO_MEMSLOT_ADD_ASYNC] = "QXL_IO_MEMSLOT_ADD_ASYNC",
|
|
[QXL_IO_CREATE_PRIMARY_ASYNC] = "QXL_IO_CREATE_PRIMARY_ASYNC",
|
|
[QXL_IO_DESTROY_PRIMARY_ASYNC] = "QXL_IO_DESTROY_PRIMARY_ASYNC",
|
|
[QXL_IO_DESTROY_SURFACE_ASYNC] = "QXL_IO_DESTROY_SURFACE_ASYNC",
|
|
[QXL_IO_DESTROY_ALL_SURFACES_ASYNC]
|
|
= "QXL_IO_DESTROY_ALL_SURFACES_ASYNC",
|
|
[QXL_IO_FLUSH_SURFACES_ASYNC] = "QXL_IO_FLUSH_SURFACES_ASYNC",
|
|
[QXL_IO_FLUSH_RELEASE] = "QXL_IO_FLUSH_RELEASE",
|
|
[QXL_IO_MONITORS_CONFIG_ASYNC] = "QXL_IO_MONITORS_CONFIG_ASYNC",
|
|
};
|
|
return io_port_to_string[io_port];
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
SimpleSpiceUpdate *update;
|
|
QXLCommandRing *ring;
|
|
QXLCommand *cmd;
|
|
int notify, ret;
|
|
|
|
trace_qxl_ring_command_check(qxl->id, qxl_mode_to_string(qxl->mode));
|
|
|
|
switch (qxl->mode) {
|
|
case QXL_MODE_VGA:
|
|
ret = false;
|
|
qemu_mutex_lock(&qxl->ssd.lock);
|
|
update = QTAILQ_FIRST(&qxl->ssd.updates);
|
|
if (update != NULL) {
|
|
QTAILQ_REMOVE(&qxl->ssd.updates, update, next);
|
|
*ext = update->ext;
|
|
ret = true;
|
|
}
|
|
qemu_mutex_unlock(&qxl->ssd.lock);
|
|
if (ret) {
|
|
trace_qxl_ring_command_get(qxl->id, qxl_mode_to_string(qxl->mode));
|
|
qxl_log_command(qxl, "vga", ext);
|
|
}
|
|
return ret;
|
|
case QXL_MODE_COMPAT:
|
|
case QXL_MODE_NATIVE:
|
|
case QXL_MODE_UNDEFINED:
|
|
ring = &qxl->ram->cmd_ring;
|
|
if (qxl->guest_bug || SPICE_RING_IS_EMPTY(ring)) {
|
|
return false;
|
|
}
|
|
SPICE_RING_CONS_ITEM(qxl, ring, cmd);
|
|
if (!cmd) {
|
|
return false;
|
|
}
|
|
ext->cmd = *cmd;
|
|
ext->group_id = MEMSLOT_GROUP_GUEST;
|
|
ext->flags = qxl->cmdflags;
|
|
SPICE_RING_POP(ring, notify);
|
|
qxl_ring_set_dirty(qxl);
|
|
if (notify) {
|
|
qxl_send_events(qxl, QXL_INTERRUPT_DISPLAY);
|
|
}
|
|
qxl->guest_primary.commands++;
|
|
qxl_track_command(qxl, ext);
|
|
qxl_log_command(qxl, "cmd", ext);
|
|
trace_qxl_ring_command_get(qxl->id, qxl_mode_to_string(qxl->mode));
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static int interface_req_cmd_notification(QXLInstance *sin)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
int wait = 1;
|
|
|
|
trace_qxl_ring_command_req_notification(qxl->id);
|
|
switch (qxl->mode) {
|
|
case QXL_MODE_COMPAT:
|
|
case QXL_MODE_NATIVE:
|
|
case QXL_MODE_UNDEFINED:
|
|
SPICE_RING_CONS_WAIT(&qxl->ram->cmd_ring, wait);
|
|
qxl_ring_set_dirty(qxl);
|
|
break;
|
|
default:
|
|
/* nothing */
|
|
break;
|
|
}
|
|
return wait;
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static inline void qxl_push_free_res(PCIQXLDevice *d, int flush)
|
|
{
|
|
QXLReleaseRing *ring = &d->ram->release_ring;
|
|
uint32_t prod;
|
|
int notify;
|
|
|
|
#define QXL_FREE_BUNCH_SIZE 32
|
|
|
|
if (ring->prod - ring->cons + 1 == ring->num_items) {
|
|
/* ring full -- can't push */
|
|
return;
|
|
}
|
|
if (!flush && d->oom_running) {
|
|
/* collect everything from oom handler before pushing */
|
|
return;
|
|
}
|
|
if (!flush && d->num_free_res < QXL_FREE_BUNCH_SIZE) {
|
|
/* collect a bit more before pushing */
|
|
return;
|
|
}
|
|
|
|
SPICE_RING_PUSH(ring, notify);
|
|
trace_qxl_ring_res_push(d->id, qxl_mode_to_string(d->mode),
|
|
d->guest_surfaces.count, d->num_free_res,
|
|
d->last_release, notify ? "yes" : "no");
|
|
trace_qxl_ring_res_push_rest(d->id, ring->prod - ring->cons,
|
|
ring->num_items, ring->prod, ring->cons);
|
|
if (notify) {
|
|
qxl_send_events(d, QXL_INTERRUPT_DISPLAY);
|
|
}
|
|
|
|
ring = &d->ram->release_ring;
|
|
prod = ring->prod & SPICE_RING_INDEX_MASK(ring);
|
|
if (prod >= ARRAY_SIZE(ring->items)) {
|
|
qxl_set_guest_bug(d, "SPICE_RING_PROD_ITEM indices mismatch "
|
|
"%u >= %zu", prod, ARRAY_SIZE(ring->items));
|
|
return;
|
|
}
|
|
ring->items[prod].el = 0;
|
|
d->num_free_res = 0;
|
|
d->last_release = NULL;
|
|
qxl_ring_set_dirty(d);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static void interface_release_resource(QXLInstance *sin,
|
|
QXLReleaseInfoExt ext)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
QXLReleaseRing *ring;
|
|
uint32_t prod;
|
|
uint64_t id;
|
|
|
|
if (!ext.info) {
|
|
return;
|
|
}
|
|
if (ext.group_id == MEMSLOT_GROUP_HOST) {
|
|
/* host group -> vga mode update request */
|
|
QXLCommandExt *cmdext = (void *)(intptr_t)(ext.info->id);
|
|
SimpleSpiceUpdate *update;
|
|
g_assert(cmdext->cmd.type == QXL_CMD_DRAW);
|
|
update = container_of(cmdext, SimpleSpiceUpdate, ext);
|
|
qemu_spice_destroy_update(&qxl->ssd, update);
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* ext->info points into guest-visible memory
|
|
* pci bar 0, $command.release_info
|
|
*/
|
|
ring = &qxl->ram->release_ring;
|
|
prod = ring->prod & SPICE_RING_INDEX_MASK(ring);
|
|
if (prod >= ARRAY_SIZE(ring->items)) {
|
|
qxl_set_guest_bug(qxl, "SPICE_RING_PROD_ITEM indices mismatch "
|
|
"%u >= %zu", prod, ARRAY_SIZE(ring->items));
|
|
return;
|
|
}
|
|
if (ring->items[prod].el == 0) {
|
|
/* stick head into the ring */
|
|
id = ext.info->id;
|
|
ext.info->next = 0;
|
|
qxl_ram_set_dirty(qxl, &ext.info->next);
|
|
ring->items[prod].el = id;
|
|
qxl_ring_set_dirty(qxl);
|
|
} else {
|
|
/* append item to the list */
|
|
qxl->last_release->next = ext.info->id;
|
|
qxl_ram_set_dirty(qxl, &qxl->last_release->next);
|
|
ext.info->next = 0;
|
|
qxl_ram_set_dirty(qxl, &ext.info->next);
|
|
}
|
|
qxl->last_release = ext.info;
|
|
qxl->num_free_res++;
|
|
trace_qxl_ring_res_put(qxl->id, qxl->num_free_res);
|
|
qxl_push_free_res(qxl, 0);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static int interface_get_cursor_command(QXLInstance *sin, struct QXLCommandExt *ext)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
QXLCursorRing *ring;
|
|
QXLCommand *cmd;
|
|
int notify;
|
|
|
|
trace_qxl_ring_cursor_check(qxl->id, qxl_mode_to_string(qxl->mode));
|
|
|
|
switch (qxl->mode) {
|
|
case QXL_MODE_COMPAT:
|
|
case QXL_MODE_NATIVE:
|
|
case QXL_MODE_UNDEFINED:
|
|
ring = &qxl->ram->cursor_ring;
|
|
if (SPICE_RING_IS_EMPTY(ring)) {
|
|
return false;
|
|
}
|
|
SPICE_RING_CONS_ITEM(qxl, ring, cmd);
|
|
if (!cmd) {
|
|
return false;
|
|
}
|
|
ext->cmd = *cmd;
|
|
ext->group_id = MEMSLOT_GROUP_GUEST;
|
|
ext->flags = qxl->cmdflags;
|
|
SPICE_RING_POP(ring, notify);
|
|
qxl_ring_set_dirty(qxl);
|
|
if (notify) {
|
|
qxl_send_events(qxl, QXL_INTERRUPT_CURSOR);
|
|
}
|
|
qxl->guest_primary.commands++;
|
|
qxl_track_command(qxl, ext);
|
|
qxl_log_command(qxl, "csr", ext);
|
|
if (qxl->have_vga) {
|
|
qxl_render_cursor(qxl, ext);
|
|
}
|
|
trace_qxl_ring_cursor_get(qxl->id, qxl_mode_to_string(qxl->mode));
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static int interface_req_cursor_notification(QXLInstance *sin)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
int wait = 1;
|
|
|
|
trace_qxl_ring_cursor_req_notification(qxl->id);
|
|
switch (qxl->mode) {
|
|
case QXL_MODE_COMPAT:
|
|
case QXL_MODE_NATIVE:
|
|
case QXL_MODE_UNDEFINED:
|
|
SPICE_RING_CONS_WAIT(&qxl->ram->cursor_ring, wait);
|
|
qxl_ring_set_dirty(qxl);
|
|
break;
|
|
default:
|
|
/* nothing */
|
|
break;
|
|
}
|
|
return wait;
|
|
}
|
|
|
|
/* called from spice server thread context */
|
|
static void interface_notify_update(QXLInstance *sin, uint32_t update_id)
|
|
{
|
|
/*
|
|
* Called by spice-server as a result of a QXL_CMD_UPDATE which is not in
|
|
* use by xf86-video-qxl and is defined out in the qxl windows driver.
|
|
* Probably was at some earlier version that is prior to git start (2009),
|
|
* and is still guest trigerrable.
|
|
*/
|
|
fprintf(stderr, "%s: deprecated\n", __func__);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static int interface_flush_resources(QXLInstance *sin)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
int ret;
|
|
|
|
ret = qxl->num_free_res;
|
|
if (ret) {
|
|
qxl_push_free_res(qxl, 1);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void qxl_create_guest_primary_complete(PCIQXLDevice *d);
|
|
|
|
/* called from spice server thread context only */
|
|
static void interface_async_complete_io(PCIQXLDevice *qxl, QXLCookie *cookie)
|
|
{
|
|
uint32_t current_async;
|
|
|
|
qemu_mutex_lock(&qxl->async_lock);
|
|
current_async = qxl->current_async;
|
|
qxl->current_async = QXL_UNDEFINED_IO;
|
|
qemu_mutex_unlock(&qxl->async_lock);
|
|
|
|
trace_qxl_interface_async_complete_io(qxl->id, current_async, cookie);
|
|
if (!cookie) {
|
|
fprintf(stderr, "qxl: %s: error, cookie is NULL\n", __func__);
|
|
return;
|
|
}
|
|
if (cookie && current_async != cookie->io) {
|
|
fprintf(stderr,
|
|
"qxl: %s: error: current_async = %d != %"
|
|
PRId64 " = cookie->io\n", __func__, current_async, cookie->io);
|
|
}
|
|
switch (current_async) {
|
|
case QXL_IO_MEMSLOT_ADD_ASYNC:
|
|
case QXL_IO_DESTROY_PRIMARY_ASYNC:
|
|
case QXL_IO_UPDATE_AREA_ASYNC:
|
|
case QXL_IO_FLUSH_SURFACES_ASYNC:
|
|
case QXL_IO_MONITORS_CONFIG_ASYNC:
|
|
break;
|
|
case QXL_IO_CREATE_PRIMARY_ASYNC:
|
|
qxl_create_guest_primary_complete(qxl);
|
|
break;
|
|
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
|
|
qxl_spice_destroy_surfaces_complete(qxl);
|
|
break;
|
|
case QXL_IO_DESTROY_SURFACE_ASYNC:
|
|
qxl_spice_destroy_surface_wait_complete(qxl, cookie->u.surface_id);
|
|
break;
|
|
default:
|
|
fprintf(stderr, "qxl: %s: unexpected current_async %u\n", __func__,
|
|
current_async);
|
|
}
|
|
qxl_send_events(qxl, QXL_INTERRUPT_IO_CMD);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static void interface_update_area_complete(QXLInstance *sin,
|
|
uint32_t surface_id,
|
|
QXLRect *dirty, uint32_t num_updated_rects)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
int i;
|
|
int qxl_i;
|
|
|
|
QEMU_LOCK_GUARD(&qxl->ssd.lock);
|
|
if (surface_id != 0 || !num_updated_rects ||
|
|
!qxl->render_update_cookie_num) {
|
|
return;
|
|
}
|
|
trace_qxl_interface_update_area_complete(qxl->id, surface_id, dirty->left,
|
|
dirty->right, dirty->top, dirty->bottom);
|
|
trace_qxl_interface_update_area_complete_rest(qxl->id, num_updated_rects);
|
|
if (qxl->num_dirty_rects + num_updated_rects > QXL_NUM_DIRTY_RECTS) {
|
|
/*
|
|
* overflow - treat this as a full update. Not expected to be common.
|
|
*/
|
|
trace_qxl_interface_update_area_complete_overflow(qxl->id,
|
|
QXL_NUM_DIRTY_RECTS);
|
|
qxl->guest_primary.resized = 1;
|
|
}
|
|
if (qxl->guest_primary.resized) {
|
|
/*
|
|
* Don't bother copying or scheduling the bh since we will flip
|
|
* the whole area anyway on completion of the update_area async call
|
|
*/
|
|
return;
|
|
}
|
|
qxl_i = qxl->num_dirty_rects;
|
|
for (i = 0; i < num_updated_rects; i++) {
|
|
qxl->dirty[qxl_i++] = dirty[i];
|
|
}
|
|
qxl->num_dirty_rects += num_updated_rects;
|
|
trace_qxl_interface_update_area_complete_schedule_bh(qxl->id,
|
|
qxl->num_dirty_rects);
|
|
qemu_bh_schedule(qxl->update_area_bh);
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
QXLCookie *cookie = (QXLCookie *)(uintptr_t)cookie_token;
|
|
|
|
switch (cookie->type) {
|
|
case QXL_COOKIE_TYPE_IO:
|
|
interface_async_complete_io(qxl, cookie);
|
|
g_free(cookie);
|
|
break;
|
|
case QXL_COOKIE_TYPE_RENDER_UPDATE_AREA:
|
|
qxl_render_update_area_done(qxl, cookie);
|
|
break;
|
|
case QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG:
|
|
break;
|
|
default:
|
|
fprintf(stderr, "qxl: %s: unexpected cookie type %d\n",
|
|
__func__, cookie->type);
|
|
g_free(cookie);
|
|
}
|
|
}
|
|
|
|
/* called from spice server thread context only */
|
|
static void interface_set_client_capabilities(QXLInstance *sin,
|
|
uint8_t client_present,
|
|
uint8_t caps[58])
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
|
|
if (qxl->revision < 4) {
|
|
trace_qxl_set_client_capabilities_unsupported_by_revision(qxl->id,
|
|
qxl->revision);
|
|
return;
|
|
}
|
|
|
|
if (runstate_check(RUN_STATE_INMIGRATE) ||
|
|
runstate_check(RUN_STATE_POSTMIGRATE)) {
|
|
return;
|
|
}
|
|
|
|
qxl->shadow_rom.client_present = client_present;
|
|
memcpy(qxl->shadow_rom.client_capabilities, caps,
|
|
sizeof(qxl->shadow_rom.client_capabilities));
|
|
qxl->rom->client_present = client_present;
|
|
memcpy(qxl->rom->client_capabilities, caps,
|
|
sizeof(qxl->rom->client_capabilities));
|
|
qxl_rom_set_dirty(qxl);
|
|
|
|
qxl_send_events(qxl, QXL_INTERRUPT_CLIENT);
|
|
}
|
|
|
|
static bool qxl_rom_monitors_config_changed(QXLRom *rom,
|
|
VDAgentMonitorsConfig *monitors_config,
|
|
unsigned int max_outputs)
|
|
{
|
|
int i;
|
|
unsigned int monitors_count;
|
|
|
|
monitors_count = MIN(monitors_config->num_of_monitors, max_outputs);
|
|
|
|
if (rom->client_monitors_config.count != monitors_count) {
|
|
return true;
|
|
}
|
|
|
|
for (i = 0 ; i < rom->client_monitors_config.count ; ++i) {
|
|
VDAgentMonConfig *monitor = &monitors_config->monitors[i];
|
|
QXLURect *rect = &rom->client_monitors_config.heads[i];
|
|
/* monitor->depth ignored */
|
|
if ((rect->left != monitor->x) ||
|
|
(rect->top != monitor->y) ||
|
|
(rect->right != monitor->x + monitor->width) ||
|
|
(rect->bottom != monitor->y + monitor->height)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/* called from main context only */
|
|
static int interface_client_monitors_config(QXLInstance *sin,
|
|
VDAgentMonitorsConfig *monitors_config)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
QXLRom *rom = memory_region_get_ram_ptr(&qxl->rom_bar);
|
|
int i;
|
|
unsigned max_outputs = ARRAY_SIZE(rom->client_monitors_config.heads);
|
|
bool config_changed = false;
|
|
|
|
if (qxl->revision < 4) {
|
|
trace_qxl_client_monitors_config_unsupported_by_device(qxl->id,
|
|
qxl->revision);
|
|
return 0;
|
|
}
|
|
/*
|
|
* Older windows drivers set int_mask to 0 when their ISR is called,
|
|
* then later set it to ~0. So it doesn't relate to the actual interrupts
|
|
* handled. However, they are old, so clearly they don't support this
|
|
* interrupt
|
|
*/
|
|
if (qxl->ram->int_mask == 0 || qxl->ram->int_mask == ~0 ||
|
|
!(qxl->ram->int_mask & QXL_INTERRUPT_CLIENT_MONITORS_CONFIG)) {
|
|
trace_qxl_client_monitors_config_unsupported_by_guest(qxl->id,
|
|
qxl->ram->int_mask,
|
|
monitors_config);
|
|
return 0;
|
|
}
|
|
if (!monitors_config) {
|
|
return 1;
|
|
}
|
|
|
|
#if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
|
|
/* limit number of outputs based on setting limit */
|
|
if (qxl->max_outputs && qxl->max_outputs <= max_outputs) {
|
|
max_outputs = qxl->max_outputs;
|
|
}
|
|
#endif
|
|
|
|
config_changed = qxl_rom_monitors_config_changed(rom,
|
|
monitors_config,
|
|
max_outputs);
|
|
|
|
memset(&rom->client_monitors_config, 0,
|
|
sizeof(rom->client_monitors_config));
|
|
rom->client_monitors_config.count = monitors_config->num_of_monitors;
|
|
/* monitors_config->flags ignored */
|
|
if (rom->client_monitors_config.count >= max_outputs) {
|
|
trace_qxl_client_monitors_config_capped(qxl->id,
|
|
monitors_config->num_of_monitors,
|
|
max_outputs);
|
|
rom->client_monitors_config.count = max_outputs;
|
|
}
|
|
for (i = 0 ; i < rom->client_monitors_config.count ; ++i) {
|
|
VDAgentMonConfig *monitor = &monitors_config->monitors[i];
|
|
QXLURect *rect = &rom->client_monitors_config.heads[i];
|
|
/* monitor->depth ignored */
|
|
rect->left = monitor->x;
|
|
rect->top = monitor->y;
|
|
rect->right = monitor->x + monitor->width;
|
|
rect->bottom = monitor->y + monitor->height;
|
|
}
|
|
rom->client_monitors_config_crc = qxl_crc32(
|
|
(const uint8_t *)&rom->client_monitors_config,
|
|
sizeof(rom->client_monitors_config));
|
|
trace_qxl_client_monitors_config_crc(qxl->id,
|
|
sizeof(rom->client_monitors_config),
|
|
rom->client_monitors_config_crc);
|
|
|
|
trace_qxl_interrupt_client_monitors_config(qxl->id,
|
|
rom->client_monitors_config.count,
|
|
rom->client_monitors_config.heads);
|
|
if (config_changed) {
|
|
qxl_send_events(qxl, QXL_INTERRUPT_CLIENT_MONITORS_CONFIG);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static const QXLInterface qxl_interface = {
|
|
.base.type = SPICE_INTERFACE_QXL,
|
|
.base.description = "qxl gpu",
|
|
.base.major_version = SPICE_INTERFACE_QXL_MAJOR,
|
|
.base.minor_version = SPICE_INTERFACE_QXL_MINOR,
|
|
|
|
#if SPICE_HAS_ATTACHED_WORKER
|
|
.attached_worker = interface_attached_worker,
|
|
#else
|
|
.attache_worker = interface_attach_worker,
|
|
#endif
|
|
|
|
.set_compression_level = interface_set_compression_level,
|
|
#if SPICE_NEEDS_SET_MM_TIME
|
|
.set_mm_time = interface_set_mm_time,
|
|
#endif
|
|
.get_init_info = interface_get_init_info,
|
|
|
|
/* the callbacks below are called from spice server thread context */
|
|
.get_command = interface_get_command,
|
|
.req_cmd_notification = interface_req_cmd_notification,
|
|
.release_resource = interface_release_resource,
|
|
.get_cursor_command = interface_get_cursor_command,
|
|
.req_cursor_notification = interface_req_cursor_notification,
|
|
.notify_update = interface_notify_update,
|
|
.flush_resources = interface_flush_resources,
|
|
.async_complete = interface_async_complete,
|
|
.update_area_complete = interface_update_area_complete,
|
|
.set_client_capabilities = interface_set_client_capabilities,
|
|
.client_monitors_config = interface_client_monitors_config,
|
|
};
|
|
|
|
static const GraphicHwOps qxl_ops = {
|
|
.gfx_update = qxl_hw_update,
|
|
.gfx_update_async = true,
|
|
};
|
|
|
|
static void qxl_enter_vga_mode(PCIQXLDevice *d)
|
|
{
|
|
if (d->mode == QXL_MODE_VGA) {
|
|
return;
|
|
}
|
|
trace_qxl_enter_vga_mode(d->id);
|
|
spice_qxl_driver_unload(&d->ssd.qxl);
|
|
graphic_console_set_hwops(d->ssd.dcl.con, d->vga.hw_ops, &d->vga);
|
|
update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_DEFAULT);
|
|
qemu_spice_create_host_primary(&d->ssd);
|
|
d->mode = QXL_MODE_VGA;
|
|
qemu_spice_display_switch(&d->ssd, d->ssd.ds);
|
|
vga_dirty_log_start(&d->vga);
|
|
graphic_hw_update(d->vga.con);
|
|
}
|
|
|
|
static void qxl_exit_vga_mode(PCIQXLDevice *d)
|
|
{
|
|
if (d->mode != QXL_MODE_VGA) {
|
|
return;
|
|
}
|
|
trace_qxl_exit_vga_mode(d->id);
|
|
graphic_console_set_hwops(d->ssd.dcl.con, &qxl_ops, d);
|
|
update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_IDLE);
|
|
vga_dirty_log_stop(&d->vga);
|
|
qxl_destroy_primary(d, QXL_SYNC);
|
|
}
|
|
|
|
static void qxl_update_irq(PCIQXLDevice *d)
|
|
{
|
|
uint32_t pending = le32_to_cpu(d->ram->int_pending);
|
|
uint32_t mask = le32_to_cpu(d->ram->int_mask);
|
|
int level = !!(pending & mask);
|
|
pci_set_irq(&d->pci, level);
|
|
qxl_ring_set_dirty(d);
|
|
}
|
|
|
|
static void qxl_check_state(PCIQXLDevice *d)
|
|
{
|
|
QXLRam *ram = d->ram;
|
|
int spice_display_running = qemu_spice_display_is_running(&d->ssd);
|
|
|
|
assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cmd_ring));
|
|
assert(!spice_display_running || SPICE_RING_IS_EMPTY(&ram->cursor_ring));
|
|
}
|
|
|
|
static void qxl_reset_state(PCIQXLDevice *d)
|
|
{
|
|
QXLRom *rom = d->rom;
|
|
|
|
qxl_check_state(d);
|
|
d->shadow_rom.update_id = cpu_to_le32(0);
|
|
*rom = d->shadow_rom;
|
|
qxl_rom_set_dirty(d);
|
|
init_qxl_ram(d);
|
|
d->num_free_res = 0;
|
|
d->last_release = NULL;
|
|
memset(&d->ssd.dirty, 0, sizeof(d->ssd.dirty));
|
|
qxl_update_irq(d);
|
|
}
|
|
|
|
static void qxl_soft_reset(PCIQXLDevice *d)
|
|
{
|
|
trace_qxl_soft_reset(d->id);
|
|
qxl_check_state(d);
|
|
qxl_clear_guest_bug(d);
|
|
qemu_mutex_lock(&d->async_lock);
|
|
d->current_async = QXL_UNDEFINED_IO;
|
|
qemu_mutex_unlock(&d->async_lock);
|
|
|
|
if (d->have_vga) {
|
|
qxl_enter_vga_mode(d);
|
|
} else {
|
|
d->mode = QXL_MODE_UNDEFINED;
|
|
}
|
|
}
|
|
|
|
static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)
|
|
{
|
|
bool startstop = qemu_spice_display_is_running(&d->ssd);
|
|
|
|
trace_qxl_hard_reset(d->id, loadvm);
|
|
|
|
if (startstop) {
|
|
qemu_spice_display_stop();
|
|
}
|
|
|
|
qxl_spice_reset_cursor(d);
|
|
qxl_spice_reset_image_cache(d);
|
|
qxl_reset_surfaces(d);
|
|
qxl_reset_memslots(d);
|
|
|
|
/* pre loadvm reset must not touch QXLRam. This lives in
|
|
* device memory, is migrated together with RAM and thus
|
|
* already loaded at this point */
|
|
if (!loadvm) {
|
|
qxl_reset_state(d);
|
|
}
|
|
qemu_spice_create_host_memslot(&d->ssd);
|
|
qxl_soft_reset(d);
|
|
|
|
if (startstop) {
|
|
qemu_spice_display_start();
|
|
}
|
|
}
|
|
|
|
static void qxl_reset_handler(DeviceState *dev)
|
|
{
|
|
PCIQXLDevice *d = PCI_QXL(PCI_DEVICE(dev));
|
|
|
|
qxl_hard_reset(d, 0);
|
|
}
|
|
|
|
static void qxl_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|
|
{
|
|
VGACommonState *vga = opaque;
|
|
PCIQXLDevice *qxl = container_of(vga, PCIQXLDevice, vga);
|
|
|
|
trace_qxl_io_write_vga(qxl->id, qxl_mode_to_string(qxl->mode), addr, val);
|
|
if (qxl->mode != QXL_MODE_VGA &&
|
|
qxl->revision <= QXL_REVISION_STABLE_V12) {
|
|
qxl_destroy_primary(qxl, QXL_SYNC);
|
|
qxl_soft_reset(qxl);
|
|
}
|
|
vga_ioport_write(opaque, addr, val);
|
|
}
|
|
|
|
static const MemoryRegionPortio qxl_vga_portio_list[] = {
|
|
{ 0x04, 2, 1, .read = vga_ioport_read,
|
|
.write = qxl_vga_ioport_write }, /* 3b4 */
|
|
{ 0x0a, 1, 1, .read = vga_ioport_read,
|
|
.write = qxl_vga_ioport_write }, /* 3ba */
|
|
{ 0x10, 16, 1, .read = vga_ioport_read,
|
|
.write = qxl_vga_ioport_write }, /* 3c0 */
|
|
{ 0x24, 2, 1, .read = vga_ioport_read,
|
|
.write = qxl_vga_ioport_write }, /* 3d4 */
|
|
{ 0x2a, 1, 1, .read = vga_ioport_read,
|
|
.write = qxl_vga_ioport_write }, /* 3da */
|
|
PORTIO_END_OF_LIST(),
|
|
};
|
|
|
|
static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,
|
|
qxl_async_io async)
|
|
{
|
|
static const int regions[] = {
|
|
QXL_RAM_RANGE_INDEX,
|
|
QXL_VRAM_RANGE_INDEX,
|
|
QXL_VRAM64_RANGE_INDEX,
|
|
};
|
|
uint64_t guest_start;
|
|
uint64_t guest_end;
|
|
int pci_region;
|
|
pcibus_t pci_start;
|
|
pcibus_t pci_end;
|
|
MemoryRegion *mr;
|
|
intptr_t virt_start;
|
|
QXLDevMemSlot memslot;
|
|
int i;
|
|
|
|
guest_start = le64_to_cpu(d->guest_slots[slot_id].slot.mem_start);
|
|
guest_end = le64_to_cpu(d->guest_slots[slot_id].slot.mem_end);
|
|
|
|
trace_qxl_memslot_add_guest(d->id, slot_id, guest_start, guest_end);
|
|
|
|
if (slot_id >= NUM_MEMSLOTS) {
|
|
qxl_set_guest_bug(d, "%s: slot_id >= NUM_MEMSLOTS %d >= %d", __func__,
|
|
slot_id, NUM_MEMSLOTS);
|
|
return 1;
|
|
}
|
|
if (guest_start > guest_end) {
|
|
qxl_set_guest_bug(d, "%s: guest_start > guest_end 0x%" PRIx64
|
|
" > 0x%" PRIx64, __func__, guest_start, guest_end);
|
|
return 1;
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(regions); i++) {
|
|
pci_region = regions[i];
|
|
pci_start = d->pci.io_regions[pci_region].addr;
|
|
pci_end = pci_start + d->pci.io_regions[pci_region].size;
|
|
/* mapped? */
|
|
if (pci_start == -1) {
|
|
continue;
|
|
}
|
|
/* start address in range ? */
|
|
if (guest_start < pci_start || guest_start > pci_end) {
|
|
continue;
|
|
}
|
|
/* end address in range ? */
|
|
if (guest_end > pci_end) {
|
|
continue;
|
|
}
|
|
/* passed */
|
|
break;
|
|
}
|
|
if (i == ARRAY_SIZE(regions)) {
|
|
qxl_set_guest_bug(d, "%s: finished loop without match", __func__);
|
|
return 1;
|
|
}
|
|
|
|
switch (pci_region) {
|
|
case QXL_RAM_RANGE_INDEX:
|
|
mr = &d->vga.vram;
|
|
break;
|
|
case QXL_VRAM_RANGE_INDEX:
|
|
case 4 /* vram 64bit */:
|
|
mr = &d->vram_bar;
|
|
break;
|
|
default:
|
|
/* should not happen */
|
|
qxl_set_guest_bug(d, "%s: pci_region = %d", __func__, pci_region);
|
|
return 1;
|
|
}
|
|
assert(guest_end - pci_start <= memory_region_size(mr));
|
|
|
|
virt_start = (intptr_t)memory_region_get_ram_ptr(mr);
|
|
memslot.slot_id = slot_id;
|
|
memslot.slot_group_id = MEMSLOT_GROUP_GUEST; /* guest group */
|
|
memslot.virt_start = virt_start + (guest_start - pci_start);
|
|
memslot.virt_end = virt_start + (guest_end - pci_start);
|
|
memslot.addr_delta = memslot.virt_start - delta;
|
|
memslot.generation = d->rom->slot_generation = 0;
|
|
qxl_rom_set_dirty(d);
|
|
|
|
qemu_spice_add_memslot(&d->ssd, &memslot, async);
|
|
d->guest_slots[slot_id].mr = mr;
|
|
d->guest_slots[slot_id].offset = memslot.virt_start - virt_start;
|
|
d->guest_slots[slot_id].size = memslot.virt_end - memslot.virt_start;
|
|
d->guest_slots[slot_id].delta = delta;
|
|
d->guest_slots[slot_id].active = 1;
|
|
return 0;
|
|
}
|
|
|
|
static void qxl_del_memslot(PCIQXLDevice *d, uint32_t slot_id)
|
|
{
|
|
qemu_spice_del_memslot(&d->ssd, MEMSLOT_GROUP_HOST, slot_id);
|
|
d->guest_slots[slot_id].active = 0;
|
|
}
|
|
|
|
static void qxl_reset_memslots(PCIQXLDevice *d)
|
|
{
|
|
qxl_spice_reset_memslots(d);
|
|
memset(&d->guest_slots, 0, sizeof(d->guest_slots));
|
|
}
|
|
|
|
static void qxl_reset_surfaces(PCIQXLDevice *d)
|
|
{
|
|
trace_qxl_reset_surfaces(d->id);
|
|
d->mode = QXL_MODE_UNDEFINED;
|
|
qxl_spice_destroy_surfaces(d, QXL_SYNC);
|
|
}
|
|
|
|
/* can be also called from spice server thread context */
|
|
static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
|
uint32_t *s, uint64_t *o,
|
|
size_t size_requested)
|
|
{
|
|
uint64_t phys = le64_to_cpu(pqxl);
|
|
uint32_t slot = (phys >> (64 - 8)) & 0xff;
|
|
uint64_t offset = phys & 0xffffffffffff;
|
|
uint64_t size_available;
|
|
|
|
if (slot >= NUM_MEMSLOTS) {
|
|
qxl_set_guest_bug(qxl, "slot too large %d >= %d", slot,
|
|
NUM_MEMSLOTS);
|
|
return false;
|
|
}
|
|
if (!qxl->guest_slots[slot].active) {
|
|
qxl_set_guest_bug(qxl, "inactive slot %d\n", slot);
|
|
return false;
|
|
}
|
|
if (offset < qxl->guest_slots[slot].delta) {
|
|
qxl_set_guest_bug(qxl,
|
|
"slot %d offset %"PRIu64" < delta %"PRIu64"\n",
|
|
slot, offset, qxl->guest_slots[slot].delta);
|
|
return false;
|
|
}
|
|
offset -= qxl->guest_slots[slot].delta;
|
|
if (offset > qxl->guest_slots[slot].size) {
|
|
qxl_set_guest_bug(qxl,
|
|
"slot %d offset %"PRIu64" > size %"PRIu64"\n",
|
|
slot, offset, qxl->guest_slots[slot].size);
|
|
return false;
|
|
}
|
|
size_available = memory_region_size(qxl->guest_slots[slot].mr);
|
|
if (qxl->guest_slots[slot].offset + offset >= size_available) {
|
|
qxl_set_guest_bug(qxl,
|
|
"slot %d offset %"PRIu64" > region size %"PRIu64"\n",
|
|
slot, qxl->guest_slots[slot].offset + offset,
|
|
size_available);
|
|
return false;
|
|
}
|
|
size_available -= qxl->guest_slots[slot].offset + offset;
|
|
if (size_requested > size_available) {
|
|
qxl_set_guest_bug(qxl,
|
|
"slot %d offset %"PRIu64" size %zu: "
|
|
"overrun by %"PRIu64" bytes\n",
|
|
slot, offset, size_requested,
|
|
size_requested - size_available);
|
|
return false;
|
|
}
|
|
|
|
*s = slot;
|
|
*o = offset;
|
|
return true;
|
|
}
|
|
|
|
/* can be also called from spice server thread context */
|
|
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id,
|
|
size_t size)
|
|
{
|
|
uint64_t offset;
|
|
uint32_t slot;
|
|
void *ptr;
|
|
|
|
switch (group_id) {
|
|
case MEMSLOT_GROUP_HOST:
|
|
offset = le64_to_cpu(pqxl) & 0xffffffffffff;
|
|
return (void *)(intptr_t)offset;
|
|
case MEMSLOT_GROUP_GUEST:
|
|
if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size)) {
|
|
return NULL;
|
|
}
|
|
ptr = memory_region_get_ram_ptr(qxl->guest_slots[slot].mr);
|
|
ptr += qxl->guest_slots[slot].offset;
|
|
ptr += offset;
|
|
return ptr;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static void qxl_create_guest_primary_complete(PCIQXLDevice *qxl)
|
|
{
|
|
/* for local rendering */
|
|
qxl_render_resize(qxl);
|
|
}
|
|
|
|
static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
|
|
qxl_async_io async)
|
|
{
|
|
QXLDevSurfaceCreate surface;
|
|
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
|
|
uint32_t requested_height = le32_to_cpu(sc->height);
|
|
int requested_stride = le32_to_cpu(sc->stride);
|
|
|
|
if (requested_stride == INT32_MIN ||
|
|
abs(requested_stride) * (uint64_t)requested_height
|
|
> qxl->vgamem_size) {
|
|
qxl_set_guest_bug(qxl, "%s: requested primary larger than framebuffer"
|
|
" stride %d x height %" PRIu32 " > %" PRIu32,
|
|
__func__, requested_stride, requested_height,
|
|
qxl->vgamem_size);
|
|
return;
|
|
}
|
|
|
|
if (qxl->mode == QXL_MODE_NATIVE) {
|
|
qxl_set_guest_bug(qxl, "%s: nop since already in QXL_MODE_NATIVE",
|
|
__func__);
|
|
}
|
|
qxl_exit_vga_mode(qxl);
|
|
|
|
surface.format = le32_to_cpu(sc->format);
|
|
surface.height = le32_to_cpu(sc->height);
|
|
surface.mem = le64_to_cpu(sc->mem);
|
|
surface.position = le32_to_cpu(sc->position);
|
|
surface.stride = le32_to_cpu(sc->stride);
|
|
surface.width = le32_to_cpu(sc->width);
|
|
surface.type = le32_to_cpu(sc->type);
|
|
surface.flags = le32_to_cpu(sc->flags);
|
|
trace_qxl_create_guest_primary(qxl->id, sc->width, sc->height, sc->mem,
|
|
sc->format, sc->position);
|
|
trace_qxl_create_guest_primary_rest(qxl->id, sc->stride, sc->type,
|
|
sc->flags);
|
|
|
|
if ((surface.stride & 0x3) != 0) {
|
|
qxl_set_guest_bug(qxl, "primary surface stride = %d %% 4 != 0",
|
|
surface.stride);
|
|
return;
|
|
}
|
|
|
|
surface.mouse_mode = true;
|
|
surface.group_id = MEMSLOT_GROUP_GUEST;
|
|
if (loadvm) {
|
|
surface.flags |= QXL_SURF_FLAG_KEEP_DATA;
|
|
}
|
|
|
|
qxl->mode = QXL_MODE_NATIVE;
|
|
qxl->cmdflags = 0;
|
|
qemu_spice_create_primary_surface(&qxl->ssd, 0, &surface, async);
|
|
|
|
if (async == QXL_SYNC) {
|
|
qxl_create_guest_primary_complete(qxl);
|
|
}
|
|
}
|
|
|
|
/* return 1 if surface destoy was initiated (in QXL_ASYNC case) or
|
|
* done (in QXL_SYNC case), 0 otherwise. */
|
|
static int qxl_destroy_primary(PCIQXLDevice *d, qxl_async_io async)
|
|
{
|
|
if (d->mode == QXL_MODE_UNDEFINED) {
|
|
return 0;
|
|
}
|
|
trace_qxl_destroy_primary(d->id);
|
|
d->mode = QXL_MODE_UNDEFINED;
|
|
qemu_spice_destroy_primary_surface(&d->ssd, 0, async);
|
|
qxl_spice_reset_cursor(d);
|
|
return 1;
|
|
}
|
|
|
|
static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm)
|
|
{
|
|
pcibus_t start = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
|
|
pcibus_t end = d->pci.io_regions[QXL_RAM_RANGE_INDEX].size + start;
|
|
QXLMode *mode = d->modes->modes + modenr;
|
|
uint64_t devmem = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
|
|
QXLMemSlot slot = {
|
|
.mem_start = start,
|
|
.mem_end = end
|
|
};
|
|
|
|
if (modenr >= d->modes->n_modes) {
|
|
qxl_set_guest_bug(d, "mode number out of range");
|
|
return;
|
|
}
|
|
|
|
QXLSurfaceCreate surface = {
|
|
.width = mode->x_res,
|
|
.height = mode->y_res,
|
|
.stride = -mode->x_res * 4,
|
|
.format = SPICE_SURFACE_FMT_32_xRGB,
|
|
.flags = loadvm ? QXL_SURF_FLAG_KEEP_DATA : 0,
|
|
.mouse_mode = true,
|
|
.mem = devmem + d->shadow_rom.draw_area_offset,
|
|
};
|
|
|
|
trace_qxl_set_mode(d->id, modenr, mode->x_res, mode->y_res, mode->bits,
|
|
devmem);
|
|
if (!loadvm) {
|
|
qxl_hard_reset(d, 0);
|
|
}
|
|
|
|
d->guest_slots[0].slot = slot;
|
|
assert(qxl_add_memslot(d, 0, devmem, QXL_SYNC) == 0);
|
|
|
|
d->guest_primary.surface = surface;
|
|
qxl_create_guest_primary(d, 0, QXL_SYNC);
|
|
|
|
d->mode = QXL_MODE_COMPAT;
|
|
d->cmdflags = QXL_COMMAND_FLAG_COMPAT;
|
|
if (mode->bits == 16) {
|
|
d->cmdflags |= QXL_COMMAND_FLAG_COMPAT_16BPP;
|
|
}
|
|
d->shadow_rom.mode = cpu_to_le32(modenr);
|
|
d->rom->mode = cpu_to_le32(modenr);
|
|
qxl_rom_set_dirty(d);
|
|
}
|
|
|
|
static void ioport_write(void *opaque, hwaddr addr,
|
|
uint64_t val, unsigned size)
|
|
{
|
|
PCIQXLDevice *d = opaque;
|
|
uint32_t io_port = addr;
|
|
qxl_async_io async = QXL_SYNC;
|
|
uint32_t orig_io_port;
|
|
|
|
if (d->guest_bug && io_port != QXL_IO_RESET) {
|
|
return;
|
|
}
|
|
|
|
if (d->revision <= QXL_REVISION_STABLE_V10 &&
|
|
io_port > QXL_IO_FLUSH_RELEASE) {
|
|
qxl_set_guest_bug(d, "unsupported io %d for revision %d\n",
|
|
io_port, d->revision);
|
|
return;
|
|
}
|
|
|
|
switch (io_port) {
|
|
case QXL_IO_RESET:
|
|
case QXL_IO_SET_MODE:
|
|
case QXL_IO_MEMSLOT_ADD:
|
|
case QXL_IO_MEMSLOT_DEL:
|
|
case QXL_IO_CREATE_PRIMARY:
|
|
case QXL_IO_UPDATE_IRQ:
|
|
case QXL_IO_LOG:
|
|
case QXL_IO_MEMSLOT_ADD_ASYNC:
|
|
case QXL_IO_CREATE_PRIMARY_ASYNC:
|
|
break;
|
|
default:
|
|
if (d->mode != QXL_MODE_VGA) {
|
|
break;
|
|
}
|
|
trace_qxl_io_unexpected_vga_mode(d->id,
|
|
addr, val, io_port_to_string(io_port));
|
|
/* be nice to buggy guest drivers */
|
|
if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&
|
|
io_port < QXL_IO_RANGE_SIZE) {
|
|
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
|
|
}
|
|
return;
|
|
}
|
|
|
|
/* we change the io_port to avoid ifdeffery in the main switch */
|
|
orig_io_port = io_port;
|
|
switch (io_port) {
|
|
case QXL_IO_UPDATE_AREA_ASYNC:
|
|
io_port = QXL_IO_UPDATE_AREA;
|
|
goto async_common;
|
|
case QXL_IO_MEMSLOT_ADD_ASYNC:
|
|
io_port = QXL_IO_MEMSLOT_ADD;
|
|
goto async_common;
|
|
case QXL_IO_CREATE_PRIMARY_ASYNC:
|
|
io_port = QXL_IO_CREATE_PRIMARY;
|
|
goto async_common;
|
|
case QXL_IO_DESTROY_PRIMARY_ASYNC:
|
|
io_port = QXL_IO_DESTROY_PRIMARY;
|
|
goto async_common;
|
|
case QXL_IO_DESTROY_SURFACE_ASYNC:
|
|
io_port = QXL_IO_DESTROY_SURFACE_WAIT;
|
|
goto async_common;
|
|
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
|
|
io_port = QXL_IO_DESTROY_ALL_SURFACES;
|
|
goto async_common;
|
|
case QXL_IO_FLUSH_SURFACES_ASYNC:
|
|
case QXL_IO_MONITORS_CONFIG_ASYNC:
|
|
async_common:
|
|
async = QXL_ASYNC;
|
|
WITH_QEMU_LOCK_GUARD(&d->async_lock) {
|
|
if (d->current_async != QXL_UNDEFINED_IO) {
|
|
qxl_set_guest_bug(d, "%d async started before last (%d) complete",
|
|
io_port, d->current_async);
|
|
return;
|
|
}
|
|
d->current_async = orig_io_port;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
trace_qxl_io_write(d->id, qxl_mode_to_string(d->mode),
|
|
addr, io_port_to_string(addr),
|
|
val, size, async);
|
|
|
|
switch (io_port) {
|
|
case QXL_IO_UPDATE_AREA:
|
|
{
|
|
QXLCookie *cookie = NULL;
|
|
QXLRect update = d->ram->update_area;
|
|
|
|
if (d->ram->update_surface > d->ssd.num_surfaces) {
|
|
qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
|
|
d->ram->update_surface);
|
|
break;
|
|
}
|
|
if (update.left >= update.right || update.top >= update.bottom ||
|
|
update.left < 0 || update.top < 0) {
|
|
qxl_set_guest_bug(d,
|
|
"QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
|
|
update.left, update.top, update.right, update.bottom);
|
|
if (update.left == update.right || update.top == update.bottom) {
|
|
/* old drivers may provide empty area, keep going */
|
|
qxl_clear_guest_bug(d);
|
|
goto cancel_async;
|
|
}
|
|
break;
|
|
}
|
|
if (async == QXL_ASYNC) {
|
|
cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
QXL_IO_UPDATE_AREA_ASYNC);
|
|
cookie->u.area = update;
|
|
}
|
|
qxl_spice_update_area(d, d->ram->update_surface,
|
|
cookie ? &cookie->u.area : &update,
|
|
NULL, 0, 0, async, cookie);
|
|
break;
|
|
}
|
|
case QXL_IO_NOTIFY_CMD:
|
|
qemu_spice_wakeup(&d->ssd);
|
|
break;
|
|
case QXL_IO_NOTIFY_CURSOR:
|
|
qemu_spice_wakeup(&d->ssd);
|
|
break;
|
|
case QXL_IO_UPDATE_IRQ:
|
|
qxl_update_irq(d);
|
|
break;
|
|
case QXL_IO_NOTIFY_OOM:
|
|
if (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {
|
|
break;
|
|
}
|
|
d->oom_running = 1;
|
|
qxl_spice_oom(d);
|
|
d->oom_running = 0;
|
|
break;
|
|
case QXL_IO_SET_MODE:
|
|
qxl_set_mode(d, val, 0);
|
|
break;
|
|
case QXL_IO_LOG:
|
|
#ifdef CONFIG_MODULES
|
|
/*
|
|
* FIXME
|
|
* trace_event_get_state_backends() does not work for modules,
|
|
* it leads to "undefined symbol: qemu_qxl_io_log_semaphore"
|
|
*/
|
|
if (true) {
|
|
#else
|
|
if (trace_event_get_state_backends(TRACE_QXL_IO_LOG) || d->guestdebug) {
|
|
#endif
|
|
/* We cannot trust the guest to NUL terminate d->ram->log_buf */
|
|
char *log_buf = g_strndup((const char *)d->ram->log_buf,
|
|
sizeof(d->ram->log_buf));
|
|
trace_qxl_io_log(d->id, log_buf);
|
|
if (d->guestdebug) {
|
|
fprintf(stderr, "qxl/guest-%d: %" PRId64 ": %s", d->id,
|
|
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), log_buf);
|
|
}
|
|
g_free(log_buf);
|
|
}
|
|
break;
|
|
case QXL_IO_RESET:
|
|
qxl_hard_reset(d, 0);
|
|
break;
|
|
case QXL_IO_MEMSLOT_ADD:
|
|
if (val >= NUM_MEMSLOTS) {
|
|
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_ADD: val out of range");
|
|
break;
|
|
}
|
|
if (d->guest_slots[val].active) {
|
|
qxl_set_guest_bug(d,
|
|
"QXL_IO_MEMSLOT_ADD: memory slot already active");
|
|
break;
|
|
}
|
|
d->guest_slots[val].slot = d->ram->mem_slot;
|
|
qxl_add_memslot(d, val, 0, async);
|
|
break;
|
|
case QXL_IO_MEMSLOT_DEL:
|
|
if (val >= NUM_MEMSLOTS) {
|
|
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_DEL: val out of range");
|
|
break;
|
|
}
|
|
qxl_del_memslot(d, val);
|
|
break;
|
|
case QXL_IO_CREATE_PRIMARY:
|
|
if (val != 0) {
|
|
qxl_set_guest_bug(d, "QXL_IO_CREATE_PRIMARY (async=%d): val != 0",
|
|
async);
|
|
goto cancel_async;
|
|
}
|
|
d->guest_primary.surface = d->ram->create_surface;
|
|
qxl_create_guest_primary(d, 0, async);
|
|
break;
|
|
case QXL_IO_DESTROY_PRIMARY:
|
|
if (val != 0) {
|
|
qxl_set_guest_bug(d, "QXL_IO_DESTROY_PRIMARY (async=%d): val != 0",
|
|
async);
|
|
goto cancel_async;
|
|
}
|
|
if (!qxl_destroy_primary(d, async)) {
|
|
trace_qxl_io_destroy_primary_ignored(d->id,
|
|
qxl_mode_to_string(d->mode));
|
|
goto cancel_async;
|
|
}
|
|
break;
|
|
case QXL_IO_DESTROY_SURFACE_WAIT:
|
|
if (val >= d->ssd.num_surfaces) {
|
|
qxl_set_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
|
|
"%" PRIu64 " >= NUM_SURFACES", async, val);
|
|
goto cancel_async;
|
|
}
|
|
qxl_spice_destroy_surface_wait(d, val, async);
|
|
break;
|
|
case QXL_IO_FLUSH_RELEASE: {
|
|
QXLReleaseRing *ring = &d->ram->release_ring;
|
|
if (ring->prod - ring->cons + 1 == ring->num_items) {
|
|
fprintf(stderr,
|
|
"ERROR: no flush, full release ring [p%d,%dc]\n",
|
|
ring->prod, ring->cons);
|
|
}
|
|
qxl_push_free_res(d, 1 /* flush */);
|
|
break;
|
|
}
|
|
case QXL_IO_FLUSH_SURFACES_ASYNC:
|
|
qxl_spice_flush_surfaces_async(d);
|
|
break;
|
|
case QXL_IO_DESTROY_ALL_SURFACES:
|
|
d->mode = QXL_MODE_UNDEFINED;
|
|
qxl_spice_destroy_surfaces(d, async);
|
|
break;
|
|
case QXL_IO_MONITORS_CONFIG_ASYNC:
|
|
qxl_spice_monitors_config_async(d, 0);
|
|
break;
|
|
default:
|
|
qxl_set_guest_bug(d, "%s: unexpected ioport=0x%x\n", __func__, io_port);
|
|
}
|
|
return;
|
|
cancel_async:
|
|
if (async) {
|
|
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
|
|
qemu_mutex_lock(&d->async_lock);
|
|
d->current_async = QXL_UNDEFINED_IO;
|
|
qemu_mutex_unlock(&d->async_lock);
|
|
}
|
|
}
|
|
|
|
static uint64_t ioport_read(void *opaque, hwaddr addr,
|
|
unsigned size)
|
|
{
|
|
PCIQXLDevice *qxl = opaque;
|
|
|
|
trace_qxl_io_read_unexpected(qxl->id);
|
|
return 0xff;
|
|
}
|
|
|
|
static const MemoryRegionOps qxl_io_ops = {
|
|
.read = ioport_read,
|
|
.write = ioport_write,
|
|
.valid = {
|
|
.min_access_size = 1,
|
|
.max_access_size = 1,
|
|
},
|
|
};
|
|
|
|
static void qxl_update_irq_bh(void *opaque)
|
|
{
|
|
PCIQXLDevice *d = opaque;
|
|
qxl_update_irq(d);
|
|
}
|
|
|
|
static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
|
|
{
|
|
uint32_t old_pending;
|
|
uint32_t le_events = cpu_to_le32(events);
|
|
|
|
trace_qxl_send_events(d->id, events);
|
|
if (!qemu_spice_display_is_running(&d->ssd)) {
|
|
/* spice-server tracks guest running state and should not do this */
|
|
fprintf(stderr, "%s: spice-server bug: guest stopped, ignoring\n",
|
|
__func__);
|
|
trace_qxl_send_events_vm_stopped(d->id, events);
|
|
return;
|
|
}
|
|
/*
|
|
* Older versions of Spice forgot to define the QXLRam struct
|
|
* with the '__aligned__(4)' attribute. clang 7 and newer will
|
|
* thus warn that qatomic_fetch_or(&d->ram->int_pending, ...)
|
|
* might be a misaligned atomic access, and will generate an
|
|
* out-of-line call for it, which results in a link error since
|
|
* we don't currently link against libatomic.
|
|
*
|
|
* In fact we set up d->ram in init_qxl_ram() so it always starts
|
|
* at a 4K boundary, so we know that &d->ram->int_pending is
|
|
* naturally aligned for a uint32_t. Newer Spice versions
|
|
* (with Spice commit beda5ec7a6848be20c0cac2a9a8ef2a41e8069c1)
|
|
* will fix the bug directly. To deal with older versions,
|
|
* we tell the compiler to assume the address really is aligned.
|
|
* Any compiler which cares about the misalignment will have
|
|
* __builtin_assume_aligned.
|
|
*/
|
|
#ifdef HAS_ASSUME_ALIGNED
|
|
#define ALIGNED_UINT32_PTR(P) ((uint32_t *)__builtin_assume_aligned(P, 4))
|
|
#else
|
|
#define ALIGNED_UINT32_PTR(P) ((uint32_t *)P)
|
|
#endif
|
|
|
|
old_pending = qatomic_fetch_or(ALIGNED_UINT32_PTR(&d->ram->int_pending),
|
|
le_events);
|
|
if ((old_pending & le_events) == le_events) {
|
|
return;
|
|
}
|
|
qemu_bh_schedule(d->update_irq);
|
|
}
|
|
|
|
/* graphics console */
|
|
|
|
static void qxl_hw_update(void *opaque)
|
|
{
|
|
PCIQXLDevice *qxl = opaque;
|
|
|
|
qxl_render_update(qxl);
|
|
}
|
|
|
|
static void qxl_dirty_one_surface(PCIQXLDevice *qxl, QXLPHYSICAL pqxl,
|
|
uint32_t height, int32_t stride)
|
|
{
|
|
uint64_t offset, size;
|
|
uint32_t slot;
|
|
bool rc;
|
|
|
|
size = (uint64_t)height * abs(stride);
|
|
rc = qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size);
|
|
assert(rc == true);
|
|
trace_qxl_surfaces_dirty(qxl->id, offset, size);
|
|
qxl_set_dirty(qxl->guest_slots[slot].mr,
|
|
qxl->guest_slots[slot].offset + offset,
|
|
qxl->guest_slots[slot].offset + offset + size);
|
|
}
|
|
|
|
static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
|
|
{
|
|
int i;
|
|
|
|
if (qxl->mode != QXL_MODE_NATIVE && qxl->mode != QXL_MODE_COMPAT) {
|
|
return;
|
|
}
|
|
|
|
/* dirty the primary surface */
|
|
qxl_dirty_one_surface(qxl, qxl->guest_primary.surface.mem,
|
|
qxl->guest_primary.surface.height,
|
|
qxl->guest_primary.surface.stride);
|
|
|
|
/* dirty the off-screen surfaces */
|
|
for (i = 0; i < qxl->ssd.num_surfaces; i++) {
|
|
QXLSurfaceCmd *cmd;
|
|
|
|
if (qxl->guest_surfaces.cmds[i] == 0) {
|
|
continue;
|
|
}
|
|
|
|
cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],
|
|
MEMSLOT_GROUP_GUEST, sizeof(QXLSurfaceCmd));
|
|
assert(cmd);
|
|
assert(cmd->type == QXL_SURFACE_CMD_CREATE);
|
|
qxl_dirty_one_surface(qxl, cmd->u.surface_create.data,
|
|
cmd->u.surface_create.height,
|
|
cmd->u.surface_create.stride);
|
|
}
|
|
}
|
|
|
|
static void qxl_vm_change_state_handler(void *opaque, bool running,
|
|
RunState state)
|
|
{
|
|
PCIQXLDevice *qxl = opaque;
|
|
|
|
if (running) {
|
|
/*
|
|
* if qxl_send_events was called from spice server context before
|
|
* migration ended, qxl_update_irq for these events might not have been
|
|
* called
|
|
*/
|
|
qxl_update_irq(qxl);
|
|
} else {
|
|
/* make sure surfaces are saved before migration */
|
|
qxl_dirty_surfaces(qxl);
|
|
}
|
|
}
|
|
|
|
/* display change listener */
|
|
|
|
static void display_update(DisplayChangeListener *dcl,
|
|
int x, int y, int w, int h)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
|
|
|
|
if (qxl->mode == QXL_MODE_VGA) {
|
|
qemu_spice_display_update(&qxl->ssd, x, y, w, h);
|
|
}
|
|
}
|
|
|
|
static void display_switch(DisplayChangeListener *dcl,
|
|
struct DisplaySurface *surface)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
|
|
|
|
qxl->ssd.ds = surface;
|
|
if (qxl->mode == QXL_MODE_VGA) {
|
|
qemu_spice_display_switch(&qxl->ssd, surface);
|
|
}
|
|
}
|
|
|
|
static void display_refresh(DisplayChangeListener *dcl)
|
|
{
|
|
PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
|
|
|
|
if (qxl->mode == QXL_MODE_VGA) {
|
|
qemu_spice_display_refresh(&qxl->ssd);
|
|
}
|
|
}
|
|
|
|
static DisplayChangeListenerOps display_listener_ops = {
|
|
.dpy_name = "spice/qxl",
|
|
.dpy_gfx_update = display_update,
|
|
.dpy_gfx_switch = display_switch,
|
|
.dpy_refresh = display_refresh,
|
|
};
|
|
|
|
static void qxl_init_ramsize(PCIQXLDevice *qxl)
|
|
{
|
|
/* vga mode framebuffer / primary surface (bar 0, first part) */
|
|
if (qxl->vgamem_size_mb < 8) {
|
|
qxl->vgamem_size_mb = 8;
|
|
}
|
|
/* XXX: we round vgamem_size_mb up to a nearest power of two and it must be
|
|
* less than vga_common_init()'s maximum on qxl->vga.vram_size (512 now).
|
|
*/
|
|
if (qxl->vgamem_size_mb > 256) {
|
|
qxl->vgamem_size_mb = 256;
|
|
}
|
|
qxl->vgamem_size = qxl->vgamem_size_mb * MiB;
|
|
|
|
/* vga ram (bar 0, total) */
|
|
if (qxl->ram_size_mb != -1) {
|
|
qxl->vga.vram_size = qxl->ram_size_mb * MiB;
|
|
}
|
|
if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
|
|
qxl->vga.vram_size = qxl->vgamem_size * 2;
|
|
}
|
|
|
|
/* vram32 (surfaces, 32bit, bar 1) */
|
|
if (qxl->vram32_size_mb != -1) {
|
|
qxl->vram32_size = qxl->vram32_size_mb * MiB;
|
|
}
|
|
if (qxl->vram32_size < 4096) {
|
|
qxl->vram32_size = 4096;
|
|
}
|
|
|
|
/* vram (surfaces, 64bit, bar 4+5) */
|
|
if (qxl->vram_size_mb != -1) {
|
|
qxl->vram_size = (uint64_t)qxl->vram_size_mb * MiB;
|
|
}
|
|
if (qxl->vram_size < qxl->vram32_size) {
|
|
qxl->vram_size = qxl->vram32_size;
|
|
}
|
|
|
|
if (qxl->revision == 1) {
|
|
qxl->vram32_size = 4096;
|
|
qxl->vram_size = 4096;
|
|
}
|
|
qxl->vgamem_size = pow2ceil(qxl->vgamem_size);
|
|
qxl->vga.vram_size = pow2ceil(qxl->vga.vram_size);
|
|
qxl->vram32_size = pow2ceil(qxl->vram32_size);
|
|
qxl->vram_size = pow2ceil(qxl->vram_size);
|
|
}
|
|
|
|
static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
|
|
{
|
|
uint8_t* config = qxl->pci.config;
|
|
uint32_t pci_device_rev;
|
|
uint32_t io_size;
|
|
|
|
qemu_spice_display_init_common(&qxl->ssd);
|
|
qxl->mode = QXL_MODE_UNDEFINED;
|
|
qxl->num_memslots = NUM_MEMSLOTS;
|
|
qemu_mutex_init(&qxl->track_lock);
|
|
qemu_mutex_init(&qxl->async_lock);
|
|
qxl->current_async = QXL_UNDEFINED_IO;
|
|
qxl->guest_bug = 0;
|
|
|
|
switch (qxl->revision) {
|
|
case 1: /* spice 0.4 -- qxl-1 */
|
|
pci_device_rev = QXL_REVISION_STABLE_V04;
|
|
io_size = 8;
|
|
break;
|
|
case 2: /* spice 0.6 -- qxl-2 */
|
|
pci_device_rev = QXL_REVISION_STABLE_V06;
|
|
io_size = 16;
|
|
break;
|
|
case 3: /* qxl-3 */
|
|
pci_device_rev = QXL_REVISION_STABLE_V10;
|
|
io_size = 32; /* PCI region size must be pow2 */
|
|
break;
|
|
case 4: /* qxl-4 */
|
|
pci_device_rev = QXL_REVISION_STABLE_V12;
|
|
io_size = pow2ceil(QXL_IO_RANGE_SIZE);
|
|
break;
|
|
case 5: /* qxl-5 */
|
|
pci_device_rev = QXL_REVISION_STABLE_V12 + 1;
|
|
io_size = pow2ceil(QXL_IO_RANGE_SIZE);
|
|
break;
|
|
default:
|
|
error_setg(errp, "Invalid revision %d for qxl device (max %d)",
|
|
qxl->revision, QXL_DEFAULT_REVISION);
|
|
return;
|
|
}
|
|
|
|
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
|
|
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
|
|
|
|
qxl->rom_size = qxl_rom_size();
|
|
memory_region_init_rom(&qxl->rom_bar, OBJECT(qxl), "qxl.vrom",
|
|
qxl->rom_size, &error_fatal);
|
|
init_qxl_rom(qxl);
|
|
init_qxl_ram(qxl);
|
|
|
|
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
|
|
memory_region_init_ram(&qxl->vram_bar, OBJECT(qxl), "qxl.vram",
|
|
qxl->vram_size, &error_fatal);
|
|
memory_region_init_alias(&qxl->vram32_bar, OBJECT(qxl), "qxl.vram32",
|
|
&qxl->vram_bar, 0, qxl->vram32_size);
|
|
|
|
memory_region_init_io(&qxl->io_bar, OBJECT(qxl), &qxl_io_ops, qxl,
|
|
"qxl-ioports", io_size);
|
|
if (qxl->have_vga) {
|
|
vga_dirty_log_start(&qxl->vga);
|
|
}
|
|
memory_region_set_flush_coalesced(&qxl->io_bar);
|
|
|
|
|
|
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
|
|
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
|
|
|
|
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
|
|
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
|
|
|
|
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
|
|
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
|
|
|
|
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
|
|
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
|
|
|
|
if (qxl->vram32_size < qxl->vram_size) {
|
|
/*
|
|
* Make the 64bit vram bar show up only in case it is
|
|
* configured to be larger than the 32bit vram bar.
|
|
*/
|
|
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
|
|
PCI_BASE_ADDRESS_SPACE_MEMORY |
|
|
PCI_BASE_ADDRESS_MEM_TYPE_64 |
|
|
PCI_BASE_ADDRESS_MEM_PREFETCH,
|
|
&qxl->vram_bar);
|
|
}
|
|
|
|
/* print pci bar details */
|
|
dprint(qxl, 1, "ram/%s: %" PRId64 " MB [region 0]\n",
|
|
qxl->have_vga ? "pri" : "sec", qxl->vga.vram_size / MiB);
|
|
dprint(qxl, 1, "vram/32: %" PRIx64 " MB [region 1]\n",
|
|
qxl->vram32_size / MiB);
|
|
dprint(qxl, 1, "vram/64: %" PRIx64 " MB %s\n",
|
|
qxl->vram_size / MiB,
|
|
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
|
|
|
|
qxl->ssd.qxl.base.sif = &qxl_interface.base;
|
|
if (qemu_spice_add_display_interface(&qxl->ssd.qxl, qxl->vga.con) != 0) {
|
|
error_setg(errp, "qxl interface %d.%d not supported by spice-server",
|
|
SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);
|
|
return;
|
|
}
|
|
|
|
#if SPICE_SERVER_VERSION >= 0x000e02 /* release 0.14.2 */
|
|
Error *err = NULL;
|
|
char device_address[256] = "";
|
|
if (qemu_console_fill_device_address(qxl->vga.con,
|
|
device_address, sizeof(device_address),
|
|
&err)) {
|
|
spice_qxl_set_device_info(&qxl->ssd.qxl,
|
|
device_address,
|
|
0,
|
|
qxl->max_outputs);
|
|
} else {
|
|
error_report_err(err);
|
|
}
|
|
#endif
|
|
|
|
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
|
|
|
|
qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
|
|
qxl_reset_state(qxl);
|
|
|
|
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
|
|
qxl->ssd.cursor_bh = qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl->ssd);
|
|
}
|
|
|
|
static void qxl_realize_primary(PCIDevice *dev, Error **errp)
|
|
{
|
|
PCIQXLDevice *qxl = PCI_QXL(dev);
|
|
VGACommonState *vga = &qxl->vga;
|
|
Error *local_err = NULL;
|
|
|
|
qxl_init_ramsize(qxl);
|
|
vga->vbe_size = qxl->vgamem_size;
|
|
vga->vram_size_mb = qxl->vga.vram_size / MiB;
|
|
vga_common_init(vga, OBJECT(dev), &local_err);
|
|
if (local_err) {
|
|
error_propagate(errp, local_err);
|
|
return;
|
|
}
|
|
vga_init(vga, OBJECT(dev),
|
|
pci_address_space(dev), pci_address_space_io(dev), false);
|
|
portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list,
|
|
vga, "vga");
|
|
portio_list_set_flush_coalesced(&qxl->vga_port_list);
|
|
portio_list_add(&qxl->vga_port_list, pci_address_space_io(dev), 0x3b0);
|
|
qxl->have_vga = true;
|
|
|
|
vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
|
|
qxl->id = qemu_console_get_index(vga->con); /* == channel_id */
|
|
if (qxl->id != 0) {
|
|
error_setg(errp, "primary qxl-vga device must be console 0 "
|
|
"(first display device on the command line)");
|
|
return;
|
|
}
|
|
|
|
qxl_realize_common(qxl, &local_err);
|
|
if (local_err) {
|
|
error_propagate(errp, local_err);
|
|
return;
|
|
}
|
|
|
|
qxl->ssd.dcl.ops = &display_listener_ops;
|
|
qxl->ssd.dcl.con = vga->con;
|
|
register_displaychangelistener(&qxl->ssd.dcl);
|
|
}
|
|
|
|
static void qxl_realize_secondary(PCIDevice *dev, Error **errp)
|
|
{
|
|
PCIQXLDevice *qxl = PCI_QXL(dev);
|
|
|
|
qxl_init_ramsize(qxl);
|
|
memory_region_init_ram(&qxl->vga.vram, OBJECT(dev), "qxl.vgavram",
|
|
qxl->vga.vram_size, &error_fatal);
|
|
qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram);
|
|
qxl->vga.con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl);
|
|
qxl->ssd.dcl.con = qxl->vga.con;
|
|
qxl->id = qemu_console_get_index(qxl->vga.con); /* == channel_id */
|
|
|
|
qxl_realize_common(qxl, errp);
|
|
}
|
|
|
|
static int qxl_pre_save(void *opaque)
|
|
{
|
|
PCIQXLDevice* d = opaque;
|
|
uint8_t *ram_start = d->vga.vram_ptr;
|
|
|
|
trace_qxl_pre_save(d->id);
|
|
if (d->last_release == NULL) {
|
|
d->last_release_offset = 0;
|
|
} else {
|
|
d->last_release_offset = (uint8_t *)d->last_release - ram_start;
|
|
}
|
|
if (d->last_release_offset >= d->vga.vram_size) {
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int qxl_pre_load(void *opaque)
|
|
{
|
|
PCIQXLDevice* d = opaque;
|
|
|
|
trace_qxl_pre_load(d->id);
|
|
qxl_hard_reset(d, 1);
|
|
qxl_exit_vga_mode(d);
|
|
return 0;
|
|
}
|
|
|
|
static void qxl_create_memslots(PCIQXLDevice *d)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < NUM_MEMSLOTS; i++) {
|
|
if (!d->guest_slots[i].active) {
|
|
continue;
|
|
}
|
|
qxl_add_memslot(d, i, 0, QXL_SYNC);
|
|
}
|
|
}
|
|
|
|
static int qxl_post_load(void *opaque, int version)
|
|
{
|
|
PCIQXLDevice* d = opaque;
|
|
uint8_t *ram_start = d->vga.vram_ptr;
|
|
QXLCommandExt *cmds;
|
|
int in, out, newmode;
|
|
|
|
assert(d->last_release_offset < d->vga.vram_size);
|
|
if (d->last_release_offset == 0) {
|
|
d->last_release = NULL;
|
|
} else {
|
|
d->last_release = (QXLReleaseInfo *)(ram_start + d->last_release_offset);
|
|
}
|
|
|
|
d->modes = (QXLModes*)((uint8_t*)d->rom + d->rom->modes_offset);
|
|
|
|
trace_qxl_post_load(d->id, qxl_mode_to_string(d->mode));
|
|
newmode = d->mode;
|
|
d->mode = QXL_MODE_UNDEFINED;
|
|
|
|
switch (newmode) {
|
|
case QXL_MODE_UNDEFINED:
|
|
qxl_create_memslots(d);
|
|
break;
|
|
case QXL_MODE_VGA:
|
|
qxl_create_memslots(d);
|
|
qxl_enter_vga_mode(d);
|
|
break;
|
|
case QXL_MODE_NATIVE:
|
|
qxl_create_memslots(d);
|
|
qxl_create_guest_primary(d, 1, QXL_SYNC);
|
|
|
|
/* replay surface-create and cursor-set commands */
|
|
cmds = g_new0(QXLCommandExt, d->ssd.num_surfaces + 1);
|
|
for (in = 0, out = 0; in < d->ssd.num_surfaces; in++) {
|
|
if (d->guest_surfaces.cmds[in] == 0) {
|
|
continue;
|
|
}
|
|
cmds[out].cmd.data = d->guest_surfaces.cmds[in];
|
|
cmds[out].cmd.type = QXL_CMD_SURFACE;
|
|
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
|
|
out++;
|
|
}
|
|
if (d->guest_cursor) {
|
|
cmds[out].cmd.data = d->guest_cursor;
|
|
cmds[out].cmd.type = QXL_CMD_CURSOR;
|
|
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
|
|
out++;
|
|
}
|
|
qxl_spice_loadvm_commands(d, cmds, out);
|
|
g_free(cmds);
|
|
if (d->guest_monitors_config) {
|
|
qxl_spice_monitors_config_async(d, 1);
|
|
}
|
|
break;
|
|
case QXL_MODE_COMPAT:
|
|
/* note: no need to call qxl_create_memslots, qxl_set_mode
|
|
* creates the mem slot. */
|
|
qxl_set_mode(d, d->shadow_rom.mode, 1);
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#define QXL_SAVE_VERSION 21
|
|
|
|
static bool qxl_monitors_config_needed(void *opaque)
|
|
{
|
|
PCIQXLDevice *qxl = opaque;
|
|
|
|
return qxl->guest_monitors_config != 0;
|
|
}
|
|
|
|
|
|
static const VMStateDescription qxl_memslot = {
|
|
.name = "qxl-memslot",
|
|
.version_id = QXL_SAVE_VERSION,
|
|
.minimum_version_id = QXL_SAVE_VERSION,
|
|
.fields = (VMStateField[]) {
|
|
VMSTATE_UINT64(slot.mem_start, struct guest_slots),
|
|
VMSTATE_UINT64(slot.mem_end, struct guest_slots),
|
|
VMSTATE_UINT32(active, struct guest_slots),
|
|
VMSTATE_END_OF_LIST()
|
|
}
|
|
};
|
|
|
|
static const VMStateDescription qxl_surface = {
|
|
.name = "qxl-surface",
|
|
.version_id = QXL_SAVE_VERSION,
|
|
.minimum_version_id = QXL_SAVE_VERSION,
|
|
.fields = (VMStateField[]) {
|
|
VMSTATE_UINT32(width, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(height, QXLSurfaceCreate),
|
|
VMSTATE_INT32(stride, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(format, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(position, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(mouse_mode, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(flags, QXLSurfaceCreate),
|
|
VMSTATE_UINT32(type, QXLSurfaceCreate),
|
|
VMSTATE_UINT64(mem, QXLSurfaceCreate),
|
|
VMSTATE_END_OF_LIST()
|
|
}
|
|
};
|
|
|
|
static const VMStateDescription qxl_vmstate_monitors_config = {
|
|
.name = "qxl/monitors-config",
|
|
.version_id = 1,
|
|
.minimum_version_id = 1,
|
|
.needed = qxl_monitors_config_needed,
|
|
.fields = (VMStateField[]) {
|
|
VMSTATE_UINT64(guest_monitors_config, PCIQXLDevice),
|
|
VMSTATE_END_OF_LIST()
|
|
},
|
|
};
|
|
|
|
static const VMStateDescription qxl_vmstate = {
|
|
.name = "qxl",
|
|
.version_id = QXL_SAVE_VERSION,
|
|
.minimum_version_id = QXL_SAVE_VERSION,
|
|
.pre_save = qxl_pre_save,
|
|
.pre_load = qxl_pre_load,
|
|
.post_load = qxl_post_load,
|
|
.fields = (VMStateField[]) {
|
|
VMSTATE_PCI_DEVICE(pci, PCIQXLDevice),
|
|
VMSTATE_STRUCT(vga, PCIQXLDevice, 0, vmstate_vga_common, VGACommonState),
|
|
VMSTATE_UINT32(shadow_rom.mode, PCIQXLDevice),
|
|
VMSTATE_UINT32(num_free_res, PCIQXLDevice),
|
|
VMSTATE_UINT32(last_release_offset, PCIQXLDevice),
|
|
VMSTATE_UINT32(mode, PCIQXLDevice),
|
|
VMSTATE_UINT32(ssd.unique, PCIQXLDevice),
|
|
VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice, NULL),
|
|
VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, 0,
|
|
qxl_memslot, struct guest_slots),
|
|
VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0,
|
|
qxl_surface, QXLSurfaceCreate),
|
|
VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice, NULL),
|
|
VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice,
|
|
ssd.num_surfaces, 0,
|
|
vmstate_info_uint64, uint64_t),
|
|
VMSTATE_UINT64(guest_cursor, PCIQXLDevice),
|
|
VMSTATE_END_OF_LIST()
|
|
},
|
|
.subsections = (const VMStateDescription*[]) {
|
|
&qxl_vmstate_monitors_config,
|
|
NULL
|
|
}
|
|
};
|
|
|
|
static Property qxl_properties[] = {
|
|
DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size, 64 * MiB),
|
|
DEFINE_PROP_UINT64("vram_size", PCIQXLDevice, vram32_size, 64 * MiB),
|
|
DEFINE_PROP_UINT32("revision", PCIQXLDevice, revision,
|
|
QXL_DEFAULT_REVISION),
|
|
DEFINE_PROP_UINT32("debug", PCIQXLDevice, debug, 0),
|
|
DEFINE_PROP_UINT32("guestdebug", PCIQXLDevice, guestdebug, 0),
|
|
DEFINE_PROP_UINT32("cmdlog", PCIQXLDevice, cmdlog, 0),
|
|
DEFINE_PROP_UINT32("ram_size_mb", PCIQXLDevice, ram_size_mb, -1),
|
|
DEFINE_PROP_UINT32("vram_size_mb", PCIQXLDevice, vram32_size_mb, -1),
|
|
DEFINE_PROP_UINT32("vram64_size_mb", PCIQXLDevice, vram_size_mb, -1),
|
|
DEFINE_PROP_UINT32("vgamem_mb", PCIQXLDevice, vgamem_size_mb, 16),
|
|
DEFINE_PROP_INT32("surfaces", PCIQXLDevice, ssd.num_surfaces, 1024),
|
|
#if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
|
|
DEFINE_PROP_UINT16("max_outputs", PCIQXLDevice, max_outputs, 0),
|
|
#endif
|
|
DEFINE_PROP_UINT32("xres", PCIQXLDevice, xres, 0),
|
|
DEFINE_PROP_UINT32("yres", PCIQXLDevice, yres, 0),
|
|
DEFINE_PROP_BOOL("global-vmstate", PCIQXLDevice, vga.global_vmstate, false),
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
};
|
|
|
|
static void qxl_pci_class_init(ObjectClass *klass, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
k->vendor_id = REDHAT_PCI_VENDOR_ID;
|
|
k->device_id = QXL_DEVICE_ID_STABLE;
|
|
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
|
dc->reset = qxl_reset_handler;
|
|
dc->vmsd = &qxl_vmstate;
|
|
device_class_set_props(dc, qxl_properties);
|
|
}
|
|
|
|
static const TypeInfo qxl_pci_type_info = {
|
|
.name = TYPE_PCI_QXL,
|
|
.parent = TYPE_PCI_DEVICE,
|
|
.instance_size = sizeof(PCIQXLDevice),
|
|
.abstract = true,
|
|
.class_init = qxl_pci_class_init,
|
|
.interfaces = (InterfaceInfo[]) {
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
{ },
|
|
},
|
|
};
|
|
|
|
static void qxl_primary_class_init(ObjectClass *klass, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
k->realize = qxl_realize_primary;
|
|
k->romfile = "vgabios-qxl.bin";
|
|
k->class_id = PCI_CLASS_DISPLAY_VGA;
|
|
dc->desc = "Spice QXL GPU (primary, vga compatible)";
|
|
dc->hotpluggable = false;
|
|
}
|
|
|
|
static const TypeInfo qxl_primary_info = {
|
|
.name = "qxl-vga",
|
|
.parent = TYPE_PCI_QXL,
|
|
.class_init = qxl_primary_class_init,
|
|
};
|
|
module_obj("qxl-vga");
|
|
module_kconfig(QXL);
|
|
|
|
static void qxl_secondary_class_init(ObjectClass *klass, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
k->realize = qxl_realize_secondary;
|
|
k->class_id = PCI_CLASS_DISPLAY_OTHER;
|
|
dc->desc = "Spice QXL GPU (secondary)";
|
|
}
|
|
|
|
static const TypeInfo qxl_secondary_info = {
|
|
.name = "qxl",
|
|
.parent = TYPE_PCI_QXL,
|
|
.class_init = qxl_secondary_class_init,
|
|
};
|
|
module_obj("qxl");
|
|
|
|
static void qxl_register_types(void)
|
|
{
|
|
type_register_static(&qxl_pci_type_info);
|
|
type_register_static(&qxl_primary_info);
|
|
type_register_static(&qxl_secondary_info);
|
|
}
|
|
|
|
type_init(qxl_register_types)
|
|
|
|
module_dep("ui-spice-core");
|