AI assistance disclosure: OpenAI Codex/ChatGPT assisted with investigation, source research, diagnostic and test tooling, and drafting this report. An experimental local correction was also developed with AI assistance. The measurements below come from executed, retained test runs. This is a bug report, not a patch submission; no AI-generated patch is attached or offered for merging.
Hello QEMU team,
GitLab account verification currently prevents me from accessing the issue
tracker. I am sending this technical report here and would appreciate advice on
routing it into the tracker if appropriate.
While developing our own Intel64 operating system, OS64, we encountered
inconsistent XSTATE enumeration. We subsequently reproduced the problem without
an OS64 image, directly while configuring a stopped KVM vCPU.
QEMU 11.1.3 passes the following CPUID leaf 0xD, subleaf 1 values to KVM:
EAX=0x00000001 EBX=0x00000340 ECX=0x00000000 EDX=0x00000000
EAX advertises XSAVEOPT, but neither XSAVEC (bit 1) nor XSAVES (bit 3). Intel's
SDM specifies EBX=0 for this combination. The observed 0x340 is 832 bytes.
## Host environment
- openSUSE Tumbleweed 20261111; Linux 7.3.3-1-default; x86_64; KVM.
- Two Intel Xeon E5-2699 v4 processors; family 6, model 0x4F, stepping 1.
- QEMU 11.1.3; distribution package qemu-x86 11.1.3-1.1.
- Also reproduced with an unmodified build of the official upstream source
release: https://download.qemu.org/qemu-11.1.3.tar.xz
- Minimal reproducer: q35/KVM, `-cpu host`, one vCPU, 64 MiB, `-S`; no guest
disk required and no guest or firmware code executed.
- Separate in-guest confirmation: OS64, q35-11.1/KVM, host-passthrough, one
vCPU, 16 GiB, OVMF, VGA. The OS64 image and CPU profile were unchanged across
the comparison.
## Expected behavior
Intel SDM Volume 1, revision 093, section 13.2, printed page 13-5 (PDF page
324), specifies that CPUID.0DH.01H:EBX is zero when both EAX[1] and EAX[3] are
zero. XSAVEOPT alone does not change that condition.
Reference:
https://cdrdv2-public.intel.com/929351/253665-093-sdm-vol-1.pdf#page=324
## Steps to reproduce
Prerequisites: KVM access, strace, and a host/exposed feature set without
XSAVEC or XSAVES. Our native host returns D.1:EAX=1 and EBX=0.
Use the unmodified QEMU binary under test. For an upstream build, replace only
the executable path; `/usr/share/qemu` is the resource directory used in our
test.
```sh
strace -f -v -s 65535 -e trace=ioctl -o cpuid-ioctl.log \
qemu-system-x86_64 -name OS64-CPUID-REPAIR-PROBE \
-no-user-config -nodefaults -display none \
-machine q35,accel=kvm -cpu host -m 64 -smp 1 -S \
-monitor none -serial none -L /usr/share/qemu -qmp stdio <<'QMP'
{"execute":"qmp_capabilities"}
{"execute":"quit"}
QMP
```
Inspect the successful `KVM_SET_CPUID2` call:
```text
{function=0xd, index=0x1, flags=KVM_CPUID_FLAG_SIGNIFCANT_INDEX,
eax=0x1, ebx=0x340, ecx=0, edx=0}
```
Each retained probe contains exactly one successful `KVM_SET_CPUID2` call, no
`KVM_RUN` call, and process exit 0. The test sent these QMP commands through
standard input; the here-document expresses that same sequence without our
local Python wrapper.
## Actual results
Values below are EAX / EBX / ECX / EDX (decimal):
| Observation | Values |
| --- | --- |
| Native host CPUID | 1 / 0 / 0 / 0 |
| KVM_GET_SUPPORTED_CPUID | 1 / 0 / 0 / 0 |
| Distribution QEMU, KVM_SET_CPUID2 | 1 / 832 / 0 / 0 |
| Unmodified upstream rebuild, same invocation | 1 / 832 / 0 / 0 |
| CPUID executed in the guest before correction | 1 / 832 / 0 / 0 |
| Experimental local correction, installation and guest | 1 / 0 / 0 / 0 |
The inconsistent value is therefore passed by QEMU to KVM before guest
execution. The direct reproducer needs neither libvirt nor our OS code. All 31
installed CPUID records match between the distribution binary and the
unmodified upstream rebuild.
## Source localization and local validation
In the 11.1.3 source, `cpu_x86_cpuid()` in `target/i386/cpu.c` computes the
compacted size for leaf 0xD/subleaf 1 without requiring the exposed
XSAVEC/XSAVES bits at that point:
https://github.com/qemu/qemu/blob/v11.1.3/target/i386/cpu.c
An experimental local change conditions that calculation on the exposed
capabilities. Across the 31 installed records, only D.1:EBX changes, from 832
to 0. EAX/ECX/EDX and all other records remain unchanged; no extra CPU
capabilities are advertised. With the identical OS64 image and CPU profile, the
VM then reaches its intended halt after CPU inventory. OS64's consistency check
was not changed.
We also exercised the compiled CPUID function with 24 synthetic inputs. These
are not 24 tested CPUs. In particular, eight XSAVES-without-XSAVEC cases are
robustness probes, not valid Intel feature combinations. We do not claim an
actual XSAVES KVM runtime test on this host. The attachment states these limits
explicitly. The local AI-assisted correction is not submitted as a patch.
## Scope and request
Runtime reproduction covers 11.1.3, including the unmodified official source
rebuild. We have not built and runtime-tested 11.2.0-rc0 or git master. We do
not claim first discovery or impact on every CPU model.
Could you please check this finding and, if confirmed, correct the CPUID
generation? If this case is already known or we have missed a relevant
limitation, a reference would be appreciated.
The attached `qemu-cpuid-evidence.zip` contains environment details, native
host/KVM output, all 31 installation records from each of the three QEMU
builds, explicitly identified ioctl excerpts, selected original guest records,
the bounded validation summary, reproduction instructions, and SHA-256
checksums. Only the process-ID prefixes were removed from the ioctl excerpts;
register and return values are unchanged. Private paths, VM identifiers, OS64
source, and guest images are not included.
Thank you for your work on QEMU and for looking into this report.
Best regards,
Mirko<<attachment: qemu-cpuid-evidence.zip>>
