* [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
@ 2025-04-03 12:50 Uros Bizjak
2025-04-03 12:55 ` Borislav Petkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Uros Bizjak @ 2025-04-03 12:50 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
Current minimum required version of binutils is 2.25,
which supports MONITOR and MWAIT instruction mnemonics.
Replace the byte-wise specification of MONITOR and
MWAIT with these proper mnemonics.
No functional change intended.
Note: LLVM assembler is not able to assemble correct forms of MONITOR
and MWAIT instructions with explicit operands and reports [1]:
error: invalid operand for instruction
monitor %rax,%ecx,%edx
^~~~
Use instruction mnemonics with implicit operands to
work around this issue.
[1] https://lore.kernel.org/oe-kbuild-all/202504030802.2lEVBSpN-lkp@intel.com/
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
v3: Use instruction mnemonics with implicit operands.
---
arch/x86/include/asm/mwait.h | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 6a2ec2083043..26b68ee5b6a5 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -27,9 +27,9 @@
static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx)
{
- /* "monitor %eax, %ecx, %edx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc8;"
- :: "a" (eax), "c" (ecx), "d"(edx));
+ /* Use the instruction mnemonic with implicit operands, as the LLVM
+ assembler fails to assemble the mnemonic with explicit operands. */
+ asm volatile("monitor" :: "a" (eax), "c" (ecx), "d" (edx));
}
static __always_inline void __monitorx(const void *eax, u32 ecx, u32 edx)
@@ -43,9 +43,9 @@ static __always_inline void __mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+ /* Use the instruction mnemonic with implicit operands, as the LLVM
+ assembler fails to assemble the mnemonic with explicit operands. */
+ asm volatile("mwait" :: "a" (eax), "c" (ecx));
}
/*
@@ -95,9 +95,8 @@ static __always_inline void __mwaitx(u32 eax, u32 ebx, u32 ecx)
static __always_inline void __sti_mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+
+ asm volatile("sti; mwait" :: "a" (eax), "c" (ecx));
}
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
2025-04-03 12:50 [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h> Uros Bizjak
@ 2025-04-03 12:55 ` Borislav Petkov
2025-04-03 13:56 ` [tip: x86/mm] " tip-bot2 for Uros Bizjak
2025-04-03 14:37 ` tip-bot2 for Uros Bizjak
2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2025-04-03 12:55 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, Dave Hansen,
H. Peter Anvin
On Thu, Apr 03, 2025 at 02:50:45PM +0200, Uros Bizjak wrote:
> static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx)
> {
> - /* "monitor %eax, %ecx, %edx;" */
> - asm volatile(".byte 0x0f, 0x01, 0xc8;"
> - :: "a" (eax), "c" (ecx), "d"(edx));
> + /* Use the instruction mnemonic with implicit operands, as the LLVM
> + assembler fails to assemble the mnemonic with explicit operands. */
mingo, pls fix up that comment style and in the other spot when applying.
Other than that:
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread* [tip: x86/mm] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
2025-04-03 12:50 [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h> Uros Bizjak
2025-04-03 12:55 ` Borislav Petkov
@ 2025-04-03 13:56 ` tip-bot2 for Uros Bizjak
2025-04-03 14:37 ` tip-bot2 for Uros Bizjak
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2025-04-03 13:56 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Uros Bizjak, Ingo Molnar,
Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: defea9e60d3f440ca8da070a478f668fec0ba659
Gitweb: https://git.kernel.org/tip/defea9e60d3f440ca8da070a478f668fec0ba659
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Thu, 03 Apr 2025 14:50:45 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 03 Apr 2025 15:27:50 +02:00
x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
Current minimum required version of binutils is 2.25,
which supports MONITOR and MWAIT instruction mnemonics.
Replace the byte-wise specification of MONITOR and
MWAIT with these proper mnemonics.
No functional change intended.
Note: LLVM assembler is not able to assemble correct forms of MONITOR
and MWAIT instructions with explicit operands and reports:
error: invalid operand for instruction
monitor %rax,%ecx,%edx
^~~~
# https://lore.kernel.org/oe-kbuild-all/202504030802.2lEVBSpN-lkp@intel.com/
Use instruction mnemonics with implicit operands to
work around this issue.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250403125111.429805-1-ubizjak@gmail.com
---
arch/x86/include/asm/mwait.h | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 6a2ec20..26b68ee 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -27,9 +27,9 @@
static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx)
{
- /* "monitor %eax, %ecx, %edx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc8;"
- :: "a" (eax), "c" (ecx), "d"(edx));
+ /* Use the instruction mnemonic with implicit operands, as the LLVM
+ assembler fails to assemble the mnemonic with explicit operands. */
+ asm volatile("monitor" :: "a" (eax), "c" (ecx), "d" (edx));
}
static __always_inline void __monitorx(const void *eax, u32 ecx, u32 edx)
@@ -43,9 +43,9 @@ static __always_inline void __mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+ /* Use the instruction mnemonic with implicit operands, as the LLVM
+ assembler fails to assemble the mnemonic with explicit operands. */
+ asm volatile("mwait" :: "a" (eax), "c" (ecx));
}
/*
@@ -95,9 +95,8 @@ static __always_inline void __mwaitx(u32 eax, u32 ebx, u32 ecx)
static __always_inline void __sti_mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+
+ asm volatile("sti; mwait" :: "a" (eax), "c" (ecx));
}
/*
^ permalink raw reply related [flat|nested] 4+ messages in thread* [tip: x86/mm] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
2025-04-03 12:50 [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h> Uros Bizjak
2025-04-03 12:55 ` Borislav Petkov
2025-04-03 13:56 ` [tip: x86/mm] " tip-bot2 for Uros Bizjak
@ 2025-04-03 14:37 ` tip-bot2 for Uros Bizjak
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2025-04-03 14:37 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Uros Bizjak, Ingo Molnar,
Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: fc1cd60042b3df1d162278461c7a87f0362502b8
Gitweb: https://git.kernel.org/tip/fc1cd60042b3df1d162278461c7a87f0362502b8
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Thu, 03 Apr 2025 14:50:45 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 03 Apr 2025 16:28:38 +02:00
x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h>
Current minimum required version of binutils is 2.25,
which supports MONITOR and MWAIT instruction mnemonics.
Replace the byte-wise specification of MONITOR and
MWAIT with these proper mnemonics.
No functional change intended.
Note: LLVM assembler is not able to assemble correct forms of MONITOR
and MWAIT instructions with explicit operands and reports:
error: invalid operand for instruction
monitor %rax,%ecx,%edx
^~~~
# https://lore.kernel.org/oe-kbuild-all/202504030802.2lEVBSpN-lkp@intel.com/
Use instruction mnemonics with implicit operands to
work around this issue.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250403125111.429805-1-ubizjak@gmail.com
---
arch/x86/include/asm/mwait.h | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 44d3bb2..dd2b129 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -27,9 +27,11 @@
static __always_inline void __monitor(const void *eax, u32 ecx, u32 edx)
{
- /* "monitor %eax, %ecx, %edx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc8;"
- :: "a" (eax), "c" (ecx), "d"(edx));
+ /*
+ * Use the instruction mnemonic with implicit operands, as the LLVM
+ * assembler fails to assemble the mnemonic with explicit operands:
+ */
+ asm volatile("monitor" :: "a" (eax), "c" (ecx), "d" (edx));
}
static __always_inline void __monitorx(const void *eax, u32 ecx, u32 edx)
@@ -43,9 +45,11 @@ static __always_inline void __mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile(".byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+ /*
+ * Use the instruction mnemonic with implicit operands, as the LLVM
+ * assembler fails to assemble the mnemonic with explicit operands:
+ */
+ asm volatile("mwait" :: "a" (eax), "c" (ecx));
}
/*
@@ -95,9 +99,8 @@ static __always_inline void __mwaitx(u32 eax, u32 ebx, u32 ecx)
static __always_inline void __sti_mwait(u32 eax, u32 ecx)
{
mds_idle_clear_cpu_buffers();
- /* "mwait %eax, %ecx;" */
- asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
- :: "a" (eax), "c" (ecx));
+
+ asm volatile("sti; mwait" :: "a" (eax), "c" (ecx));
}
/*
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-03 14:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-03 12:50 [PATCH -tip v3] x86/idle: Use MONITOR and MWAIT mnemonics in <asm/mwait.h> Uros Bizjak
2025-04-03 12:55 ` Borislav Petkov
2025-04-03 13:56 ` [tip: x86/mm] " tip-bot2 for Uros Bizjak
2025-04-03 14:37 ` tip-bot2 for Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox