mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/boot: Sanitise PKRU on boot
While the reset value of the register is 0, it might not be after kexec/etc.
If PKEY0.{WD,AD} have leaked in from an earlier context, construction of a PV
dom0 will explode.
Sequencing wise, this must come after setting CR4.PKE, and before we touch any
user mappings.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
5f08bc9404
commit
c4f9a3bad3
3 files changed
+5
-1
No files matched your search
@@ -936,6 +936,9 @@ void cpu_init(void)
|
||||
write_debugreg(6, X86_DR6_DEFAULT);
|
||||
write_debugreg(7, X86_DR7_DEFAULT);
|
||||
|
||||
if (cpu_has_pku)
|
||||
wrpkru(0);
|
||||
|
||||
/*
|
||||
* If the platform is performing a Secure Launch via SKINIT, GIF is
|
||||
* clear to prevent external interrupts interfering with Secure
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
|
||||
/* CPUID level 0x00000007:0.ecx */
|
||||
#define cpu_has_avx512_vbmi boot_cpu_has(X86_FEATURE_AVX512_VBMI)
|
||||
#define cpu_has_pku boot_cpu_has(X86_FEATURE_PKU)
|
||||
#define cpu_has_avx512_vbmi2 boot_cpu_has(X86_FEATURE_AVX512_VBMI2)
|
||||
#define cpu_has_gfni boot_cpu_has(X86_FEATURE_GFNI)
|
||||
#define cpu_has_vaes boot_cpu_has(X86_FEATURE_VAES)
|
||||
|
||||
@@ -1798,7 +1798,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
|
||||
if ( boot_cpu_has(X86_FEATURE_FSGSBASE) )
|
||||
set_in_cr4(X86_CR4_FSGSBASE);
|
||||
|
||||
if ( boot_cpu_has(X86_FEATURE_PKU) )
|
||||
if ( cpu_has_pku )
|
||||
set_in_cr4(X86_CR4_PKE);
|
||||
|
||||
if ( opt_invpcid && cpu_has_invpcid )
|
||||
|
||||