Re: [RFC][PATCH 15/22] x86,vmx: Remove .fixup usage

From: Paolo Bonzini
Date: Sun Nov 07 2021 - 14:14:00 EST


On 11/6/21 09:36, Peter Zijlstra wrote:
Ouch, good catch. It should be actually very simple to fix it, just mark
"value" as an "early clobber" output:

: ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc");

That's an output which is written before the instruction is finished using
the input operands. The manual even says "this operand may not lie in a
register that is read by the instruction or as part of any memory address",
which is exactly what you caught with %1 and %2 both being the same GPR.
Yes, but as Sean points out, that will negatively affect code-gen on the
happy path. But perhaps that's acceptable if we add the asm-goto-output
variant?

I think it's acceptable even without the #ifdef. Forcing registers using the a/b/c/d/S/D constraints takes away some freedom from the compiler, but using two "r" registers is going to give as good assembly as anything else. Most callers of __vmcs_readl call it either at the beginning or at the end of a function, where there aren't many live registers anyway.

Paolo