[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [UNIKRAFT PATCH v2 2/4] plat/xen: toggle PKE bit if HAVE_X86PKU is enabled
În vin., 11 dec. 2020 la 18:35, Hugo Lefeuvre < hle@xxxxxxxxxx> a scris: This patch is identical to the KVM patch.
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@xxxxxxxxxxxxxxxx>
---
plat/xen/x86/entry64.S | 9 +++++++++
plat/xen/x86/setup.c | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/plat/xen/x86/entry64.S b/plat/xen/x86/entry64.S
index ae118e1d..c1bee635 100644
--- a/plat/xen/x86/entry64.S
+++ b/plat/xen/x86/entry64.S
@@ -115,6 +115,15 @@ noxsave:
orl $(X86_CR4_FSGSBASE), %edi
movq %rdi, %cr4
nofsgsbase:
+#if CONFIG_HAVE_X86PKU
+ /* check for Memory Protection Keys (PKU) */
+ testl $(X86_CPUID7_ECX_PKU), %ecx
+ jz nopku
+ /* if PKU is supported, enable it via CR4 */
+ orl $(X86_CR4_PKE), %edi
+ movq %rdi, %cr4
+nopku:
+#endif /* CONFIG_HAVE_X86PKU */
/* Done setting up CPU capabilities, hand over to C entry point. */
movq %r8, %rdi /* pass pointer to start_info page to C entry */
call _libxenplat_x86entry
diff --git a/plat/xen/x86/setup.c b/plat/xen/x86/setup.c
index ebe99328..e5d51b32 100644
--- a/plat/xen/x86/setup.c
+++ b/plat/xen/x86/setup.c
@@ -211,5 +211,9 @@ void _libxenplat_x86entry(void *start_info)
init_console();
+#if CONFIG_HAVE_X86PKU
+ _check_ospke();
+#endif /* CONFIG_HAVE_X86PKU */
+
ukplat_entry_argp(CONFIG_UK_NAME, cmdline, MAX_GUEST_CMDLINE);
}
--
2.20.1
|