selftests: KVM: Handle compiler optimizations in ucall
authorRaghavendra Rao Ananta <rananta@google.com>
Wed, 15 Jun 2022 18:57:06 +0000 (18:57 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Aug 2022 11:07:51 +0000 (13:07 +0200)
commite423893fe3209604236874e412dd3a9386578cff
tree7fbe02d3bfcc8662685f9abade90798e5adc4da6
parentbc2cee443c7401a15227bb7f9e7e0a967563cfd2
selftests: KVM: Handle compiler optimizations in ucall

[ Upstream commit 9e2f6498efbbc880d7caa7935839e682b64fe5a6 ]

The selftests, when built with newer versions of clang, is found
to have over optimized guests' ucall() function, and eliminating
the stores for uc.cmd (perhaps due to no immediate readers). This
resulted in the userspace side always reading a value of '0', and
causing multiple test failures.

As a result, prevent the compiler from optimizing the stores in
ucall() with WRITE_ONCE().

Suggested-by: Ricardo Koller <ricarkol@google.com>
Suggested-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
Message-Id: <20220615185706.1099208-1-rananta@google.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/kvm/lib/aarch64/ucall.c