aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-01-26target/arm: Expose arm_cpu_mp_affinity() in 'multiprocessing.h' headerPhilippe Mathieu-Daudé10-5/+29
Declare arm_cpu_mp_affinity() prototype in the new "target/arm/multiprocessing.h" header so units in hw/arm/ can use it without having to include the huge target-specific "cpu.h". File list to include the new header generated using: $ git grep -lw arm_cpu_mp_affinity Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-11-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26target/arm: Create arm_cpu_mp_affinityRichard Henderson8-11/+17
Wrapper to return the mp affinity bits from the cpu. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-10-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26target/arm: Rename arm_cpu_mp_affinityRichard Henderson5-7/+7
Rename to arm_build_mp_affinity. This frees up the name for other usage, and emphasizes that the cpu object is not involved. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-9-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26target/arm/cpregs: Include missing 'kvm-consts.h' headerPhilippe Mathieu-Daudé1-0/+1
target/arm/cpregs.h uses the CP_REG_ARCH_* definitions from "target/arm/kvm-consts.h". Include it in order to avoid when refactoring unrelated headers: target/arm/cpregs.h:191:18: error: use of undeclared identifier 'CP_REG_ARCH_MASK' if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-8-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26target/arm/cpregs: Include missing 'hw/registerfields.h' headerPhilippe Mathieu-Daudé1-0/+2
target/arm/cpregs.h uses the FIELD() macro defined in "hw/registerfields.h". Include it in order to avoid when refactoring unrelated headers: target/arm/cpregs.h:347:30: error: expected identifier FIELD(HFGRTR_EL2, AFSR0_EL1, 0, 1) ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-7-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26target/arm/cpu-features: Include missing 'hw/registerfields.h' headerPhilippe Mathieu-Daudé1-0/+2
target/arm/cpu-features.h uses the FIELD_EX32() macro defined in "hw/registerfields.h". Include it in order to avoid when refactoring unrelated headers: target/arm/cpu-features.h:44:12: error: call to undeclared function 'FIELD_EX32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-6-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/xlnx-versal: Include missing 'cpu.h' headerPhilippe Mathieu-Daudé1-0/+1
include/hw/arm/xlnx-versal.h uses the ARMCPU structure which is defined in the "target/arm/cpu.h" header. Include it in order to avoid when refactoring unrelated headers: In file included from hw/arm/xlnx-versal-virt.c:20: include/hw/arm/xlnx-versal.h:62:23: error: array has incomplete element type 'ARMCPU' (aka 'struct ArchCPU') ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-5-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/smmuv3: Include missing 'hw/registerfields.h' headerPhilippe Mathieu-Daudé1-0/+1
hw/arm/smmuv3-internal.h uses the REG32() and FIELD() macros defined in "hw/registerfields.h". Include it in order to avoid when refactoring unrelated headers: In file included from ../../hw/arm/smmuv3.c:34: hw/arm/smmuv3-internal.h:36:28: error: expected identifier REG32(IDR0, 0x0) ^ hw/arm/smmuv3-internal.h:37:5: error: expected function body after function declarator FIELD(IDR0, S2P, 0 , 1) ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-4-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/xilinx_zynq: Include missing 'exec/tswap.h' headerPhilippe Mathieu-Daudé1-0/+1
hw/arm/xilinx_zynq.c calls tswap32() which is declared in "exec/tswap.h". Include it in order to avoid when refactoring unrelated headers: hw/arm/xilinx_zynq.c:103:31: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] board_setup_blob[n] = tswap32(board_setup_blob[n]); ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-3-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/exynos4210: Include missing 'exec/tswap.h' headerPhilippe Mathieu-Daudé1-0/+1
hw/arm/exynos4210.c calls tswap32() which is declared in "exec/tswap.h". Include it in order to avoid when refactoring unrelated headers: hw/arm/exynos4210.c:499:22: error: call to undeclared function 'tswap32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] smpboot[n] = tswap32(smpboot[n]); ^ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240118200643.29037-2-philmd@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm: Add watchdog timer to Allwinner H40 and Bananapi boardGuenter Roeck4-1/+13
Add watchdog timer support to Allwinner-H40 and Bananapi. The watchdog timer is added as an overlay to the Timer module memory map. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> Message-id: 20240115182757.1095012-4-linux@roeck-us.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm: Add AHCI/SATA controller to Allwinner R40 and Bananapi boardGuenter Roeck4-1/+16
Allwinner R40 supports an AHCI compliant SATA controller. Add support for it. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Message-id: 20240115182757.1095012-3-linux@roeck-us.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm: Add EHCI/OHCI controllers to Allwinner R40 and Bananapi boardGuenter Roeck4-3/+57
Allwinner R40 supports two USB host ports shared between a USB 2.0 EHCI host controller and a USB 1.1 OHCI host controller. Add support for both of them. If machine USB support is not enabled, create unimplemented devices for the USB memory ranges to avoid crashes when booting Linux. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20240115182757.1095012-2-linux@roeck-us.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/nseries: Unconditionally map the TUSB6010 USB Host controllerPhilippe Mathieu-Daudé1-3/+1
The TUSB6010 USB controller is soldered on the N800 and N810 tablets, thus is always present. This is a migration compatibility break for the n800/n810 machines started with the '-usb none' option. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20240119215106.45776-3-philmd@linaro.org [PMM: fixed commit message typo] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/allwinner-a10: Unconditionally map the USB Host controllersPhilippe Mathieu-Daudé1-31/+22
The USB Controllers are part of the chipset, thus are always present and mapped in memory. This is a migration compatibility break for the cubieboard machine started with the '-usb none' option. Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Message-id: 20240119215106.45776-2-philmd@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26hw/arm/musicpal: Convert to qemu_add_kbd_event_handler()Peter Maydell1-68/+59
Convert the musicpal key input device to use qemu_add_kbd_event_handler(). This lets us simplify it because we no longer need to track whether we're in the middle of a PS/2 multibyte key sequence. In the conversion we move the keyboard handler registration from init to realize, because devices shouldn't disturb the state of the simulation by doing things like registering input handlers until they're realized, so that device objects can be introspected safely. The behaviour where key-repeat is permitted for the arrow-keys only is intentional (added in commit 7c6ce4baedfcd0c), so we retain it, and add a comment to that effect. This is a migration compatibility break for musicpal. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20231103182750.855577-1-peter.maydell@linaro.org
2024-01-26hw/arm/virt.c: Remove newline from error_report() stringPeter Maydell1-2/+2
error_report() strings should not include trailing newlines; remove the newline from the error we print when devices won't fit into the address space of the CPU. This commit also fixes the accidental hardcoded tabs that were in this line, since we have to touch the line anyway. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20240118131649.2726375-1-peter.maydell@linaro.org
2024-01-26target/arm: Fix VNCR fault detection logicPeter Maydell1-1/+1
In arm_deliver_fault() we check for whether the fault is caused by a data abort due to an access to a FEAT_NV2 sysreg in the memory pointed to by the VNCR. Unfortunately part of the condition checks the wrong argument to the function, meaning that it would spuriously trigger, resulting in some instruction aborts being taken to the wrong EL and reported incorrectly. Use the right variable in the condition. Fixes: 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly") Reported-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Message-id: 20240116165605.2523055-1-peter.maydell@linaro.org
2024-01-26target/xtensa: fix OOB TLB entry accessMax Filippov1-12/+35
r[id]tlb[01], [iw][id]tlb opcodes use TLB way index passed in a register by the guest. The host uses 3 bits of the index for ITLB indexing and 4 bits for DTLB, but there's only 7 entries in the ITLB array and 10 in the DTLB array, so a malicious guest may trigger out-of-bound access to these arrays. Change split_tlb_entry_spec return type to bool to indicate whether TLB way passed to it is valid. Change get_tlb_entry to return NULL in case invalid TLB way is requested. Add assertion to xtensa_tlb_get_entry that requested TLB way and entry indices are valid. Add checks to the [rwi]tlb helpers that requested TLB way is valid and return 0 or do nothing when it's not. Cc: qemu-stable@nongnu.org Fixes: b67ea0cd7441 ("target-xtensa: implement memory protection options") Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20231215120307.545381-1-jcmvbkbc@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26iotests/277: Use iotests.sock_dir for socket creationAndrey Drobyshev1-1/+2
If socket path is too long (longer than 108 bytes), socket can't be opened. This might lead to failure when test dir path is long enough. Make sure socket is created in iotests.sock_dir to avoid such a case. This commit basically aligns iotests/277 with the rest of iotests. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Message-ID: <20240124162257.168325-1-andrey.drobyshev@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26iotests/iothreads-stream: Use the right TimeoutErrorKevin Wolf1-1/+2
Since Python 3.11 asyncio.TimeoutError is an alias for TimeoutError, but in older versions it's not. We really have to catch asyncio.TimeoutError here, otherwise a slow test run will fail (as has happened multiple times on CI recently). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20240125152150.42389-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26tests/unit: Bump test-replication timeout to 60 secondsKevin Wolf1-1/+2
We're seeing timeouts for this test on CI runs (specifically for ubuntu-20.04-s390x-all). It doesn't fail consistently, but even the successful runs take about 27 or 28 seconds, which is not very far from the 30 seconds timeout. Bump the timeout a bit to make failure less likely even on this CI host. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20240125165803.48373-1-kwolf@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26Merge tag 'pull-qapi-2024-01-26' of https://repo.or.cz/qemu/armbru into stagingPeter Maydell19-59/+64
QAPI patches patches for 2024-01-26 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmWzT/QSHGFybWJydUBy # ZWRoYXQuY29tAAoJEDhwtADrkYZTznQQALpsbanZR+gfTDOI/kvFuoLtOdhibtxW # /5IwAP68Hdj2unHyHRBaNQIwyAfnHlyks1ywNyv0JCAqoyLuoa/ertir3zKc/1xP # hOer7C76jrWiL2Gg4EMxl1oWussyHLq7XtQQEmL4aLV+EnnoytUfnosUpO0Ee5Pg # Fz1EwJi74LEfYtrZjfX/YXZrX+3PJpYywtSWlyDluER0xfjh5d3JAsrjpgcPHZKc # fwD2W7myxnW8IRyHdIgbu6Spv0vcM39PMrIK0ZlnVKgUz+/YcMgeK0eSXd6y+FjX # Wehd7Ik5YE8el+SvGDPEMSTCkA2CP7dEnKt9Fk1pn+N8YhPGnQxDSBQOIae5Tnbf # rrlOrCWXqW2a5FtbG/E4SwtXZlOo1BjkSy6+xP86YwXr23DSafVaeJp4CUls+ABZ # LX6vR0p6bxPxOwVhoYeqxv+TpdA206g0yhN7bknoIp42DG4oj81toD5Ki3fedfwC # pPl2sxniBm4MaO57YXxFgSN0lrur5vCcPadRppGbrGEO8XaX7F+9c5OWsPh+jt1x # /l+A7RakrTg39NR2X46D1clPj3NQHwMVNIoSJek4+nCnM7eKVhMSm9YjpQEPupt0 # Aa+5QdiKcgjYEoSljE6ZsYJIrxd0OoaSpP1BWl4P+NcjgyUGcUkQ2X3AEL8Xkm6H # wLv5U6ob99eL # =nXml # -----END PGP SIGNATURE----- # gpg: Signature made Fri 26 Jan 2024 06:23:48 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * tag 'pull-qapi-2024-01-26' of https://repo.or.cz/qemu/armbru: qapi: Fix malformed "Since:" section tags (again) qapi: Indent tagged doc comment sections properly qapi: Fix mangled "Returns" sections in documentation docs/interop/bitmaps: Clean up a reference to qemu-qmp-ref qapi: Fix dangling references to docs/devel/qapi-code-gen.txt docs: Replace dangling references to docs/interop/qmp-intro.txt docs/devel/qapi-code-gen: Fix missing ':' in tagged section docs docs/devel/qapi-code-gen: Don't reserve types ending with 'Kind' Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into stagingPeter Maydell1-4/+9
# -----BEGIN PGP SIGNATURE----- # # iQEzBAABCAAdFiEEIV1G9IJGaJ7HfzVi7wSWWzmNYhEFAmWyBtIACgkQ7wSWWzmN # YhHWDgf+P9Jnlt8tCmOV6oKYrhKBbNZ5mZGmd83LpgFpn0YTdBQrauje2DziQ6u8 # KSVO6VGK/yzFLe8+xIIZXT0pFTbr8KuGhpKwqU8hq33dZtkRPUM6psirGgh2Z94K # zWvBt/gL8DaO4ywShqwTZxhNBke1WduZpwzd/2XehmfT2SM/krpWeI2CjistQTBe # IVbD7QioVuolh4Vq3W8On14NhwMp85Z/POh0kIAYHq5eDp2U6uYfK+1O8KHsRV4j # Ae0Comul3YvNj9t3WPB6i1fLAzHvSfc1vO18CHKnznRONBLuhfnm9HKU7PtT/BC0 # JY59tU1lGYaQ9Ok3fDtxkaU41gkBWQ== # =FHOd # -----END PGP SIGNATURE----- # gpg: Signature made Thu 25 Jan 2024 06:59:30 GMT # gpg: using RSA key 215D46F48246689EC77F3562EF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * tag 'net-pull-request' of https://github.com/jasowang/qemu: virtio-net: correctly copy vnet header when flushing TX Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26Merge tag 'pull-loongarch-20240125' of https://gitlab.com/gaosong/qemu into ↵Peter Maydell2-10/+45
staging pull-loongarch-20240125 # -----BEGIN PGP SIGNATURE----- # # iLMEAAEKAB0WIQS4/x2g0v3LLaCcbCxAov/yOSY+3wUCZbINEAAKCRBAov/yOSY+ # 3yVsBACz0E5gVPc5Fp5hgQsAiiZPga/Pr565BOypIw8iAPs0RNxMMnywinFsOi1w # A6euynZTEW9lxx5cq/O5j7yaXUmgfChcJ1OkS/IEZaUtiG25ksOIqvoeYvuROfuV # nYrM0nuOMNwJzkOJy+qZAwGaUbyWdiqUTkP369V2xxngTneDkw== # =1YQg # -----END PGP SIGNATURE----- # gpg: Signature made Thu 25 Jan 2024 07:26:08 GMT # gpg: using RSA key B8FF1DA0D2FDCB2DA09C6C2C40A2FFF239263EDF # gpg: Good signature from "Song Gao <m17746591750@163.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B8FF 1DA0 D2FD CB2D A09C 6C2C 40A2 FFF2 3926 3EDF * tag 'pull-loongarch-20240125' of https://gitlab.com/gaosong/qemu: target/loongarch/kvm: Enable LSX/LASX extension target/loongarch: Set cpuid CSR register only once with kvm mode Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-26iotests/264: Use iotests.sock_dir for socket creationAndrey Drobyshev1-1/+2
If socket path is too long (longer than 108 bytes), socket can't be opened. This might lead to failure when test dir path is long enough. Make sure socket is created in iotests.sock_dir to avoid such a case. This commit basically aligns iotests/264 with the rest of iotests. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Message-ID: <20240125135237.189493-1-andrey.drobyshev@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26block/blklogwrites: Protect mutable driver state with a mutex.Ari Sundholm1-8/+77
During the review of a fix for a concurrency issue in blklogwrites, it was found that the driver needs an additional fix when enabling multiqueue, which is a new feature introduced in QEMU 9.0, as the driver state may be read and written by multiple threads at the same time, which was not the case when the driver was originally written. Fix the multi-threaded scenario by introducing a mutex to protect the mutable fields in the driver state, and always having the mutex locked by the current thread when accessing them. Also use the mutex and a CoQueue to ensure that the super block is not being written to by multiple threads concurrently and updates are properly serialized. Additionally, add the const qualifier to a few BDRVBlkLogWritesState pointer targets in contexts where the driver state is not written to. Signed-off-by: Ari Sundholm <ari@tuxera.com> Message-ID: <20240119162913.2620245-1-ari@tuxera.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: always set ioeventfd during startupStefan Hajnoczi1-6/+6
When starting ioeventfd it is common practice to set the event notifier so that the ioeventfd handler is triggered to run immediately. There may be no requests waiting to be processed, but the idea is that if a request snuck in then we guarantee that it will be detected. One scenario where self-triggering the ioeventfd is necessary is when virtio_blk_handle_output() is called from a vCPU thread before the VIRTIO Device Status transitions to DRIVER_OK. In that case we need to self-trigger the ioeventfd so that the kick handled by the vCPU thread causes the vq AioContext thread to take over handling the request(s). Fixes: b6948ab01df0 ("virtio-blk: add iothread-vq-mapping parameter") Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-7-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: tolerate failure to set BlockBackend AioContextStefan Hajnoczi1-14/+5
We no longer rely on setting the AioContext since the block layer IO_CODE APIs can be called from any thread. Now it's just a hint to help block jobs and other operations co-locate themselves in a thread with the guest I/O requests. Keep going if setting the AioContext fails. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-6-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: restart s->rq reqs in vq AioContextsStefan Hajnoczi1-11/+33
A virtio-blk device with the iothread-vq-mapping parameter has per-virtqueue AioContexts. It is not thread-safe to process s->rq requests in the BlockBackend AioContext since that may be different from the virtqueue's AioContext to which this request belongs. The code currently races and could crash. Adapt virtio_blk_dma_restart_cb() to first split s->rq into per-vq lists and then schedule a BH each vq's AioContext as necessary. This way requests are safely processed in their vq's AioContext. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-5-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: rename dataplane to ioeventfdStefan Hajnoczi2-43/+43
The dataplane code is really about using ioeventfd. It's used both for IOThreads (what we think of as dataplane) and for the core virtio-pci code's ioeventfd feature (which is enabled by default and used when no IOThread has been specified). Rename the code to reflect this. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-4-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: rename dataplane create/destroy functionsStefan Hajnoczi1-11/+12
virtio_blk_data_plane_create() and virtio_blk_data_plane_destroy() are actually about s->vq_aio_context[] rather than managing dataplane-specific state. As a prerequisite to using s->vq_aio_context[] in all code paths (even when dataplane is not used), rename these functions to reflect that they just manage s->vq_aio_context and call them regardless of whether or not dataplane is in use. Note that virtio-blk supports running with -device virtio-blk-pci,ioevent=off where the vCPU thread enters the device emulation code. In this mode ioeventfd is not used for virtqueue processing. However, we still want to initialize s->vq_aio_context[] to qemu_aio_context in that case since I/O completion callbacks will be invoked in the main loop thread. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-3-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26virtio-blk: move dataplane code into virtio-blk.cStefan Hajnoczi8-463/+357
The dataplane code used to be significantly different from the non-dataplane code and therefore had a separate source file. Over time the difference has gotten smaller because the I/O code paths were unified. Nowadays the distinction between the VirtIOBlock and VirtIOBlockDataPlane structs is more of an inconvenience that hinders code simplification. Move hw/block/dataplane/virtio-blk.c into hw/block/virtio-blk.c, merging VirtIOBlockDataPlane's fields into VirtIOBlock. hw/block/virtio-blk.c used VirtIOBlock->dataplane to check if virtio_blk_data_plane_create() was successful. This is not necessary because ->dataplane_started and ->dataplane_disabled can be used instead. This patch makes those changes in order to drop VirtIOBlock->dataplane. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240119135748.270944-2-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26monitor: only run coroutine commands in qemu_aio_contextStefan Hajnoczi32-178/+205
monitor_qmp_dispatcher_co() runs in the iohandler AioContext that is not polled during nested event loops. The coroutine currently reschedules itself in the main loop's qemu_aio_context AioContext, which is polled during nested event loops. One known problem is that QMP device-add calls drain_call_rcu(), which temporarily drops the BQL, leading to all sorts of havoc like other vCPU threads re-entering device emulation code while another vCPU thread is waiting in device emulation code with aio_poll(). Paolo Bonzini suggested running non-coroutine QMP handlers in the iohandler AioContext. This avoids trouble with nested event loops. His original idea was to move coroutine rescheduling to monitor_qmp_dispatch(), but I resorted to moving it to qmp_dispatch() because we don't know if the QMP handler needs to run in coroutine context in monitor_qmp_dispatch(). monitor_qmp_dispatch() would have been nicer since it's associated with the monitor implementation and not as general as qmp_dispatch(), which is also used by qemu-ga. A number of qemu-iotests need updated .out files because the order of QMP events vs QMP responses has changed. Solves Issue #1933. Cc: qemu-stable@nongnu.org Fixes: 7bed89958bfbf40df9ca681cefbdca63abdde39d ("device_core: use drain_call_rcu in in qmp_device_add") Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2215192 Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2214985 Buglink: https://issues.redhat.com/browse/RHEL-17369 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240118144823.1497953-4-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Tested-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26iotests: port 141 to Python for reliable QMP testingStefan Hajnoczi2-331/+176
The common.qemu bash functions allow tests to interact with the QMP monitor of a QEMU process. I spent two days trying to update 141 when the order of the test output changed, but found it would still fail occassionally because printf() and QMP events race with synchronous QMP communication. I gave up and ported 141 to the existing Python API for QMP tests. The Python API is less affected by the order in which QEMU prints output because it does not print all QMP traffic by default. The next commit changes the order in which QMP messages are received. Make 141 reliable first. Cc: Hanna Czenczek <hreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240118144823.1497953-3-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26iotests: add filter_qmp_generated_node_ids()Stefan Hajnoczi1-0/+7
Add a filter function for QMP responses that contain QEMU's automatically generated node ids. The ids change between runs and must be masked in the reference output. The next commit will use this new function. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20240118144823.1497953-2-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26stream: Allow users to request only format driver names in backing file formatPeter Krempa5-3/+28
Introduce a new flag 'backing-mask-protocol' for the block-stream QMP command which instructs the internals to use 'raw' instead of the protocol driver in case when a image is used without a dummy 'raw' wrapper. The flag is designed such that it can be always asserted by management tools even when there isn't any update to backing files. The flag will be used by libvirt so that the backing images still reference the proper format even when libvirt will stop using the dummy raw driver (raw driver with no other config). Libvirt needs this so that the images stay compatible with older libvirt versions which didn't expect that a protocol driver name can appear in the backing file format field. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-ID: <bbee9a0a59748a8893289bf8249f568f0d587e62.1701796348.git.pkrempa@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26commit: Allow users to request only format driver names in backing file formatPeter Krempa8-12/+58
Introduce a new flag 'backing-mask-protocol' for the block-commit QMP command which instructs the internals to use 'raw' instead of the protocol driver in case when a image is used without a dummy 'raw' wrapper. The flag is designed such that it can be always asserted by management tools even when there isn't any update to backing files. The flag will be used by libvirt so that the backing images still reference the proper format even when libvirt will stop using the dummy raw driver (raw driver with no other config). Libvirt needs this so that the images stay compatible with older libvirt versions which didn't expect that a protocol driver name can appear in the backing file format field. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-ID: <2cb46e37093ce793ea1604abc8bbb90f4c8e434b.1701796348.git.pkrempa@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26string-output-visitor: Fix (pseudo) struct handlingKevin Wolf1-0/+46
Commit ff32bb53 tried to get minimal struct support into the string output visitor by just making it return "<omitted>". Unfortunately, it forgot that the caller will still make more visitor calls for the content of the struct. If the struct is contained in a list, such as IOThreadVirtQueueMapping, in the better case its fields show up as separate list entries. In the worse case, it contains another list, and the string output visitor doesn't support nested lists and asserts that this doesn't happen. So as soon as the optional "vqs" field in IOThreadVirtQueueMapping is specified, we get a crash. This can be reproduced with the following command line: echo "info qtree" | ./qemu-system-x86_64 \ -object iothread,id=t0 \ -blockdev null-co,node-name=disk \ -device '{"driver": "virtio-blk-pci", "drive": "disk", "iothread-vq-mapping": [{"iothread": "t0", "vqs": [0]}]}' \ -monitor stdio Fix the problem by counting the nesting level of structs and ignoring any visitor calls for values (apart from start/end_struct) while we're not on the top level. Lists nested directly within lists remain unimplemented, as we don't currently have a use case for them. Fixes: ff32bb53476539d352653f4ed56372dced73a388 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2069 Reported-by: Aihua Liang <aliang@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20240109181717.42493-1-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26block/blklogwrites: Fix a bug when logging "write zeroes" operations.Ari Sundholm1-9/+26
There is a bug in the blklogwrites driver pertaining to logging "write zeroes" operations, causing log corruption. This can be easily observed by setting detect-zeroes to something other than "off" for the driver. The issue is caused by a concurrency bug pertaining to the fact that "write zeroes" operations have to be logged in two parts: first the log entry metadata, then the zeroed-out region. While the log entry metadata is being written by bdrv_co_pwritev(), another operation may begin in the meanwhile and modify the state of the blklogwrites driver. This is as intended by the coroutine-driven I/O model in QEMU, of course. Unfortunately, this specific scenario is mishandled. A short example: 1. Initially, in the current operation (#1), the current log sector number in the driver state is only incremented by the number of sectors taken by the log entry metadata, after which the log entry metadata is written. The current operation yields. 2. Another operation (#2) may start while the log entry metadata is being written. It uses the current log position as the start offset for its log entry. This is in the sector right after the operation #1 log entry metadata, which is bad! 3. After bdrv_co_pwritev() returns (#1), the current log sector number is reread from the driver state in order to find out the start offset for bdrv_co_pwrite_zeroes(). This is an obvious blunder, as the offset will be the sector right after the (misplaced) operation #2 log entry, which means that the zeroed-out region begins at the wrong offset. 4. As a result of the above, the log is corrupt. Fix this by only reading the driver metadata once, computing the offsets and sizes in one go (including the optional zeroed-out region) and setting the log sector number to the appropriate value for the next operation in line. Signed-off-by: Ari Sundholm <ari@tuxera.com> Cc: qemu-stable@nongnu.org Message-ID: <20240109184646.1128475-1-megari@gmx.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2024-01-26qapi: Fix malformed "Since:" section tags (again)Markus Armbruster2-9/+9
"Since X.Y" is not recognized as a tagged section, and therefore not formatted as such in generated documentation. Fix by adding the required colon. Previously fixed in commit 433a4fdc420 (qapi: Fix malformed "Since:" section tags) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-8-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26qapi: Indent tagged doc comment sections properlyMarkus Armbruster5-22/+22
docs/devel/qapi-code-gen demands that the "second and subsequent lines of sections other than "Example"/"Examples" should be indented". Commit a937b6aa739 (qapi: Reformat doc comments to conform to current conventions) missed a few instances, and a few more have crept in since. Indent them. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26qapi: Fix mangled "Returns" sections in documentationMarkus Armbruster3-12/+18
Commit e050e426782e (qapi: Use explicit bulleted lists) added list markup to correct bad rendering: A JSON block comment like this: Returns: nothing on success If @node is not a valid block device, DeviceNotFound If @name is not found, GenericError with an explanation renders like this: Returns: nothing on success If node is not a valid block device, DeviceNotFound If name is not found, GenericError with an explanation because whitespace is not significant. Use an actual bulleted list, so that the formatting is correct. It missed a few instances. Commit a937b6aa739 (qapi: Reformat doc comments to conform to current conventions) then reflowed them. Revert the reflowing, and add list markup. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-6-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26docs/interop/bitmaps: Clean up a reference to qemu-qmp-refMarkus Armbruster2-4/+4
docs/interop/bitmaps.rst uses references like `qemu-qmp-ref <qemu-qmp-ref.html>`_ `query-block <qemu-qmp-ref.html#index-query_002dblock>`_ to refer to and into docs/interop/qemu-qmp-ref.rst. Clean up the former: use :doc:`qemu-qmp-ref`. I don't know how to clean up the latter. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-5-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26qapi: Fix dangling references to docs/devel/qapi-code-gen.txtMarkus Armbruster7-8/+8
Conversion of docs/devel/qapi-code-gen.txt to ReST left several dangling references behind. Fix them to point to docs/devel/qapi-code-gen.rst. Fixes: f7aa076dbdfc (docs: convert qapi-code-gen.txt to ReST) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-4-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26docs: Replace dangling references to docs/interop/qmp-intro.txtMarkus Armbruster2-5/+5
Deletion of docs/interop/qmp-intro.txt left two dangling references behind. Replace them by references to docs/interop/qmp-spec.rst. Fixes: 0ec4468f233c (docs/interop: Delete qmp-intro.txt) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-3-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26docs/devel/qapi-code-gen: Fix missing ':' in tagged section docsMarkus Armbruster1-2/+2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240120095327.666239-2-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-26docs/devel/qapi-code-gen: Don't reserve types ending with 'Kind'Markus Armbruster1-3/+2
We reserved type names ending with 'Kind' because a simple union 'SomeSimpleUnion' generated both a struct type SomeSimpleUnion and an enum type SomeSimpleUnionKind. Gone since commit 4e99f4b12c0 (qapi: Drop simple unions). The commit neglected to update the documentation not to reserve type names ending with 'Kind'. Do that now. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20231221145727.835905-1-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2024-01-25Merge tag 'pull-request-2024-01-24' of https://gitlab.com/thuth/qemu into ↵Peter Maydell4-874/+27
staging * Test timeout fixes * Clean up URI code # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmWw6SsRHHRodXRoQHJl # ZGhhdC5jb20ACgkQLtnXdP5wLbXsVQ//Ss33GMIu1aUEFsZTSUghUXPx8035zin/ # TugiIcLfcONxxCi+Q/jfUPowJ3TLwt0vdv3V73M94+XBDrWClLyJYuu8eew0EMZI # zqBl5AyO2hdGXxnF/wJAtdKfleUElJDooUyGPIlsJ2gXmmLi60qkQfKR8dGl3h2r # fLM36LVsWWtM3HaCePHlHYaYdfy917w4bNWJRf/QfBqSMX5F5mlU+EvzEFLBTkT/ # 4HCaYhE1ouQnudO+rvuK78I72BgXgaPTn2oCXVdBvbEM+36heJyhYRDCW4ncf5QN # PH8UQUih/NrU9BSrLT3aHE3VcYWzik7s8A4Nkg21bHYHhXstO/KKzhUU5//wOUp5 # BV+mwjwTxpnOAFqmgQuvH8rTx/YuXCpdkNdoLd41VX8Qa4DP1AjBWAC6LrJkDq51 # 2PIKqMPjSsBaXd/itBKBFzY7JkDRLFUZQMk78l/JjFuhvhE8OfpBPtCofgYo9/OE # cn9khZ6Oh9zxzZWb9YIdHiu4v1VP0ZtGfB0Zt4WIi2oBm3ql6+cHFkVcssaEIiNQ # h5tI/xLviUIIRMIPpu7W+WSZBHt+w6wjBlu3O5fjoPSoHQsmNg2S9mS9+AQ2/KGJ # 4/78/Pg4XpKVd2MSLMQ6A2LlI1iQd51TV0aTqrzd/DdZYP3TBXdasQPR/WZN4eWw # kYwt0bA5FGs= # =1N9B # -----END PGP SIGNATURE----- # gpg: Signature made Wed 24 Jan 2024 10:40:43 GMT # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full] # gpg: aka "Thomas Huth <thuth@redhat.com>" [full] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2024-01-24' of https://gitlab.com/thuth/qemu: util/uri: Remove unused macros ISA_RESERVED() and ISA_GEN_DELIM() util/uri: Remove the uri_string_escape() function util/uri: Remove unused functions uri_resolve() and uri_resolve_relative() util/uri: Remove uri_string_unescape() tests/qtest: Bump timeouts of boot_sector_test()-based tests to 610 seconds tests/unit/test-iov: Fix timeout problem on NetBSD and OpenBSD tests/qtest: Bump timeout of the boot-serial-test to 360 seconds Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-01-25Merge tag 'pull-tcg-20240123' of https://gitlab.com/rth7680/qemu into stagingPeter Maydell8-17/+25
tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns tcg: Clean up error paths in alloc_code_gen_buffer_splitwx_memfd linux-user/riscv: Adjust vdso signal frame cfa offsets linux-user: Fixed cpu restore with pc 0 on SIGBUS # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmWvk08dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+hSQf6A2h1vn0eVk+GaIUP # 1WN1xaqvN5DmZm8AcQkdqZxdmMZO+zq592zHcZ4RNWlyq8NU93cPCLpMkw4RltLU # NkHkqXcYIXUx12StJQ4EKuGNyBSu+emkPbkd31KBMM69zDXbugAmPGH7VGn5Mw7R # 8D02D8dvsG/iqmvI8L/ZJFjkrbO3A0AaSdb1Ynkwl6vlLLjpWCqoSFtwv+ZMYyWn # q9eLzrJ2pUtoO/CDq3WFnODdAh/QUMHKmgj/4YYvGylPIti7eoM24LXGJWQOeUkX # c0soBB24DEd92jJWjCsYUokcUVQOITOGbNdlhRGrxICNdIapUvVhvLW/IYxeBTlV # s5zl+g== # =rNAP # -----END PGP SIGNATURE----- # gpg: Signature made Tue 23 Jan 2024 10:22:07 GMT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * tag 'pull-tcg-20240123' of https://gitlab.com/rth7680/qemu: tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct linux-user/elfload: check PR_GET_DUMPABLE before creating coredump linux-user/elfload: test return value of getrlimit linux-user/riscv: Adjust vdso signal frame cfa offsets tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns linux-user: Fixed cpu restore with pc 0 on SIGBUS tcg: Make the cleanup-on-error path unique tcg: Remove unreachable code Signed-off-by: Peter Maydell <peter.maydell@linaro.org>