Re: [GIT PULL] KVM fixes for Linux 7.2-rc6

From: Linus Torvalds

Date: Wed Jul 29 2026 - 18:08:13 EST


On Wed, 29 Jul 2026 at 14:45, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> - Add memory clobber to asm for VMX instructions; without one, the compiler
> could reorder them in troublesome ways because "asm volatile" and "asm goto"
> only protect against removal of the asm.

This is simply not true.

"asm volatile" is not just a "don't remove". It is an ordering
constraint too. It cannot move wrt other asm volatiles.

I've merged this, because that added clobber won't really hurt, but
the bug is simply not what the description says it is.

You have to have a memory clobber if you modify memory, or read memory
that you didn't tell about.

So asm volatile is very much a "you can't re-order this asm or move it
around significantly".

But at the same time it does *not* necessarily protect against the
compiler re-ordering *other* things - like regular non-volatile memory
reads and writes.

So I think the commit message is misleading and actively wrong, and is
stating things that simply aren't even remotely true.

In fact, I think the "none of this has been observed" probably means
that the code wasn't actually even buggy, and clearly the people
involved didn't really think things through.

If all accesses are to memory that gcc isn't aware of, and all of
those are done with 'asm volatile', then the code is fine *without* a
memory clobber. The asms won't be re-ordered wrt each other, because
you have told the compiler that there are side effects.

But if you do *regular* memory accesses to some memory area, and then
you use "asm volatile" without a memory clobber, then gcc may be
moving those regular memory accesses around the asm.

See the difference?

Linus