]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
authorPawan Gupta <pawan.kumar.gupta@linux.intel.com>
Wed, 30 Nov 2022 15:25:51 +0000 (07:25 -0800)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:02:50 +0000 (14:02 +0100)
commit0279882f68ffc9729b87b671ca417227c1de474a
tree640dbeeedbb9512bef568d20a614eaac50ba4f45
parentb0cb8d4818664b1cba5466fcd796480a38a86b03
x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3

commit 66065157420c5b9b3f078f43d313c153e1ff7f83 upstream.

The "force" argument to write_spec_ctrl_current() is currently ambiguous
as it does not guarantee the MSR write. This is due to the optimization
that writes to the MSR happen only when the new value differs from the
cached value.

This is fine in most cases, but breaks for S3 resume when the cached MSR
value gets out of sync with the hardware MSR value due to S3 resetting
it.

When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write
is skipped. Which results in SPEC_CTRL mitigations not getting restored.

Move the MSR write from write_spec_ctrl_current() to a new function that
unconditionally writes to the MSR. Update the callers accordingly and
rename functions.

  [ bp: Rework a bit. ]

Fixes: caa0ff24d5d0 ("x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value")
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/806d39b0bfec2fe8f50dc5446dff20f5bb24a959.1669821572.git.pawan.kumar.gupta@linux.intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 41296b85fafa48bece8db50bfc4742aebe5393ea)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
arch/x86/include/asm/nospec-branch.h
arch/x86/kernel/cpu/bugs.c
arch/x86/kernel/process.c