Skip to content

Commit

Permalink
KVM: selftests: fix ucall on x86
Browse files Browse the repository at this point in the history
After commit e8bb4755eea2("KVM: selftests: Split ucall.c into architecture
specific files") selftests which use ucall on x86 started segfaulting and
apparently it's gcc to blame: it "optimizes" ucall() function throwing away
va_start/va_end part because it thinks the structure is not being used.
Previously, it couldn't do that because the there was also MMIO version and
the decision which particular implementation to use was done at runtime.

With older gccs it's possible to solve the problem by adding 'volatile'
to 'struct ucall' but at least with gcc-8.3 this trick doesn't work.

'memory' clobber seems to do the job.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Vitaly Kuznetsov authored and Paolo Bonzini committed Sep 25, 2019
1 parent 89340d0 commit 90a4884
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/kvm/lib/x86_64/ucall.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void ucall(uint64_t cmd, int nargs, ...)
va_end(va);

asm volatile("in %[port], %%al"
: : [port] "d" (UCALL_PIO_PORT), "D" (&uc) : "rax");
: : [port] "d" (UCALL_PIO_PORT), "D" (&uc) : "rax", "memory");
}

uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)
Expand Down

0 comments on commit 90a4884

Please sign in to comment.