x86/time: fix wc_version retry check When using | instead of || (attempting to make the compiler issue just a single branch), both sides of the operator aren't separated by a sequence point, and hence evaluation can happen in any order. In particular the rightmost read of s->wc_version could get carried out before the leftmost one. Use a local variable to prevent this. (In reality the compiler is very likely to do only a single memory read here anyway.) Reported-by: Julian Stecklina Signed-off-by: Jan Beulich --- a/arch/i386/kernel/time-xen.c +++ b/arch/i386/kernel/time-xen.c @@ -257,6 +257,7 @@ static void update_wallclock(void) { shared_info_t *s = HYPERVISOR_shared_info; + u32 version; do { shadow_tv_version = s->wc_version; @@ -264,7 +265,8 @@ shadow_tv.tv_sec = s->wc_sec; shadow_tv.tv_nsec = s->wc_nsec; rmb(); - } while ((s->wc_version & 1) | (shadow_tv_version ^ s->wc_version)); + version = s->wc_version; + } while ((version & 1) | (shadow_tv_version ^ version)); if (!independent_wallclock) __update_wallclock(shadow_tv.tv_sec, shadow_tv.tv_nsec);