[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170126975575.398.1797223222857571697.tip-bot2@tip-bot2>
Date: Wed, 29 Nov 2023 14:55:55 -0000
From: "tip-bot2 for Frederic Weisbecker" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Frederic Weisbecker <frederic@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/core] x86: Add a comment about the "magic" behind shadow
sti before mwait
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 7d09a052a3bdb62de9a86d43359d6c22eeaf105a
Gitweb: https://git.kernel.org/tip/7d09a052a3bdb62de9a86d43359d6c22eeaf105a
Author: Frederic Weisbecker <frederic@...nel.org>
AuthorDate: Wed, 15 Nov 2023 10:13:22 -05:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Wed, 29 Nov 2023 15:44:01 +01:00
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@...nel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Acked-by: Rafael J. Wysocki <rafael@...nel.org>
Link: https://lkml.kernel.org/r/20231115151325.6262-2-frederic@kernel.org
---
arch/x86/include/asm/mwait.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 778df05..341ee4f 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -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();
Powered by blists - more mailing lists