Miscellaneous changes for 2025-10-28
Subsystems (11)
The following changes since commit 36076d24f04ea9dc3357c0fbe7bb14917375819c:
Merge tag 'next-pr-pull-request' of https://gitlab.com/berrange/qemu into staging (2025-10-25 10:42:55 +0200)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to d77cb7d68dacb696900ca83d03e4d50735e45e5f:
rust: migration: allow passing ParentField<> to vmstate_of! (2025-10-28 14:50:44 +0100)
----------------------------------------------------------------
* char: rename CharBackend->CharFrontend
* esp: fix esp_cdb_ready() FIFO wraparound limit calculation
* isapc: warn rather than reject modern x86 CPU models
* mshv: fix Coverity issues
* qdev: Change PropertyInfo method print() to return malloc'ed string
* qobject: make refcount atomic
* rcu: make synchronize_rcu() more efficient
* rust: cleanup glib_sys bindings
* rust: Convert bit value to u8 within #[property]
* rust: only leave leaf crates as workspace members
* scripts: clean up meson-buildoptions.py
* scsi: make refcount atomic
* target/i386: Init SMM cpu address space for hotplugged CPUs
----------------------------------------------------------------
Akihiko Odaki (1):
rcu: Unify force quiescent state
Marc-André Lureau (1):
char: rename CharBackend->CharFrontend
Mark Cave-Ayland (4):
esp.c: fix esp_cdb_ready() FIFO wraparound limit calculation qtest/am53c974-test: add additional test for cmdfifo overflow hw/i386/isapc.c: warn rather than reject modern x86 CPU models docs/about/deprecated.rst: document isapc deprecation for modern x86 CPU models
Markus Armbruster (1):
qdev: Change PropertyInfo method print() to return malloc'ed string
Martin Kletzander (1):
rust: remove useless glib_sys bindings
Paolo Bonzini (8):
scripts: clean up meson-buildoptions.py
rust: only leave leaf crates as workspace members
qobject: make refcount atomic
accel/mshv: initialize thread name
accel/mshv: use return value of handle_pio_str_read
scsi: make SCSIRequest refcount atomic target/i386: clear CPU_INTERRUPT_SIPI for all accelerators
rust: migration: allow passing ParentField<> to vmstate_of!
Xiaoyao Li (1):
i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
Zhao Liu (1):
rust/qemu-macros: Convert bit value to u8 within #[property]
docs/about/deprecated.rst | 14 +++ meson.build | 1 + chardev/chardev-internal.h | 12 +-- include/chardev/char-fe.h | 67 ++++++------ include/chardev/char.h | 4 +- include/hw/char/avr_usart.h | 2 +- include/hw/char/bcm2835_aux.h | 2 +- include/hw/char/cadence_uart.h | 2 +- include/hw/char/cmsdk-apb-uart.h | 2 +- include/hw/char/digic-uart.h | 2 +- include/hw/char/escc.h | 2 +- include/hw/char/goldfish_tty.h | 2 +- include/hw/char/ibex_uart.h | 2 +- include/hw/char/imx_serial.h | 2 +- include/hw/char/max78000_uart.h | 2 +- include/hw/char/nrf51_uart.h | 2 +- include/hw/char/parallel.h | 2 +- include/hw/char/pl011.h | 2 +- include/hw/char/renesas_sci.h | 2 +- include/hw/char/riscv_htif.h | 2 +- include/hw/char/serial.h | 2 +- include/hw/char/shakti_uart.h | 2 +- include/hw/char/sifive_uart.h | 2 +- include/hw/char/stm32f2xx_usart.h | 2 +- include/hw/char/stm32l4x5_usart.h | 2 +- include/hw/misc/ivshmem-flat.h | 2 +- include/hw/qdev-properties-system.h | 2 +- include/hw/qdev-properties.h | 2 +- include/hw/virtio/vhost-user-base.h | 2 +- include/hw/virtio/vhost-user-blk.h | 2 +- include/hw/virtio/vhost-user-fs.h | 2 +- include/hw/virtio/vhost-user-scmi.h | 2 +- include/hw/virtio/vhost-user-vsock.h | 2 +- include/hw/virtio/vhost-user.h | 8 +- include/hw/virtio/virtio-gpu.h | 2 +- include/hw/virtio/virtio-scsi.h | 2 +- include/qobject/qobject.h | 5 +- include/system/qtest.h | 4 +- include/system/vhost-user-backend.h | 2 +- monitor/monitor-internal.h | 2 +- target/i386/kvm/kvm_i386.h | 1 + accel/mshv/mshv-all.c | 3 + backends/cryptodev-vhost-user.c | 2 +- backends/rng-egd.c | 2 +- backends/tpm/tpm_emulator.c | 4 +- chardev/char-fe.c | 144 ++++++++++++------------- chardev/char-hub.c | 18 ++-- chardev/char-mux.c | 40 +++---- chardev/char.c | 44 ++++---- gdbstub/system.c | 2 +- hw/arm/strongarm.c | 2 +- hw/char/debugcon.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/char/ipoctal232.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/sclpconsole-lm.c | 2 +- hw/char/sclpconsole.c | 2 +- hw/char/sh_serial.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/terminal3270.c | 2 +- hw/char/virtio-console.c | 2 +- hw/char/xen_console.c | 2 +- hw/char/xilinx_uartlite.c | 2 +- hw/core/qdev-properties-system.c | 23 ++-- hw/core/qdev-properties.c | 9 +- hw/hppa/machine.c | 2 +- hw/i386/isapc.c | 55 ++++------ hw/i386/x86-common.c | 11 ++ hw/ipmi/ipmi_bmc_extern.c | 2 +- hw/mips/boston.c | 2 +- hw/mips/malta.c | 2 +- hw/misc/ivshmem-pci.c | 2 +- hw/ppc/spapr_rtas.c | 2 +- hw/riscv/riscv_hart.c | 2 +- hw/scsi/esp.c | 6 +- hw/scsi/scsi-bus.c | 13 +-- hw/usb/ccid-card-passthru.c | 2 +- hw/usb/dev-serial.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio/vhost-stub.c | 2 +- hw/virtio/vhost-user.c | 20 ++-- net/colo-compare.c | 10 +- net/filter-mirror.c | 4 +- net/passt.c | 2 +- net/slirp.c | 2 +- net/vhost-user.c | 2 +- semihosting/console.c | 6 +- system/qtest.c | 20 ++-- target/hppa/sys_helper.c | 12 +-- target/i386/hvf/x86hvf.c | 1 + target/i386/kvm/kvm.c | 7 ++ target/i386/mshv/mshv-cpu.c | 4 + target/i386/nvmm/nvmm-all.c | 1 + target/i386/whpx/whpx-all.c | 1 + target/riscv/kvm/kvm-cpu.c | 10 +- target/xtensa/xtensa-semi.c | 10 +- tests/qtest/am53c974-test.c | 40 +++++++ tests/qtest/vhost-user-test.c | 16 +-- tests/unit/test-char.c | 202 +++++++++++++++++------------------ tests/unit/test-yank.c | 12 +-- util/rcu.c | 81 +++++++++----- roms/opensbi | 2 +- rust/Cargo.toml | 10 -- rust/bindings/src/lib.rs | 4 +- rust/bql/src/bindings.rs | 4 +- rust/chardev/src/bindings.rs | 10 +- rust/chardev/src/chardev.rs | 26 ++--- rust/hw/char/pl011/src/bindings.rs | 2 +- rust/hw/char/pl011/src/device.rs | 12 +-- rust/hw/core/src/bindings.rs | 4 +- rust/hw/core/src/qdev.rs | 2 +- rust/hw/timer/hpet/src/device.rs | 2 +- rust/migration/src/bindings.rs | 2 +- rust/migration/src/vmstate.rs | 3 +- rust/qemu-macros/src/lib.rs | 23 +++- rust/qemu-macros/src/tests.rs | 15 ++- rust/qom/src/bindings.rs | 2 +- rust/qom/src/qom.rs | 3 +- rust/system/src/bindings.rs | 4 +- rust/util/src/bindings.rs | 2 +- scripts/meson-buildoptions.py | 51 +++++---- 122 files changed, 679 insertions(+), 573 deletions(-)
Signature · 1 line
2.51.1
[PULL 01/18] scripts: clean up meson-buildoptions.py
Fix a few issues reported by flake8 and pylint, mostly parameter names that shadow globals.
--- scripts/meson-buildoptions.py | 51 +++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 23 deletions(-)
scripts/meson-buildoptions.py +28 -23
@@ -111,13 +111,13 @@ def help_line(left, opt, indent, long): right = f'{opt["description"]}' if long: value = get_help(opt) - if value != "auto" and value != "": + if value not in {"", "auto"}: right += f" [{value}]" if "choices" in opt and long: choices = "/".join(sorted(opt["choices"])) right += f" (choices: {choices})" - for x in wrap(" " + left, right, indent): - sh_print(x) + for line in wrap(" " + left, right, indent): + sh_print(line) # Return whether the option (a dictionary) can be used with
@@ -144,18 +144,18 @@ def require_arg(opt): return not ({"enabled", "disabled"}.intersection(opt["choices"])) -def filter_options(json): - if ":" in json["name"]: +def filter_options(opt): + if ":" in opt["name"]: return False - if json["section"] == "user": - return json["name"] not in SKIP_OPTIONS + if opt["section"] == "user": + return opt["name"] not in SKIP_OPTIONS else: - return json["name"] in BUILTIN_OPTIONS + return opt["name"] in BUILTIN_OPTIONS -def load_options(json): - json = [x for x in json if filter_options(x)] - return sorted(json, key=lambda x: x["name"]) +def load_options(opts): + opts = [opt for opt in opts if filter_options(opt)] + return sorted(opts, key=lambda opt: opt["name"]) def cli_option(opt):
@@ -223,7 +223,7 @@ def print_parse(options): key = cli_option(opt) name = opt["name"] if require_arg(opt): - if opt["type"] == "array" and not "choices" in opt: + if opt["type"] == "array" and "choices" not in opt: print(f' --{key}=*) quote_sh "-D{name}=$(meson_option_build_array $2)" ;;') else: print(f' --{key}=*) quote_sh "-D{name}=$2" ;;')
@@ -241,14 +241,19 @@ def print_parse(options): print(" esac") print("}") -json_data = sys.stdin.read() -try: - options = load_options(json.loads(json_data)) -except: - print("Failure in scripts/meson-buildoptions.py parsing stdin as json", - file=sys.stderr) - print(json_data, file=sys.stderr) - sys.exit(1) -print("# This file is generated by meson-buildoptions.py, do not edit!") -print_help(options) -print_parse(options) + +def main(): + json_data = sys.stdin.read() + try: + options = load_options(json.loads(json_data)) + except: + print("Failure in scripts/meson-buildoptions.py parsing stdin as json", + file=sys.stderr) + print(json_data, file=sys.stderr) + sys.exit(1) + print("# This file is generated by meson-buildoptions.py, do not edit!") + print_help(options) + print_parse(options) + + +sys.exit(main())
Signature · 1 line
2.51.1
[PULL 07/18] char: rename CharBackend->CharFrontend
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
The actual backend is "Chardev", CharBackend is the frontend side of it (whatever talks to the backend), let's rename it for readability.
--- chardev/chardev-internal.h | 12 +- include/chardev/char-fe.h | 67 +++++---- include/chardev/char.h | 4 +- include/hw/char/avr_usart.h | 2 +- include/hw/char/bcm2835_aux.h | 2 +- include/hw/char/cadence_uart.h | 2 +- include/hw/char/cmsdk-apb-uart.h | 2 +- include/hw/char/digic-uart.h | 2 +- include/hw/char/escc.h | 2 +- include/hw/char/goldfish_tty.h | 2 +- include/hw/char/ibex_uart.h | 2 +- include/hw/char/imx_serial.h | 2 +- include/hw/char/max78000_uart.h | 2 +- include/hw/char/nrf51_uart.h | 2 +- include/hw/char/parallel.h | 2 +- include/hw/char/pl011.h | 2 +- include/hw/char/renesas_sci.h | 2 +- include/hw/char/riscv_htif.h | 2 +- include/hw/char/serial.h | 2 +- include/hw/char/shakti_uart.h | 2 +- include/hw/char/sifive_uart.h | 2 +- include/hw/char/stm32f2xx_usart.h | 2 +- include/hw/char/stm32l4x5_usart.h | 2 +- include/hw/misc/ivshmem-flat.h | 2 +- include/hw/qdev-properties-system.h | 2 +- include/hw/virtio/vhost-user-base.h | 2 +- include/hw/virtio/vhost-user-blk.h | 2 +- include/hw/virtio/vhost-user-fs.h | 2 +- include/hw/virtio/vhost-user-scmi.h | 2 +- include/hw/virtio/vhost-user-vsock.h | 2 +- include/hw/virtio/vhost-user.h | 8 +- include/hw/virtio/virtio-gpu.h | 2 +- include/hw/virtio/virtio-scsi.h | 2 +- include/system/qtest.h | 4 +- include/system/vhost-user-backend.h | 2 +- monitor/monitor-internal.h | 2 +- backends/cryptodev-vhost-user.c | 2 +- backends/rng-egd.c | 2 +- backends/tpm/tpm_emulator.c | 4 +- chardev/char-fe.c | 144 +++++++++---------- chardev/char-hub.c | 18 +-- chardev/char-mux.c | 40 +++--- chardev/char.c | 44 +++--- gdbstub/system.c | 2 +- hw/arm/strongarm.c | 2 +- hw/char/debugcon.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/char/ipoctal232.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/sclpconsole-lm.c | 2 +- hw/char/sclpconsole.c | 2 +- hw/char/sh_serial.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/terminal3270.c | 2 +- hw/char/virtio-console.c | 2 +- hw/char/xen_console.c | 2 +- hw/char/xilinx_uartlite.c | 2 +- hw/core/qdev-properties-system.c | 16 +-- hw/hppa/machine.c | 2 +- hw/ipmi/ipmi_bmc_extern.c | 2 +- hw/mips/boston.c | 2 +- hw/mips/malta.c | 2 +- hw/misc/ivshmem-pci.c | 2 +- hw/ppc/spapr_rtas.c | 2 +- hw/riscv/riscv_hart.c | 2 +- hw/usb/ccid-card-passthru.c | 2 +- hw/usb/dev-serial.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio/vhost-stub.c | 2 +- hw/virtio/vhost-user.c | 20 +-- net/colo-compare.c | 10 +- net/filter-mirror.c | 4 +- net/passt.c | 2 +- net/slirp.c | 2 +- net/vhost-user.c | 2 +- semihosting/console.c | 6 +- system/qtest.c | 20 +-- target/hppa/sys_helper.c | 12 +- target/riscv/kvm/kvm-cpu.c | 10 +- target/xtensa/xtensa-semi.c | 10 +- tests/qtest/vhost-user-test.c | 16 +-- tests/unit/test-char.c | 202 +++++++++++++-------------- tests/unit/test-yank.c | 12 +- rust/bindings/src/lib.rs | 4 +- rust/chardev/src/bindings.rs | 6 +- rust/chardev/src/chardev.rs | 26 ++-- rust/hw/char/pl011/src/device.rs | 12 +- rust/hw/core/src/qdev.rs | 2 +- 89 files changed, 428 insertions(+), 429 deletions(-)
chardev/chardev-internal.h +6 -6
@@ -37,9 +37,9 @@struct MuxChardev {Chardev parent;/* Linked frontends */ -CharBackend *backends[MAX_MUX ]; -/* Linked backend */ -CharBackend chr; +CharFrontend *frontends[MAX_MUX ]; +/* frontend of the underlying muxed chardev */ +CharFrontend chr;unsigned long mux_bitset;int focus;bool term_got_escape;
@@ -64,8 +64,8 @@ typedef struct HubCharBackend HubCharBackend;* `hub->backends` array */ struct HubCharBackend { -HubChardev *hub; -CharBackend be; +HubChardev *hub; +CharFrontend fe;unsigned int be_ind; };
@@ -108,7 +108,7 @@ DECLARE_INSTANCE_CHECKER(HubChardev, HUB_CHARDEV,#define CHARDEV_IS_HUB (chr) \ object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_HUB) -bool mux_chr_attach_frontend (MuxChardev *d,CharBackend *b, +bool mux_chr_attach_frontend (MuxChardev *d,CharFrontend *c,unsigned int *tag,Error **errp);bool mux_chr_detach_frontend (MuxChardev *d,unsigned int tag);void mux_set_focus (Chardev *chr,unsigned int focus);
include/chardev/char-fe.h +33 -34
219 lines not on this page · raw message
include/chardev/char.h +2 -2
@@ -15,7 +15,7 @@#define IAC 255/* character device */ -typedef struct CharBackend CharBackend ; +typedef struct CharFrontend CharFrontend ; typedef enum { CHR_EVENT_BREAK, /* serial break char */
@@ -60,7 +60,7 @@ struct Chardev {Object parent_obj;QemuMutex chr_write_lock; -CharBackend *be; +CharFrontend *fe;char *label;char *filename;int logfd;
include/hw/char/avr_usart.h +1 -1
@@ -66,7 +66,7 @@ struct AVRUsartState {/* <public> */ MemoryRegion mmio; -CharBackend chr; +CharFrontend chr;bool enabled;
include/hw/char/bcm2835_aux.h +1 -1
@@ -24,7 +24,7 @@ struct BCM2835AuxState {/*< public >*/ MemoryRegion iomem; -CharBackend chr; +CharFrontend chr;qemu_irq irq;uint8_t read_fifo[BCM2835_AUX_RX_FIFO_LEN ];
include/hw/char/cadence_uart.h +1 -1
@@ -47,7 +47,7 @@ struct CadenceUARTState {uint32_t rx_count;uint32_t tx_count;uint64_t char_tx_time; -CharBackend chr; +CharFrontend chr;qemu_irq irq;QEMUTimer *fifo_trigger_handle;Clock *refclk;
include/hw/char/cmsdk-apb-uart.h +1 -1
@@ -25,7 +25,7 @@ struct CMSDKAPBUART {/*< public >*/ MemoryRegion iomem; -CharBackend chr; +CharFrontend chr;qemu_irq txint;qemu_irq rxint;qemu_irq txovrint;
include/hw/char/digic-uart.h +1 -1
@@ -38,7 +38,7 @@ struct DigicUartState {/*< public >*/ MemoryRegion regs_region; -CharBackend chr; +CharFrontend chr;uint32_t reg_rx;uint32_t reg_st;
include/hw/char/escc.h +1 -1
@@ -36,7 +36,7 @@ typedef struct ESCCChannelState {uint32_t reg;uint8_t wregs[ESCC_SERIAL_REGS ], rregs[ESCC_SERIAL_REGS ];ESCCSERIOQueue queue; -CharBackend chr; +CharFrontend chr;int e0_mode, led_mode, caps_lock_mode, num_lock_mode;int disabled;int clock;
include/hw/char/goldfish_tty.h +1 -1
@@ -24,7 +24,7 @@ struct GoldfishTTYState {MemoryRegion iomem;qemu_irq irq; -CharBackend chr; +CharFrontend chr;uint32_t data_len;uint64_t data_ptr;
include/hw/char/ibex_uart.h +1 -1
@@ -64,7 +64,7 @@ struct IbexUartState {Clock *f_clk; -CharBackend chr; +CharFrontend chr;qemu_irq tx_watermark;qemu_irq rx_watermark;qemu_irq tx_empty;
include/hw/char/imx_serial.h +1 -1
@@ -122,7 +122,7 @@ struct IMXSerialState {uint32_t ucr4;qemu_irq irq; - CharBackend chr; + CharFrontend chr; };#endif
include/hw/char/max78000_uart.h +1 -1
@@ -72,7 +72,7 @@ struct Max78000UartState {Fifo8 rx_fifo; -CharBackend chr; +CharFrontend chr; qemu_irq irq; };#endif /* HW_STM32F2XX_USART_H */
include/hw/char/nrf51_uart.h +1 -1
@@ -59,7 +59,7 @@ struct NRF51UARTState {SysBusDevice parent_obj;MemoryRegion iomem; -CharBackend chr; +CharFrontend chr;qemu_irq irq;guint watch_tag;
include/hw/char/parallel.h +1 -1
@@ -15,7 +15,7 @@ typedef struct ParallelState {uint8_t control;qemu_irq irq;int irq_pending; -CharBackend chr; +CharFrontend chr;int hw_driver;int epp_timeout;uint32_t last_read_offset;/* For debugging */
include/hw/char/pl011.h +1 -1
@@ -47,7 +47,7 @@ struct PL011State {int read_pos;int read_count;int read_trigger; -CharBackend chr; +CharFrontend chr;qemu_irq irq[6 ];Clock *clk;bool migrate_clk;
include/hw/char/renesas_sci.h +1 -1
@@ -33,7 +33,7 @@ struct RSCIState {MemoryRegion memory;QEMUTimer timer; -CharBackend chr; +CharFrontend chr;qemu_irq irq[SCI_NR_IRQ ];uint8_t smr;
include/hw/char/riscv_htif.h +1 -1
@@ -36,7 +36,7 @@ typedef struct HTIFState {hwaddr fromhost_offset;MemoryRegion mmio; -CharBackend chr; +CharFrontend chr;uint64_t pending_read; } HTIFState;
include/hw/char/serial.h +1 -1
@@ -54,7 +54,7 @@ struct SerialState {it can be reset while reading iir */ int thr_ipending;qemu_irq irq; -CharBackend chr; +CharFrontend chr;int last_break_enable;uint32_t baudbase;uint32_t tsr_retry;
include/hw/char/shakti_uart.h +1 -1
@@ -68,7 +68,7 @@ typedef struct {uint32_t uart_iq_cycles;uint32_t uart_rx_threshold; - CharBackend chr; + CharFrontend chr; } ShaktiUartState;#endif /* HW_SHAKTI_UART_H */
include/hw/char/sifive_uart.h +1 -1
@@ -67,7 +67,7 @@ struct SiFiveUARTState {/*< public >*/ qemu_irq irq;MemoryRegion mmio; -CharBackend chr; +CharFrontend chr;uint32_t txfifo;uint32_t ie;
include/hw/char/stm32f2xx_usart.h +1 -1
@@ -73,7 +73,7 @@ struct STM32F2XXUsartState {uint32_t usart_cr3;uint32_t usart_gtpr; -CharBackend chr; +CharFrontend chr; qemu_irq irq; };#endif /* HW_STM32F2XX_USART_H */
include/hw/char/stm32l4x5_usart.h +1 -1
@@ -53,7 +53,7 @@ struct Stm32l4x5UsartBaseState {uint32_t tdr;Clock *clk; -CharBackend chr; +CharFrontend chr;qemu_irq irq;guint watch_tag; };
include/hw/misc/ivshmem-flat.h +1 -1
@@ -65,7 +65,7 @@ struct IvshmemFTState { QTAILQ_HEAD(, IvshmemPeer) peer;IvshmemPeer own; -CharBackend server_chr; +CharFrontend server_chr;/* IRQ */ qemu_irq irq;
include/hw/qdev-properties-system.h +1 -1
@@ -38,7 +38,7 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_list; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)#define DEFINE_PROP_CHR (_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend) + DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharFrontend)#define DEFINE_PROP_NETDEV (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers)#define DEFINE_PROP_DRIVE (_n, _s, _f) \
include/hw/virtio/vhost-user-base.h +1 -1
@@ -20,7 +20,7 @@ struct VHostUserBase {VirtIODevice parent_obj;/* Properties */ -CharBackend chardev; +CharFrontend chardev;uint16_t virtio_id;uint32_t num_vqs;uint32_t vq_size;/* can't exceed VIRTIO_QUEUE_MAX */
include/hw/virtio/vhost-user-blk.h +1 -1
@@ -29,7 +29,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK)struct VHostUserBlk {VirtIODevice parent_obj; -CharBackend chardev; +CharFrontend chardev;int32_t bootindex;struct virtio_blk_config blkcfg;uint16_t num_queues;
include/hw/virtio/vhost-user-fs.h +1 -1
@@ -24,7 +24,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFS, VHOST_USER_FS) typedef struct { - CharBackend chardev; + CharFrontend chardev; char *tag; uint16_t num_request_queues; uint16_t queue_size;
include/hw/virtio/vhost-user-scmi.h +1 -1
@@ -18,7 +18,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);struct VHostUserSCMI {VirtIODevice parent; -CharBackend chardev; +CharFrontend chardev;struct vhost_virtqueue *vhost_vqs;struct vhost_dev vhost_dev;VhostUserState vhost_user;
include/hw/virtio/vhost-user-vsock.h +1 -1
@@ -20,7 +20,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSOCK)typedef struct { -CharBackend chardev; +CharFrontend chardev; }VHostUserVSockConf ;struct VHostUserVSock {
include/hw/virtio/vhost-user.h +4 -4
@@ -64,7 +64,7 @@ typedef struct VhostUserHostNotifier {* @memory_slots: */ typedef struct VhostUserState { - CharBackend *chr; + CharFrontend *chr; GPtrArray *notifiers; int memory_slots; bool supports_config;
@@ -82,7 +82,7 @@ typedef struct VhostUserState {* * Return: true on success, false on error while setting errp. */ -bool vhost_user_init (VhostUserState *user,CharBackend *chr,Error **errp); +bool vhost_user_init (VhostUserState *user,CharFrontend *chr,Error **errp);/** * vhost_user_cleanup() - cleanup state
@@ -96,7 +96,7 @@ void vhost_user_cleanup(VhostUserState *user);/** * vhost_user_async_close() - cleanup vhost-user post connection drop * @d: DeviceState for the associated device (passed to callback) -* @chardev: the CharBackend associated with the connection +* @chardev: the CharFrontend associated with the connection * @vhost: the common vhost device * @cb: the user callback function to complete the clean-up *
@@ -108,7 +108,7 @@ void vhost_user_cleanup(VhostUserState *user);typedef void (*vu_async_close_fn )(DeviceState *cb);void vhost_user_async_close (DeviceState *d, -CharBackend *chardev,struct vhost_dev *vhost, +CharFrontend *chardev,struct vhost_dev *vhost,vu_async_close_fn cb);#endif
include/hw/virtio/virtio-gpu.h +1 -1
@@ -257,7 +257,7 @@ struct VhostUserGPU {VhostUserBackend *vhost;int vhost_gpu_fd;/* closed by the chardev */ -CharBackend vhost_chr; +CharFrontend vhost_chr;QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS ];bool backend_blocked; };
include/hw/virtio/virtio-scsi.h +1 -1
@@ -58,7 +58,7 @@ struct VirtIOSCSIConf {uint32_t cmd_per_lun;char *vhostfd;char *wwpn; -CharBackend chardev; +CharFrontend chardev;uint32_t boot_tpgt;IOThread *iothread;IOThreadVirtQueueMappingList *iothread_vq_mapping_list;
include/system/qtest.h +2 -2
@@ -23,8 +23,8 @@ static inline bool qtest_enabled(void)return qtest_allowed; } -void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...); -void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)); +void G_GNUC_PRINTF(2, 3) qtest_sendf(CharFrontend *chr, const char *fmt, ...); +void qtest_set_command_cb(bool (*pc_cb)(CharFrontend *chr, gchar **words));bool qtest_driver (void );void qtest_server_init (const char *qtest_chrdev,const char *qtest_log,Error **errp);
include/system/vhost-user-backend.h +1 -1
@@ -32,7 +32,7 @@ struct VhostUserBackend {Object parent;char *chr_name; -CharBackend chr; +CharFrontend chr;VhostUserState vhost_user;struct vhost_dev dev;VirtIODevice *vdev;
monitor/monitor-internal.h +1 -1
@@ -93,7 +93,7 @@ typedef struct HMPCommand { } HMPCommand;struct Monitor { -CharBackend chr; +CharFrontend chr;int suspend_cnt;/* Needs to be accessed atomically */ bool is_qmp;bool skip_flush;
backends/cryptodev-vhost-user.c +1 -1
@@ -46,7 +46,7 @@ struct CryptoDevBackendVhostUser {CryptoDevBackend parent_obj;VhostUserState vhost_user; -CharBackend chr; +CharFrontend chr;char *chr_name;bool opened;CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM ];
backends/rng-egd.c +1 -1
@@ -24,7 +24,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(RngEgd, RNG_EGD)struct RngEgd {RngBackend parent; -CharBackend chr; +CharFrontend chr;char *chr_name; };
backends/tpm/tpm_emulator.c +2 -2
@@ -69,7 +69,7 @@ struct TPMEmulator {TPMBackend parent;TPMEmulatorOptions *options; -CharBackend ctrl_chr; +CharFrontend ctrl_chr;QIOChannel *data_ioc;TPMVersion tpm_version;uint32_t caps;/* capabilities of the TPM */
@@ -126,7 +126,7 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsigned long cmd, void *msg, size_t msg_len_in, size_t msg_len_out_err, size_t msg_len_out_total) { - CharBackend *dev = &tpm->ctrl_chr; + CharFrontend *dev = &tpm->ctrl_chr;uint32_t cmd_no =cpu_to_be32 (cmd);ssize_t n =sizeof (uint32_t ) + msg_len_in;ptm_res res;
chardev/char-fe.c +72 -72
335 lines not on this page · raw message
chardev/char-hub.c +9 -9
@@ -54,7 +54,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len) d->be_eagain_ind =-1 ;for (i =0 ; i < d->be_cnt; i++) { -if (!d->backends[i].be.chr->be_open) { +if (!d->backends[i].fe.chr->be_open) {/* Skip closed backend */ continue ; }
@@ -64,7 +64,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len) ret =MIN (written, ret);continue ; } - r =qemu_chr_fe_write (&d->backends[i].be, buf, len); + r =qemu_chr_fe_write (&d->backends[i].fe, buf, len);if (r <0 ) {if (errno ==EAGAIN ) {/* Set index and expect to be called soon on watch wake up */
@@ -84,7 +84,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)static int hub_chr_can_read (void *opaque) {HubCharBackend *backend = opaque; -CharBackend *fe = backend->hub->parent.be; +CharFrontend *fe = backend->hub->parent.fe;if (fe && fe->chr_can_read) {return fe->chr_can_read (fe->opaque);
@@ -96,7 +96,7 @@ static int hub_chr_can_read(void *opaque)static void hub_chr_read (void *opaque,const uint8_t *buf,int size) {HubCharBackend *backend = opaque; -CharBackend *fe = backend->hub->parent.be; +CharFrontend *fe = backend->hub->parent.fe;if (fe && fe->chr_read) { fe->chr_read (fe->opaque, buf, size);
@@ -107,7 +107,7 @@ static void hub_chr_event(void *opaque, QEMUChrEvent event) {HubCharBackend *backend = opaque;HubChardev *d = backend->hub; -CharBackend *fe = d->parent.be; +CharFrontend *fe = d->parent.fe;if (event ==CHR_EVENT_OPENED ) {/*
@@ -147,7 +147,7 @@ static GSource *hub_chr_add_watch(Chardev *s, GIOCondition cond) }assert (d->be_eagain_ind < d->be_cnt); - chr =qemu_chr_fe_get_driver (&d->backends[d->be_eagain_ind].be); + chr =qemu_chr_fe_get_driver (&d->backends[d->be_eagain_ind].fe); cc =CHARDEV_GET_CLASS (chr);if (!cc->chr_add_watch) {return NULL ;
@@ -167,7 +167,7 @@ static bool hub_chr_attach_chardev(HubChardev *d, Chardev *chr, d->parent.label);return false; } - ret =qemu_chr_fe_init (&d->backends[d->be_cnt].be, chr, errp); + ret =qemu_chr_fe_init (&d->backends[d->be_cnt].fe, chr, errp);if (ret) { d->backends[d->be_cnt].hub = d; d->backends[d->be_cnt].be_ind = d->be_cnt;
@@ -183,7 +183,7 @@ static void char_hub_finalize(Object *obj)int i;for (i =0 ; i < d->be_cnt; i++) { -qemu_chr_fe_deinit (&d->backends[i].be, false); +qemu_chr_fe_deinit (&d->backends[i].fe, false); } }
@@ -193,7 +193,7 @@ static void hub_chr_update_read_handlers(Chardev *chr)int i;for (i =0 ; i < d->be_cnt; i++) { - qemu_chr_fe_set_handlers_full(&d->backends[i].be, + qemu_chr_fe_set_handlers_full(&d->backends[i].fe, hub_chr_can_read, hub_chr_read, hub_chr_event,
chardev/char-mux.c +20 -20
@@ -128,10 +128,10 @@ static void mux_print_help(Chardev *chr)static void mux_chr_send_event (MuxChardev *d,unsigned int mux_nr,QEMUChrEvent event) { -CharBackend *be = d->backends[mux_nr]; +CharFrontend *fe = d->frontends[mux_nr]; -if (be && be->chr_event) { - be->chr_event (be->opaque, event); +if (fe && fe->chr_event) { + fe->chr_event (fe->opaque, event); } }
@@ -200,11 +200,11 @@ static void mux_chr_accept_input(Chardev *chr) {MuxChardev *d =MUX_CHARDEV (chr);int m = d->focus; -CharBackend *be = d->backends[m]; +CharFrontend *fe = d->frontends[m]; -while (be && d->prod[m] != d->cons[m] && - be->chr_can_read && be->chr_can_read (be->opaque)) { - be->chr_read (be->opaque, +while (fe && d->prod[m] != d->cons[m] && + fe->chr_can_read && fe->chr_can_read (fe->opaque)) { + fe->chr_read (fe->opaque, &d->buffer[m][d->cons[m]++ &MUX_BUFFER_MASK ],1 ); } }
@@ -213,14 +213,14 @@ static int mux_chr_can_read(void *opaque) {MuxChardev *d =MUX_CHARDEV (opaque);int m = d->focus; -CharBackend *be = d->backends[m]; +CharFrontend *fe = d->frontends[m];if ((d->prod[m] - d->cons[m]) <MUX_BUFFER_SIZE ) {return 1 ; } -if (be && be->chr_can_read) { -return be->chr_can_read (be->opaque); +if (fe && fe->chr_can_read) { +return fe->chr_can_read (fe->opaque); }return 0 ;
@@ -231,7 +231,7 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)Chardev *chr =CHARDEV (opaque);MuxChardev *d =MUX_CHARDEV (opaque);int m = d->focus; -CharBackend *be = d->backends[m]; +CharFrontend *fe = d->frontends[m];int i;mux_chr_accept_input (opaque);
@@ -239,9 +239,9 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size)for (i =0 ; i < size; i++)if (mux_proc_byte (chr, d, buf[i])) {if (d->prod[m] == d->cons[m] && - be && be->chr_can_read && - be->chr_can_read (be->opaque)) { - be->chr_read (be->opaque, &buf[i],1 ); + fe && fe->chr_can_read && + fe->chr_can_read (fe->opaque)) { + fe->chr_read (fe->opaque, &buf[i],1 ); }else { d->buffer[m][d->prod[m]++ &MUX_BUFFER_MASK ] = buf[i]; }
@@ -289,9 +289,9 @@ static void char_mux_finalize(Object *obj) bit =-1 ;while ((bit =find_next_bit (&d->mux_bitset,MAX_MUX , bit +1 )) <MAX_MUX ) { -CharBackend *be = d->backends[bit]; +CharFrontend *be = d->frontends[bit]; be->chr =NULL ; - d->backends[bit] =NULL ; + d->frontends[bit] =NULL ; } d->mux_bitset =0 ;qemu_chr_fe_deinit (&d->chr, false);
@@ -311,7 +311,7 @@ static void mux_chr_update_read_handlers(Chardev *chr) chr->gcontext, true, false); } -bool mux_chr_attach_frontend (MuxChardev *d,CharBackend *b, +bool mux_chr_attach_frontend (MuxChardev *d,CharFrontend *c,unsigned int *tag,Error **errp) {unsigned int bit;
@@ -328,7 +328,7 @@ bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b, } d->mux_bitset |= (1ul << bit); - d->backends[bit] = b; + d->frontends[bit] = c; *tag = bit;return true;
@@ -341,7 +341,7 @@ bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag) } d->mux_bitset &= ~(1ul << tag); - d->backends[tag] =NULL ; + d->frontends[tag] =NULL ;return true; }
@@ -357,7 +357,7 @@ void mux_set_focus(Chardev *chr, unsigned int focus) } d->focus = focus; - chr->be = d->backends[focus]; + chr->fe = d->frontends[focus];mux_chr_send_event (d, d->focus,CHR_EVENT_MUX_IN ); }
chardev/char.c +22 -22
112 lines not on this page · raw message
gdbstub/system.c +1 -1
@@ -34,7 +34,7 @@/* System emulation specific state */ typedef struct { -CharBackend chr; +CharFrontend chr;Chardev *mon_chr; }GDBSystemState ;
hw/arm/strongarm.c +1 -1
@@ -927,7 +927,7 @@ struct StrongARMUARTState {SysBusDevice parent_obj;MemoryRegion iomem; -CharBackend chr; +CharFrontend chr;qemu_irq irq;uint8_t utcr0;
hw/char/debugcon.c +1 -1
@@ -40,7 +40,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(ISADebugconState, ISA_DEBUGCON_DEVICE)typedef struct DebugconState {MemoryRegion io; -CharBackend chr; +CharFrontend chr;uint32_t readback; }DebugconState ;
hw/char/exynos4210_uart.c +1 -1
@@ -154,7 +154,7 @@ struct Exynos4210UartState {QEMUTimer *fifo_timeout_timer;uint64_t wordtime;/* word time in ns */ -CharBackend chr; +CharFrontend chr;qemu_irq irq;qemu_irq dmairq;
hw/char/grlib_apbuart.c +1 -1
@@ -84,7 +84,7 @@ struct UART {MemoryRegion iomem;qemu_irq irq; -CharBackend chr; +CharFrontend chr;/* registers */ uint32_t status;
hw/char/ipoctal232.c +1 -1
@@ -99,7 +99,7 @@ typedef struct SCC2698Block SCC2698Block;struct SCC2698Channel {IPOctalState *ipoctal; -CharBackend dev; +CharFrontend dev;bool rx_enabled;uint8_t mr[2 ];uint8_t mr_idx;
hw/char/mcf_uart.c +1 -1
@@ -36,7 +36,7 @@ struct mcf_uart_state {int tx_enabled;int rx_enabled;qemu_irq irq; -CharBackend chr; +CharFrontend chr; };#define TYPE_MCF_UART "mcf-uart"
hw/char/sclpconsole-lm.c +1 -1
@@ -41,7 +41,7 @@ typedef struct OprtnsCommand {struct SCLPConsoleLM {SCLPEvent event; -CharBackend chr; +CharFrontend chr;bool echo;/* immediate echo of input if true */ uint32_t write_errors;/* errors writing to char layer */ uint32_t length;/* length of byte stream in buffer */
hw/char/sclpconsole.c +1 -1
@@ -35,7 +35,7 @@ typedef struct ASCIIConsoleData {struct SCLPConsole {SCLPEvent event; -CharBackend chr; +CharFrontend chr;uint8_t iov[SIZE_BUFFER_VT220 ];uint32_t iov_sclp;/* offset in buf for SCLP read operation */ uint32_t iov_bs;/* offset in buf for char layer read operation */
hw/char/sh_serial.c +1 -1
@@ -67,7 +67,7 @@ struct SHSerialState {int flags;int rtrg; -CharBackend chr; +CharFrontend chr;QEMUTimer fifo_timeout_timer;uint64_t etu;/* Elementary Time Unit (ns) */
hw/char/spapr_vty.c +1 -1
@@ -14,7 +14,7 @@struct SpaprVioVty {SpaprVioDevice sdev; -CharBackend chardev; +CharFrontend chardev;uint32_t in, out;uint8_t buf[VTERM_BUFSIZE ]; };
hw/char/terminal3270.c +1 -1
@@ -30,7 +30,7 @@struct Terminal3270 {EmulatedCcw3270Device cdev; -CharBackend chr; +CharFrontend chr;uint8_t inv[INPUT_BUFFER_SIZE ];uint8_t outv[OUTPUT_BUFFER_SIZE ];int in_len;
hw/char/virtio-console.c +1 -1
@@ -30,7 +30,7 @@ DECLARE_INSTANCE_CHECKER(VirtConsole, VIRTIO_CONSOLE,struct VirtConsole {VirtIOSerialPort parent_obj; -CharBackend chr; +CharFrontend chr;guint watch; };
hw/char/xen_console.c +1 -1
@@ -53,7 +53,7 @@ struct XenConsole {char *fe_path;unsigned int ring_ref;void *sring; -CharBackend chr; +CharFrontend chr;int backlog; };typedef struct XenConsole XenConsole ;
hw/char/xilinx_uartlite.c +1 -1
@@ -60,7 +60,7 @@ struct XilinxUARTLite {EndianMode model_endianness;MemoryRegion mmio; -CharBackend chr; +CharFrontend chr;qemu_irq irq;uint8_t rx_fifo[8 ];
hw/core/qdev-properties-system.c +8 -8
@@ -258,10 +258,10 @@ const PropertyInfo qdev_prop_drive_iothread = {static void get_chr (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { -CharBackend *be =object_field_prop_ptr (obj, opaque); +CharFrontend *fe =object_field_prop_ptr (obj, opaque);char *p; - p =g_strdup (be->chr && be->chr->label ? be->chr->label :"" ); + p =g_strdup (fe->chr && fe->chr->label ? fe->chr->label :"" );visit_type_str (v, name, &p, errp);g_free (p); }
@@ -271,7 +271,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, {ERRP_GUARD ();const Property *prop = opaque; -CharBackend *be =object_field_prop_ptr (obj, prop); +CharFrontend *fe =object_field_prop_ptr (obj, prop);Chardev *s;char *str;
@@ -283,13 +283,13 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,* TODO Should this really be an error? If no, the old value * needs to be released before we store the new one. */ -if (!check_prop_still_unset (obj, name, be->chr, str, false, errp)) { +if (!check_prop_still_unset (obj, name, fe->chr, str, false, errp)) {return ; }if (!*str) {g_free (str); - be->chr =NULL ; + fe->chr =NULL ;return ; }
@@ -297,7 +297,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,if (s ==NULL ) {error_setg (errp,"Property '%s.%s' can't find value '%s'" ,object_get_typename (obj), name, str); - }else if (!qemu_chr_fe_init (be, s, errp)) { + }else if (!qemu_chr_fe_init (fe, s, errp)) {error_prepend (errp,"Property '%s.%s' can't take value '%s': " ,object_get_typename (obj), name, str); }
@@ -307,9 +307,9 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,static void release_chr (Object *obj,const char *name,void *opaque) {const Property *prop = opaque; -CharBackend *be =object_field_prop_ptr (obj, prop); +CharFrontend *fe =object_field_prop_ptr (obj, prop); -qemu_chr_fe_deinit (be, false); +qemu_chr_fe_deinit (fe, false); }const PropertyInfo qdev_prop_chr = {
hw/hppa/machine.c +1 -1
@@ -149,7 +149,7 @@ static void io_cpu_write(void *opaque, hwaddr addr, ch = val; debugout =serial_hd (0 );if (debugout) { -qemu_chr_fe_write_all (debugout->be, &ch,1 ); +qemu_chr_fe_write_all (debugout->fe, &ch,1 ); }else {fprintf (stderr,"%c" , ch); }
hw/ipmi/ipmi_bmc_extern.c +1 -1
@@ -67,7 +67,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(IPMIBmcExtern, IPMI_BMC_EXTERN)struct IPMIBmcExtern {IPMIBmc parent; -CharBackend chr; +CharFrontend chr;bool connected;
hw/mips/boston.c +1 -1
@@ -68,7 +68,7 @@ struct BostonState {SerialMM *uart;Clock *cpuclk; -CharBackend lcd_display; +CharFrontend lcd_display;char lcd_content[8 ];bool lcd_inited;
hw/mips/malta.c +1 -1
@@ -89,7 +89,7 @@ typedef struct {uint32_t i2coe;uint32_t i2cout;uint32_t i2csel; -CharBackend display; +CharFrontend display;char display_text[9 ];SerialMM *uart;bool display_inited;
hw/misc/ivshmem-pci.c +1 -1
@@ -94,7 +94,7 @@ struct IVShmemState {/* exactly one of these two may be set */ HostMemoryBackend *hostmem;/* with interrupts */ -CharBackend server_chr;/* without interrupts */ +CharFrontend server_chr;/* without interrupts */ /* registers */ uint32_t intrmask;
hw/ppc/spapr_rtas.c +1 -1
@@ -623,7 +623,7 @@ static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,return H_PARAMETER ; } -static bool spapr_qtest_callback (CharBackend *chr,gchar **words) +static bool spapr_qtest_callback (CharFrontend *chr,gchar **words) {if (strcmp (words[0 ],"rtas" ) ==0 ) {uint64_t res, args, ret;
hw/riscv/riscv_hart.c +1 -1
@@ -78,7 +78,7 @@ static void csr_call(char *cmd, uint64_t cpu_num, int csrno, uint64_t *val)g_assert (ret ==RISCV_EXCP_NONE ); } -static bool csr_qtest_callback (CharBackend *chr,gchar **words) +static bool csr_qtest_callback (CharFrontend *chr,gchar **words) {if (strcmp (words[0 ],"csr" ) ==0 ) {
hw/usb/ccid-card-passthru.c +1 -1
@@ -56,7 +56,7 @@ typedef struct PassthruState PassthruState;struct PassthruState {CCIDCardState base; -CharBackend cs; +CharFrontend cs;uint8_t vscard_in_data[VSCARD_IN_SIZE ];uint32_t vscard_in_pos;uint32_t vscard_in_hdr;
hw/usb/dev-serial.c +1 -1
@@ -105,7 +105,7 @@ struct USBSerialState {uint8_t xoff;QEMUSerialSetParams params;int latency;/* ms */ -CharBackend cs; +CharFrontend cs; };#define TYPE_USB_SERIAL "usb-serial-dev"
hw/usb/redirect.c +1 -1
@@ -113,7 +113,7 @@ struct PacketIdQueue {struct USBRedirDevice {USBDevice dev;/* Properties */ -CharBackend cs; +CharFrontend cs;bool enable_streams;bool suppress_remote_wake;bool in_write;
hw/virtio/vhost-stub.c +1 -1
@@ -12,7 +12,7 @@ unsigned int vhost_get_free_memslots(void)return UINT_MAX ; } -bool vhost_user_init (VhostUserState *user,CharBackend *chr,Error **errp) +bool vhost_user_init (VhostUserState *user,CharFrontend *chr,Error **errp) {return false; }
hw/virtio/vhost-user.c +10 -10
@@ -275,7 +275,7 @@ struct scrub_regions {static int vhost_user_read_header (struct vhost_dev *dev,VhostUserMsg *msg) {struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;uint8_t *p = (uint8_t *) msg;int r, size =VHOST_USER_HDR_SIZE ;
@@ -303,7 +303,7 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)static int vhost_user_read (struct vhost_dev *dev,VhostUserMsg *msg) {struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;uint8_t *p = (uint8_t *) msg;int r, size;
@@ -383,7 +383,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, int *fds, int fd_num) {struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;int ret, size =VHOST_USER_HDR_SIZE + msg->hdr.size;/*
@@ -1680,7 +1680,7 @@ int vhost_user_get_shared_object(struct vhost_dev *dev, unsigned char *uuid, int *dmabuf_fd) {struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;int ret;VhostUserMsg msg = { .hdr.request =VHOST_USER_GET_SHARED_OBJECT ,
@@ -1721,7 +1721,7 @@ vhost_user_backend_handle_shared_object_lookup(struct vhost_user *u, VhostUserPayload *payload) {QemuUUID uuid; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;Error *local_err =NULL ;int dmabuf_fd =-1 ;int fd_num =0 ;
@@ -2004,7 +2004,7 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp) {#ifdef CONFIG_LINUX struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;int ufd;int ret; VhostUserMsg msg = {
@@ -2670,7 +2670,7 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev,int fd;int ret;struct vhost_user *u = dev->opaque; -CharBackend *chr = u->user->chr; +CharFrontend *chr = u->user->chr;VhostUserMsg msg = { .hdr.request =VHOST_USER_GET_INFLIGHT_FD , .hdr.flags =VHOST_USER_VERSION ,
@@ -2761,7 +2761,7 @@ static void vhost_user_state_destroy(gpointer data)vhost_user_host_notifier_remove (n,NULL , true); } -bool vhost_user_init (VhostUserState *user,CharBackend *chr,Error **errp) +bool vhost_user_init (VhostUserState *user,CharFrontend *chr,Error **errp) {if (user->chr) {error_setg (errp,"Cannot initialize vhost-user state" );
@@ -2787,7 +2787,7 @@ void vhost_user_cleanup(VhostUserState *user)typedef struct {vu_async_close_fn cb;DeviceState *dev; -CharBackend *cd; +CharFrontend *cd;struct vhost_dev *vhost; }VhostAsyncCallback ;
@@ -2806,7 +2806,7 @@ static void vhost_user_async_close_bh(void *opaque)* purposes. */ void vhost_user_async_close (DeviceState *d, -CharBackend *chardev,struct vhost_dev *vhost, +CharFrontend *chardev,struct vhost_dev *vhost,vu_async_close_fn cb) {if (!runstate_check (RUN_STATE_SHUTDOWN )) {
net/colo-compare.c +5 -5
@@ -88,7 +88,7 @@ static uint32_t max_queue_size; typedef struct SendCo { Coroutine *co; struct CompareState *s; - CharBackend *chr; + CharFrontend *chr; GQueue send_list; bool notify_remote_frame; bool done;
@@ -108,10 +108,10 @@ struct CompareState {char *sec_indev;char *outdev;char *notify_dev; -CharBackend chr_pri_in; -CharBackend chr_sec_in; -CharBackend chr_out; -CharBackend chr_notify_dev; +CharFrontend chr_pri_in; +CharFrontend chr_sec_in; +CharFrontend chr_out; +CharFrontend chr_notify_dev;SocketReadState pri_rs;SocketReadState sec_rs;SocketReadState notify_rs;
net/filter-mirror.c +2 -2
@@ -37,8 +37,8 @@ struct MirrorState {NetFilterState parent_obj;char *indev;char *outdev; -CharBackend chr_in; -CharBackend chr_out; +CharFrontend chr_in; +CharFrontend chr_out;SocketReadState rs;bool vnet_hdr; };
net/passt.c +1 -1
@@ -71,7 +71,7 @@ typedef struct NetPasstState {/* vhost user */ VhostUserState *vhost_user;VHostNetState *vhost_net; -CharBackend vhost_chr; +CharFrontend vhost_chr;guint vhost_watch;uint64_t acked_features;bool started;
net/slirp.c +1 -1
@@ -80,7 +80,7 @@ struct slirp_config_str { };struct GuestFwd { -CharBackend hd; +CharFrontend hd;struct in_addr server;int port;Slirp *slirp;
net/vhost-user.c +1 -1
@@ -65,7 +65,7 @@ static const int user_feature_bits[] = { typedef struct NetVhostUserState { NetClientState nc; - CharBackend chr; /* only queue index 0 */ + CharFrontend chr; /* only queue index 0 */ VhostUserState *vhost_user; VHostNetState *vhost_net; guint watch;
semihosting/console.c +3 -3
@@ -30,7 +30,7 @@/* Access to this structure is protected by the BQL */ typedef struct SemihostingConsole { - CharBackend backend; + CharFrontend frontend; Chardev *chr; GSList *sleeping_cpus; bool got;
@@ -122,8 +122,8 @@ void qemu_semihosting_console_init(Chardev *chr) console.chr = chr;if (chr) {fifo8_create (&console.fifo,FIFO_SIZE ); -qemu_chr_fe_init (&console.backend, chr, &error_abort); - qemu_chr_fe_set_handlers(&console.backend, +qemu_chr_fe_init (&console.frontend, chr, &error_abort); + qemu_chr_fe_set_handlers(&console.frontend, console_can_read, console_read, NULL, NULL, &console,
system/qtest.c +10 -10
@@ -44,7 +44,7 @@ struct QTest {bool has_machine_link;char *chr_name;Chardev *chr; -CharBackend qtest_chr; +CharFrontend qtest_chr;char *log; };
@@ -293,20 +293,20 @@ static void G_GNUC_PRINTF(1, 2) qtest_log_send(const char *fmt, ...)static void qtest_server_char_be_send (void *opaque,const char *str) {size_t len =strlen (str); -CharBackend * chr = (CharBackend *)opaque; +CharFrontend * chr = (CharFrontend *)opaque;qemu_chr_fe_write_all (chr, (uint8_t *)str, len);if (qtest_log_fp && qtest_opened) {fprintf (qtest_log_fp,"%s" , str); } } -static void qtest_send (CharBackend *chr,const char *str) +static void qtest_send (CharFrontend *chr,const char *str) {qtest_log_timestamp ();qtest_server_send (qtest_server_send_opaque, str); } -void qtest_sendf (CharBackend *chr,const char *fmt, ...) +void qtest_sendf (CharFrontend *chr,const char *fmt, ...) {va_list ap;gchar *buffer;
@@ -324,16 +324,16 @@ static void qtest_irq_handler(void *opaque, int n, int level)qemu_set_irq (old_irq, level);if (irq_levels[n] != level) { -CharBackend *chr = &qtest->qtest_chr; +CharFrontend *chr = &qtest->qtest_chr; irq_levels[n] = level;qtest_sendf (chr,"IRQ %s %d\n" , level ?"raise" :"lower" , n); } } -static bool (*process_command_cb)(CharBackend *chr,gchar **words); +static bool (*process_command_cb)(CharFrontend *chr,gchar **words); -void qtest_set_command_cb (bool (*pc_cb)(CharBackend *chr,gchar **words)) +void qtest_set_command_cb (bool (*pc_cb)(CharFrontend *chr,gchar **words)) {assert (!process_command_cb);/* Switch to a list if we need more than one */
@@ -349,7 +349,7 @@ static void qtest_install_gpio_out_intercept(DeviceState *dev, const char *name, *disconnected =qdev_intercept_gpio_out (dev, icpt, name, n); } -static void qtest_process_command (CharBackend *chr,gchar **words) +static void qtest_process_command (CharFrontend *chr,gchar **words) {const gchar *command;
@@ -757,7 +757,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words)* Process as much of @inbuf as we can in newline terminated chunks. * Remove the processed commands from @inbuf as we go. */ -static void qtest_process_inbuf (CharBackend *chr,GString *inbuf) +static void qtest_process_inbuf (CharFrontend *chr,GString *inbuf) {char *end;
@@ -773,7 +773,7 @@ static void qtest_process_inbuf(CharBackend *chr, GString *inbuf)static void qtest_read (void *opaque,const uint8_t *buf,int size) { -CharBackend *chr = opaque; +CharFrontend *chr = opaque;g_string_append_len (inbuf, (const gchar *)buf, size);qtest_process_inbuf (chr, inbuf);
target/hppa/sys_helper.c +6 -6
@@ -135,7 +135,7 @@ void HELPER(rfi_r)(CPUHPPAState *env)*/ void HELPER (diag_console_output )(CPUHPPAState *env) { -CharBackend *serial_backend; +CharFrontend *fe;Chardev *serial_port;unsigned char c;
@@ -145,14 +145,14 @@ void HELPER(diag_console_output)(CPUHPPAState *env) return; } -/* get serial_backend for the serial port */ - serial_backend = serial_port->be; -if (!serial_backend || - !qemu_chr_fe_backend_connected (serial_backend)) { +/* get the frontend for the serial port */ + fe = serial_port->fe; +if (!fe || + !qemu_chr_fe_backend_connected (fe)) {return ; } c = (unsigned char )env->gr[26 ]; -qemu_chr_fe_write (serial_backend, &c,sizeof (c)); +qemu_chr_fe_write (fe, &c,sizeof (c)); }#endif
target/riscv/kvm/kvm-cpu.c +5 -5
@@ -1598,7 +1598,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run) buf =g_malloc0 (num_bytes);if (run->riscv_sbi.function_id ==SBI_EXT_DBCN_CONSOLE_READ ) { - ret =qemu_chr_fe_read_all (serial_hd (0 )->be, buf, num_bytes); + ret =qemu_chr_fe_read_all (serial_hd (0 )->fe, buf, num_bytes);if (ret <0 ) {error_report ("SBI_EXT_DBCN_CONSOLE_READ: error when " "reading chardev" );
@@ -1609,7 +1609,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run) }else {address_space_read (cs->as, addr, attrs, buf, num_bytes); - ret =qemu_chr_fe_write_all (serial_hd (0 )->be, buf, num_bytes); + ret =qemu_chr_fe_write_all (serial_hd (0 )->fe, buf, num_bytes);if (ret <0 ) {error_report ("SBI_EXT_DBCN_CONSOLE_WRITE: error when " "writing chardev" );
@@ -1622,7 +1622,7 @@ static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run)break ;case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE : ch = run->riscv_sbi.args[0 ]; - ret =qemu_chr_fe_write_all (serial_hd (0 )->be, &ch,sizeof (ch)); + ret =qemu_chr_fe_write_all (serial_hd (0 )->fe, &ch,sizeof (ch));if (ret <0 ) { error_report("SBI_EXT_DBCN_CONSOLE_WRITE_BYTE: error when "
@@ -1645,10 +1645,10 @@ static int kvm_riscv_handle_sbi(CPUState *cs, struct kvm_run *run)switch (run->riscv_sbi.extension_id) {case SBI_EXT_0_1_CONSOLE_PUTCHAR : ch = run->riscv_sbi.args[0 ]; -qemu_chr_fe_write (serial_hd (0 )->be, &ch,sizeof (ch)); +qemu_chr_fe_write (serial_hd (0 )->fe, &ch,sizeof (ch));break ;case SBI_EXT_0_1_CONSOLE_GETCHAR : - ret =qemu_chr_fe_read_all (serial_hd (0 )->be, &ch,sizeof (ch)); + ret =qemu_chr_fe_read_all (serial_hd (0 )->fe, &ch,sizeof (ch));if (ret ==sizeof (ch)) { run->riscv_sbi.ret[0 ] = ch; }else {
target/xtensa/xtensa-semi.c +5 -5
@@ -148,7 +148,7 @@ static uint32_t errno_h2g(int host_errno) } typedef struct XtensaSimConsole { - CharBackend be; + CharFrontend fe; struct { char buffer[16]; size_t offset;
@@ -182,8 +182,8 @@ void xtensa_sim_open_console(Chardev *chr) {static XtensaSimConsole console; -qemu_chr_fe_init (&console.be, chr, &error_abort); - qemu_chr_fe_set_handlers(&console.be, +qemu_chr_fe_init (&console.fe, chr, &error_abort); + qemu_chr_fe_set_handlers(&console.fe, sim_console_can_read, sim_console_read, NULL, NULL, &console,
@@ -227,7 +227,7 @@ void HELPER(simcall)(CPUXtensaState *env) len -= io_sz;if (fd <3 && sim_console) {if (is_write && (fd ==1 || fd ==2 )) { - io_done =qemu_chr_fe_write_all (&sim_console->be, + io_done =qemu_chr_fe_write_all (&sim_console->fe, buf, io_sz); regs[3 ] =errno_h2g (errno); }else if (!is_write && fd ==0 ) {
@@ -241,7 +241,7 @@ void HELPER(simcall)(CPUXtensaState *env) sim_console->input.buffer + io_done, sim_console->input.offset - io_done); sim_console->input.offset -= io_done; -qemu_chr_fe_accept_input (&sim_console->be); +qemu_chr_fe_accept_input (&sim_console->fe); }else { io_done =-1 ; regs[3 ] =TARGET_EAGAIN ;
tests/qtest/vhost-user-test.c +8 -8
@@ -155,7 +155,7 @@ typedef struct TestServer {gchar *mig_path;gchar *chr_name;gchar *tmpfs; -CharBackend chr; +CharFrontend chr;int fds_num;int fds[VHOST_MEMORY_MAX_NREGIONS ];VhostUserMemory memory;
@@ -180,10 +180,10 @@ struct vhost_user_ops {/* VHOST-USER commands. */ uint64_t (*get_features)(TestServer *s); -void (*set_features)(TestServer *s,CharBackend *chr, +void (*set_features)(TestServer *s,CharFrontend *chr,VhostUserMsg *msg);void (*get_protocol_features)(TestServer *s, -CharBackend *chr,VhostUserMsg *msg); +CharFrontend *chr,VhostUserMsg *msg); };static const char *init_hugepagefs (void );
@@ -331,7 +331,7 @@ static int chr_can_read(void *opaque)static void chr_read (void *opaque,const uint8_t *buf,int size) {TestServer *s = opaque; -CharBackend *chr = &s->chr; +CharFrontend *chr = &s->chr;VhostUserMsg msg;uint8_t *p = (uint8_t *) &msg;int fd =-1 ;
@@ -1051,7 +1051,7 @@ static uint64_t vu_net_get_features(TestServer *s)return features; } -static void vu_net_set_features (TestServer *s,CharBackend *chr, +static void vu_net_set_features (TestServer *s,CharFrontend *chr,VhostUserMsg *msg) {g_assert (msg->payload.u64 & (0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ));
@@ -1061,7 +1061,7 @@ static void vu_net_set_features(TestServer *s, CharBackend *chr, } } -static void vu_net_get_protocol_features (TestServer *s,CharBackend *chr, +static void vu_net_get_protocol_features (TestServer *s,CharFrontend *chr,VhostUserMsg *msg) {/* send back features to qemu */
@@ -1148,7 +1148,7 @@ static uint64_t vu_gpio_get_features(TestServer *s)* that we support VHOST_USER_PROTOCOL_F_CONFIG as gpio would use it * talking to a read vhost-user daemon. */ -static void vu_gpio_get_protocol_features (TestServer *s,CharBackend *chr, +static void vu_gpio_get_protocol_features (TestServer *s,CharFrontend *chr,VhostUserMsg *msg) {/* send back features to qemu */
@@ -1191,7 +1191,7 @@ static uint64_t vu_scmi_get_features(TestServer *s)0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; } -static void vu_scmi_get_protocol_features (TestServer *s,CharBackend *chr, +static void vu_scmi_get_protocol_features (TestServer *s,CharFrontend *chr,VhostUserMsg *msg) { msg->flags |=VHOST_USER_REPLY_MASK ;
tests/unit/test-char.c +101 -101
634 lines not on this page · raw message
tests/unit/test-yank.c +6 -6
@@ -65,7 +65,7 @@ static void char_change_test(gconstpointer opaque)CharChangeTestConfig *conf = (gpointer ) opaque;SocketAddress *addr;Chardev *chr; -CharBackend be; +CharFrontend fe;ChardevReturn *ret;QIOChannelSocket *ioc;QemuThread thread;
@@ -144,9 +144,9 @@ static void char_change_test(gconstpointer opaque)qemu_thread_join (&thread); } -qemu_chr_fe_init (&be, chr, &error_abort); +qemu_chr_fe_init (&fe, chr, &error_abort);/* allow chardev-change */ -qemu_chr_fe_set_handlers (&be,NULL ,NULL , +qemu_chr_fe_set_handlers (&fe,NULL ,NULL ,NULL , chardev_change,NULL ,NULL , true);if (conf->fail) {
@@ -154,7 +154,7 @@ static void char_change_test(gconstpointer opaque) ret =qmp_chardev_change ("chardev" , &fail_backend[conf->new_yank],NULL );g_assert_null (ret); -g_assert (be.chr == chr); +g_assert (fe.chr == chr);g_assert (is_yank_instance_registered () == conf->old_yank);g_unsetenv ("QTEST_SILENT_ERRORS" ); }else {
@@ -168,11 +168,11 @@ static void char_change_test(gconstpointer opaque)qemu_thread_join (&thread); }g_assert_nonnull (ret); -g_assert (be.chr != chr); +g_assert (fe.chr != chr);g_assert (is_yank_instance_registered () == conf->new_yank); } -object_unparent (OBJECT (be.chr)); +object_unparent (OBJECT (fe.chr));object_unref (OBJECT (ioc));qapi_free_ChardevReturn (ret);qapi_free_SocketAddress (addr);
rust/bindings/src/lib.rs +2 -2
@@ -28,8 +28,8 @@// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`. // When bindings for character devices are introduced, this can be // moved to the Opaque<> wrapper in src/chardev.rs. -unsafe impl Send for CharBackend {} -unsafe impl Sync for CharBackend {} +unsafe impl Send for CharFrontend {} +unsafe impl Sync for CharFrontend {}// SAFETY: this is a pure data struct unsafe impl Send for CoalescedMemoryRange {}
rust/chardev/src/bindings.rs +3 -3
@@ -34,7 +34,7 @@// BQL is taken, either directly or via `BqlCell` and `BqlRefCell`. // When bindings for character devices are introduced, this can be // moved to the Opaque<> wrapper in src/chardev.rs. -unsafe impl Send for CharBackend {} -unsafe impl Sync for CharBackend {} +unsafe impl Send for CharFrontend {} +unsafe impl Sync for CharFrontend {} -unsafe impl Zeroable for CharBackend {} +unsafe impl Zeroable for CharFrontend {}
rust/chardev/src/chardev.rs +13 -13
@@ -6,7 +6,7 @@//! //! Character devices in QEMU can run under the big QEMU lock or in a separate //! `GMainContext`. Here we only support the former, because the bindings -//! enforce that the BQL is taken whenever the functions in [`CharBackend`] are +//! enforce that the BQL is taken whenever the functions in [`CharFrontend`] are //! called. use std::{
@@ -32,25 +32,25 @@pub type ChardevClass = bindings::ChardevClass ;pub type Event = bindings::QEMUChrEvent ; -/// A safe wrapper around [`bindings::CharBackend`], denoting the character +/// A safe wrapper around [`bindings::CharFrontend`], denoting the character /// back-end that is used for example by a device. Compared to the /// underlying C struct it adds BQL protection, and is marked as pinned /// because the QOM object ([`bindings::Chardev`]) contains a pointer to -/// the `CharBackend`. -pub struct CharBackend { - inner:BqlRefCell <bindings::CharBackend >, +/// the `CharFrontend`. +pub struct CharFrontend { + inner:BqlRefCell <bindings::CharFrontend >, _pin:PhantomPinned , } -pub struct CharBackendMut <'a>(BqlRefMut <'a, bindings::CharBackend >); +pub struct CharFrontendMut <'a>(BqlRefMut <'a, bindings::CharFrontend >); -impl Write for CharBackendMut <'_> { +impl Write for CharFrontendMut <'_> {fn flush (&mut self) -> io::Result <()> {Ok (()) }fn write (&mut self, buf: &[u8 ]) -> io::Result <usize > { -let chr: &mut bindings::CharBackend = &mut self.0 ; +let chr: &mut bindings::CharFrontend = &mut self.0 ;let len = buf.len ().try_into ().unwrap ();let r =unsafe { bindings::qemu_chr_fe_write (addr_of_mut! (*chr), buf.as_ptr (), len) };
@@ -58,7 +58,7 @@ fn write(&mut self, buf: &[u8]) -> io::Result<usize> { }fn write_all (&mut self, buf: &[u8 ]) -> io::Result <()> { -let chr: &mut bindings::CharBackend = &mut self.0 ; +let chr: &mut bindings::CharFrontend = &mut self.0 ;let len = buf.len ().try_into ().unwrap ();let r =unsafe { bindings::qemu_chr_fe_write_all (addr_of_mut! (*chr), buf.as_ptr (), len) };
@@ -72,7 +72,7 @@ fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { } } -impl Debug for CharBackend { +impl Debug for CharFrontend {fn fmt (&self, f: &mut fmt::Formatter <'_>) -> fmt::Result {// SAFETY: accessed just to print the values let chr = self.inner.as_ptr ();
@@ -81,13 +81,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { }// FIXME: use something like PinnedDrop from the pinned_init crate -impl Drop for CharBackend { +impl Drop for CharFrontend {fn drop (&mut self) { self.disable_handlers (); } } -impl CharBackend { +impl CharFrontend {/// Enable the front-end's character device handlers, if there is an /// associated `Chardev`. pub fn enable_handlers<
@@ -198,7 +198,7 @@ pub fn accept_input(&self) {/// the big QEMU lock while the character device is borrowed, as /// that might cause C code to write to the character device. pub fn borrow_mut (&self) ->impl Write + '_ { -CharBackendMut (self.inner.borrow_mut ()) +CharFrontendMut (self.inner.borrow_mut ()) }/// Send a continuous stream of zero bits on the line if `enabled` is
rust/hw/char/pl011/src/device.rs +6 -6
@@ -5,7 +5,7 @@use std::{ffi::CStr , mem::size_of};use bql::BqlRefCell ; -use chardev::{CharBackend ,Chardev ,Event }; +use chardev::{CharFrontend ,Chardev ,Event };use common::{static_assert, uninit_field_mut};use hwcore::{Clock ,ClockEvent ,DeviceImpl ,DeviceMethods ,DeviceState ,IRQState ,InterruptSource ,
@@ -106,7 +106,7 @@ pub struct PL011State { pub iomem: MemoryRegion,#[doc(alias = "chr" )] #[property(rename = "chardev" )] - pub char_backend: CharBackend, + pub char_frontend: CharFrontend, pub regs: BqlRefCell<PL011Registers>,/// QEMU interrupts ///
@@ -240,7 +240,7 @@ pub(self) fn write(&mut self, offset: RegisterOffset, value: u32, device: &PL011 }let update = (self.line_control.send_break () != new_val.send_break ()) && {let break_enable = new_val.send_break (); -let _ = device.char_backend.send_break (break_enable); +let _ = device.char_frontend.send_break (break_enable); self.loopback_break (break_enable) }; self.line_control = new_val;
@@ -561,7 +561,7 @@ fn read(&self, offset: hwaddr, _size: u32) -> u64 { trace::trace_pl011_read (offset, result,c"" );if update_irq { self.update (); - self.char_backend.accept_input (); + self.char_frontend.accept_input (); } result.into () }
@@ -579,7 +579,7 @@ fn write(&self, offset: hwaddr, value: u64, _size: u32) {let ch: [u8 ;1 ] = [valueas u8 ];// XXX this blocks entire thread. Rewrite to use // qemu_chr_fe_write and background I/O callbacks -let _ = self.char_backend.write_all (&ch); +let _ = self.char_frontend.write_all (&ch); } update_irq = self.regs.borrow_mut ().write (field, valueas u32 , self);
@@ -645,7 +645,7 @@ fn event(&self, event: Event) { }fn realize (&self) -> util::Result <()> { - self.char_backend + self.char_frontend .enable_handlers (self,Self ::can_receive,Self ::receive,Self ::event);Ok (()) }
rust/hw/core/src/qdev.rs +1 -1
@@ -156,7 +156,7 @@ unsafe impl $crate::qdev::QDevProp for $type {impl_qdev_prop! (usize , qdev_prop_usize);impl_qdev_prop! (i32 , qdev_prop_int32);impl_qdev_prop! (i64 , qdev_prop_int64); -impl_qdev_prop! (chardev::CharBackend , qdev_prop_chr); +impl_qdev_prop! (chardev::CharFrontend , qdev_prop_chr);/// Trait to define device properties. ///
Signature · 1 line
2.51.1
[PULL 09/18] accel/mshv: use return value of handle_pio_str_read
In reply to Paolo BonziniCoverity complains because we assign to ret here but then never read it again before we overwrite it with the call to set_x64_registers().
--- target/i386/mshv/mshv-cpu.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/mshv/mshv-cpu.c +4 -0
@@ -1489,6 +1489,10 @@ static int handle_pio_str(CPUState *cpu, hv_x64_io_port_intercept_message *info) reg_values[0 ] = info->rsi; }else { ret =handle_pio_str_read (cpu, info, repeat, port, direction_flag); +if (ret <0 ) { +error_report ("Failed to handle pio str read" ); +return -1 ; + } reg_names[0 ] =HV_X64_REGISTER_RDI ; reg_values[0 ] = info->rdi; }
Signature · 1 line
2.51.1
[PULL 05/18] rust: only leave leaf crates as workspace members
In reply to Paolo BonziniEverything else can be obtained as a dependency.
--- rust/Cargo.toml | 10 ---------- 1 file changed, 10 deletions(-)
rust/Cargo.toml +0 -10
@@ -1,18 +1,8 @@ [workspace] resolver = "2" members = [ - "bits", - "bql", - "common", - "migration", - "qemu-macros", - "qom", - "system", - "hw/core", "hw/char/pl011", "hw/timer/hpet", - "trace", - "util", "tests", ]
Signature · 1 line
2.51.1
[PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
In reply to Paolo BonziniFrom: Xiaoyao Li <[email protected]>
The SMM cpu address space is initialized in a machine_init_done notifier. It only runs once when QEMU starts up, which leads to the issue that for any hotplugged CPU after the machine is ready, SMM cpu address space doesn't get initialized.
Fix the issue by initializing the SMM cpu address space in x86_cpu_plug() when the cpu is hotplugged.
--- target/i386/kvm/kvm_i386.h | 1 + hw/i386/x86-common.c | 11 +++++++++++ target/i386/kvm/kvm.c | 6 ++++++ 3 files changed, 18 insertions(+)
target/i386/kvm/kvm_i386.h +1 -0
@@ -74,6 +74,7 @@ uint32_t kvm_x86_build_cpuid(CPUX86State *env, struct kvm_cpuid_entry2 *entries, uint32_t cpuid_i);#endif /* CONFIG_KVM */ +void kvm_smm_cpu_address_space_init (X86CPU *cpu);void kvm_pc_setup_irq_routing (bool pci_enabled);#endif
hw/i386/x86-common.c +11 -0
@@ -183,6 +183,17 @@ void x86_cpu_plug(HotplugHandler *hotplug_dev,fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); } +/* +* Non-hotplugged CPUs get their SMM cpu address space initialized in +* machine init done notifier: register_smram_listener(). +* +* We need initialize the SMM cpu address space for the hotplugged CPU +* specifically. +*/ +if (kvm_enabled () && dev->hotplugged &&x86_machine_is_smm_enabled (x86ms)) { +kvm_smm_cpu_address_space_init (cpu); + } + found_cpu =x86_find_cpu_slot (MACHINE (x86ms), cpu->apic_id,NULL ); found_cpu->cpu =CPU (dev); out:
target/i386/kvm/kvm.c +6 -0
@@ -2748,6 +2748,12 @@ static void register_smram_listener(Notifier *n, void *unused) } } +/* It should only be called in cpu's hotplug callback */ +void kvm_smm_cpu_address_space_init (X86CPU *cpu) +{ +cpu_address_space_init (CPU (cpu), X86ASIdx_SMM,"cpu-smm" , &smram_as_root); +} +static void *kvm_msr_energy_thread (void *data) {KVMState *s = data;
Signature · 1 line
2.51.1
Re: [PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
Quoted 9 lines
hw/i386/x86-common.c +1
-0@@ -183,6 +183,17 @@ void x86_cpu_plug(HotplugHandler *hotplug_dev,fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); } +/*
hw/i386/x86-common.c void x86_cpu_plug(HotplugHandler *hotplug_dev, · line 196
Quoted 10 lines
hw/i386/x86-common.c +10
-0+* Non-hotplugged CPUs get their SMM cpu address space initialized in +* machine init done notifier: register_smram_listener(). +* +* We need initialize the SMM cpu address space for the hotplugged CPU +* specifically. +*/ +if (kvm_enabled () && dev->hotplugged &&x86_machine_is_smm_enabled (x86ms)) { +kvm_smm_cpu_address_space_init (cpu); + } +
Unfortunately, the original KVM SMM patch caused this bug, but even more unfortunately, CPU_FOREACH in the machine_done callback is more fragile than I originally anticipated, now requiring more hack checks to fix. :-(
IMO, the root of the chaos is that KVM SMM doesn't do this in the CPU context like TCG did for a long time. I'll find time to sort all this out.
Regards,
Zhao
Re: [PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
Quoted 25 lines · Zhao Liu
Quoted 9 lines
hw/i386/x86-common.c +1
-0@@ -183,6 +183,17 @@ void x86_cpu_plug(HotplugHandler *hotplug_dev,fw_cfg_modify_i16 (x86ms->fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus); } +/* hw/i386/x86-common.c void x86_cpu_plug(HotplugHandler *hotplug_dev, · line 196
Quoted 10 lines
hw/i386/x86-common.c +10
-0+* Non-hotplugged CPUs get their SMM cpu address space initialized in +* machine init done notifier: register_smram_listener(). +* +* We need initialize the SMM cpu address space for the hotplugged CPU +* specifically. +*/ +if (kvm_enabled () && dev->hotplugged &&x86_machine_is_smm_enabled (x86ms)) { +kvm_smm_cpu_address_space_init (cpu); + } +Unfortunately, the original KVM SMM patch caused this bug, but even more unfortunately,
CPU_FOREACHin themachine_donecallback is more fragile than I originally anticipated, now requiring more hack checks to fix. :-(
Quoted 3 lines
IMO, the root of the chaos is that KVM SMM doesn't do this in the CPU context like TCG did for a long time. I'll find time to sort all this out.
I had this idea before. It needs to move the initialization of KVM SMM MemoryRegion a bit earlier at least. And it seems to require more time than I expected, especially the effort to test the SMM functionality after the change. So I went with the most straightforward fix.
It will be great if you can find time to clean it up. Looking forward to it.
Quoted 3 lines
Regards,
Zhao
Re: [PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
In reply to Paolo BonziniQuoted 11 lines · Paolo Bonzini
From: Xiaoyao Li <[email protected]>
The SMM cpu address space is initialized in a
machine_init_donenotifier. It only runs once when QEMU starts up, which leads to the issue that for any hotplugged CPU after the machine is ready, SMM cpu address space doesn't get initialized.Fix the issue by initializing the SMM cpu address space in
x86_cpu_plug()when the cpu is hotplugged.Fixes 591f817d819f ("target/i386: Define enum X86ASIdx for x86's address spaces")
How this commit can be fixing 591f817d819f, while technically 591f817d819f is a no-op, - it changed 0s and 1s in a few places to symbolic names with the same 0s and 1s.
It seems the "Fixes" commit should be something else. The way it is now, it's confusing.
Thanks,
/mjt
Re: [PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
Quoted 11 lines · Michael Tokarev
Quoted 10 lines · Paolo Bonzini
From: Xiaoyao Li <[email protected]>
The SMM cpu address space is initialized in a
machine_init_donenotifier. It only runs once when QEMU starts up, which leads to the issue that for any hotplugged CPU after the machine is ready, SMM cpu address space doesn't get initialized.Fix the issue by initializing the SMM cpu address space in
x86_cpu_plug()when the cpu is hotplugged.
Quoted 8 lines
Quoted 1 line
Fixes 591f817d819f ("target/i386: Define enum X86ASIdx for x86's address spaces")How this commit can be fixing
591f817d819f, while technically591f817d819fis a no-op, - it changed 0s and 1s in a few places to symbolic names with the same 0s and 1s.It seems the "Fixes" commit should be something else. The way it is now, it's confusing.
It should be
0516f4b70264 ("i386/cpu: Enable SMM cpu address space under KVM")
Sorry for my carelessness. Is there a way to remedy as the patch has been merged into the master?
Quoted 4 lines
Thanks,
/mjt
Re: [PULL 02/18] i386/kvm/cpu: Init SMM cpu address space for hotplugged CPUs
Quoted 18 lines · Xiaoyao Li
Quoted 17 lines · Michael Tokarev
Quoted 11 lines · Paolo Bonzini
From: Xiaoyao Li <[email protected]>
The SMM cpu address space is initialized in a
machine_init_donenotifier. It only runs once when QEMU starts up, which leads to the issue that for any hotplugged CPU after the machine is ready, SMM cpu address space doesn't get initialized.Fix the issue by initializing the SMM cpu address space in
x86_cpu_plug()when the cpu is hotplugged.Fixes 591f817d819f ("target/i386: Define enum X86ASIdx for x86's address spaces")How this commit can be fixing
591f817d819f, while technically591f817d819fis a no-op, - it changed 0s and 1s in a few places to symbolic names with the same 0s and 1s.
Quoted 8 lines
Quoted 2 lines
It seems the "Fixes" commit should be something else. The way it is now, it's confusing.
It should be
0516f4b70264("i386/cpu: Enable SMM cpu address space under KVM")Sorry for my carelessness. Is there a way to remedy as the patch has been merged into the master?
I hope it's possible still.
Paolo, please also add Cc: qemu-stable@ in there, -- because the change which is being fixed here (Enable SMM cpu address space) has been picked up to the stable series too. It's best to keep all the pieces :)
Thank you Xiaoyao, Paolo!
/mjt
[PULL 18/18] rust: migration: allow passing ParentField<> to vmstate_of!
In reply to Paolo BonziniThe common superclass for devices could have its own migration state; for it to be included in the subclass's VMState, ParentField<> must implement the VMState trait.
--- roms/opensbi | 2 +- rust/migration/src/vmstate.rs | 3 ++- rust/qom/src/qom.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
roms/opensbi +1 -1
@@ -1 +1 @@ -Subproject commit a32a91069119e7a5aa31e6bc51d5e00860be3d80 +Subproject commit 43cace6c3671e5172d0df0a8963e552bb04b7b20
rust/migration/src/vmstate.rs +2 -1
@@ -268,7 +268,7 @@ macro_rules! impl_vmstate_transparent { ($type:ty where $base:tt: VMState $($where:tt)*) => { unsafe impl<$base> $crate::vmstate::VMState for $type where $base: $crate::vmstate::VMState $($where)* {const BASE : $crate::vmstate::VMStateField = $crate::vmstate::VMStateField { - size: mem::size_of ::<$type>(), + size: ::core::mem::size_of ::<$type>(), ..<$baseas $crate::vmstate::VMState >::BASE };const VARRAY_FLAG : $crate::bindings::VMStateFlags = <$baseas $crate::vmstate::VMState >::VARRAY_FLAG ;
@@ -282,6 +282,7 @@ unsafe impl<$base> $crate::vmstate::VMState for $type where $base: $crate::vmstaimpl_vmstate_transparent! (std::cell::UnsafeCell <T >where T :VMState );impl_vmstate_transparent! (std::pin::Pin <T >where T :VMState );impl_vmstate_transparent! (common::Opaque <T >where T :VMState ); +impl_vmstate_transparent! (std::mem::ManuallyDrop <T >where T :VMState );#[macro_export] macro_rules! impl_vmstate_bitsized {
rust/qom/src/qom.rs +2 -1
@@ -102,7 +102,7 @@ };use common::Opaque ; -use migration::impl_vmstate_pointer; +use migration::{impl_vmstate_pointer, impl_vmstate_transparent};use crate ::bindings::{ self, object_class_dynamic_cast, object_dynamic_cast, object_get_class, object_get_typename,
@@ -182,6 +182,7 @@ fn as_ref(&self) -> &$parent {#[derive( Debug )] #[repr(transparent)] pub struct ParentField <T :ObjectType >(std::mem::ManuallyDrop <T >); +impl_vmstate_transparent! (ParentField <T >where T :VMState +ObjectType );impl <T :ObjectType >Deref for ParentField <T > {type Target =T ;
Signature · 1 line
2.51.1
Re: [PULL 18/18] rust: migration: allow passing ParentField<> to vmstate_of!
Quoted 17 lines · Paolo Bonzini
The common superclass for devices could have its own migration state; for it to be included in the subclass's VMState, ParentField<> must implement the VMState trait.
Reported-by Chen Miao <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- roms/opensbi | 2 +- rust/migration/src/vmstate.rs | 3 ++- rust/qom/src/qom.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)roms/opensbi +0
-0
roms/opensbi line 1
Quoted 2 lines
roms/opensbi +1
-1@@ -1 +1 @@ -Subproject commit a32a91069119e7a5aa31e6bc51d5e00860be3d80 +Subproject commit 43cace6c3671e5172d0df0a8963e552bb04b7b20
Spurious subproject change.
r~
Quoted 42 lines
rust/migration/src/vmstate.rs +2
-1@@ -268,7 +268,7 @@ macro_rules! impl_vmstate_transparent { ($type:ty where $base:tt: VMState $($where:tt)*) => { unsafe impl<$base> $crate::vmstate::VMState for $type where $base: $crate::vmstate::VMState $($where)* {const BASE : $crate::vmstate::VMStateField = $crate::vmstate::VMStateField { - size: mem::size_of ::<$type>(), + size: ::core::mem::size_of ::<$type>(), ..<$baseas $crate::vmstate::VMState >::BASE };const VARRAY_FLAG : $crate::bindings::VMStateFlags = <$baseas $crate::vmstate::VMState >::VARRAY_FLAG ;@@ -282,6 +282,7 @@ unsafe impl<$base> $crate::vmstate::VMState for $type where $base: $crate::vmstaimpl_vmstate_transparent! (std::cell::UnsafeCell <T >where T :VMState );impl_vmstate_transparent! (std::pin::Pin <T >where T :VMState );impl_vmstate_transparent! (common::Opaque <T >where T :VMState ); +impl_vmstate_transparent! (std::mem::ManuallyDrop <T >where T :VMState );#[macro_export] macro_rules! impl_vmstate_bitsized {rust/qom/src/qom.rs +2
-1@@ -102,7 +102,7 @@ };use common::Opaque ; -use migration::impl_vmstate_pointer; +use migration::{impl_vmstate_pointer, impl_vmstate_transparent};use crate ::bindings::{ self, object_class_dynamic_cast, object_dynamic_cast, object_get_class, object_get_typename,@@ -182,6 +182,7 @@ fn as_ref(&self) -> &$parent {#[derive( Debug )] #[repr(transparent)] pub struct ParentField <T :ObjectType >(std::mem::ManuallyDrop <T >); +impl_vmstate_transparent! (ParentField <T >where T :VMState +ObjectType );impl <T :ObjectType >Deref for ParentField <T > {type Target =T ;
[PULL 14/18] qdev: Change PropertyInfo method print() to return malloc'ed string
In reply to Paolo BonziniFrom: Markus Armbruster <[email protected]>
Simpler (more so after the next commit), and no risk of truncation because the caller's buffer is too small. Performance doesn't matter; the method is only used for "info qdev".
--- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 7 +++---- hw/core/qdev-properties.c | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -34,7 +34,7 @@ struct PropertyInfo {const char *description;const QEnumLookup *enum_table;bool realized_set_allowed;/* allow setting property on realized device */ -int (*print)(Object *obj,const Property *prop,char *dest,size_t len); +char *(*print)(Object *obj,const Property *prop);void (*set_default_value)(ObjectProperty *op,const Property *prop);ObjectProperty *(*create)(ObjectClass *oc,const char *name,const Property *prop);
hw/core/qdev-properties-system.c +3 -4
@@ -865,15 +865,14 @@ out:visit_end_alternate (v, (void **) &alt); } -static int print_pci_devfn (Object *obj,const Property *prop,char *dest, -size_t len) +static char *print_pci_devfn (Object *obj,const Property *prop) {int32_t *ptr =object_field_prop_ptr (obj, prop);if (*ptr ==-1 ) { -return snprintf (dest, len,"<unset>" ); +return g_strdup ("<unset>" ); }else { -return snprintf (dest, len,"%02x.%x" , *ptr >>3 , *ptr &7 ); +return g_strdup_printf ("%02x.%x" , *ptr >>3 , *ptr &7 ); } }
hw/core/qdev-properties.c +4 -5
@@ -1117,12 +1117,11 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v, Error **errp) {const Property *prop = opaque; +char *s; -char buffer[1024 ]; -char *ptr = buffer; - - prop->info->sizeof (buffer)); -visit_type_str (v, name, &ptr, errp); + s = prop->info->visit_type_str (v, name, &s, errp); +g_free (s); }/**
Signature · 1 line
2.51.1
[PULL 10/18] esp.c: fix esp_cdb_ready() FIFO wraparound limit calculation
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
The original calculation in commit 3cc70889a3 ("esp.c: prevent cmdfifo overflow in esp_cdb_ready()") subtracted cmdfifo_cdb_offset from fifo8_num_used() to calculate the outstanding cmdfifo length, but this is incorrect because fifo8_num_used() can also include wraparound data.
Instead calculate the maximum offset used by scsi_cdb_length() which is just the first byte after cmdfifo_cdb_offset, and then peek the entire content of the cmdfifo. The fifo8_peek_bufptr() result will then return the maximum length of remaining data up to the end of the internal cmdfifo array, which can then be used for the overflow check.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3082
--- hw/scsi/esp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/scsi/esp.c +4 -2
@@ -447,7 +447,9 @@ static void write_response(ESPState *s)static bool esp_cdb_ready (ESPState *s) { -int len =fifo8_num_used (&s->cmdfifo) - s->cmdfifo_cdb_offset; +/* scsi_cdb_length() only reads the first byte */ +int limit = s->cmdfifo_cdb_offset +1 ; +int len =fifo8_num_used (&s->cmdfifo);const uint8_t *pbuf;uint32_t n;int cdblen;
@@ -457,7 +459,7 @@ static bool esp_cdb_ready(ESPState *s) } pbuf =fifo8_peek_bufptr (&s->cmdfifo, len, &n); -if (n < len) { +if (n < limit) {/* * In normal use the cmdfifo should never wrap, but include this check * to prevent a malicious guest from reading past the end of the
Signature · 1 line
2.51.1
Re: [PULL 10/18] esp.c: fix esp_cdb_ready() FIFO wraparound limit calculation
Quoted 13 lines · Paolo Bonzini
From: Mark Cave-Ayland <[email protected]>
The original calculation in commit
3cc70889a3("esp.c: prevent cmdfifo overflow inesp_cdb_ready()") subtractedcmdfifo_cdb_offsetfromfifo8_num_used()to calculate the outstanding cmdfifo length, but this is incorrect becausefifo8_num_used()can also include wraparound data.Instead calculate the maximum offset used by
scsi_cdb_length()which is just the first byte aftercmdfifo_cdb_offset, and then peek the entire content of the cmdfifo. Thefifo8_peek_bufptr()result will then return the maximum length of remaining data up to the end of the internal cmdfifo array, which can then be used for the overflow check.
Quoted 6 lines
Signed-off-by Mark Cave-Ayland <[email protected]>Fixes 3cc70889a3 ("esp.c: prevent cmdfifo overflow in esp_cdb_ready()")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3082
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>
This smells like a qemu-stable material (this and the subsequent patch adding the test). Please let me know if it is not.
Thanks,
/mjt
[PULL 17/18] target/i386: clear CPU_INTERRUPT_SIPI for all accelerators
In reply to Paolo BonziniSimilar to what commit df32e5c5 did for TCG; fixes boot with multiple processors on WHPX and probably more accelerators
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3178
--- target/i386/hvf/x86hvf.c | 1 + target/i386/kvm/kvm.c | 1 + target/i386/nvmm/nvmm-all.c | 1 + target/i386/whpx/whpx-all.c | 1 + 4 files changed, 4 insertions(+)
target/i386/hvf/x86hvf.c +1 -0
@@ -446,6 +446,7 @@ int hvf_process_events(CPUState *cs) cs->halted =0 ; }if (cpu_test_interrupt (cs,CPU_INTERRUPT_SIPI )) { +cpu_reset_interrupt (cs,CPU_INTERRUPT_SIPI );cpu_synchronize_state (cs);do_cpu_sipi (cpu); }
target/i386/kvm/kvm.c +1 -0
@@ -5659,6 +5659,7 @@ int kvm_arch_process_async_events(CPUState *cs) cs->halted =0 ; }if (cpu_test_interrupt (cs,CPU_INTERRUPT_SIPI )) { +cpu_reset_interrupt (cs,CPU_INTERRUPT_SIPI );kvm_cpu_synchronize_state (cs);do_cpu_sipi (cpu); }
target/i386/nvmm/nvmm-all.c +1 -0
@@ -709,6 +709,7 @@ nvmm_vcpu_loop(CPUState *cpu) cpu->halted = false; }if (cpu_test_interrupt (cpu,CPU_INTERRUPT_SIPI )) { +cpu_reset_interrupt (cpu,CPU_INTERRUPT_SIPI );nvmm_cpu_synchronize_state (cpu);do_cpu_sipi (x86_cpu); }
target/i386/whpx/whpx-all.c +1 -0
@@ -1621,6 +1621,7 @@ static void whpx_vcpu_process_async_events(CPUState *cpu) }if (cpu_test_interrupt (cpu,CPU_INTERRUPT_SIPI )) { +cpu_reset_interrupt (cpu,CPU_INTERRUPT_SIPI );whpx_cpu_synchronize_state (cpu);do_cpu_sipi (x86_cpu); }
Signature · 1 line
2.51.1
[PULL 11/18] qtest/am53c974-test: add additional test for cmdfifo overflow
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
Based upon the qtest reproducer posted to Gitlab issue #3082 at
https://gitlab.com/qemu-project/qemu/-/issues/3082.
--- tests/qtest/am53c974-test.c | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
tests/qtest/am53c974-test.c +40 -0
@@ -109,6 +109,44 @@ static void test_cmdfifo_overflow2_ok(void)qtest_quit (s); } +/* Reported as https://issues.oss-fuzz.com/issues/439878564 */ +static void test_cmdfifo_overflow3_ok (void ) +{ +QTestState *s =qtest_init ( +"-device am53c974,id=scsi -device scsi-hd,drive=disk0 " +"-drive id=disk0,if=none,file=null-co://,format=raw -nodefaults" ); +qtest_outl (s,0xcf8 ,0x80001010 ); +qtest_outl (s,0xcfc ,0xc000 ); +qtest_outl (s,0xcf8 ,0x80001004 ); +qtest_outw (s,0xcfc ,0x01 ); +qtest_outb (s,0xc00c ,0x43 ); +qtest_outl (s,0xc00b ,0x9100 ); +qtest_outl (s,0xc009 ,0x02000000 ); +qtest_outl (s,0xc000 ,0x0b ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outl (s,0xc00b ,0xc200 ); +qtest_outl (s,0xc00b ,0x1000 ); +qtest_outl (s,0xc00b ,0x9000 ); +qtest_outb (s,0xc008 ,0x00 ); +qtest_outb (s,0xc008 ,0x00 ); +qtest_outl (s,0xc03f ,0x0300 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outw (s,0xc00b ,0x4200 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outw (s,0xc00b ,0x1200 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outb (s,0xc00c ,0x43 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outl (s,0xc00b ,0x00 ); +qtest_outl (s,0xc007 ,0x00 ); +qtest_outl (s,0xc007 ,0x00 ); +qtest_outl (s,0xc007 ,0x00 ); +qtest_outl (s,0xc00b ,0x1000 ); +qtest_outl (s,0xc007 ,0x00 ); +qtest_quit (s); +} +/* Reported as crash_0900379669 */ static void test_fifo_pop_buf (void ) {
@@ -266,6 +304,8 @@ int main(int argc, char **argv) test_cmdfifo_overflow_ok);qtest_add_func ("am53c974/test_cmdfifo_overflow2_ok" , test_cmdfifo_overflow2_ok); +qtest_add_func ("am53c974/test_cmdfifo_overflow3_ok" , + test_cmdfifo_overflow3_ok);qtest_add_func ("am53c974/test_fifo_pop_buf" , test_fifo_pop_buf); qtest_add_func("am53c974/test_target_selected_ok",
Signature · 1 line
2.51.1
[PULL 04/18] rust: remove useless glib_sys bindings
In reply to Paolo BonziniFrom: Martin Kletzander <[email protected]>
The definition of types needed for g_autolist(), g_autoslist(), g_autoqueue() need the imports for GList, GSList and GQueue to appear everything. Rust code is never going to see those, since they are not used in structs. Block the types from appearing in the bindings.
--- meson.build | 1 + rust/bql/src/bindings.rs | 4 +--- rust/chardev/src/bindings.rs | 4 ++-- rust/hw/char/pl011/src/bindings.rs | 2 +- rust/hw/core/src/bindings.rs | 4 +--- rust/migration/src/bindings.rs | 2 +- rust/qom/src/bindings.rs | 2 +- rust/system/src/bindings.rs | 4 ++-- rust/util/src/bindings.rs | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-)
meson.build +1 -0
@@ -4251,6 +4251,7 @@ if have_rust '--allowlist-file', meson.project_source_root() + '/include/.*', '--allowlist-file', meson.project_build_root() + '/.*', '--blocklist-file', glib_pc.get_variable('includedir') + '/glib-2.0/.*', + '--blocklist-type', '.*_([a-z]*autoptr)$', ] if not rustfmt.found() if bindgen.version().version_compare('<0.65.0')
rust/bql/src/bindings.rs +1 -3
@@ -18,9 +18,7 @@ clippy::too_many_arguments )] -use glib_sys::{ - guint,GArray ,GHashTable ,GHashTableIter ,GList ,GPollFD ,GPtrArray ,GQueue ,GSList ,GSource , -}; +use glib_sys::{guint,GArray ,GHashTable ,GHashTableIter ,GPollFD ,GPtrArray ,GSList ,GSource };#[cfg( MESON )] include! ("bindings.inc.rs" );
rust/chardev/src/bindings.rs +2 -2
@@ -20,8 +20,8 @@use common::Zeroable ;use glib_sys::{ - gboolean, guint,GArray ,GHashTable ,GHashTableIter ,GIOCondition ,GList ,GMainContext , -GPollFD ,GPtrArray ,GQueue ,GSList ,GSource ,GSourceFunc , + gboolean, guint,GArray ,GHashTable ,GHashTableIter ,GIOCondition ,GMainContext ,GPollFD , +GPtrArray ,GSList ,GSource ,GSourceFunc , };#[cfg( MESON )]
rust/hw/char/pl011/src/bindings.rs +1 -1
@@ -22,7 +22,7 @@use glib_sys::{ gboolean, guint,GArray ,GByteArray ,GHashTable ,GHashTableIter ,GIOCondition ,GList , -GMainContext ,GPollFD ,GPtrArray ,GQueue ,GSList ,GSource ,GSourceFunc ,GString , +GMainContext ,GPollFD ,GPtrArray ,GSList ,GSource ,GSourceFunc ,GString , };#[cfg( MESON )]
rust/hw/core/src/bindings.rs +1 -3
@@ -20,9 +20,7 @@use chardev::bindings::Chardev ;use common::Zeroable ; -use glib_sys::{ -GArray ,GByteArray ,GHashTable ,GHashTableIter ,GList ,GPtrArray ,GQueue ,GSList ,GString , -}; +use glib_sys::{GArray ,GByteArray ,GHashTable ,GHashTableIter ,GList ,GPtrArray ,GSList ,GString };use migration::bindings::VMStateDescription ;use qom::bindings::ObjectClass ;use system::bindings::MemoryRegion ;
rust/migration/src/bindings.rs +1 -1
@@ -19,7 +19,7 @@ )]use common::Zeroable ; -use glib_sys::{GHashTable ,GHashTableIter ,GList ,GPtrArray ,GQueue ,GSList }; +use glib_sys::{GHashTable ,GHashTableIter ,GPtrArray ,GSList };#[cfg( MESON )] include! ("bindings.inc.rs" );
rust/qom/src/bindings.rs +1 -1
@@ -18,7 +18,7 @@ clippy::too_many_arguments )] -use glib_sys::{GHashTable ,GHashTableIter ,GList ,GPtrArray ,GQueue ,GSList }; +use glib_sys::{GHashTable ,GHashTableIter ,GPtrArray ,GSList };#[cfg( MESON )] include! ("bindings.inc.rs" );
rust/system/src/bindings.rs +2 -2
@@ -20,8 +20,8 @@use common::Zeroable ;use glib_sys::{ - guint,GArray ,GByteArray ,GHashTable ,GHashTableIter ,GList ,GPollFD ,GPtrArray ,GQueue , -GSList ,GString , + guint,GArray ,GByteArray ,GHashTable ,GHashTableIter ,GList ,GPollFD ,GPtrArray ,GSList , +GString , };#[cfg( MESON )]
rust/util/src/bindings.rs +1 -1
@@ -18,7 +18,7 @@ clippy::too_many_arguments )] -use glib_sys::{guint,GList ,GPollFD ,GQueue ,GSList ,GString }; +use glib_sys::{guint,GPollFD ,GString };#[cfg( MESON )] include! ("bindings.inc.rs" );
Signature · 1 line
2.51.1
[PULL 13/18] scsi: make SCSIRequest refcount atomic
In reply to Paolo Bonzini--- hw/scsi/scsi-bus.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
hw/scsi/scsi-bus.c +4 -9
@@ -823,7 +823,6 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, {SCSIRequest *req;SCSIBus *bus =scsi_bus_from_device (d); -BusState *qbus =BUS (bus);const int memset_off = offsetof(SCSIRequest , sense) +sizeof (req->sense);
@@ -838,8 +837,6 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, req->status =-1 ; req->host_status =-1 ; req->ops = reqops; -object_ref (OBJECT (d)); -object_ref (OBJECT (qbus->parent));notifier_list_init (&req->cancel_notifiers);if (reqops->init_req) {
@@ -1496,15 +1493,15 @@ void scsi_device_report_change(SCSIDevice *dev, SCSISense sense)SCSIRequest *scsi_req_ref (SCSIRequest *req) { -assert (req->refcount >0 ); - req->refcount++; +assert (qatomic_read (&req->refcount) >0 ); +qatomic_inc (&req->refcount);return req; }void scsi_req_unref (SCSIRequest *req) { -assert (req->refcount >0 ); -if (--req->refcount ==0 ) { +assert (qatomic_read (&req->refcount) >0 ); +if (qatomic_fetch_dec (&req->refcount) ==1 ) {BusState *qbus = req->dev->qdev.parent_bus;SCSIBus *bus =DO_UPCAST (SCSIBus, qbus, qbus);
@@ -1514,8 +1511,6 @@ void scsi_req_unref(SCSIRequest *req)if (req->ops->free_req) { req->ops->free_req (req); } -object_unref (OBJECT (req->dev)); -object_unref (OBJECT (qbus->parent));g_free (req); } }
Signature · 1 line
2.51.1
[PULL 12/18] rust/qemu-macros: Convert bit value to u8 within #[property]
In reply to Paolo BonziniFrom: Zhao Liu <[email protected]>
For bit property, make the type conversion within the #[property] macro so that users do not need to handle the conversion.
--- rust/hw/timer/hpet/src/device.rs | 2 +- rust/qemu-macros/src/lib.rs | 23 ++++++++++++++++++----- rust/qemu-macros/src/tests.rs | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 9 deletions(-)
rust/hw/timer/hpet/src/device.rs +1 -1
@@ -539,7 +539,7 @@ pub struct HPETState {// Internal state /// Capabilities that QEMU HPET supports. /// bit 0: MSI (or FSB) support. -#[property(rename = "msi" , bit = HPET_FLAG_MSI_SUPPORT_SHIFT as u8 , default = false )] +#[property(rename = "msi" , bit = HPET_FLAG_MSI_SUPPORT_SHIFT , default = false )] flags: u32,/// Offset of main counter relative to qemu clock.
rust/qemu-macros/src/lib.rs +18 -5
@@ -262,12 +262,25 @@ macro_rules! str_to_c_str { }, )?;let field_ty = field.ty.clone (); -let qdev_prop =if bitnr.is_none () { -quote! { <#field_ty as ::hwcore::QDevProp >::BASE_INFO } +let (qdev_prop, bitval) =if let Some (bitval) = bitnr { + ( +quote! { <#field_ty as ::hwcore::QDevProp >::BIT_INFO }, +quote! { + { +const { +assert! (#bitval >=0 && #bitval < #field_ty::BITS as _ , +"bit number exceeds type bits range" ); + } + #bitvalas u8 + } + }, + ) }else { -quote! { <#field_ty as ::hwcore::QDevProp >::BIT_INFO } + ( +quote! { <#field_ty as ::hwcore::QDevProp >::BASE_INFO }, +quote! {0 }, + ) }; -let bitnr = bitnr.unwrap_or (syn::Expr ::Verbatim (quote! {0 }));let set_default = defval.is_some ();let defval = defval.unwrap_or (syn::Expr ::Verbatim (quote! {0 })); properties_expanded.push (quote! {
@@ -275,7 +288,7 @@ macro_rules! str_to_c_str { name: ::std::ffi::CStr::as_ptr(#prop_name), info: #qdev_prop, offset: ::core::mem::offset_of!(#name, #field_name) as isize, - bitnr: #bitnr, + bitnr: #bitval, set_default: #set_default, defval: ::hwcore::bindings::Property__bindgen_ty_1 { u: #defval as u64 }, ..::common::Zeroable ::ZERO
rust/qemu-macros/src/tests.rs +12 -3
@@ -179,7 +179,10 @@ unsafe impl ::hwcore::DevicePropertiesImpl for DummyState { name: ::std::ffi::CStr::as_ptr(c"flags"), info: <u32 as ::hwcore::QDevProp>::BIT_INFO, offset: ::core::mem::offset_of!(DummyState, flags) as isize, - bitnr: 3, + bitnr : { + const { assert!(3 >= 0 && 3 < u32::BITS as _ , "bit number exceeds type bits range"); } + 3 as u8 + }, set_default: false, defval: ::hwcore::bindings::Property__bindgen_ty_1 { u: 0 as u64 }, ..::common::Zeroable ::ZERO
@@ -207,7 +210,10 @@ unsafe impl ::hwcore::DevicePropertiesImpl for DummyState { name: ::std::ffi::CStr::as_ptr(c"flags"), info: <u32 as ::hwcore::QDevProp>::BIT_INFO, offset: ::core::mem::offset_of!(DummyState, flags) as isize, - bitnr: 3, + bitnr : { + const { assert!(3 >= 0 && 3 < u32::BITS as _ , "bit number exceeds type bits range"); } + 3 as u8 + }, set_default: true, defval: ::hwcore::bindings::Property__bindgen_ty_1 { u: true as u64 }, ..::common::Zeroable ::ZERO
@@ -235,7 +241,10 @@ unsafe impl ::hwcore::DevicePropertiesImpl for DummyState { name: ::std::ffi::CStr::as_ptr(c"msi"), info: <u64 as ::hwcore::QDevProp>::BIT_INFO, offset: ::core::mem::offset_of!(DummyState, flags) as isize, - bitnr: 3, + bitnr : { + const { assert!(3 >= 0 && 3 < u64::BITS as _ , "bit number exceeds type bits range"); } + 3 as u8 + }, set_default: true, defval: ::hwcore::bindings::Property__bindgen_ty_1 { u: false as u64 }, ..::common::Zeroable ::ZERO
Signature · 1 line
2.51.1
[PULL 16/18] docs/about/deprecated.rst: document isapc deprecation for modern x86 CPU models
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
Add a new paragraph in the "Backwards compatibility" section documenting that using modern x86 CPU models with the isapc machine is deprecated, and will be rejected in a future release.
--- docs/about/deprecated.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
docs/about/deprecated.rst +14 -0
@@ -544,6 +544,20 @@ available firmwares that are using the current (wrong) name. The property is kept as is in 9.1, together with "riscv,delegation", to give more time for firmware developers to change their code. +x86 "isapc" board use of modern x86 CPUs (since 10.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The "isapc" board represents a historical x86 ISA PC and is intended for +older 32-bit x86 CPU models, defaulting to a 486 CPU model. Previously it +was possible (but non-sensical) to specify a more modern x86 CPU, including +``-cpu host`` or ``-cpu max`` even if the features were incompatible with many +of the intended guest OSs. + +If the user requests a modern x86 CPU model (i.e. not one of ``486``, +``athlon``, ``kvm32``, ``pentium``, ``pentium2``, ``pentium3``or ``qemu32``) +a warning will be displayed until a future QEMU version when such CPUs will +be rejected. + Migration ---------
Signature · 1 line
2.51.1
[PULL 15/18] hw/i386/isapc.c: warn rather than reject modern x86 CPU models
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
Commit e1e2909f8e ("hw/i386/pc_piix.c: restrict isapc machine to 32-bit CPUs") restricted the isapc machine to 32-bit CPUs, but subsequent concern has been expressed as to the effect this could have on users.
The outcome of the latest discussion is that we should exercise more caution and follow the official deprecation route, so instead of rejecting modern x86 CPUs issue a deprecation warning but allow the user to continue.
--- hw/i386/isapc.c | 55 ++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 33 deletions(-)
hw/i386/isapc.c +22 -33
@@ -41,29 +41,31 @@ static void pc_init_isa(MachineState *machine)DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];int i; -/* -* There is a small chance that someone unintentionally passes "-cpu max" -* for the isapc machine, which will provide a much more modern 32-bit -* CPU than would be expected for an ISA-era PC. If the "max" cpu type has -* been specified, choose the "best" 32-bit cpu possible which we consider -* be the pentium3 (deliberately choosing an Intel CPU given that the -* default 486 CPU for the isapc machine is also an Intel CPU). -*/ -if (!strcmp (machine->cpu_type,X86_CPU_TYPE_NAME ("max" ))) { - machine->cpu_type =X86_CPU_TYPE_NAME ("pentium3" ); -warn_report ("-cpu max is invalid for isapc machine, using pentium3" ); - } +bool valid_cpu_type = false; +static const char *const valid_cpu_types[] = { +X86_CPU_TYPE_NAME ("486" ), +X86_CPU_TYPE_NAME ("athlon" ), +X86_CPU_TYPE_NAME ("kvm32" ), +X86_CPU_TYPE_NAME ("pentium" ), +X86_CPU_TYPE_NAME ("pentium2" ), +X86_CPU_TYPE_NAME ("pentium3" ), +X86_CPU_TYPE_NAME ("qemu32" ), + };/* -* Similarly if someone unintentionally passes "-cpu host" for the isapc -* machine then display a warning and also switch to the "best" 32-bit -* cpu possible which we consider to be the pentium3. This is because any -* host CPU will already be modern than this, but it also ensures any -* newer CPU flags/features are filtered out for older guests. +* The isapc machine is supposed to represent a legacy ISA-only PC with a +* 32-bit processor. For historical reasons the machine can still accept +* almost any valid processor, but this is now deprecated in 10.2. Emit +* a warning if anyone tries to use a deprecated CPU. */ -if (!strcmp (machine->cpu_type,X86_CPU_TYPE_NAME ("host" ))) { - machine->cpu_type =X86_CPU_TYPE_NAME ("pentium3" ); -warn_report ("-cpu host is invalid for isapc machine, using pentium3" ); +for (i =0 ; i <ARRAY_SIZE (valid_cpu_types); i++) { +if (!strcmp (machine->cpu_type, valid_cpu_types[i])) { + valid_cpu_type = true; + } + } + +if (!valid_cpu_type) { +warn_report ("cpu type %s is deprecated for isapc machine" , machine->cpu_type); }if (machine->ram_size >3.5 * GiB) {
@@ -154,18 +156,6 @@ static void pc_init_isa(MachineState *machine)static void isapc_machine_options (MachineClass *m) { -static const char *const valid_cpu_types[] = { -X86_CPU_TYPE_NAME ("486" ), -X86_CPU_TYPE_NAME ("athlon" ), -X86_CPU_TYPE_NAME ("kvm32" ), -X86_CPU_TYPE_NAME ("pentium" ), -X86_CPU_TYPE_NAME ("pentium2" ), -X86_CPU_TYPE_NAME ("pentium3" ), -X86_CPU_TYPE_NAME ("qemu32" ), -X86_CPU_TYPE_NAME ("max" ), -X86_CPU_TYPE_NAME ("host" ), -NULL - };PCMachineClass *pcmc =PC_MACHINE_CLASS (m); m->desc ="ISA-only PC" ;
@@ -180,7 +170,6 @@ static void isapc_machine_options(MachineClass *m) pcmc->has_reserved_memory = false; m->default_nic ="ne2k_isa" ; m->default_cpu_type =X86_CPU_TYPE_NAME ("486" ); - m->valid_cpu_types = valid_cpu_types; m->no_floppy = !module_object_class_by_name (TYPE_ISA_FDC ); m->no_parallel = !module_object_class_by_name (TYPE_ISA_PARALLEL ); }
Signature · 1 line
2.51.1
[PULL 03/18] rcu: Unify force quiescent state
In reply to Paolo BonziniFrom: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Background
==========
The previous implementation had four steps to begin reclamation.
1. call_rcu_thread() would wait for the first callback.
2. call_rcu_thread() would periodically poll until a decent number of callbacks piled up or it timed out.
3. synchronize_rcu() would statr a grace period (GP).
4. wait_for_readers() would wait for the GP to end. It would also trigger the force_rcu notifier to break busy loops in a read-side critical section if drain_call_rcu() had been called.
Problem
=======
The separation of waiting logic across these steps led to suboptimal behavior:
The GP was delayed until call_rcu_thread() stops polling.
force_rcu was not consistently triggered when call_rcu_thread() detected a high number of pending callbacks or a timeout. This inconsistency sometimes led to stalls, as reported in a virtio-gpu issue where memory unmapping was blocked[1].
wait_for_readers() imposed unnecessary overhead in non-urgent cases by unconditionally executing qatomic_set(&index->waiting, true) and qemu_event_reset(&rcu_gp_event), which are necessary only for expedited synchronization.
Solution
========
Move the polling in call_rcu_thread() to wait_for_readers() to prevent the delay of the GP. Additionally, reorganize wait_for_readers() to distinguish between two states:
Normal State: it relies exclusively on periodic polling to detect the end of the GP and maintains the read-side fast path.
Force Quiescent State: Whenever expediting synchronization, it always triggers force_rcu and executes both qatomic_set(&index->waiting, true) and qemu_event_reset(&rcu_gp_event). This avoids stalls while confining the read-side overhead to this state.
This unified approach, inspired by the Linux RCU, ensures consistent and efficient RCU grace period handling and confirms resolution of the virtio-gpu issue.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
--- util/rcu.c | 81 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 29 deletions(-)
util/rcu.c +52 -29
@@ -43,10 +43,14 @@#define RCU_GP_LOCKED (1UL << 0)#define RCU_GP_CTR (1UL << 1) + +#define RCU_CALL_MIN_SIZE 30 +unsigned long rcu_gp_ctr =RCU_GP_LOCKED ;QemuEvent rcu_gp_event;static int in_drain_call_rcu; +static int rcu_call_count;static QemuMutex rcu_registry_lock;static QemuMutex rcu_sync_lock;
@@ -76,15 +80,29 @@ static void wait_for_readers(void) {ThreadList qsreaders =QLIST_HEAD_INITIALIZER (qsreaders);struct rcu_reader_data *index, *tmp; +int sleeps =0 ; +bool forced = false;for (;;) { -/* We want to be notified of changes made to rcu_gp_ongoing -* while we walk the list. +/* +* Force the grace period to end and wait for it if any of the +* following heuristical conditions are satisfied: +* - A decent number of callbacks piled up. +* - It timed out. +* - It is in a drain_call_rcu() call. +* +* Otherwise, periodically poll the grace period, hoping it ends +* promptly. */ -qemu_event_reset (&rcu_gp_event); +if (!forced && + (qatomic_read (&rcu_call_count) >=RCU_CALL_MIN_SIZE || + sleeps >=5 ||qatomic_read (&in_drain_call_rcu))) { + forced = true; - QLIST_FOREACH(index, ®istry, node) { -qatomic_set (&index->waiting, true); + QLIST_FOREACH(index, ®istry, node) { +notifier_list_notify (&index->force_rcu,NULL ); +qatomic_set (&index->waiting, true); + } }/* Here, order the stores to index->waiting before the loads of
@@ -106,8 +124,6 @@ static void wait_for_readers(void)* get some extra futex wakeups. */ qatomic_set (&index->waiting, false); - }else if (qatomic_read (&in_drain_call_rcu)) { -notifier_list_notify (&index->force_rcu,NULL ); } }
@@ -115,7 +131,8 @@ static void wait_for_readers(void)break ; } -/* Wait for one thread to report a quiescent state and try again. +/* +* Sleep for a while and try again. * Release rcu_registry_lock, so rcu_(un)register_thread() doesn't * wait too much time. *
@@ -133,7 +150,20 @@ static void wait_for_readers(void)* rcu_registry_lock is released. */ qemu_mutex_unlock (&rcu_registry_lock); -qemu_event_wait (&rcu_gp_event); + +if (forced) { +qemu_event_wait (&rcu_gp_event); + +/* +* We want to be notified of changes made to rcu_gp_ongoing +* while we walk the list. +*/ +qemu_event_reset (&rcu_gp_event); + }else { +g_usleep (10000 ); + sleeps++; + } +qemu_mutex_lock (&rcu_registry_lock); }
@@ -173,15 +203,11 @@ void synchronize_rcu(void) } } - -#define RCU_CALL_MIN_SIZE 30 -/* Multi-producer, single-consumer queue based on urcu/static/wfqueue.h * from liburcu. Note that head is only used by the consumer. */ static struct rcu_head dummy;static struct rcu_head *head = &dummy, **tail = &dummy.next; -static int rcu_call_count;static QemuEvent rcu_call_ready_event;static void enqueue (struct rcu_head *node)
@@ -259,30 +285,27 @@ static void *call_rcu_thread(void *opaque)rcu_register_thread ();for (;;) { -int tries =0 ; -int n =qatomic_read (&rcu_call_count); +int n; -/* Heuristically wait for a decent number of callbacks to pile up. +/* * Fetch rcu_call_count now, we only must process elements that were * added before synchronize_rcu() starts. */ -while (n ==0 || (n <RCU_CALL_MIN_SIZE && ++tries <=5 )) { -g_usleep (10000 ); -if (n ==0 ) { -qemu_event_reset (&rcu_call_ready_event); - n =qatomic_read (&rcu_call_count); -if (n ==0 ) { -#if defined(CONFIG_MALLOC_TRIM ) -malloc_trim (4 *1024 *1024 ); -#endif -qemu_event_wait (&rcu_call_ready_event); - } - } +for (;;) { +qemu_event_reset (&rcu_call_ready_event); n =qatomic_read (&rcu_call_count); +if (n) { +break ; + } + +#if defined(CONFIG_MALLOC_TRIM ) +malloc_trim (4 *1024 *1024 ); +#endif +qemu_event_wait (&rcu_call_ready_event); } -qatomic_sub (&rcu_call_count, n);synchronize_rcu (); +qatomic_sub (&rcu_call_count, n);bql_lock ();while (n >0 ) { node =try_dequeue ();
Signature · 1 line
2.51.1
Regression with the "replay" test on target alpha (was: [PULL 03/18] rcu: Unify force quiescent state)
Quoted 4 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Hi Akihiko,
looks like this commit has introduced a regression with the "replay" functional test on the alpha target. When I run something like:
pyvenv/bin/meson test --no-rebuild -t 1 --setup thorough \
--num-processes 1 --repeat 10 func-alpha-replay
in the build folder, approx. half of the test runs are failing for me now.
I bisected the issue to this patch here - when I rebuild qemu-system-alpha with the commit right before this change here, the above test runs work fine, so I'm pretty sure that the problem has been introduced by this commit here.
Could you please have a look?
Thanks,
Thomas
Quoted 218 lines
Background
==========The previous implementation had four steps to begin reclamation.
1.
call_rcu_thread()would wait for the first callback.2.
call_rcu_thread()would periodically poll until a decent number of callbacks piled up or it timed out.3.
synchronize_rcu()would statr a grace period (GP).4.
wait_for_readers()would wait for the GP to end. It would also trigger theforce_rcunotifier to break busy loops in a read-side critical section ifdrain_call_rcu()had been called.Problem
=======The separation of waiting logic across these steps led to suboptimal behavior:
The GP was delayed until
call_rcu_thread()stops polling.
force_rcuwas not consistently triggered whencall_rcu_thread()detected a high number of pending callbacks or a timeout. This inconsistency sometimes led to stalls, as reported in a virtio-gpu issue where memory unmapping was blocked[1].
wait_for_readers()imposed unnecessary overhead in non-urgent cases by unconditionally executingqatomic_set(&index->waiting, true)andqemu_event_reset(&rcu_gp_event), which are necessary only for expedited synchronization.Solution
========Move the polling in
call_rcu_thread()towait_for_readers()to prevent the delay of the GP. Additionally, reorganizewait_for_readers()to distinguish between two states:Normal State: it relies exclusively on periodic polling to detect the end of the GP and maintains the read-side fast path.
Force Quiescent State: Whenever expediting synchronization, it always triggers
force_rcuand executes bothqatomic_set(&index->waiting, true)andqemu_event_reset(&rcu_gp_event). This avoids stalls while confining the read-side overhead to this state.This unified approach, inspired by the Linux RCU, ensures consistent and efficient RCU grace period handling and confirms resolution of the virtio-gpu issue.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by Akihiko Odaki <[email protected]>Tested-by Dmitry Osipenko <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- util/rcu.c | 81 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 29 deletions(-)util/rcu.c +52
-29@@ -43,10 +43,14 @@#define RCU_GP_LOCKED (1UL << 0)#define RCU_GP_CTR (1UL << 1) + +#define RCU_CALL_MIN_SIZE 30 +unsigned long rcu_gp_ctr =RCU_GP_LOCKED ;QemuEvent rcu_gp_event;static int in_drain_call_rcu; +static int rcu_call_count;static QemuMutex rcu_registry_lock;static QemuMutex rcu_sync_lock;@@ -76,15 +80,29 @@ static void wait_for_readers(void) {ThreadList qsreaders =QLIST_HEAD_INITIALIZER (qsreaders);struct rcu_reader_data *index, *tmp; +int sleeps =0 ; +bool forced = false;for (;;) { -/* We want to be notified of changes made to rcu_gp_ongoing -* while we walk the list. +/* +* Force the grace period to end and wait for it if any of the +* following heuristical conditions are satisfied: +* - A decent number of callbacks piled up. +* - It timed out. +* - It is in a drain_call_rcu() call. +* +* Otherwise, periodically poll the grace period, hoping it ends +* promptly. */ -qemu_event_reset (&rcu_gp_event); +if (!forced && + (qatomic_read (&rcu_call_count) >=RCU_CALL_MIN_SIZE || + sleeps >=5 ||qatomic_read (&in_drain_call_rcu))) { + forced = true; - QLIST_FOREACH(index, ®istry, node) { -qatomic_set (&index->waiting, true); + QLIST_FOREACH(index, ®istry, node) { +notifier_list_notify (&index->force_rcu,NULL ); +qatomic_set (&index->waiting, true); + } }/* Here, order the stores to index->waiting before the loads of @@ -106,8 +124,6 @@ static void wait_for_readers(void)* get some extra futex wakeups. */ qatomic_set (&index->waiting, false); - }else if (qatomic_read (&in_drain_call_rcu)) { -notifier_list_notify (&index->force_rcu,NULL ); } }@@ -115,7 +131,8 @@ static void wait_for_readers(void)break ; } -/* Wait for one thread to report a quiescent state and try again. +/* +* Sleep for a while and try again. * Release rcu_registry_lock, so rcu_(un)register_thread() doesn't * wait too much time. * @@ -133,7 +150,20 @@ static void wait_for_readers(void)* rcu_registry_lock is released. */ qemu_mutex_unlock (&rcu_registry_lock); -qemu_event_wait (&rcu_gp_event); + +if (forced) { +qemu_event_wait (&rcu_gp_event); + +/* +* We want to be notified of changes made to rcu_gp_ongoing +* while we walk the list. +*/ +qemu_event_reset (&rcu_gp_event); + }else { +g_usleep (10000 ); + sleeps++; + } +qemu_mutex_lock (&rcu_registry_lock); }@@ -173,15 +203,11 @@ void synchronize_rcu(void) } } - -#define RCU_CALL_MIN_SIZE 30 -/* Multi-producer, single-consumer queue based on urcu/static/wfqueue.h * from liburcu. Note that head is only used by the consumer. */ static struct rcu_head dummy;static struct rcu_head *head = &dummy, **tail = &dummy.next; -static int rcu_call_count;static QemuEvent rcu_call_ready_event;static void enqueue (struct rcu_head *node)@@ -259,30 +285,27 @@ static void *call_rcu_thread(void *opaque)rcu_register_thread ();for (;;) { -int tries =0 ; -int n =qatomic_read (&rcu_call_count); +int n; -/* Heuristically wait for a decent number of callbacks to pile up. +/* * Fetch rcu_call_count now, we only must process elements that were * added before synchronize_rcu() starts. */ -while (n ==0 || (n <RCU_CALL_MIN_SIZE && ++tries <=5 )) { -g_usleep (10000 ); -if (n ==0 ) { -qemu_event_reset (&rcu_call_ready_event); - n =qatomic_read (&rcu_call_count); -if (n ==0 ) { -#if defined(CONFIG_MALLOC_TRIM ) -malloc_trim (4 *1024 *1024 ); -#endif -qemu_event_wait (&rcu_call_ready_event); - } - } +for (;;) { +qemu_event_reset (&rcu_call_ready_event); n =qatomic_read (&rcu_call_count); +if (n) { +break ; + } + +#if defined(CONFIG_MALLOC_TRIM ) +malloc_trim (4 *1024 *1024 ); +#endif +qemu_event_wait (&rcu_call_ready_event); } -qatomic_sub (&rcu_call_count, n);synchronize_rcu (); +qatomic_sub (&rcu_call_count, n);bql_lock ();while (n >0 ) { node =try_dequeue ();
Re: Regression with the "replay" test on target alpha
Quoted 11 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Hi Akihiko,
looks like this commit has introduced a regression with the "replay" functional test on the alpha target. When I run something like:
Quoted 8 lines
pyvenv/bin/meson test --no-rebuild -t 1 --setup thorough \
--num-processes 1 --repeat 10 func-alpha-replayin the build folder, approx. half of the test runs are failing for me now.
I bisected the issue to this patch here - when I rebuild qemu-system- alpha with the commit right before this change here, the above test runs work fine, so I'm pretty sure that the problem has been introduced by this commit here.
Could you please have a look?
I cannot reproduce it with commit 55d98e3edeeb ("rcu: Unify force quiescent state").
Can you provide meson-logs/testlog-thorough.txt so that I can look into the failure you are facing? If you think you have something useful for debugging, please share it to me too.
Regards,
Akihiko Odaki
Re: Regression with the "replay" test on target alpha
Quoted 17 lines · Akihiko Odaki
Quoted 16 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Hi Akihiko,
looks like this commit has introduced a regression with the "replay" functional test on the alpha target. When I run something like:
pyvenv/bin/meson test --no-rebuild -t 1 --setup thorough \
--num-processes 1 --repeat 10 func-alpha-replayin the build folder, approx. half of the test runs are failing for me now.
Quoted 7 lines
Quoted 3 lines
I bisected the issue to this patch here - when I rebuild qemu-system- alpha with the commit right before this change here, the above test runs work fine, so I'm pretty sure that the problem has been introduced by this commit here.
Could you please have a look?
I cannot reproduce it with commit
55d98e3edeeb("rcu: Unify force quiescent state").Can you provide
meson-logs/testlog-thorough.txtso that I can look into the failure you are facing? If you think you have something useful for debugging, please share it to me too.
There's not much in that testlog-thorough.txt that could be helpful here, it's basically just the information that the test has been killed due to the timeout:
==================================== 1/1 ===================================
test: qemu:func-thorough+func-alpha-thorough+thorough / func-alpha-replay start time: 07:25:26 duration: 90.01s result: killed by signal 15 SIGTERM command: RUST_BACKTRACE=1 QEMU_TEST_QEMU_IMG=/tmp/qemu-rcu/qemu-img QEMU_TEST_GDB=/usr/bin/gdb MALLOC_PERTURB_=255 MESON_TEST_ITERATION=1 PYTHONPATH=/home/thuth/devel/qemu/python:/home/thuth/devel/qemu/tests/functional G_TEST_SLOW=1 SPEED=thorough QEMU_TEST_QEMU_BINARY=/tmp/qemu-rcu/qemu-system-alpha ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=/tmp/qemu-rcu/tests/tcg/plugins:/tmp/qemu-rcu/contrib/plugins UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 QEMU_BUILD_ROOT=/tmp/qemu-rcu /tmp/qemu-rcu/pyvenv/bin/python3 /home/thuth/devel/qemu/tests/functional/alpha/test_replay.py
=============================================================================
Summary of Failures:
1/1 qemu:func-thorough+func-alpha-thorough+thorough / func-alpha-replay TIMEOUT 90.01s killed by signal 15 SIGTERM
There is also not that much helpful information in tests/functional/alpha/test_replay.AlphaReplay.test_clipper, apart from the console.log file. For a good run, the console log looks like this:
2025-11-04 08:16:46,148: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:46,149: PCI: region 0: 0000c000 2025-11-04 08:16:46,149: PCI: region 1: 0000c008 2025-11-04 08:16:46,149: PCI: region 2: 0000c010 2025-11-04 08:16:46,149: PCI: region 3: 0000c018 2025-11-04 08:16:46,149: PCI: region 4: 0000c020 2025-11-04 08:16:46,149: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:16:48,149: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:16:48,149: [ 0.000000] Linux version 2.6.26-2-alpha-generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:16:48,150: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:16:48,150: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:16:48,150: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:16:48,150: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:16:48,150: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 15:2048 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:16:48,151: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:16:48,151: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:16:48,151: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0 2025-11-04 08:16:57,358: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:57,358: PCI: region 0: 0000c000 2025-11-04 08:16:57,358: PCI: region 1: 0000c008 2025-11-04 08:16:57,359: PCI: region 2: 0000c010 2025-11-04 08:16:57,359: PCI: region 3: 0000c018 2025-11-04 08:16:57,359: PCI: region 4: 0000c020 2025-11-04 08:16:57,360: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:17:08,468: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:17:08,470: [ 0.000000] Linux version 2.6.26-2-alpha-generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:17:08,471: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:17:08,471: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:17:08,472: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:17:08,472: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:17:08,473: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:17:08,473: [ 0.000000] freeing pages 15:2048 2025-11-04 08:17:08,474: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:17:08,474: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:17:08,475: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:17:08,476: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0
I.e. the replay worked as expected. When it fails, console.log only contains:
2025-11-04 08:25:26,601: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:25:26,601: PCI: region 0: 0000c000 2025-11-04 08:25:26,601: PCI: region 1: 0000c008 2025-11-04 08:25:26,601: PCI: region 2: 0000c010 2025-11-04 08:25:26,601: PCI: region 3: 0000c018 2025-11-04 08:25:26,601: PCI: region 4: 0000c020 2025-11-04 08:25:26,602: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:25:28,601: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:25:28,602: [ 0.000000] Linux version 2.6.26-2-alpha-generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:25:28,602: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:25:28,602: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:25:28,602: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:25:28,602: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:25:28,602: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:25:28,602: [ 0.000000] freeing pages 15:2048 2025-11-04 08:25:28,603: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:25:28,603: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:25:28,603: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:25:28,603: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0
I.e. the replay did not work.
Could this RCU stuff somehow influence the replay mechanism in QEMU?
Thomas
Re: Regression with the "replay" test on target alpha
Quoted 108 lines · Thomas Huth
Quoted 17 lines · Akihiko Odaki
Quoted 16 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Hi Akihiko,
looks like this commit has introduced a regression with the "replay" functional test on the alpha target. When I run something like:
pyvenv/bin/meson test --no-rebuild -t 1 --setup thorough \
--num-processes 1 --repeat 10 func-alpha-replayin the build folder, approx. half of the test runs are failing for me now.
Quoted 7 lines
Quoted 3 lines
I bisected the issue to this patch here - when I rebuild qemu-system- alpha with the commit right before this change here, the above test runs work fine, so I'm pretty sure that the problem has been introduced by this commit here.
Could you please have a look?
I cannot reproduce it with commit
55d98e3edeeb("rcu: Unify force quiescent state").Can you provide
meson-logs/testlog-thorough.txtso that I can look into the failure you are facing? If you think you have something useful for debugging, please share it to me too.There's not much in that testlog-thorough.txt that could be helpful here, it's basically just the information that the test has been killed due to the timeout:
==================================== 1/1 ===================================
test: qemu:func-thorough+func-alpha-thorough+thorough / func- alpha-replay
start time: 07:25:26
duration: 90.01s
result: killed by signal 15 SIGTERM
command: RUST_BACKTRACE=1 QEMU_TEST_QEMU_IMG=/tmp/qemu-rcu/qemu-img QEMU_TEST_GDB=/usr/bin/gdb MALLOC_PERTURB_=255 MESON_TEST_ITERATION=1 PYTHONPATH=/home/thuth/devel/qemu/python:/home/thuth/devel/qemu/tests/ functional G_TEST_SLOW=1 SPEED=thorough QEMU_TEST_QEMU_BINARY=/tmp/qemu- rcu/qemu-system-alpha ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=/tmp/qemu-rcu/tests/tcg/plugins:/tmp/qemu-rcu/contrib/ plugins UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 QEMU_BUILD_ROOT=/tmp/qemu-rcu/tmp/qemu-rcu/pyvenv/bin/python3/home/thuth/devel/qemu/tests/functional/alpha/test_replay.py
=============================================================================Summary of Failures:
1/1 qemu:func-thorough+func-alpha-thorough+thorough / func-alpha-replay TIMEOUT 90.01s killed by signal 15 SIGTERM
There is also not that much helpful information in tests/functional/alpha/test_replay.AlphaReplay.test_clipper, apart from the console.log file. For a good run, the console log looks like this:
2025-11-04 08:16:46,148: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:46,149: PCI: region 0: 0000c000 2025-11-04 08:16:46,149: PCI: region 1: 0000c008 2025-11-04 08:16:46,149: PCI: region 2: 0000c010 2025-11-04 08:16:46,149: PCI: region 3: 0000c018 2025-11-04 08:16:46,149: PCI: region 4: 0000c020 2025-11-04 08:16:46,149: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:16:48,149: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:16:48,149: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:16:48,150: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:16:48,150: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:16:48,150: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:16:48,150: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:16:48,150: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 15:2048 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:16:48,151: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:16:48,151: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:16:48,151: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0 2025-11-04 08:16:57,358: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:57,358: PCI: region 0: 0000c000 2025-11-04 08:16:57,358: PCI: region 1: 0000c008 2025-11-04 08:16:57,359: PCI: region 2: 0000c010 2025-11-04 08:16:57,359: PCI: region 3: 0000c018 2025-11-04 08:16:57,359: PCI: region 4: 0000c020 2025-11-04 08:16:57,360: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:17:08,468: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:17:08,470: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:17:08,471: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:17:08,471: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:17:08,472: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:17:08,472: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:17:08,473: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:17:08,473: [ 0.000000] freeing pages 15:2048 2025-11-04 08:17:08,474: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:17:08,474: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:17:08,475: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:17:08,476: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0I.e. the replay worked as expected. When it fails, console.log only contains:
2025-11-04 08:25:26,601: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:25:26,601: PCI: region 0: 0000c000 2025-11-04 08:25:26,601: PCI: region 1: 0000c008 2025-11-04 08:25:26,601: PCI: region 2: 0000c010 2025-11-04 08:25:26,601: PCI: region 3: 0000c018 2025-11-04 08:25:26,601: PCI: region 4: 0000c020 2025-11-04 08:25:26,602: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:25:28,601: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:25:28,602: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:25:28,602: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:25:28,602: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:25:28,602: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:25:28,602: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:25:28,602: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:25:28,602: [ 0.000000] freeing pages 15:2048 2025-11-04 08:25:28,603: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:25:28,603: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:25:28,603: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:25:28,603: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0
Quoted 3 lines
I.e. the replay did not work.
Could this RCU stuff somehow influence the replay mechanism in QEMU?
I don't know (yet).
Can you attach gdb and show a backtrace for each thread? It often reveals deadlock among threads.
Regards,
Akihiko Odaki
Re: Regression with the "replay" test on target alpha
Quoted 109 lines · Akihiko Odaki
Quoted 108 lines · Thomas Huth
Quoted 17 lines · Akihiko Odaki
Quoted 16 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Borrow the concept of force quiescent state from Linux to ensure readers remain fast during normal operation and to avoid stalls.
Hi Akihiko,
looks like this commit has introduced a regression with the "replay" functional test on the alpha target. When I run something like:
pyvenv/bin/meson test --no-rebuild -t 1 --setup thorough \
--num-processes 1 --repeat 10 func-alpha-replayin the build folder, approx. half of the test runs are failing for me now.
Quoted 7 lines
Quoted 3 lines
I bisected the issue to this patch here - when I rebuild qemu-system- alpha with the commit right before this change here, the above test runs work fine, so I'm pretty sure that the problem has been introduced by this commit here.
Could you please have a look?
I cannot reproduce it with commit
55d98e3edeeb("rcu: Unify force quiescent state").Can you provide
meson-logs/testlog-thorough.txtso that I can look into the failure you are facing? If you think you have something useful for debugging, please share it to me too.There's not much in that testlog-thorough.txt that could be helpful here, it's basically just the information that the test has been killed due to the timeout:
==================================== 1/1 ===================================
test: qemu:func-thorough+func-alpha-thorough+thorough / func- alpha-replay
start time: 07:25:26
duration: 90.01s
result: killed by signal 15 SIGTERM
command: RUST_BACKTRACE=1 QEMU_TEST_QEMU_IMG=/tmp/qemu-rcu/qemu-img QEMU_TEST_GDB=/usr/bin/gdb MALLOC_PERTURB_=255 MESON_TEST_ITERATION=1 PYTHONPATH=/home/thuth/devel/qemu/python:/home/thuth/devel/qemu/tests/ functional G_TEST_SLOW=1 SPEED=thorough QEMU_TEST_QEMU_BINARY=/tmp/qemu- rcu/qemu-system-alpha ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=/tmp/qemu-rcu/tests/tcg/plugins:/tmp/qemu-rcu/contrib/ plugins UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 QEMU_BUILD_ROOT=/tmp/qemu-rcu/tmp/qemu-rcu/pyvenv/bin/python3/home/thuth/devel/qemu/tests/functional/alpha/test_replay.py
=============================================================================Summary of Failures:
1/1 qemu:func-thorough+func-alpha-thorough+thorough / func-alpha-replay TIMEOUT 90.01s killed by signal 15 SIGTERM
There is also not that much helpful information in tests/functional/alpha/test_replay.AlphaReplay.test_clipper, apart from the console.log file. For a good run, the console log looks like this:
2025-11-04 08:16:46,148: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:46,149: PCI: region 0: 0000c000 2025-11-04 08:16:46,149: PCI: region 1: 0000c008 2025-11-04 08:16:46,149: PCI: region 2: 0000c010 2025-11-04 08:16:46,149: PCI: region 3: 0000c018 2025-11-04 08:16:46,149: PCI: region 4: 0000c020 2025-11-04 08:16:46,149: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:16:48,149: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:16:48,149: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:16:48,150: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:16:48,150: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:16:48,150: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:16:48,150: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:16:48,150: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 15:2048 2025-11-04 08:16:48,150: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:16:48,151: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:16:48,151: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:16:48,151: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0 2025-11-04 08:16:57,358: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:16:57,358: PCI: region 0: 0000c000 2025-11-04 08:16:57,358: PCI: region 1: 0000c008 2025-11-04 08:16:57,359: PCI: region 2: 0000c010 2025-11-04 08:16:57,359: PCI: region 3: 0000c018 2025-11-04 08:16:57,359: PCI: region 4: 0000c020 2025-11-04 08:16:57,360: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:17:08,468: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:17:08,470: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:17:08,471: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:17:08,471: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:17:08,472: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:17:08,472: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:17:08,473: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:17:08,473: [ 0.000000] freeing pages 15:2048 2025-11-04 08:17:08,474: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:17:08,474: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:17:08,475: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:17:08,476: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0I.e. the replay worked as expected. When it fails, console.log only contains:
2025-11-04 08:25:26,601: PCI: 00:01:0 class 0101 id 1095:0646 2025-11-04 08:25:26,601: PCI: region 0: 0000c000 2025-11-04 08:25:26,601: PCI: region 1: 0000c008 2025-11-04 08:25:26,601: PCI: region 2: 0000c010 2025-11-04 08:25:26,601: PCI: region 3: 0000c018 2025-11-04 08:25:26,601: PCI: region 4: 0000c020 2025-11-04 08:25:26,602: PCI: 00:07:0 class 0601 id 8086:0484 2025-11-04 08:25:28,601: [ 0.000000] Initializing cgroup subsys cpu 2025-11-04 08:25:28,602: [ 0.000000] Linux version 2.6.26-2-alpha- generic (Debian 2.6.26-29) ([email protected]) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 Sun Mar 4 21:08:03 UTC 2012 2025-11-04 08:25:28,602: [ 0.000000] Booting GENERIC on Tsunami variation Clipper using machine vector Clipper from SRM 2025-11-04 08:25:28,602: [ 0.000000] Major Options: MAGIC_SYSRQ 2025-11-04 08:25:28,602: [ 0.000000] Command line: printk.time=0 console=ttyS0 2025-11-04 08:25:28,602: [ 0.000000] memcluster 0, usage 1, start 0, end 15 2025-11-04 08:25:28,602: [ 0.000000] memcluster 1, usage 0, start 15, end 16384 2025-11-04 08:25:28,602: [ 0.000000] freeing pages 15:2048 2025-11-04 08:25:28,603: [ 0.000000] freeing pages 2987:16384 2025-11-04 08:25:28,603: [ 0.000000] reserving pages 2987:2988 2025-11-04 08:25:28,603: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16272 2025-11-04 08:25:28,603: [ 0.000000] Kernel command line: printk.time=0 console=ttyS0
Quoted 7 lines
Quoted 3 lines
I.e. the replay did not work.
Could this RCU stuff somehow influence the replay mechanism in QEMU?
I don't know (yet).
Can you attach gdb and show a backtrace for each thread? It often reveals deadlock among threads.
Sure, it looks like this:
(gdb) thread apply all bt
Thread 4 (Thread 0x7f31bd1ff6c0 (LWP 89223) "qemu-system-alp"):
#0 0x00007f31c47150cd in syscall () at /lib64/libc.so.6 #1 0x00005593dd2b578d in qemu_futex_wait (f=0x5593ddad9e50 <rcu_call_ready_event>, val=4294967295) at /home/thuth/devel/qemu/include/qemu/futex.h:47 #2 0x00005593dd2b59a1 in qemu_event_wait (ev=0x5593ddad9e50 <rcu_call_ready_event>) at ../../home/thuth/devel/qemu/util/event.c:162 #3 0x00005593dd2c12e3 in call_rcu_thread (opaque=0x0) at ../../home/thuth/devel/qemu/util/rcu.c:304 #4 0x00005593dd2b3311 in qemu_thread_start (args=0x5594051010c0) at ../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393 #5 0x00007f31c4693f54 in start_thread () at /lib64/libc.so.6 #6 0x00007f31c471732c in __clone3 () at /lib64/libc.so.6
Thread 3 (Thread 0x7f31bc8fd6c0 (LWP 89224) "qemu-system-alp"):
#0 0x00007f31c469c462 in __syscall_cancel_arch () at /lib64/libc.so.6 #1 0x00007f31c469075c in __internal_syscall_cancel () at /lib64/libc.so.6 #2 0x00007f31c46907a4 in __syscall_cancel () at /lib64/libc.so.6 #3 0x00007f31c470a7c6 in ppoll () at /lib64/libc.so.6 #4 0x00007f31c6916890 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0 #5 0x00007f31c6916a4f in g_main_loop_run () at /lib64/libglib-2.0.so.0 #6 0x00005593dd0d1ab0 in iothread_run (opaque=0x559405a567a0) at ../../home/thuth/devel/qemu/iothread.c:70 #7 0x00005593dd2b3311 in qemu_thread_start (args=0x559405a571a0) at ../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393 #8 0x00007f31c4693f54 in start_thread () at /lib64/libc.so.6 #9 0x00007f31c471732c in __clone3 () at /lib64/libc.so.6
Thread 2 (Thread 0x7f3137fff6c0 (LWP 89225) "qemu-system-alp"):
#0 0x00007f31c469c462 in __syscall_cancel_arch () at /lib64/libc.so.6 #1 0x00007f31c469075c in __internal_syscall_cancel () at /lib64/libc.so.6 #2 0x00007f31c46907a4 in __syscall_cancel () at /lib64/libc.so.6 #3 0x00007f31c470b2be in write () at /lib64/libc.so.6 #4 0x00005593dd2af441 in event_notifier_set (e=0x559405a56a54) at ../../home/thuth/devel/qemu/util/event_notifier-posix.c:117 #5 0x00005593dd2cdcde in aio_notify (ctx=0x559405a56980) at ../../home/thuth/devel/qemu/util/async.c:506 #6 0x00005593dd2cdd2a in aio_timerlist_notify (opaque=0x559405a56980, type=QEMU_CLOCK_VIRTUAL) at ../../home/thuth/devel/qemu/util/async.c:524 #7 0x00005593dd2d4014 in timerlist_notify (timer_list=0x559405a56d50) at ../../home/thuth/devel/qemu/util/qemu-timer.c:293 #8 0x00005593dd2d3aaf in qemu_clock_notify (type=QEMU_CLOCK_VIRTUAL) at ../../home/thuth/devel/qemu/util/qemu-timer.c:147 #9 0x00005593dcf92c2c in icount_notify_aio_contexts () at ../../home/thuth/devel/qemu/accel/tcg/tcg-accel-ops-icount.c:72
#10 0x00005593dcf92c92 in icount_handle_deadline () at ../../home/thuth/devel/qemu/accel/tcg/tcg-accel-ops-icount.c:88 #11 0x00005593dcf93c45 in rr_cpu_thread_fn (arg=0x559405ce47d0) at ../../home/thuth/devel/qemu/accel/tcg/tcg-accel-ops-rr.c:251 #12 0x00005593dd2b3311 in qemu_thread_start (args=0x559405ce4720) at ../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393 #13 0x00007f31c4693f54 in start_thread () at /lib64/libc.so.6
#14 0x00007f31c471732c in __clone3 () at /lib64/libc.so.6
Thread 1 (Thread 0x7f31bd82bb00 (LWP 89222) "qemu-system-alp"):
#0 0x00007f31c469c462 in __syscall_cancel_arch () at /lib64/libc.so.6 #1 0x00007f31c469075c in __internal_syscall_cancel () at /lib64/libc.so.6 #2 0x00007f31c46907a4 in __syscall_cancel () at /lib64/libc.so.6 #3 0x00007f31c470a7c6 in ppoll () at /lib64/libc.so.6 #4 0x00005593dd2d418e in qemu_poll_ns (fds=0x5594064aad30, nfds=5, timeout=993592000) at ../../home/thuth/devel/qemu/util/qemu-timer.c:342 #5 0x00005593dd2cf1bd in os_host_main_loop_wait (timeout=993592000) at ../../home/thuth/devel/qemu/util/main-loop.c:308 #6 0x00005593dd2cf30f in main_loop_wait (nonblocking=0) at ../../home/thuth/devel/qemu/util/main-loop.c:592 #7 0x00005593dce7edf6 in qemu_main_loop () at ../../home/thuth/devel/qemu/system/runstate.c:903 #8 0x00005593dd1e212e in qemu_default_main (opaque=0x0) at ../../home/thuth/devel/qemu/system/main.c:50 #9 0x00005593dd1e21e8 in main (argc=25, argv=0x7ffdad60bf18) at ../../home/thuth/devel/qemu/system/main.c:93
HTH,
Thomas
Re: Regression with the "replay" test on target alpha
Quoted 5 lines · Thomas Huth
Thread 4 (Thread
0x7f31bd1ff6c0(LWP 89223) "qemu-system-alp"):
#00x00007f31c47150cdin syscall () at/lib64/libc.so.6
#10x00005593dd2b578dinqemu_futex_wait(f=0x5593ddad9e50 <rcu_call_ready_event>, val=4294967295) at/home/thuth/devel/qemu/include/qemu/futex.h:47#20x00005593dd2b59a1inqemu_event_wait(ev=0x5593ddad9e50 <rcu_call_ready_event>) at../../home/thuth/devel/qemu/util/event.c:162#30x00005593dd2c12e3incall_rcu_thread(opaque=0x0) at ../../home/thuth/devel/qemu/util/rcu.c:304
The RCU thread is simply waiting.
Quoted 11 lines
Thread 3 (Thread
0x7f31bc8fd6c0(LWP 89224) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470a7c6in ppoll () at/lib64/libc.so.6
#40x00007f31c6916890in g_main_context_iterate_unlocked.isra () at / lib64/libglib-2.0.so.0
#50x00007f31c6916a4fing_main_loop_run() at/lib64/libglib-2.0.so.0
#60x00005593dd0d1ab0iniothread_run(opaque=0x559405a567a0) at ../../home/thuth/devel/qemu/iothread.c:70#70x00005593dd2b3311inqemu_thread_start(args=0x559405a571a0) at../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393#80x00007f31c4693f54instart_thread() at/lib64/libc.so.6
#90x00007f31c471732cin__clone3() at/lib64/libc.so.6
This iothread is doing nothing.
Quoted 7 lines
Thread 2 (Thread
0x7f3137fff6c0(LWP 89225) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470b2bein write () at/lib64/libc.so.6
#40x00005593dd2af441inevent_notifier_set(e=0x559405a56a54) at../../home/thuth/devel/qemu/util/event_notifier-posix.c:117#50x00005593dd2cdcdeinaio_notify(ctx=0x559405a56980) at ../../home/thuth/devel/qemu/util/async.c:506
In this backtrace the CPU is waking up the main loop (thread 1), but the main loop is running so I don't think it's really a deadlock. It's more likely that the replay is not matching the record, or there's a similar reason why the replay is not proceeding.
Paolo
Re: Regression with the "replay" test on target alpha
Quoted 23 lines · Paolo Bonzini
Quoted 5 lines · Thomas Huth
Thread 4 (Thread
0x7f31bd1ff6c0(LWP 89223) "qemu-system-alp"):
#00x00007f31c47150cdin syscall () at/lib64/libc.so.6
#10x00005593dd2b578dinqemu_futex_wait(f=0x5593ddad9e50 <rcu_call_ready_event>, val=4294967295) at/home/thuth/devel/qemu/include/qemu/futex.h:47#20x00005593dd2b59a1inqemu_event_wait(ev=0x5593ddad9e50 <rcu_call_ready_event>) at../../home/thuth/devel/qemu/util/event.c:162#30x00005593dd2c12e3incall_rcu_thread(opaque=0x0) at ../../home/thuth/devel/qemu/util/rcu.c:304The RCU thread is simply waiting.
Quoted 11 lines
Thread 3 (Thread
0x7f31bc8fd6c0(LWP 89224) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470a7c6in ppoll () at/lib64/libc.so.6
#40x00007f31c6916890in g_main_context_iterate_unlocked.isra () at / lib64/libglib-2.0.so.0
#50x00007f31c6916a4fing_main_loop_run() at/lib64/libglib-2.0.so.0
#60x00005593dd0d1ab0iniothread_run(opaque=0x559405a567a0) at ../../home/thuth/devel/qemu/iothread.c:70#70x00005593dd2b3311inqemu_thread_start(args=0x559405a571a0) at../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393#80x00007f31c4693f54instart_thread() at/lib64/libc.so.6
#90x00007f31c471732cin__clone3() at/lib64/libc.so.6This iothread is doing nothing.
Quoted 8 lines
Quoted 7 lines
Thread 2 (Thread
0x7f3137fff6c0(LWP 89225) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470b2bein write () at/lib64/libc.so.6
#40x00005593dd2af441inevent_notifier_set(e=0x559405a56a54) at../../home/thuth/devel/qemu/util/event_notifier-posix.c:117#50x00005593dd2cdcdeinaio_notify(ctx=0x559405a56980) at ../../ home/thuth/devel/qemu/util/async.c:506In this backtrace the CPU is waking up the main loop (thread 1), but the main loop is running so I don't think it's really a deadlock. It's more likely that the replay is not matching the record, or there's a similar reason why the replay is not proceeding.
I agree. It is more likely that debugging the replay code instead of the RCU change will lead to the real cause.
Regards,
Akihiko Odaki
Re: Regression with the "replay" test on target alpha
Quoted 31 lines · Akihiko Odaki
Quoted 30 lines · Paolo Bonzini
Quoted 5 lines · Thomas Huth
Thread 4 (Thread
0x7f31bd1ff6c0(LWP 89223) "qemu-system-alp"):
#00x00007f31c47150cdin syscall () at/lib64/libc.so.6
#10x00005593dd2b578dinqemu_futex_wait(f=0x5593ddad9e50 <rcu_call_ready_event>, val=4294967295) at/home/thuth/devel/qemu/include/qemu/futex.h:47#20x00005593dd2b59a1inqemu_event_wait(ev=0x5593ddad9e50 <rcu_call_ready_event>) at../../home/thuth/devel/qemu/util/event.c:162#30x00005593dd2c12e3incall_rcu_thread(opaque=0x0) at ../../home/thuth/devel/qemu/util/rcu.c:304The RCU thread is simply waiting.
Quoted 11 lines
Thread 3 (Thread
0x7f31bc8fd6c0(LWP 89224) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470a7c6in ppoll () at/lib64/libc.so.6
#40x00007f31c6916890in g_main_context_iterate_unlocked.isra () at / lib64/libglib-2.0.so.0
#50x00007f31c6916a4fing_main_loop_run() at/lib64/libglib-2.0.so.0
#60x00005593dd0d1ab0iniothread_run(opaque=0x559405a567a0) at ../../home/thuth/devel/qemu/iothread.c:70#70x00005593dd2b3311inqemu_thread_start(args=0x559405a571a0) at../../home/thuth/devel/qemu/util/qemu-thread-posix.c:393#80x00007f31c4693f54instart_thread() at/lib64/libc.so.6
#90x00007f31c471732cin__clone3() at/lib64/libc.so.6This iothread is doing nothing.
Quoted 7 lines
Thread 2 (Thread
0x7f3137fff6c0(LWP 89225) "qemu-system-alp"):
#00x00007f31c469c462in__syscall_cancel_arch() at/lib64/libc.so.6
#10x00007f31c469075cin__internal_syscall_cancel() at/lib64/libc.so.6
#20x00007f31c46907a4in__syscall_cancel() at/lib64/libc.so.6
#30x00007f31c470b2bein write () at/lib64/libc.so.6
#40x00005593dd2af441inevent_notifier_set(e=0x559405a56a54) at ../../home/thuth/devel/qemu/util/event_notifier-posix.c:117#50x00005593dd2cdcdeinaio_notify(ctx=0x559405a56980) at ../../ home/thuth/devel/qemu/util/async.c:506
Quoted 3 lines
Quoted 1 line
In this backtrace the CPU is waking up the main loop (thread 1), but the main loop is running so I don't think it's really a deadlock. It's more likely that the replay is not matching the record, or there's a similar reason why the replay is not proceeding.
I agree. It is more likely that debugging the replay code instead of the RCU change will lead to the real cause.
This now also impacts the Gitlab-CI :
https://gitlab.com/qemu-project/qemu/-/jobs/11984309870
How do we tackle this? It feels bad that we have such a subtle problem at the beginning of the freeze period. Shall we revert the RCU patch 'til the problem is understood?
Thomas
Re: Regression with the "replay" test on target alpha
Quoted 11 lines · Thomas Huth
Quoted 4 lines · Akihiko Odaki
Quoted 1 line · Paolo Bonzini
In this backtrace the CPU is waking up the main loop (thread 1), but the main loop is running so I don't think it's really a deadlock. It's more likely that the replay is not matching the record, or there's a similar reason why the replay is not proceeding.
I agree. It is more likely that debugging the replay code instead of the RCU change will lead to the real cause.
This now also impacts the Gitlab-CI :
https://gitlab.com/qemu-project/qemu/-/jobs/11984309870
How do we tackle this? It feels bad that we have such a subtle problem at the beginning of the freeze period. Shall we revert the RCU patch 'til the problem is understood?
I'll look at it today; if I can't make heads or tails of it we'll revert it, yes.
Paolo
Re: Regression with the "replay" test on target alpha
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Thomas Huth
Quoted 4 lines · Akihiko Odaki
Quoted 1 line · Paolo Bonzini
In this backtrace the CPU is waking up the main loop (thread 1), but the main loop is running so I don't think it's really a deadlock. It's more likely that the replay is not matching the record, or there's a similar reason why the replay is not proceeding.
I agree. It is more likely that debugging the replay code instead of the RCU change will lead to the real cause.
Quoted 7 lines
Quoted 5 lines
This now also impacts the Gitlab-CI :
https://gitlab.com/qemu-project/qemu/-/jobs/11984309870
How do we tackle this? It feels bad that we have such a subtle problem at the beginning of the freeze period. Shall we revert the RCU patch 'til the problem is understood?
I'll look at it today; if I can't make heads or tails of it we'll revert it, yes.
Sorry if I missed it, but did you find out anything? ... the test is still failing for me, which is somewhat annoying ...
Thomas
Re: Regression with the "replay" test on target alpha
Quoted 5 lines · Thomas Huth
Quoted 2 lines
I'll look at it today; if I can't make heads or tails of it we'll revert it, yes.
Sorry if I missed it, but did you find out anything? ... the test is still failing for me, which is somewhat annoying ...
It was failing and when I started debugging it, it fixed itself. :(
I did pin it: 1) to the _recording_ side. That is, the broken recording cannot be loaded by a good QEMU and a good recording can be loaded by a broken QEMU; 2) to the write of the WAIT system register, which is where the CPU goes to sleep and never gets the event to wake up.
The reproducer is
./qemu-system-alpha -display none -vga none -machine clipper -serial stdio -kernel kernel-alpha -append 'printk.time=0 console=ttyS0 -net none -no-reboot -nodefaults' -icount shift=9,rr=replay,rrfile=replay-bad.bin
Also, I wrote a patch to add trace events for instructions written to the replay stream, which I will send.
Paolo
[PULL 08/18] accel/mshv: initialize thread name
In reply to Paolo BonziniThe initialization was dropped when the code was copied from existing accelerators. Coverity knows (CID 1641400). Fix it.
--- accel/mshv/mshv-all.c | 3 +++ 1 file changed, 3 insertions(+)
accel/mshv/mshv-all.c +3 -0
@@ -596,6 +596,9 @@ static void mshv_start_vcpu_thread(CPUState *cpu) {char thread_name[VCPU_THREAD_NAME_SIZE ]; +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/MSHV" , + cpu->cpu_index); + cpu->thread =g_malloc0 (sizeof (QemuThread)); cpu->halt_cond =g_malloc0 (sizeof (QemuCond));
Signature · 1 line
2.51.1
[PULL 06/18] qobject: make refcount atomic
In reply to Paolo BonziniThe Rust bindings for QObject will only operate on complete objects, treating them as immutable as long as the Rust QObject is live.
With that constraint, it is trivial for Rust code to treat QObjects as thread-safe; all that's needed is to make reference count operations atomic. Do the same when the C code adds or removes references, since we don't really know what the Rust code is up to; of course C code will have to agree with not making changes to the QObjects after they've been passed to Rust code.
--- include/qobject/qobject.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/qobject/qobject.h +3 -2
@@ -32,6 +32,7 @@#ifndef QOBJECT_H #define QOBJECT_H +#include "qemu/atomic.h" #include "qapi/qapi-builtin-types.h" /* Not for use outside include/qobject/ */
@@ -73,7 +74,7 @@ QEMU_BUILD_BUG_MSG(QTYPE__MAX != 7,static inline void qobject_ref_impl (QObject *obj) {if (obj) { - obj->base.refcnt++; +qatomic_inc (&obj->base.refcnt); } }
@@ -95,7 +96,7 @@ void qobject_destroy(QObject *obj);static inline void qobject_unref_impl (QObject *obj) {assert (!obj || obj->base.refcnt); -if (obj && --obj->base.refcnt ==0 ) { +if (obj &&qatomic_fetch_dec (&obj->base.refcnt) ==1 ) {qobject_destroy (obj); } }
Signature · 1 line
2.51.1