Skip to content

Commit 9da77e1

Browse files
dkaplan2Ma Wupeng
authored andcommitted
x86/cpu: Fix check for RDPKRU in __show_regs()
stable inclusion from stable-v6.6.30 commit 3b1ce482e2e669fc8093035e9a9fabd7e6ff2289 bugzilla: https://gitee.com/openeuler/kernel/issues/I9MPZ8 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3b1ce482e2e669fc8093035e9a9fabd7e6ff2289 -------------------------------- 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> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
1 parent 93bfcb7 commit 9da77e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/process_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
138138
log_lvl, d3, d6, d7);
139139
}
140140

141-
if (cpu_feature_enabled(X86_FEATURE_OSPKE))
141+
if (cr4 & X86_CR4_PKE)
142142
printk("%sPKRU: %08x\n", log_lvl, read_pkru());
143143
}
144144

0 commit comments

Comments
 (0)