qemu-system-x86_64 : cannot resume from S3 suspend for Q35 + OVMF
Host environment
- Operating system: Ubuntu 24.04, Debian Sid
- OS/kernel version: Kernel 6.8
- Architecture: x86
- QEMU flavor: qemu-system-x86_64
- QEMU version: 8.2.50
- QEMU command line:
qemu-system-x86_64 -machine q35 -m 256 -nographic -kernel /boot/vmlinuz-$(uname -r) -initrd ./tiny-initrd.img -append 'console=ttyS0 quiet' -bios /usr/share/ovmf/OVMF.fd -serial stdio -monitor unix:/tmp/qemu-monitor.sock,server,nowait
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version: 6.8
- Architecture: x86
Description of problem
There is a specific configuration where the resume from S3 does not work:
- Q35 machine + OVMF.fd (https://retrage.github.io/edk2-nightly/)
- TCG acceleration (it works when --accel=kvm is set)
The output at resume is:
!!!! X64 Exception Type - 05(#BR - BOUND Range Exceeded) CPU Apic ID - 00000000 !!!!
RIP - 0000000000006237, CS - 0000000000000028, RFLAGS - 0000000000000002
RAX - 0000000080000027, RCX - 0000000000000000, RDX - 0000000000000000
RBX - 0000000099200000, RSP - 000000000FF96236, RBP - 000000000FF96320
RSI - 000000000F74E000, RDI - 0000000000833F31
R8 - 0000002800000000, R9 - 0000000000000000, R10 - 000000000FF968F0
R11 - 0000000000828B30, R12 - 000000000FF9ACD0, R13 - 000000000F76B000
R14 - 000000000F76A000, R15 - 0000000000000000
DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
GS - 0000000000000030, SS - 0000000000000030
CR0 - 0000000080000033, CR2 - 0000000000000000, CR3 - 000000000F75B000
CR4 - 0000000000000668, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 0000000000833DE0 0000000000000047, LDTR - 0000000000000000
IDTR - 000000000FF97D70 000000000000021F, TR - 0000000000000000
FXSAVE_STATE - 000000000FF95E90
!!!! Can't find image information. !!!!
After bisecting, this is caused by commit : 18a536f1 If i revert this comment, the resume works nicely.
I used a script to generate a tiny initrd to test but i think the problem can be reproduced with any guest kernel + rootfs. I also verify that this problem can be reproduced with different host kernels (6.5) than the one i used (6.8)
Steps to reproduce
- Use https://gitlab.com/berrange/tiny-vm-tools/-/blob/master/make-tiny-image.py to generate tiny-initrd.img
- Run qemu and drop into shell
- Put machine into S3 (echo mem > /sys/power/state)
- Use socat to connect to QEMU monitor and wake up the machine (system_wakeup)
- The machine does not resume correctly
Additional information
Edited by Hector Cao