qemu-system-x86_64 doesn't support x2APIC when -icount is used
I compile this minimal example code
.intel_syntax noprefix
.text
.align 4
.long 0x1BADB002, 0, -0x1BADB002
.globl _start
_start:
# Enable x2APIC via IA32_APIC_BASE
mov ecx, 0x1B
rdmsr
or eax, (1 << 10)
wrmsr
# Read the now available IA32_X2APIC_CUR_COUNT MSR.
mov ecx, 0x839
rdmsr
infinite:
jmp infiniteto a Multiboot v1-aware ELF32 image using
i686-elf-gcc -nostdlib -x assembler -o minimal.elf minimal.asmThen I can run this image successfully until the infinite loop via
qemu-system-x86_64 -cpu Skylake-Client -m 256 -kernel minimal-example.elfHowever, when I add -icount 1 like
qemu-system-x86_64 -cpu Skylake-Client -m 256 -icount 1 -kernel minimal-example.elfQEMU fails at the rdmsr instruction with
qemu-system-x86_64: Bad icount readThis looks like a bug in QEMU. The use of -icount should not influence whether x2APIC can be accessed or not.