Re: [PATCH v3 2/3] intel_idle: Sync up the SPEC_CTRL MSR value to x86_spec_ctrl_current
From: Peter Zijlstra
Date: Thu Jun 22 2023 - 09:09:16 EST
On Thu, Jun 22, 2023 at 11:38:28AM +0200, Peter Zijlstra wrote:
> Both this and the play_dead case can't use update_spec_ctrl() because
> RCU isn't there anymore and all that is noinstr. Additionally, both
> sites rely on preemption being off already, where update_spec_ctrl()
> can't do that.
Oh, I might be wrong about the preemption thing; it doesn't make sense
to do wrmsr with preemption on, so it could be simpler.
> That said, I suppose one could write it like so:
>
> static __always_inline __update_spec_ctrl(u64 val)
> {
> __this_cpu_write(x86_spec_ctrl_current, val);
> native_wrmsrl(MSR_IA32_SPEC_CTRL, val);
> }
>
> static void update_spec_ctrl(u64 val)
> {
> preempt_disable();
> __update_spec_ctrl(val);
> preempt_enable();
> }
>
> And then you can use __update_spec_ctrl(). But that would need a wee
> audit of using native_wrmsrl() in all places, probably ok, IIRC Xen
> wasn't using our IBRS stuff anyway.