[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250403070453.214190-1-ubizjak@gmail.com>
Date: Thu, 3 Apr 2025 09:04:37 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: x86@...nel.org,
linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
kernel test robot <lkp@...el.com>
Subject: [PATCH -tip] x86/idle: Work around LLVM assembler bug with MONITOR and MWAIT insn
LLVM assembler is not able to assemble correct forms of MONITOR
and MWAIT instructions with explicit operands:
error: invalid operand for instruction
monitor %rax,%ecx,%edx
^~~~
Use instruction mnemonics with implicit operands when LLVM assembler
is detected to work around this issue.
Signed-off-by: Uros Bizjak <ubizjak@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Fixes: cd3b85b27542 ("x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>")
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504030802.2lEVBSpN-lkp@intel.com/
---
arch/x86/include/asm/mwait.h | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 5141d2acc0ef..d956d1be4873 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -25,9 +25,18 @@
#define TPAUSE_C01_STATE 1
#define TPAUSE_C02_STATE 0
+#ifdef CONFIG_LD_IS_LLD
+# define ASM_MONITOR "monitor"
+# define ASM_MWAIT "mwait"
+#else
+# define ASM_MONITOR "monitor %[eax], %[ecx], %[edx]"
+# define ASM_MWAIT "mwait %[eax], %[ecx]"
+#endif
+
static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx)
{
- asm volatile("monitor %0, %1, %2" :: "a" (eax), "c" (ecx), "d" (edx));
+ asm volatile(ASM_MONITOR
+ :: [eax] "a" (eax), [ecx] "c" (ecx), [edx] "d" (edx));
}
static __always_inline void __monitorx(const void *eax, u32 ecx, u32 edx)
@@ -41,7 +50,7 @@ static __always_inline void __mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- asm volatile("mwait %0, %1" :: "a" (eax), "c" (ecx));
+ asm volatile(ASM_MWAIT :: [eax] "a" (eax), [ecx] "c" (ecx));
}
/*
@@ -92,7 +101,8 @@ static __always_inline void __sti_mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- asm volatile("sti; mwait %0, %1" :: "a" (eax), "c" (ecx));
+ asm volatile("sti\n\t"
+ ASM_MWAIT :: [eax] "a" (eax), [ecx] "c" (ecx));
}
/*
--
2.49.0
Powered by blists - more mailing lists