Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4637295rdh; Wed, 29 Nov 2023 06:56:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPasLaF7DDXO6EZ/t5UNtbBCcAOFKEG143CUxOcOivKIKRnx+fOaGaD3yuQIs5pXBwGgdi X-Received: by 2002:a05:6a20:3943:b0:18b:46b4:9333 with SMTP id r3-20020a056a20394300b0018b46b49333mr20734640pzg.41.1701269791001; Wed, 29 Nov 2023 06:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701269790; cv=none; d=google.com; s=arc-20160816; b=mszJXrlkxa7+EmJVK1RVjgy+g3kLt8O31FYoMslKXidQZehFRJ6MD/+LucrC8O3xgt 99JAIklClbFrlMgpDvYvy8iFjNaL5KHlDit7qOkoiktsnyeyxclAllvfNz91JTrdfX5e 0UkYzO+QEgPQN3NwbkoVFRttUMckL5KcoxwlRTWbTi43Q758SUstxRNlHY/S7X4dMYCb 9fyzTczh70TPKlsU+aSW7O7x/+Lr24VVqSbynJwfxxCdp8UYo7rilss3jM5izz17iwIu zxVCfMMWQEJXGiKsovHi03qCeTPDOaT0ExZPvquiL2lh3HfonR0D/KMQ0AQLILIK8m8k 1aZA== 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 header.b=pinjTksF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n42-20020a056a000d6a00b0068fa57cc15bsi640503pfv.124.2023.11.29.06.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 06:56:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; 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 header.b=pinjTksF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 3F22E8077F98; Wed, 29 Nov 2023 06:56:28 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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:28 -0800 (PST) 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();