Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1135357rdg; Fri, 11 Aug 2023 10:48:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv4NpQMzKMV4gz7YkLk5yR83F9h28qRW8BxFOZsngmtX47vZkAWVNx0p/VLYNqAsBzEpb7 X-Received: by 2002:a05:6a20:1589:b0:13a:43e8:3fa6 with SMTP id h9-20020a056a20158900b0013a43e83fa6mr2975918pzj.23.1691776090455; Fri, 11 Aug 2023 10:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691776090; cv=none; d=google.com; s=arc-20160816; b=ukYQpHnMxhcsLP7GKRyhNSrSPKKOP0/fnZ/MzlAM/uKWUIG2ozWISqFEcGzCKW5gtB uQeCOpdUd97Y3KN6sfBmvSs6JTBJvLw63MRctPESUVNo1JE5r1uLRZ5Fb/B1w5Vg3LMz +59it0t3z77MWVeD3BGvXmyBszH9S0SsHUWpF+CLy9dMoRMvE+1n9fQkWEa23Znv3QpO 0853nPybmHDCogwClpKyHbMPXvDxNkDcHom97ajtB1Y2DQF3HSfxvq9f4T+ceZa5nF+0 4Q3AhRTpHXDXlfWv6779Xtc4vKZ05ICRpVwoiQ+spf+9/6ekzbcje9G8n5PnRIvGK0e3 7SAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1KIWZtD6Y5wj0lSHAnbM5Pjjl10GiUETFG+MrqYmCQU=; fh=K1m6n+brToPLMsYko3rtXKxC+lCostu9M84onRqB7cU=; b=ET2RyqOPf32KpSbTAYi+24G/aJZbmyNIsTKEwXaj8s6fpuQEPbCn69WOMaUHn16w7N iJk5BtZfQWuaeHuPKJY71iFIricTpRILOQLjwKKujI7QjxaXtaE1dwIlfF7QTneplUzE eYsmqH+JhR58FRSdZ1LTTzzStEuMl7WFX8jdT4VnhiMBrzX92UWaizdgDhHH1g7WncN4 RcQogGfYHFZh6NSg5JmGK3P8LLYNpu9hzem2KDVfy7BeNqWVYsEsYKQpRuzdqVrQIfb4 BBUZC4vtkHJnTBfUFNvIA1QeQ9jG0EjDm69lPvMX5GRfy+2rPpKGSsjKoaYsIpJ2Kzr1 9F1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KedcF9hv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 80-20020a630253000000b00563de9d4edasi3786860pgc.366.2023.08.11.10.47.58; Fri, 11 Aug 2023 10:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KedcF9hv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236076AbjHKRBA (ORCPT + 99 others); Fri, 11 Aug 2023 13:01:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235273AbjHKRA6 (ORCPT ); Fri, 11 Aug 2023 13:00:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7811FE3 for ; Fri, 11 Aug 2023 10:00:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0313565816 for ; Fri, 11 Aug 2023 17:00:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5BF6C433CC; Fri, 11 Aug 2023 17:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691773257; bh=erurmBk6eYQvncO35/wgAhKngMgxH6cwdYjQXfYK+oY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KedcF9hvhoiTuwvwmjKJlSSKEawCZwEKWmHJ6+4HPVPxmFuWODvSihQVsIlxVDdEK j2eFLIFuxieQuQL/D8VMiGtY9AAsI2NsHptzs0cFPjhp+flYNfGCrgFHvOjD8dsuMw 2J0E7jS4x3RebYPuezSCYxWADvoWlaqUTpY0MB/Rlo7acpO0mmH8SI/mn8qOE+e62S bLdD7ZjPSZlxKPEIv78y+xLAt0R3Q4ihSud4LIcd2pshg2vEDyWcZjN1gTdncJO7l7 fUj4hhvlQqUI93iJ9lb8c+sm1IPpcregD/9taiXt9gWl3FroW81kFREy2WF9fa1atG 8oJo73E1HIvVA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Peter Zijlstra , "Rafael J . Wysocki" , Daniel Lezcano , Thomas Gleixner , Anna-Maria Behnsen Subject: [PATCH 01/10] x86: Add a comment about the "magic" behind shadow sti before mwait Date: Fri, 11 Aug 2023 19:00:40 +0200 Message-Id: <20230811170049.308866-2-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230811170049.308866-1-frederic@kernel.org> References: <20230811170049.308866-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a note to make sure we never miss and break the requirements behind it. 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)); } +/* + * 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(); -- 2.34.1