Re: [PATCH 03 of 36] x86: add memory barriers to wrmsr
From: H. Peter Anvin
Date: Wed Jun 25 2008 - 20:17:32 EST
Jeremy Fitzhardinge wrote:
Actually, I believe the barrier(); before is actually incorrect, since
it would affect the wrmsr() register arguments rather than the wrmsr
instruction itself.
How so? What kind of failure do think might occur? Some effect on how
the wrmsr arguments are evaluated?
barrier() is specifically a compiler optimisation barrier, so the
barrier before would prevent the compiler from moving anything logically
before the wrmsr to afterwards.
The barrier() before prevents the compiler from optimizing the access to
the arguments (before they go into registers), not the actual wrmsr;
this has to do with the ordering of operations around the barrier above.
The barrier *after* does what you just describe.
That said, making the wrmsr itself a memory clobber may be simpler
understand with a comment, rather than separate barriers...
This should be functionally equivalent to a barrier(); after, and given
that this is clearly a point of confusion *already*, I think the memory
clobber is better.
-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/