Skip to content

Commit b53c6bd

Browse files
dkaplan2bp3tk0v
authored andcommitted
x86/cpu: Fix check for RDPKRU in __show_regs()
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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2718a7f commit b53c6bd

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
@@ -139,7 +139,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
139139
log_lvl, d3, d6, d7);
140140
}
141141

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

0 commit comments

Comments
 (0)