[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aRtAOM040vM9RGfK@google.com>
Date: Mon, 17 Nov 2025 07:33:12 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Borislav Petkov <bp@...en8.de>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Brendan Jackman <jackmanb@...gle.com>
Subject: Re: [PATCH v5 3/9] x86/bugs: Decouple ALTERNATIVE usage from VERW
macro definition
On Mon, Nov 17, 2025, Borislav Petkov wrote:
> On Thu, Nov 13, 2025 at 03:37:40PM -0800, Sean Christopherson wrote:
> > +#define __CLEAR_CPU_BUFFERS __stringify(VERW)
>
> Let's get rid of one indirection level pls:
>
> diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
> index 8b4885a1b2ef..59945cb5e5f9 100644
> --- a/arch/x86/include/asm/nospec-branch.h
> +++ b/arch/x86/include/asm/nospec-branch.h
> @@ -309,23 +309,21 @@
> * Note: Only the memory operand variant of VERW clears the CPU buffers.
> */
> #ifdef CONFIG_X86_64
> -#define VERW verw x86_verw_sel(%rip)
> +#define VERW __stringify(verw x86_verw_sel(%rip))
> #else
> /*
> * In 32bit mode, the memory operand must be a %cs reference. The data segments
> * may not be usable (vm86 mode), and the stack segment may not be flat (ESPFIX32).
> */
> -#define VERW verw %cs:x86_verw_sel
> +#define VERW __stringify(verw %cs:x86_verw_sel)
> #endif
Brendan also brought this up in v4[*]. Unless there's a way to coerce ALTERNATIVE_2
into working with multiple strings, the layer of indirection is needed so that KVM
can emit __stringify() for the entire sequence.
: Heh, I tried that, and AFAICT it simply can't work with the way ALTERNATIVE and
: friends are implemented, as each paramater needs to be a single unbroken string.
:
: E.g. this
:
: diff --git a/arch/x86/kvm/vmx/vmenter.S b/arch/x86/kvm/vmx/vmenter.S
: index 61a809790a58..ffa6bc2345e3 100644
: --- a/arch/x86/kvm/vmx/vmenter.S
: +++ b/arch/x86/kvm/vmx/vmenter.S
: @@ -63,6 +63,8 @@
: RET
: .endm
:
: +#define CLEAR_CPU_BUFFERS_SEQ_STRING "verw x86_verw_sel(%rip)"
: +
: .section .noinstr.text, "ax"
:
: /**
: @@ -169,9 +171,9 @@ SYM_FUNC_START(__vmx_vcpu_run)
:
: /* Clobbers EFLAGS.ZF */
: ALTERNATIVE_2 "", \
: - __stringify(jz .Lskip_clear_cpu_buffers; \
: - CLEAR_CPU_BUFFERS_SEQ; \
: - .Lskip_clear_cpu_buffers:), \
: + "jz .Lskip_clear_cpu_buffers; " \
: + CLEAR_CPU_BUFFERS_SEQ_STRING; \
: + ".Lskip_clear_cpu_buffers:", \
: X86_FEATURE_CLEAR_CPU_BUF_MMIO, \
: __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF_VM
:
: yields wonderfully helpful error messages like so:
:
: arch/x86/kvm/vmx/vmenter.S: Assembler messages:
: arch/x86/kvm/vmx/vmenter.S:173: Error: too many positional arguments
:
: If there's a magic incanation to get things to work, it's unknown to me.
[*] https://lore.kernel.org/all/aQT1JgdgiNae3Ybl@google.com
Powered by blists - more mailing lists