aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-10-13 21:12:34 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2022-10-28 06:10:28 -0400
commit5addaf530995ac203fa46efde0d1ded4c15ff98e (patch)
tree5916939a21c694df4e481ed4a2687078eb3ccf21 /tools/testing
parentKVM: selftests: Add tests in xen_shinfo_test to detect lock races (diff)
downloadlinux-dev-5addaf530995ac203fa46efde0d1ded4c15ff98e.tar.xz
linux-dev-5addaf530995ac203fa46efde0d1ded4c15ff98e.zip
KVM: selftests: Mark "guest_saw_irq" as volatile in xen_shinfo_test
Tag "guest_saw_irq" as "volatile" to ensure that the compiler will never optimize away lookups. Relying on the compiler thinking that the flag is global and thus might change also works, but it's subtle, less robust, and looks like a bug at first glance, e.g. risks being "fixed" and breaking the test. Make the flag "static" as well since convincing the compiler it's global is no longer necessary. Alternatively, the flag could be accessed with {READ,WRITE}_ONCE(), but literally every access would need the wrappers, and eking out performance isn't exactly top priority for selftests. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20221013211234.1318131-17-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
index caa3f5ab9e10..2a5727188c8d 100644
--- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
@@ -132,7 +132,7 @@ struct {
struct kvm_irq_routing_entry entries[2];
} irq_routes;
-bool guest_saw_irq;
+static volatile bool guest_saw_irq;
static void evtchn_handler(struct ex_regs *regs)
{