Skip to content

Commit efec8d2

Browse files
committed
selftests: kvm: make syncregs more reliable on s390
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 <[email protected]> Suggested-by: Paolo Bonzini <[email protected]> Reviewed-by: Thomas Huth <[email protected]>
1 parent f76f637 commit efec8d2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tools/testing/selftests/kvm/s390x/sync_regs_test.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525

2626
static void guest_code(void)
2727
{
28-
register u64 stage asm("11") = 0;
29-
30-
for (;;) {
31-
GUEST_SYNC(0);
32-
asm volatile ("ahi %0,1" : : "r"(stage));
33-
}
28+
/*
29+
* We embed diag 501 here instead of doing a ucall to avoid that
30+
* the compiler has messed with r11 at the time of the ucall.
31+
*/
32+
asm volatile (
33+
"0: diag 0,0,0x501\n"
34+
" ahi 11,1\n"
35+
" j 0b\n"
36+
);
3437
}
3538

3639
#define REG_COMPARE(reg) \

0 commit comments

Comments
 (0)