]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/cpu: Fix check for RDPKRU in __show_regs()
authorDavid Kaplan <david.kaplan@amd.com>
Sun, 21 Apr 2024 19:17:28 +0000 (21:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:32:42 +0000 (16:32 +0200)
commit3b1ce482e2e669fc8093035e9a9fabd7e6ff2289
treef2de07ff6c15b7254049e205378a1b62fe1dfd1f
parentcec11fa2eb512ebe3a459c185f4aca1d44059bbf
x86/cpu: Fix check for RDPKRU in __show_regs()

commit b53c6bd5d271d023857174b8fd3e32f98ae51372 upstream.

cpu_feature_enabled(X86_FEATURE_OSPKE) does not necessarily reflect
whether CR4.PKE is set on the CPU.  In particular, they may differ on
non-BSP CPUs before setup_pku() is executed.  In this scenario, RDPKRU
will #UD causing the system to hang.

Fix by checking CR4 for PKE enablement which is always correct for the
current CPU.

The scenario happens by inserting a WARN* before setup_pku() in
identiy_cpu() or some other diagnostic which would lead to calling
__show_regs().

  [ bp: Massage commit message. ]

Signed-off-by: David Kaplan <david.kaplan@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20240421191728.32239-1-bp@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/process_64.c