qemu-cr16/tests
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
..
bench tests/bench: Rename test_akcipher_keys.inc -> test_akcipher_keys.c.inc 2024-09-20 10:08:24 +03:00
data tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _DSM change 2025-11-09 08:24:29 -05:00
decode decodetree: Infer argument set before inferring format 2025-07-25 10:31:45 +01:00
docker tests/docker: drop --disable-[tools|system] from all-test-cross 2025-12-05 15:26:19 +00:00
fp fpu: allow flushing of output denormals to be after rounding 2025-02-11 16:22:07 +00:00
functional tests/functional: migrate sbsa_ref test images 2026-02-02 16:18:57 +03:00
guest-debug tests, scripts: Don't import print_function from __future__ 2025-09-16 17:31:53 +01:00
image-fuzzer
include meson: fix Windows build 2025-06-16 13:16:27 -04:00
keys
lcitool tests/docker: drop --disable-[tools|system] from all-test-cross 2025-12-05 15:26:19 +00:00
migration-stress guestperf: Add test result data into report 2025-02-14 15:19:07 -03:00
multiboot
perf/block/qcow2
qapi-schema qapi: Add documentation format validation 2025-11-04 13:55:27 +01:00
qemu-iotests tests/qemu-iotests: Fix check for existing file in _require_disk_usage() 2025-12-10 17:40:34 +01:00
qtest q35: Fix migration of SMRAM state 2026-02-06 00:46:09 +03:00
rocker
tcg tests: add tcg coverage for fixed mremap bugs 2026-01-13 00:33:05 +03:00
tracetool tracetool/syslog: add Rust support 2025-10-01 11:22:07 -04:00
tsan system/physmem: Drop 'cpu_' prefix in Physical Memory API 2025-10-07 05:03:56 +02:00
uefi-test-tools uefi-test-tools:: Add LoongArch64 support 2025-06-01 06:38:53 -04:00
unit tests: Clean up includes 2025-11-14 13:18:04 +00:00
vm tests/docker: add coreutils to the package list 2025-11-17 15:51:00 +00:00
dbus-vmstate-daemon.sh
Makefile.include tests/tcg: honour the available QEMU binaries when running check-tcg 2025-12-05 15:25:51 +00:00
meson.build tracetool: add test suite for tracetool with reference output 2025-09-16 13:31:40 -04:00
test-qht-par.c
vhost-user-bridge.c tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc 2025-12-16 14:28:30 +01:00