From nobody Tue Dec 30 14:33:36 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65A53C2BB3F for ; Wed, 15 Nov 2023 15:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344431AbjKOPOM (ORCPT ); Wed, 15 Nov 2023 10:14:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344468AbjKOPOE (ORCPT ); Wed, 15 Nov 2023 10:14:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED45D41 for ; Wed, 15 Nov 2023 07:14:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9651C433CA; Wed, 15 Nov 2023 15:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700061240; bh=CGc4yN675I1g1HtS2yRFvKBFqp1N2IpYVLKrHGqJRhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5OSOvr+26OB70bGr8parKnbffR+qe+cbu6cntwePyetORAYqXomqnEf+fL9pK1nA oil1YHr0Ngj4yeGAdJjXSgqCzf8HyyZtltBVN7hrWyy5TY4NJBonMHGbhwVNGYME+h cfwWz8A4lZ6utJQNakqG1cT/t6t1aOb4N1PnGxbvfRag/XsbyQcu13wz8fAtMNlhGu +30WIPYtzl4OUvZvcFZgCYAU00jt01npgmCgwmDV+3cc5oXnM1FHxsLKs2ITAFFryn 7Mt+n70WFKOhDEQKJhwn8+i92ASJo9pZ0RVp+XGD/esOsLCDE5v3zC0qY5wne766bW Zh76QhVKMQPBQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra , x86@kernel.org, "Rafael J . Wysocki" Subject: [PATCH 1/4] x86: Add a comment about the "magic" behind shadow sti before mwait Date: Wed, 15 Nov 2023 10:13:22 -0500 Message-ID: <20231115151325.6262-2-frederic@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115151325.6262-1-frederic@kernel.org> References: <20231115151325.6262-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a note to make sure we never miss and break the requirements behind it. Acked-by: Rafael J. Wysocki Signed-off-by: Frederic Weisbecker --- 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 778df05f8539..341ee4f1d91e 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)); } =20 +/* + * 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 e= cx) { mds_idle_clear_cpu_buffers(); --=20 2.42.1