Re: [PATCH v3 1/3] x86/idle: Disable IBRS when cpu is offline

From: Waiman Long
Date: Thu Jun 22 2023 - 08:28:22 EST


On 6/22/23 01:40, Josh Poimboeuf wrote:
On Wed, Jun 21, 2023 at 08:36:01PM -0400, Waiman Long wrote:
+/*
+ * naitve_play_dead() is essentially a __noreturn function, but it can't
+ * be marked as such as the compiler may complain about it.
+ */
FWIW, we could in theory do so by marking the smp_ops.play_dead function
pointer as __noreturn, but it would be tricky to teach objtool how to
understand that.
I added the comment here because I had taken out the MSR restoration code. We can always replace that later on if there is a better way to do that.

void native_play_dead(void)
{
+ if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS)) {
+ this_cpu_write(x86_spec_ctrl_current, 0);
+ native_wrmsrl(MSR_IA32_SPEC_CTRL, 0);
+ }
Can update_spec_ctrl() be used instead?

Yes, the code is similar to what has been done in update_spec_ctrl(). Using it, however, will require exporting the function either by putting it into a public header or making it a global function.

Cheers,
Longman