lkml.org 
[lkml]   [2023]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 4/4] intel_idle: Add ibrs_off module parameter to force disable IBRS
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;
> }

\
 
 \ /
  Last update: 2023-07-03 12:33    [W:0.066 / U:0.980 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site