Commit 7d09a052 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Peter Zijlstra
Browse files

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: default avatarFrederic Weisbecker <frederic@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Link: https://lkml.kernel.org/r/20231115151325.6262-2-frederic@kernel.org
parent 2cc14f52
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -87,6 +87,15 @@ static __always_inline void __mwaitx(unsigned long eax, unsigned long ebx,
		     :: "a" (eax), "b" (ebx), "c" (ecx));
}

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