Re: [PATCH 2/2] KVM: VMX: Use ASM_INPUT_RM in __vmcs_writel
From: Nathan Chancellor
Date: Wed Feb 25 2026 - 14:02:28 EST
On Wed, Feb 11, 2026 at 11:28:50AM +0100, Uros Bizjak wrote:
> Use the ASM_INPUT_RM macro for VMCS write operation in vmx_ops.h to
> work around clang problems with "rm" asm constraint. clang seems to
> always chose the memory input, while it is almost always the worst
> choice.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Acked-by: Nathan Chancellor <nathan@xxxxxxxxxx>
FWIW, I hope this issue will soon be fixed in clang properly so we can
add a version check to this workaround:
https://github.com/llvm/llvm-project/pull/181973
> ---
> arch/x86/kvm/vmx/vmx_ops.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx_ops.h b/arch/x86/kvm/vmx/vmx_ops.h
> index 1000d37f5b0c..81784befaaf4 100644
> --- a/arch/x86/kvm/vmx/vmx_ops.h
> +++ b/arch/x86/kvm/vmx/vmx_ops.h
> @@ -221,7 +221,7 @@ fault: \
>
> static __always_inline void __vmcs_writel(unsigned long field, unsigned long value)
> {
> - vmx_asm2(vmwrite, "r"(field), "rm"(value), field, value);
> + vmx_asm2(vmwrite, "r" (field), ASM_INPUT_RM (value), field, value);
> }
>
> static __always_inline void vmcs_write16(unsigned long field, u16 value)
> --
> 2.53.0
>