Bug: arch/x86/kvm/x86.c:3241: Error: bad register name `%dil'

From: H. Nikolaus Schaller
Date: Fri Nov 19 2021 - 05:34:06 EST


Hi Paolo and David,
I have a strange compile error which appeared in v5.15.3:

CALL scripts/checksyscalls.sh - due to target missing
CALL scripts/atomic/check-atomics.sh - due to target missing
CHK include/generated/compile.h - due to compile.h not in $(targets)
CC arch/x86/kvm/x86.o - due to target missing
arch/x86/kvm/x86.c: Assembler messages:
arch/x86/kvm/x86.c:3241: Error: bad register name `%dil'
scripts/Makefile.build:277: recipe for target 'arch/x86/kvm/x86.o' failed
make[3]: *** [arch/x86/kvm/x86.o] Error 1
scripts/Makefile.build:540: recipe for target 'arch/x86/kvm' failed
make[2]: *** [arch/x86/kvm] Error 2
Makefile:1868: recipe for target 'arch/x86' failed
make[1]: *** [arch/x86] Error 2
Makefile:350: recipe for target '__build_one_by_one' failed
make: *** [__build_one_by_one] Error 2

My (cross-)compiler is a gcc 6.3.0 for 32 bit x86.

It is neither with v5.15.2 nor v5.16-rc1 nor v5.14.20.

The code line 3241 is:

asm volatile("1: xchgb %0, %2\n"
"xor %1, %1\n"
"2:\n"
_ASM_EXTABLE_UA(1b, 2b)
: "+r" (st_preempted),
"+&r" (err)
: "m" (st->preempted));

This seems to have been introduced by:

9d12bf19b278 KVM: x86: Fix recording of guest steal time / preempted status

but it is a backport of commit 7e2175ebd695f17860c5bd4ad7616cce12ed4591
which was also merged to 5.14.20.

So maybe the backport is incomplete or has some hidden dependency?
But only on the 5.15.y series?

BR and thanks,
Nikolaus Schaller