@@ -18,6 +18,7 @@
#include <asm/processor.h>
#include <asm/user.h>
#include <asm/fpu/xstate.h>
+#include <asm/fpu/api.h>
#include <asm/sgx.h>
#include "cpuid.h"
#include "lapic.h"
@@ -97,6 +98,17 @@ static int kvm_check_cpuid(struct kvm_cpuid_entry2 *entries, int nent)
return -EINVAL;
}
+ /*
+ * Check guest permissions for XSTATE features which must
+ * be enabled dynamically.
+ */
+ best = cpuid_entry2_find(entries, nent, 7, 0);
+ if (best && cpuid_entry_has(best, X86_FEATURE_AMX_TILE)) {
+ if (!(xstate_get_guest_group_perm() &
+ XFEATURE_MASK_XTILE_DATA))
+ return -EINVAL;
+ }
+
return 0;
}