On 4/1/22 10:58, Dave Hansen wrote:
On 3/24/22 19:22, Chang S. Bae wrote:
Some old GCC versions (4.9.x and 5.x) have an issue that incorrectlyI thought you *actually* saw xgetbv() be reordered, though. Was that on
reordering volatile asm statements with each other [1]. While this bug was
fixed on later versions (8.1, 7.3, and 6.5), and the kernel's current XCR0
read/write do not appear to be impacted, it is preventive to ensure them on
the program order.
a buggy compiler?
Actually, reading the gcc bug[1] a bit more, it says:
However, correctness here depends on the compiler honouring theIn your case, there was presumably no volatile code, just a
ordering of volatile asm statements with respect to other volatile
code, and this patch fixes that.
fpu_state_size_dynamic() call. The compiler thought the xgetbv() was
safe to reorder, and did so.
So, I'm not quite sure how that bug is relevant. It just dealt with
multiple "asm volatile" statements that don't have memory clobbers. We
only have one "asm volatile" in play. Adding the memory clobber should
make that bug totally irrelevant.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82602