Skip to content

Commit

Permalink
selftests: kvm: make syncregs more reliable on s390
Browse files Browse the repository at this point in the history
similar to commit 2c57da356800 ("selftests: kvm: fix sync_regs_test with
newer gccs") and commit 204c91e ("KVM: selftests: do not blindly
clobber registers in guest asm") we better do not rely on gcc leaving
r11 untouched.  We can write the simple ucall inline and have the guest
code completely as small assembler function.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
Christian Borntraeger committed Oct 10, 2019
1 parent f76f637 commit efec8d2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tools/testing/selftests/kvm/s390x/sync_regs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@

static void guest_code(void)
{
register u64 stage asm("11") = 0;

for (;;) {
GUEST_SYNC(0);
asm volatile ("ahi %0,1" : : "r"(stage));
}
/*
* We embed diag 501 here instead of doing a ucall to avoid that
* the compiler has messed with r11 at the time of the ucall.
*/
asm volatile (
"0: diag 0,0,0x501\n"
" ahi 11,1\n"
" j 0b\n"
);
}

#define REG_COMPARE(reg) \
Expand Down

0 comments on commit efec8d2

Please sign in to comment.