Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1497983rdh; Fri, 24 Nov 2023 14:33:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHb5c2RMa6LLMJpilp8WHQchOCXTFQWpm6fQqBdQxxb3osq3VYWjvYbEgVAhwDgKfToezX X-Received: by 2002:a05:6808:1211:b0:3b8:3d37:998f with SMTP id a17-20020a056808121100b003b83d37998fmr6083216oil.40.1700865194779; Fri, 24 Nov 2023 14:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700865194; cv=none; d=google.com; s=arc-20160816; b=0tcZHKDup3kfOWJ96RcxLYy4nKPRIrKtJq7YMoEMWpwhLItmHBFjjVUDTT+lGfbMC2 1otO8qgHbysyxfLjlM8pCvXuq54iK8MZENT7SoYDZGo2P3KUle+JER8rzWU+Fn2r/5SJ hAhJ1x2LWKh4gh3l3I443Rnyk8nrckA/xrMWJ51KLeI2xGH6YUCJ+E9HjdSTnA/Iab7w ze6Rj76u1mum0A/zACinAwgTdvrDH1YbJbKNKB7bUlFMIFgP1YbxvMcYKdbwmE0HBaPo 00838smOuXK9DcqEEn4ToY9L7k4p8hqjp75Q3Zw8XCkJzAk9jQwSFENWllChyIJInw1B sJTA== 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=moq9PRfsPBX9cKDCPNLdFWCMWjIroUd98HLlD4iBVI0=; fh=FP7vh/uLSL8T47BAINXnJeKRz+lJwSPdPP4Si4L9mlE=; b=QYFdicVCEjT1unW5fvooFyOu5qyp/ke7r6aW9u5+w0mrZrf+gvOMW+ZL8hys+H2pma m48+KUnQ/rTRHjiqpZAAAyZkf1zomLdq00uiG1bQjIdSwr8FNl2cRjj/yQDblo+K0QYB ivoOZIyFDiWYcXlo60Vx5TtFbm/v0F5VFj/LTt1MLoyOVVEAXbuEQywTZGI83hZjqBcH v5DGzWVjWARBJl9NxmwL1xZ5x1f9XvDXhIOYoGGEEPlGQ9IUmjMUub7u96sgoHRhwHXy +UpxVoDwK03Cx4gGMckIVC72fdrRnt228jE82XgMen+Y5hXKhLX2U6Omd0OIe9Pbenuk Xvcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="q/lnFaSV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y18-20020a634b12000000b005b90b310e26si4454152pga.403.2023.11.24.14.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 14:33:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="q/lnFaSV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B283E8026C12; Fri, 24 Nov 2023 14:33:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbjKXWcl (ORCPT + 99 others); Fri, 24 Nov 2023 17:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbjKXWck (ORCPT ); Fri, 24 Nov 2023 17:32:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F8710E2 for ; Fri, 24 Nov 2023 14:32:47 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7070AC433CA; Fri, 24 Nov 2023 22:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700865166; bh=SruwsS2l79TbUPDZT8+hJEb5a4kT01b9VD/LZ7J5AKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q/lnFaSVMQiMkEsslwmzjqzy22MQXd8r9dOLxCa7TLWnoQvJK3pQYuE+Q6CrbEoyR 39RMK7baBkVlSAzMhxWIcg0mYsY1sVWkYmD7FkCurSO46YSXqsjEIDzPqOUbgXsK63 FrjQ75lmSpZu6ETzAaNH/vz7tuQvdYh2RmvwuKVhJT3Osmh1h/AU7TIvg2inx3mdMd ZSEbZeLhQldnmaE5WqzqY3UPniXAsGIpPw26G6aZrTQOnaTyR73iSfEFzIgSYztgH1 740u66mQXDlK06o2pQUyCJzQf3vn4xdoPoqlU1Bn+bD2I/HX6a0CQkejm6GKWo+zh0 jjdqFVncadX3A== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra Subject: [PATCH 2/7] x86: Add a comment about the "magic" behind shadow sti before mwait Date: Fri, 24 Nov 2023 23:32:21 +0100 Message-ID: <20231124223226.24249-3-frederic@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231124223226.24249-1-frederic@kernel.org> References: <20231124223226.24249-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 24 Nov 2023 14:33:10 -0800 (PST) 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 bae83810505b..920426d691ce 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.42.1