KVM: selftests: do not blindly clobber registers in guest asm
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 20 May 2019 11:31:02 +0000 (13:31 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 May 2019 19:27:10 +0000 (21:27 +0200)
commit204c91eff798a78498cc7cbf1bc76892badfa96d
treecd9516683048d89eaba676657df4ac615b86c52c
parent12e9612cae0c272e0dabfc570a6d855f07361914
KVM: selftests: do not blindly clobber registers in guest asm

The guest_code of sync_regs_test is assuming that the compiler will not
touch %r11 outside the asm that increments it, which is a bit brittle.
Instead, we can increment a variable and use a dummy asm to ensure the
increment is not optimized away.  However, we also need to use a
callee-save register or the compiler will insert a save/restore around
the vmexit, breaking the whole idea behind the test.

(Yes, "if it ain't broken...", but I would like the test to be clean
before it is copied into the upcoming s390 selftests).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/sync_regs_test.c