From: "Jürgen Groß" <jgross@suse.com>
To: Shreshth Srivastava <shreshth.srivastava@intel.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
linux-coco@lists.linux.dev, kvm@vger.kernel.org,
linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev,
llvm@lists.linux.dev
Cc: tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, xin@zytor.com,
nathan@kernel.org, ndesaulniers@google.com, jpoimboe@kernel.org,
peterz@infradead.org, boris.ostrovsky@oracle.com,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 00/17] x86/msr: Inline rdmsr/wrmsr instructions
Date: Fri, 25 Sep 2026 12:25:34 +0200 [thread overview]
Message-ID: <a5c73733-af28-4c74-b7e1-c64b5e3232c4@suse.com> (raw)
In-Reply-To: <20260923193619.1408940-1-shreshth.srivastava@intel.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 3224 bytes --]
On 23.09.26 21:36, Shreshth Srivastava wrote:
> On 11.09.26 10:41, Juergen Gross wrote:
>> When building a kernel with CONFIG_PARAVIRT_XXL the paravirt
>> infrastructure will always use functions for reading or writing MSRs,
>> even when running on bare metal.
>
> Hi Juergen,
>
> This doesn't build with CONFIG_PARAVIRT_XXL=y. 16/17 and 17/17 are where
> it breaks, but the cause is the .byte fallbacks: ASM_WRMSRNS_IMM from
> 08/17 and ASM_RDMSR_IMM from 10/17 don't end in a separator, unlike the
> .insn variants above them.
>
> #define ASM_RDMSR_IMM \
> " .byte 0xc4,0xe7,0x7b,0xf6,0xc0; .long %c[msr]"
>
> That worked while they were only ever the last argument of an
> ALTERNATIVE(), which appends its own newline. 16/17 concatenates them
> with ASM_CLRERR:
>
> ASM_RDMSR_IMM ASM_CLRERR, X86_FEATURE_MSR_IMM, \
>
> so the .long operand runs into the xor. From
> make arch/x86/kernel/cpu/common.s:
>
> .byte 0xc4,0xe7,0x7b,0xf6,0xc0; .long 266xor %rdx,%rdx
>
> paravirt-msr.h:165: Error: junk at end of line, first unrecognized character is `x'
>
> clang reports "error: unexpected token" in the same place. 71 objects
> fail, the same 71 either way, no vmlinux.
>
> msr.h chooses between the .insn form and the .byte fallback with:
>
> #if defined(CONFIG_AS_IS_GNU) && CONFIG_AS_VERSION >= 24100
>
> Two kinds of toolchain end up on the .byte side of that test:
>
> - GNU as older than 2.41. RHEL 9 and CentOS Stream 9 ship 2.35, and
> Documentation/process/changes.rst sets the minimum at 2.30, so this
> is a supported configuration rather than an old outlier.
> - clang, any version. CONFIG_AS_IS_GNU is never set for clang, so the
> && short-circuits and the version comparison is never reached. Your
> 08/17 comment already notes that clang has no .insn support.
>
> gcc with binutils 2.41 or newer takes the .insn path, where both macros
> do end in a separator, and is unaffected.
>
> Reproduced on v7.3-rc2 with your v3 00/13, v2 0/5 and v5 00/17 applied in
> that order, x86_64 defconfig plus HYPERVISOR_GUEST, PARAVIRT, XEN and
> XEN_PV. gcc 11.5.0 with GNU as 2.35.2, and clang 21.1.7.
>
> Terminating both fallbacks fixes it, and both toolchains then build
> vmlinux with no errors or warnings:
>
> diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
> index eba325ecfe4c..529c13553c63 100644
> --- a/arch/x86/include/asm/msr.h
> +++ b/arch/x86/include/asm/msr.h
> @@ -78,9 +78,9 @@ static inline void do_trace_rdpmc(u32 msr, u64 val, int failed) {}
> * form MSR access instructions reference %rax as the register operand.
> */
> #define ASM_RDMSR_IMM \
> - " .byte 0xc4,0xe7,0x7b,0xf6,0xc0; .long %c[msr]"
> + " .byte 0xc4,0xe7,0x7b,0xf6,0xc0; .long %c[msr]\n\t"
> #define ASM_WRMSRNS_IMM \
> - " .byte 0xc4,0xe7,0x7a,0xf6,0xc0; .long %c[msr]"
> + " .byte 0xc4,0xe7,0x7a,0xf6,0xc0; .long %c[msr]\n\t"
> #endif
>
> #define RDMSR_AND_SAVE_RESULT \
>
> ASM_WRMSRNS needs no change, _ASM_BYTES() already emits a semicolon.
>
> The WRMSRNS line belongs in 08/17 and the RDMSR line in 10/17.
Thanks, will be fixed in V6.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
prev parent reply other threads:[~2026-09-25 10:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 8:41 Juergen Gross
2026-09-11 8:41 ` [PATCH v5 01/17] x86/alternative: Support alt_replace_call() with instructions after call Juergen Gross
2026-09-11 8:41 ` [PATCH v5 02/17] coco/tdx: Rename MSR access helpers Juergen Gross
2026-09-11 8:41 ` [PATCH v5 03/17] x86/msr: Minimize usage of native_*() msr access functions Juergen Gross
2026-09-11 8:41 ` [PATCH v5 04/17] x86/msr: Move MSR trace calls one function level up Juergen Gross
2026-09-23 20:26 ` Shreshth Srivastava
2026-09-25 13:15 ` Jürgen Groß
2026-09-11 8:41 ` [PATCH v5 05/17] x86/hyperv: Switch from __rdmsr() to native_rdmsrq() Juergen Gross
2026-09-11 8:42 ` [PATCH v5 06/17] x86/opcode: Add immediate form MSR instructions Juergen Gross
2026-09-11 8:42 ` [PATCH v5 07/17] x86/extable: Add support for " Juergen Gross
2026-09-11 8:42 ` [PATCH v5 08/17] x86/msr: Make wrmsrns() a first class citizen Juergen Gross
2026-09-11 8:42 ` [PATCH v5 09/17] x86/msr: Introduce sync_cpu_after_wrmsrns() Juergen Gross
2026-09-11 8:42 ` [PATCH v5 10/17] x86/msr: Use the alternatives mechanism for RDMSR Juergen Gross
2026-09-11 8:42 ` [PATCH v5 11/17] x86/alternatives: Add ALTERNATIVE_4() Juergen Gross
2026-09-11 8:42 ` [PATCH v5 12/17] x86/paravirt: Split off MSR related hooks into new header Juergen Gross
2026-09-11 8:42 ` [PATCH v5 13/17] x86/paravirt: Prepare support of MSR instruction interfaces Juergen Gross
2026-09-11 8:42 ` [PATCH v5 14/17] x86/paravirt: Switch MSR access pv_ops functions to " Juergen Gross
2026-09-11 8:42 ` [PATCH v5 15/17] x86/msr: Reduce number of low level MSR access helpers Juergen Gross
2026-09-11 8:42 ` [PATCH v5 16/17] x86/paravirt: Use alternatives for MSR access with paravirt Juergen Gross
2026-09-11 8:42 ` [PATCH v5 17/17] x86/msr: Make all MSR access functions __always_inline Juergen Gross
2026-09-23 19:36 ` [PATCH v5 00/17] x86/msr: Inline rdmsr/wrmsr instructions Shreshth Srivastava
2026-09-23 20:15 ` Nick Desaulniers
2026-09-25 10:25 ` Jürgen Groß [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a5c73733-af28-4c74-b7e1-c64b5e3232c4@suse.com \
--to=jgross@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=shreshth.srivastava@intel.com \
--cc=tglx@kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xin@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®