tests: avoid ioctl_kvm_run test failure when built with gcc -O0
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 13 Feb 2018 01:38:54 +0000 (02:38 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 13 Feb 2018 03:12:29 +0000 (03:12 +0000)
commit101621d4c7aac7be44570477480de04181236a09
tree903bd6041d46e6476697a52ea76687f0af115ecd
parent9730e10317ce36ce59d689752dd9643ead7e5509
tests: avoid ioctl_kvm_run test failure when built with gcc -O0

When built with -O0, gcc (rightfully) generates function prologue, which
results in writing %rbp to the stack, causing premature KVM_EXIT_MMIO.
It could be possible to avoid such problems by "naked" attribute but,
unfortunately, the latter is not available on x86 with older GCC.
A trick suggested in [1] is used instead: assembly is moved
to the global scope.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50242#c3

* tests/ioctl_kvm_run.c (code): Remove function.
Add globally scoped __asm__ with the function code and its size.
(code, code_size): New extern symbols declarations.
(run_kvm): Remove code_size definition and initialization.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
tests/ioctl_kvm_run.c