We are using {rd,wr}pkru instructions for saving and restoring the
PKRU, so tie the exposure of PKU feature bit to vmm having the
ability to properly handle the guest state.
-/* $OpenBSD: vmm.c,v 1.336 2023/01/30 02:32:01 dv Exp $ */
+/* $OpenBSD: vmm.c,v 1.337 2023/01/30 14:05:36 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
*rbx = curcpu()->ci_feature_sefflags_ebx & VMM_SEFF0EBX_MASK;
*rcx = curcpu()->ci_feature_sefflags_ecx & VMM_SEFF0ECX_MASK;
*rdx = curcpu()->ci_feature_sefflags_edx & VMM_SEFF0EDX_MASK;
+ /*
+ * Only expose PKU support if we've detected it in use
+ * on the host.
+ */
+ if (vmm_softc->pkru_enabled)
+ *rcx |= SEFF0ECX_PKU;
+ else
+ *rcx &= ~SEFF0ECX_PKU;
} else {
/* Unsupported subleaf */
DPRINTF("%s: function 0x07 (SEFF) unsupported subleaf "