linux-2.6.18/x86/time: fix wc_version retry check
PATCH 1/1 linux-2.6.18/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.)
arch/i386/kernel/time-xen.c +3 -1
@@ -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);
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.)
arch/i386/kernel/time-xen.c +3 -1
@@ -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);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel