File xsa471-06.patch of Package xen.39650
# Commit 61e10fc28ccddff7c72c14acec56dc7ef2b155d1
# Date 2025-06-25 17:54:41 +0100
# Author Andrew Cooper <andrew.cooper3@citrix.com>
# Committer Andrew Cooper <andrew.cooper3@citrix.com>
x86/idle: Move monitor()/mwait() wrappers into cpu-idle.c
They're not used by any other translation unit, so shouldn't live in
asm/processor.h, which is included almost everywhere.
Change the hint/extention parameters from long to int. They're specified to
remain 32bit operands even 64-bit mode.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/acpi/cpu_idle.c
+++ b/xen/arch/x86/acpi/cpu_idle.c
@@ -59,6 +59,19 @@
/*#define DEBUG_PM_CX*/
+static always_inline void monitor(
+ const void *addr, unsigned int ecx, unsigned int edx)
+{
+ asm volatile ( ".byte 0x0f, 0x01, 0xc8" /* monitor */
+ :: "a" (addr), "c" (ecx), "d" (edx) );
+}
+
+static always_inline void mwait(unsigned int eax, unsigned int ecx)
+{
+ asm volatile ( ".byte 0x0f, 0x01, 0xc9" /* mwait */
+ :: "a" (eax), "c" (ecx) );
+}
+
#define GET_HW_RES_IN_NS(msr, val) \
do { rdmsrl(msr, val); val = tsc_ticks2ns(val); } while( 0 )
#define GET_MC6_RES(val) GET_HW_RES_IN_NS(0x664, val)
@@ -467,7 +480,7 @@ void mwait_idle_with_hints(unsigned int
mb();
}
- __monitor(monitor_addr, 0, 0);
+ monitor(monitor_addr, 0, 0);
smp_mb();
/*
@@ -481,7 +494,7 @@ void mwait_idle_with_hints(unsigned int
cpumask_set_cpu(cpu, &cpuidle_mwait_flags);
spec_ctrl_enter_idle(info);
- __mwait(eax, ecx);
+ mwait(eax, ecx);
spec_ctrl_exit_idle(info);
cpumask_clear_cpu(cpu, &cpuidle_mwait_flags);
@@ -912,9 +925,9 @@ void acpi_dead_idle(void)
*/
mb();
clflush(mwait_ptr);
- __monitor(mwait_ptr, 0, 0);
+ monitor(mwait_ptr, 0, 0);
mb();
- __mwait(cx->address, 0);
+ mwait(cx->address, 0);
}
}
else if ( (current_cpu_data.x86_vendor &
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -407,23 +407,6 @@ static inline bool_t read_pkru_wd(uint32
return (pkru >> (pkey * PKRU_ATTRS + PKRU_WRITE)) & 1;
}
-static always_inline void __monitor(const void *eax, unsigned long ecx,
- unsigned long edx)
-{
- /* "monitor %eax,%ecx,%edx;" */
- asm volatile (
- ".byte 0x0f,0x01,0xc8;"
- : : "a" (eax), "c" (ecx), "d"(edx) );
-}
-
-static always_inline void __mwait(unsigned long eax, unsigned long ecx)
-{
- /* "mwait %eax,%ecx;" */
- asm volatile (
- ".byte 0x0f,0x01,0xc9;"
- : : "a" (eax), "c" (ecx) );
-}
-
#define IOBMP_BYTES 8192
#define IOBMP_INVALID_OFFSET 0x8000