Skip to content

Commit 7d09a05

Browse files
Frederic WeisbeckerPeter Zijlstra
authored andcommitted
x86: Add a comment about the "magic" behind shadow sti before mwait
Add a note to make sure we never miss and break the requirements behind it. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Rafael J. Wysocki <rafael@kernel.org> Link: https://lkml.kernel.org/r/20231115151325.6262-2-frederic@kernel.org
1 parent 2cc14f5 commit 7d09a05

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

arch/x86/include/asm/mwait.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ static __always_inline void __mwaitx(unsigned long eax, unsigned long ebx,
8787
:: "a" (eax), "b" (ebx), "c" (ecx));
8888
}
8989

90+
/*
91+
* Re-enable interrupts right upon calling mwait in such a way that
92+
* no interrupt can fire _before_ the execution of mwait, ie: no
93+
* instruction must be placed between "sti" and "mwait".
94+
*
95+
* This is necessary because if an interrupt queues a timer before
96+
* executing mwait, it would otherwise go unnoticed and the next tick
97+
* would not be reprogrammed accordingly before mwait ever wakes up.
98+
*/
9099
static __always_inline void __sti_mwait(unsigned long eax, unsigned long ecx)
91100
{
92101
mds_idle_clear_cpu_buffers();

0 commit comments

Comments
 (0)