qemu-cr16/tests/qtest
Igor Mammedov 080b623ed4 q35: Fix migration of SMRAM state
When migrating, dst QEMU by default has SMRAM unlocked,
and since wmask is not migrated, the migrated value of
MCH_HOST_BRIDGE_F_SMBASE in config space fall to prey of

  mch_update_smbase_smram()
    ...
    if (pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] == 0xff) {
        *reg = 0x00;

and is getting cleared and leads to unlocked smram
on dst even if on source it's been locked.

As Andrey has pointed out [1], we should derive wmask
from config and not other way around.

Drop offending chunk and resync wmask based on MCH_HOST_BRIDGE_F_SMBASE
register value. That would preserve the register during
migration and set smram regions into corresponding state.

What that changes is:
that it would let guest write junk values in register
(with no apparent effect) until it's stumbles upon
reserved 0x1 [|] 0x2 values, at which point it
would be only possible to lock register and trigger
switch to SMRAM blackhole in CPU AS.

While at it, fix up test by removing junk discard before negotiation hunk.

PS2:
Instead of adding a dedicated post_load handler for it,
reuse mch_update->mch_update_smbase_smram call chain
that is called on write/reset/post_load to be consistent
with how we handle mch registers.

PS3:
for prosterity here is erro message Andrey got due to this bug:
    qemu: vfio_container_dma_map(0x..., 0x0, 0xa0000, 0x....) = -22 (Invalid argument)
    qemu: hardware error: vfio: DMA mapping failed, unable to continue

1) https://patchew.org/QEMU/20251203180851.6390-1-arbn@yandex-team.com/

Fixes: f404220e27 ("q35: implement 128K SMRAM at default SMBASE address")
Reported-by: Andrey Ryabinin <arbn@yandex-team.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrey Ryabinin <arbn@yandex-team.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20251211165454.288476-1-imammedo@redhat.com>
(cherry picked from commit 66cf169e29b06dca104c5a229fba0da4ce33599c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-02-06 00:46:09 +03:00
..
fuzz treewide: use qemu_set_blocking instead of g_unix_set_fd_nonblocking 2025-09-19 12:46:07 +01:00
libqos tests/libqos: extract qvirtqueue_set_avail_idx() 2025-10-05 09:01:08 -04:00
migration tests/migration-test: Use MEM_TYPE_MEMFD for memory_backend 2025-11-21 19:23:46 -05:00
ac97-test.c tests/qtest/ac97-test: add up-/downsampling tests 2023-05-26 09:10:49 +02:00
acpi-utils.c tests/qtest: remove return after g_assert_not_reached() 2024-09-24 13:53:35 +02:00
acpi-utils.h
adm1266-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
adm1272-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
ahci-test.c cleanup: Drop pointless return at end of function 2025-04-24 09:33:42 +02:00
am53c974-test.c qtest/am53c974-test: add additional test for cmdfifo overflow 2025-10-28 14:50:07 +01:00
arm-cpu-features.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
aspeed-hace-utils.c test/qtest/hace: Support to validate 64-bit hmac key buffer addresses 2025-05-25 23:39:11 +02:00
aspeed-hace-utils.h tests: Clean up includes 2025-11-14 13:18:04 +00:00
aspeed-smc-utils.c test/qtest: Introduce a new aspeed-smc-utils.c to place common testcases 2024-12-11 07:25:53 +01:00
aspeed-smc-utils.h tests: Clean up includes 2025-11-14 13:18:04 +00:00
aspeed_fsi-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
aspeed_gpio-test.c tests: Clean up includes 2025-11-14 13:18:04 +00:00
aspeed_hace-test.c test/qtest/hace: Support to validate 64-bit hmac key buffer addresses 2025-05-25 23:39:11 +02:00
aspeed_scu-test.c tests/qtest: Add test for ASPEED SCU 2025-07-03 13:41:57 +02:00
aspeed_smc-test.c hw/arm/aspeed: ast2600-evb: Use w25q512jv flash model 2025-10-22 08:14:09 +02:00
ast2700-gpio-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
ast2700-hace-test.c test/qtest/hace: Add tests for AST2700 2025-05-25 23:39:11 +02:00
ast2700-smc-test.c tests/qtest/ast2700-smc-test: Fix leak 2025-05-25 23:39:11 +02:00
bcm2835-dma-test.c tests/: spelling fixes 2023-09-08 13:08:52 +03:00
bcm2835-i2c-test.c hw/sensor/tmp105: Lower 4 bit of limit registers are always 0 2024-09-13 20:11:13 +02:00
bios-tables-test-allowed-diff.h tests/acpi: virt: update HEST and DSDT tables 2025-10-05 08:16:07 -04:00
bios-tables-test.c tests/qtest: Add missing checks for the availability of machines 2025-10-01 17:09:21 -03:00
boot-order-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
boot-sector.c tests: boot_sector_test(): make it multi-shot 2023-01-28 06:21:29 -05:00
boot-sector.h
boot-serial-test.c tests: Add functional tests for HPPA machines 2025-01-13 17:16:04 +01:00
cdrom-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
cmsdk-apb-dualtimer-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
cmsdk-apb-timer-test.c
cmsdk-apb-watchdog-test.c cleanup: Re-run return_directly.cocci 2025-04-24 09:33:24 +02:00
cpu-plug-test.c tests/qtest: Add missing checks for the availability of machines 2025-10-01 17:09:21 -03:00
cxl-test.c qtest/cxl: Add aarch64 virt test for CXL 2025-07-10 09:11:19 +01:00
dbus-display-test.c tests: Clean up includes 2025-11-14 13:18:04 +00:00
dbus-vmstate-test.c tests/qtest: Use EXIT_FAILURE instead of magic number 2022-10-28 14:31:49 +02:00
device-introspect-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
device-plug-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
display-vga-test.c tests/qtest/display-vga-test: Add proper checks if a device is available 2023-01-31 09:05:26 +01:00
dm163-test.c tests/qtest: Add missing qtest_quit() to stm32 tests 2024-09-06 13:59:30 +01:00
drive_del-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
ds1338-test.c tests/qtest/ds1338: Reuse from_bcd() 2025-10-22 08:55:15 +02:00
e1000-test.c tests: Fix error strings 2022-09-20 11:23:02 +02:00
e1000e-test.c tests/qtest/e1000e-test: Fabricate ethernet header 2023-03-10 17:26:47 +08:00
eepro100-test.c
emc141x-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
endianness-test.c Revert "Remove the unused sh4eb target" 2024-11-04 14:16:11 +01:00
erst-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
es1370-test.c tests/qtest: Specify audiodev= and -audiodev 2023-09-22 16:30:08 +02:00
fdc-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
fuzz-e1000e-test.c
fuzz-lsi53c895a-test.c hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330) 2023-05-26 09:37:04 +02:00
fuzz-megasas-test.c qtest: "-display none" is set in qtest_init() 2022-10-11 12:36:15 +02:00
fuzz-sb16-test.c qtest: "-display none" is set in qtest_init() 2022-10-11 12:36:15 +02:00
fuzz-sdcard-test.c qtest: "-display none" is set in qtest_init() 2022-10-11 12:36:15 +02:00
fuzz-virtio-scsi-test.c qtest: "-display none" is set in qtest_init() 2022-10-11 12:36:15 +02:00
fuzz-xlnx-dp-test.c qtest: "-display none" is set in qtest_init() 2022-10-11 12:36:15 +02:00
fw_cfg-test.c qtest/fw-cfg: remove compiled out code 2025-01-02 19:02:11 -03:00
hd-geo-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
hexloader-test.c cleanup: Tweak and re-run return_directly.cocci 2022-12-14 16:19:35 +01:00
i440fx-test.c tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable 2022-09-27 20:51:20 +02:00
i82801b11-test.c
ide-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
igb-test.c igb: Introduce qtest for igb device 2023-03-10 17:26:47 +08:00
intel-hda-test.c tests/qtest: Specify audiodev= and -audiodev 2023-09-22 16:30:08 +02:00
intel-iommu-test.c tests/qtest: Add intel-iommu test 2025-01-15 13:06:39 -05:00
ioh3420-test.c
ipmi-bt-test.c chardev: finalize 'reconnect' deprecation 2024-10-28 14:37:25 +08:00
ipmi-kcs-test.c tests/qtest: replace assert(0) with g_assert_not_reached() 2024-09-17 10:50:39 +02:00
ipoctal232-test.c
isl_pmbus_vr-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
ivshmem-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
libqmp.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
libqmp.h qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
libqtest-single.h tests/qtest: libqtest: Adapt global_qtest declaration for win32 2022-09-27 20:51:21 +02:00
libqtest.c tests/qtest: Use exit-with-parent=on in qtest invocations 2025-11-03 10:05:39 +00:00
libqtest.h tests/qtest: qtest_init_after_exec 2025-10-01 17:09:22 -03:00
lpc-ich9-test.c
lsm303dlhc-mag-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
m48t59-test.c ppc/ppc405: Remove tests 2025-03-11 22:40:47 +10:00
machine-none-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
max34451-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
megasas-test.c
meson.build tests/qtest/bios-tables-test: Add basic testing for LoongArch 2025-07-14 09:16:40 -04:00
microbit-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
migration-test.c tests/qtest/migration: Pick smoke tests 2025-02-10 13:47:58 +00:00
modules-test.c blkio: add libblkio block driver 2022-10-26 14:56:42 -04:00
ne2000-test.c
netdev-socket.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
npcm7xx_adc-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
npcm7xx_emc-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
npcm7xx_gpio-test.c
npcm7xx_pwm-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
npcm7xx_rng-test.c
npcm7xx_sdhci-test.c tests/qtest/npcm7xx_sdhci: Access the card using its published address 2024-07-05 23:50:12 +02:00
npcm7xx_smbus-test.c
npcm7xx_timer-test.c tests/qtest: don't step clock at start of npcm7xx periodic IRQ test 2025-02-10 13:47:58 +00:00
npcm7xx_watchdog_timer-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
npcm_gmac-test.c tests/qtest: Migrate GMAC test from 7xx to 8xx 2025-05-29 17:45:09 +01:00
numa-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
nvme-test.c hw/nvme: Validate PMR memory size 2025-11-25 09:21:41 +01:00
pca9552-test.c misc/pca955*: Move models under hw/gpio 2024-03-25 15:05:38 +01:00
pci-test.c
pcnet-test.c
pflash-cfi02-test.c tests/qtest/pflash: Clean up local variable shadowing 2023-09-12 12:07:31 +02:00
pnv-host-i2c-test.c cleanup: Re-run return_directly.cocci 2025-04-24 09:33:24 +02:00
pnv-spi-seeprom-test.c tests: Clean up includes 2025-11-14 13:18:04 +00:00
pnv-xive2-common.c tests/qtest: Add XIVE tests for the powernv10 machine 2024-11-04 09:14:57 +10:00
pnv-xive2-common.h ppc/xive2: Add support for MMIO operations on the NVPG/NVC BAR 2025-03-11 22:43:31 +10:00
pnv-xive2-flush-sync.c qtest/xive: Change printf to g_test_message 2025-03-11 22:43:31 +10:00
pnv-xive2-nvpg_bar.c qtest/xive: Change printf to g_test_message 2025-03-11 22:43:31 +10:00
pnv-xive2-test.c qtest/xive: Add test of pool interrupts 2025-03-11 22:43:31 +10:00
pnv-xscom-test.c ppc/pnv: Test pnv i2c master and connected devices 2024-02-23 23:24:42 +10:00
pnv-xscom.h ppc/pnv: Update Power10's cfam id to use Power10 DD2 2024-07-26 09:21:06 +10:00
ppc-util.h tests/qtest: Move common define from libqos-spapr.h to new ppc-util.h 2024-06-14 14:00:46 -03:00
prom-env-test.c tests/qtest: Move common define from libqos-spapr.h to new ppc-util.h 2024-06-14 14:00:46 -03:00
pvpanic-pci-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
pvpanic-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
pxe-test.c tests/qtest: Move common define from libqos-spapr.h to new ppc-util.h 2024-06-14 14:00:46 -03:00
q35-test.c q35: Fix migration of SMRAM state 2026-02-06 00:46:09 +03:00
qmp-cmd-test.c hw/uefi: add query-firmware-log monitor command 2025-10-22 11:32:07 +02:00
qmp-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
qom-test.c qtest/qom-test: Don't bother to execute QMP command quit 2025-09-01 13:44:19 +02:00
qos-test.c Revert "tests/qtest: use qos_printf instead of g_test_message" 2025-09-01 13:44:28 +02:00
qtest_aspeed.c qtest: Add functions for accessing devices on Aspeed I2C controller 2023-04-20 11:25:32 +02:00
qtest_aspeed.h aspeed: Clean up includes 2024-01-30 21:20:20 +03:00
readconfig-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
riscv-csr-test.c tests/qtest: Add missing checks for the availability of machines 2025-10-01 17:09:21 -03:00
riscv-iommu-test.c qtest/riscv-iommu-test: add init queues test 2024-10-31 13:51:24 +10:00
rs5c372-test.c hw/rtc: Add Ricoh RS5C372 RTC emulation 2025-03-11 20:01:26 +01:00
rtas-test.c tests: add G_GNUC_PRINTF for various functions 2023-01-11 10:44:34 +01:00
rtc-test.c tests/qtest: Adapt {m48t59,rtc}-test cases for win32 2022-08-25 15:24:09 +02:00
rtl8139-test.c tests/qtest: replace assert(0) with g_assert_not_reached() 2024-09-17 10:50:39 +02:00
sdhci-test.c
sifive-e-aon-watchdog-test.c tests/qtest: sifive-e-aon-watchdog-test.c: Add QTest of watchdog of sifive_e 2023-07-10 22:29:15 +10:00
spapr-phb-test.c
sse-timer-test.c tests/qtest : Use g_assert_cmphex instead of g_assert_cmpuint 2024-04-25 07:03:04 +02:00
stm32l4x5.h tests/qtest: Check STM32L4x5 clock connections 2024-10-15 11:29:46 +01:00
stm32l4x5_exti-test.c tests/qtest: Ensure STM32L4x5 EXTI state is correct at the end of QTests 2024-07-01 15:40:54 +01:00
stm32l4x5_gpio-test.c tests/qtest: Use qtest_system_reset() instead of open-coded versions 2024-12-12 10:25:38 -03:00
stm32l4x5_rcc-test.c tests/qtest/stm32l4x5_rcc-test.c: Add tests for the STM32L4x5_RCC 2024-03-05 13:22:56 +00:00
stm32l4x5_syscfg-test.c tests/qtest: Use qtest_system_reset() instead of open-coded versions 2024-12-12 10:25:38 -03:00
stm32l4x5_usart-test.c cleanup: Re-run return_directly.cocci 2025-04-24 09:33:24 +02:00
tco-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
test-arm-mptimer.c
test-filter-mirror.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
test-filter-redirector.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
test-hmp.c hmp: Remove deprecated 'singlestep' command 2024-01-19 11:38:32 +01:00
test-netfilter.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
test-x86-cpuid-compat.c hw/i386/pc: Remove deprecated pc-q35-2.4 and pc-i440fx-2.4 machines 2025-05-30 09:52:08 +02:00
tmp105-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
tpm-crb-swtpm-test.c qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tpm-crb-test.c qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tpm-emu.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
tpm-emu.h include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
tpm-tests.c tests: Wait for migration completion on destination QEMU to avoid failures 2024-10-18 07:58:04 -04:00
tpm-tests.h tests/: spelling fixes 2023-09-08 13:08:52 +03:00
tpm-tis-device-swtpm-test.c qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tpm-tis-device-test.c
tpm-tis-i2c-test.c tests/: spelling fixes 2023-09-08 13:08:52 +03:00
tpm-tis-swtpm-test.c qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tpm-tis-test.c
tpm-tis-util.c tests/: spelling fixes 2023-09-08 13:08:52 +03:00
tpm-tis-util.h qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tpm-util.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
tpm-util.h qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it 2023-04-20 11:25:32 +02:00
tulip-test.c
ufs-test.c tests/qtest/ufs-test: Add test for mcq completion queue wraparound 2026-02-02 16:21:37 +03:00
usb-hcd-ehci-test.c tests/qtest/usb-hcd-ehci-test: Check for EHCI and UHCI HCDs before using them 2023-05-26 09:10:49 +02:00
usb-hcd-ohci-test.c
usb-hcd-uhci-test.c tests/qtest/usb-hcd: Remove the empty "init" tests 2023-09-08 13:08:52 +03:00
usb-hcd-xhci-test.c tests/qtest/usb-hcd: Remove the empty "init" tests 2023-09-08 13:08:52 +03:00
vhost-user-blk-test.c tests/qtest/vhost-user-blk-test: use memory-backend-shm 2024-07-03 18:14:06 -04:00
vhost-user-test.c char: rename CharBackend->CharFrontend 2025-10-28 14:49:52 +01:00
virtio-9p-test.c tests/9p: Test Tsetattr can truncate unlinked file 2025-05-05 11:28:29 +02:00
virtio-balloon-test.c tests/qtest: add test for querying balloon guest stats 2024-12-03 12:26:24 +01:00
virtio-blk-test.c tests/qtest: replace qmp_discard_response with qtest_qmp_assert_success 2023-05-16 09:14:18 +02:00
virtio-ccw-test.c tests/qtest/virtio-ccw: Fix device presence checking 2024-01-11 11:39:26 +01:00
virtio-iommu-test.c tests/qtest/virtio-iommu-test: Don't pass uninitialized data into qtest_memwrite 2025-01-02 16:00:50 -03:00
virtio-net-failover.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
virtio-net-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
virtio-rng-test.c
virtio-scsi-test.c tests/virtio-scsi: add a virtio_error() IOThread test 2025-10-05 09:01:08 -04:00
virtio-serial-test.c
virtio-test.c
vmcoreinfo-test.c tests/qtest/vmcoreinfo: add a unit test to exercize basic vmcoreinfo function 2025-02-03 12:15:50 -03:00
vmgenid-test.c treewide: update docs file extensions (.txt -> .rst) in comments 2025-07-02 18:26:27 +02:00
vmxnet3-test.c
vnc-display-test.c qtest: enable vnc-display test on win32 2023-03-13 15:41:32 +04:00
wdt_ib700-test.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
xlnx-can-test.c
xlnx-canfd-test.c tests/qtest: xlnx-canfd-test: Fix code coverity issues 2023-07-06 13:26:43 +01:00
xlnx-versal-trng-test.c tests/qtest/xlnx-versal-trng-test.c: Drop use of variable length array 2024-02-02 13:51:58 +00:00