Skip to content

Commit 454de1e

Browse files
Janakarajan NatarajanIngo Molnar
authored andcommitted
x86/asm: Fix MWAITX C-state hint value
As per "AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions", MWAITX EAX[7:4]+1 specifies the optional hint of the optimized C-state. For C0 state, EAX[7:4] should be set to 0xf. Currently, a value of 0xf is set for EAX[3:0] instead of EAX[7:4]. Fix this by changing MWAITX_DISABLE_CSTATES from 0xf to 0xf0. This hasn't had any implications so far because setting reserved bits in EAX is simply ignored by the CPU. [ bp: Fixup comment in delay_mwaitx() and massage. ] Signed-off-by: Janakarajan Natarajan <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "[email protected]" <[email protected]> Cc: Zhenzhong Duan <[email protected]> Cc: <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent da0c9ea commit 454de1e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

arch/x86/include/asm/mwait.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define MWAIT_ECX_INTERRUPT_BREAK 0x1
2222
#define MWAITX_ECX_TIMER_ENABLE BIT(1)
2323
#define MWAITX_MAX_LOOPS ((u32)-1)
24-
#define MWAITX_DISABLE_CSTATES 0xf
24+
#define MWAITX_DISABLE_CSTATES 0xf0
2525

2626
static inline void __monitor(const void *eax, unsigned long ecx,
2727
unsigned long edx)

arch/x86/lib/delay.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ static void delay_mwaitx(unsigned long __loops)
113113
__monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0);
114114

115115
/*
116-
* AMD, like Intel, supports the EAX hint and EAX=0xf
117-
* means, do not enter any deep C-state and we use it
116+
* AMD, like Intel's MWAIT version, supports the EAX hint and
117+
* EAX=0xf0 means, do not enter any deep C-state and we use it
118118
* here in delay() to minimize wakeup latency.
119119
*/
120120
__mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE);

0 commit comments

Comments
 (0)