From patchwork Wed Nov 29 14:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 171416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp392418vqn; Wed, 29 Nov 2023 06:56:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0cKpc1ykZf3gZSQx3ZvlZonw/VtWPMr+En+YdGhIOEwA9NsemvqEfQVBJzJ4SDkGB0QB3 X-Received: by 2002:a05:6a20:1483:b0:18b:31eb:8b66 with SMTP id o3-20020a056a20148300b0018b31eb8b66mr14283318pzi.50.1701269788090; Wed, 29 Nov 2023 06:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701269788; cv=none; d=google.com; s=arc-20160816; b=JcH4J5scXE0t2A8ay/2gd9qwe/PL1KPcd/UooE1gy2bxTKezDaUh8RTag/HXyEv/z4 97EYGHpNUwvtuBP3TGhBgbpu4cDEfEL36qlwbodAaTJHQLS9fdyEkGbhI5ZbMLBb1uCQ peXvUbW50KezOutZGMajVZY7NptUNxFRDT63W12DDezQS/+lo2ekrFmhoewjeiy+LMp/ 6PkeFaMVBup+k6+Zuf9Ir441HdmOhQzGCEffCcLQbv0z7kXq1SCEwlvRSKBwVfdakfDc Kl8KxlvTcdtwnqP6H4W5NROGPBSK7vnRAdoCv/fhbNRjtk2lPf96aw164sQnnLzLf0we GycA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=MLbikOtVJDhPJBfsK4WcWQ/4AM6wkB1f7QXWa/N/ZQw=; fh=KFSO1avKpsj2PbLT7939+iqdBuUcdlAP4LSCNdUZQ/k=; b=dOEqi/LdpiKVr0Wg5c3jDmzKB1ADkky3u6pvIeNM0kuWgRBvL4KK89+2FE7dBT+JIj qXHbCS6c8qpC531aNRmZkzBU2JZpuskop2z5+NdzdxZsWKVU1n2uSpcoK11tf6FXsW8o V793wqvzo2R8RZ9bzyDJoGQMh3jFaG5YuqKi288S2RKY5J8rl4vBkLThnNpd7trm7HvO VXzH95AOVlysdmVigitt96pyiIxnVk9HjmAdjrK2bS6VJS5roFutXJhEQH76ihA+7Ucu dpzEmzEDE+ADarh+OymzeueA+JGKIqSXFT10CLVao2wzSleRKAjn51HaUeflPVZEB0I4 DIlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yid6oUJk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j33-20020a635961000000b005bdf597ed49si14653557pgm.56.2023.11.29.06.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 06:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yid6oUJk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 73B4B8038918; Wed, 29 Nov 2023 06:56:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234720AbjK2Oz6 (ORCPT + 99 others); Wed, 29 Nov 2023 09:55:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbjK2Ozv (ORCPT ); Wed, 29 Nov 2023 09:55:51 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE19D5E; Wed, 29 Nov 2023 06:55:57 -0800 (PST) Date: Wed, 29 Nov 2023 14:55:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701269756; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLbikOtVJDhPJBfsK4WcWQ/4AM6wkB1f7QXWa/N/ZQw=; b=yid6oUJkHcYXRz3rztYDdSTogDbw2haTPKwU2WIusiyMeKNGDYF0k6lJaPQuHnnm81J/fl JMOHgvKFQqrmp+0vBNkPdITF/HYVvGJgN6WfAHkxNNbkgpaxuF3EwpqOjRW1W/3s6w8MMQ pZmw+rhjd+7yqJvGVMRryQkM0F4ViX6NEOtbagTx+MGsSu3G1rjqJAjQE5bm8H1zmQ3ByN BHwIGLvHATUYeJx4kUU0QHKQv4nNFKCoWDOG50Pk64Ugzu4xJQKTdQQB+V27BPix5HIGuB 5RseIfxRC5ieK0Wsq8I5v8XEJSbyUoc/bphOVp8zPfwFcWipbNl6nFUHgdxCGA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701269756; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLbikOtVJDhPJBfsK4WcWQ/4AM6wkB1f7QXWa/N/ZQw=; b=pinjTksFVPwufqzimrubx9ROVEhd8rpem3qJyZB+y0Golgkvd5w1S6fVPe7S/bMB8sg1FF XwQlg1OJC2CDE7Cg== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86: Add a comment about the "magic" behind shadow sti before mwait Cc: Frederic Weisbecker , "Peter Zijlstra (Intel)" , "Rafael J. Wysocki" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231115151325.6262-2-frederic@kernel.org> References: <20231115151325.6262-2-frederic@kernel.org> MIME-Version: 1.0 Message-ID: <170126975575.398.1797223222857571697.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 06:56:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782643428227540222 X-GMAIL-MSGID: 1783910669283096709 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 AuthorDate: Wed, 15 Nov 2023 10:13:22 -05:00 Committer: Peter Zijlstra 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 Signed-off-by: Peter Zijlstra (Intel) Acked-by: Rafael J. Wysocki 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();