Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25961374rwd; Mon, 3 Jul 2023 03:36:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGn/11+DOopuHIqKizp6JLKXOJLjHIX8gEXM/IsIxQSvhRTac1ylLJU4UYHk3bXkiYkwkzF X-Received: by 2002:a05:6a21:32a1:b0:12d:53ad:f55a with SMTP id yt33-20020a056a2132a100b0012d53adf55amr9155829pzb.55.1688380578005; Mon, 03 Jul 2023 03:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688380577; cv=none; d=google.com; s=arc-20160816; b=bKacgeFRftnhgDEF8E9u1BUjFWso5GIWSeFdnlJzgWXK9Wy1eWUahstMe++zyiA+z9 tyUVXAB0bwLyJh9AvjLT44/633WOSuUf/Gf5tjTn6Tph3FjUbME9bsaYctsxNeEckfr+ vkDD5XidaqfY14EQtcokvJblRAy5M+5omaMrRV1WCSGJnMNBA7PeViuAgjQi7mUniam0 u+0+1F4sOdbmLgaizzkXlBbdbSDBvC93RnEj6vTCBTxCbLcL5m56tNAFB2taUe9eQ2sf yPR41x8L7Bkr5R1evqMtMKhACj/QrWIc7CH8QtBcJhKcT/y8UrHIfi6CoEVNhWFXROUE 1iaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jUUST+pTV/4ng8wB0em4I/zFSWFIzrwruNy94bYcubQ=; fh=S/sFtnMW9meNGabqkJ7+dKv7Q55i/xo0nYsbXTxHkE4=; b=LWP7LYAhtSRX/Yn6F9VjD6NrqRA87itgYb9zEP21oFO22hnZjDHUmy4m9NsKmbnaLA Oi3sRNbV0/ndj5g+/fpxob8THhmv653DgnRpNRTQHqazXnvigNyeyjD3KbI6ANI69Nqc H2CN75kkWk96yf1frhx4TQbx2dUh8bofzT3RXhBXAcRysCkfVc44gAIYR7SeELAVTWsL DtdlJ5Ymj4tV1yJGq2QD0OxlTR83HIZr7wZHJOx/AspgVDrP2XtY69niK09fwRsQk/p3 3S/DaCAVwzy8KAhOI0gvgJ3VhUOg20gyDhFtkTjPLE7twBEYsRf3H/41ZLe5wXGmnoCH 6I8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=bZgglhjr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a056a0021cb00b006824cf05f31si8914983pfj.348.2023.07.03.03.36.05; Mon, 03 Jul 2023 03:36:17 -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=@infradead.org header.s=desiato.20200630 header.b=bZgglhjr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbjGCKdU (ORCPT + 99 others); Mon, 3 Jul 2023 06:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbjGCKdQ (ORCPT ); Mon, 3 Jul 2023 06:33:16 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF99EE; Mon, 3 Jul 2023 03:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jUUST+pTV/4ng8wB0em4I/zFSWFIzrwruNy94bYcubQ=; b=bZgglhjrJ9YzLn+sG4WglTktGF 8iD39nRKO6vYiN18s57xpXy8ME8jpneRQ0CQfnyuxwtVdOGclfdRXbL9xP4PczkHSrOSMxa1xIQqE e7kZHTcGzsajOCD42RZrrlDDMrQzLkhtWEMvpeh/eOkt8E04HDdygN/2Khzux068xzCMeTPwp5nNo QID/rvjDCHnwEX45sW6agBYfeu/cev378Sn3V1bJP4RV3L/HzTyIlvEcEqbT3fhoA135y1TJtU8zS 90D8fp+MjYAMvhoxleMVeBzeVfCtrRmZcNU8+X21wp9BagLWJ6bo/XklHUGzd0pteOH6vgFW4VqzP T+kPvzyw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qGGrY-00A3wH-1j; Mon, 03 Jul 2023 10:32:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2A32630012F; Mon, 3 Jul 2023 12:32:56 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 11721202A2A17; Mon, 3 Jul 2023 12:32:56 +0200 (CEST) Date: Mon, 3 Jul 2023 12:32:55 +0200 From: Peter Zijlstra To: Waiman Long Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Pawan Gupta , Jacob Pan , Len Brown , Jonathan Corbet , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario Subject: Re: [PATCH v4 4/4] intel_idle: Add ibrs_off module parameter to force disable IBRS Message-ID: <20230703103255.GE4253@hirez.programming.kicks-ass.net> References: <20230628022554.1638318-1-longman@redhat.com> <20230628022554.1638318-5-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230628022554.1638318-5-longman@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Tue, Jun 27, 2023 at 10:25:54PM -0400, Waiman Long wrote: > @@ -69,6 +69,7 @@ static int max_cstate = CPUIDLE_STATE_MAX - 1; > static unsigned int disabled_states_mask __read_mostly; > static unsigned int preferred_states_mask __read_mostly; > static bool force_irq_on __read_mostly; > +static bool ibrs_off __read_mostly; > > static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; > > @@ -1919,12 +1920,15 @@ static void state_update_enter_method(struct cpuidle_state *state, int cstate) > } > > if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && > - state->flags & CPUIDLE_FLAG_IBRS) { > + ((state->flags & CPUIDLE_FLAG_IBRS) || ibrs_off)) { > /* > * IBRS mitigation requires that C-states are entered > * with interrupts disabled. > */ > - WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); > + if (ibrs_off && (state->flags & CPUIDLE_FLAG_IRQ_ENABLE)) > + state->flags &= ~CPUIDLE_FLAG_IRQ_ENABLE; > + else > + WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); If you're respinning this, you can leave out the else and avoid the indent on the WARN: + if (ibrs_off && (state->flags & CPUIDLE_FLAG_IRQ_ENABLE)) + state->flags &= ~CPUIDLE_FLAG_IRQ_ENABLE; WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); Same effect, simpler code and all that. > state->enter = intel_idle_ibrs; > return; > }