From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D705EB64DD for ; Mon, 3 Jul 2023 15:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231715AbjGCPKO (ORCPT ); Mon, 3 Jul 2023 11:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbjGCPKM (ORCPT ); Mon, 3 Jul 2023 11:10:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78F010C1 for ; Mon, 3 Jul 2023 08:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688396960; h=from:from: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=6g4SgMrAx5lx8sYPsFEruVMXFbKKSUycENj60N3/Gvk=; b=HHjQBcdMYJs1cI3sN9TNQinEKLKRW0J+CaV38hEVyq5yn9uabsPZ8V5F4iPJmqXPizOMRG evwXoxMkzxmUtG70fM7IrR8XoMKElULv8I4AsxtDO4ecOSAug25/rRT+nbXo+VHk0Bweta iO/vrVBkWAB7ePUNvSczOPRRPjkK0HY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-288-JZofT6OTOEG7gcU8sMfiFQ-1; Mon, 03 Jul 2023 11:09:14 -0400 X-MC-Unique: JZofT6OTOEG7gcU8sMfiFQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9662790EEA5; Mon, 3 Jul 2023 15:09:13 +0000 (UTC) Received: from [10.22.17.92] (unknown [10.22.17.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB2C714682F9; Mon, 3 Jul 2023 15:09:12 +0000 (UTC) Message-ID: <0a4f1738-dd0e-efdb-b137-7a7c9875786d@redhat.com> Date: Mon, 3 Jul 2023 11:09:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v4 4/4] intel_idle: Add ibrs_off module parameter to force disable IBRS Content-Language: en-US To: Peter Zijlstra 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 References: <20230628022554.1638318-1-longman@redhat.com> <20230628022554.1638318-5-longman@redhat.com> <20230703103255.GE4253@hirez.programming.kicks-ass.net> From: Waiman Long In-Reply-To: <20230703103255.GE4253@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/3/23 06:32, Peter Zijlstra wrote: > 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. That is true. I can certainly respin that as there is another suggested doc change that is pending. Cheers, Longman