summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingwei Zhang <mizhang@google.com>2023-02-21 17:36:50 +0100
committerSean Christopherson <seanjc@google.com>2023-03-24 22:21:39 +0100
commitbfc5afc37c9dba85f8c057fb85109a72e72d64a5 (patch)
treed54d27b7c1d087de3cd82ff6b32cf284ea49f5d3
parentKVM: selftests: Assert that XTILE_DATA is set in IA32_XFD on #NM (diff)
downloadlinux-bfc5afc37c9dba85f8c057fb85109a72e72d64a5.tar.xz
linux-bfc5afc37c9dba85f8c057fb85109a72e72d64a5.zip
KVM: selftests: Verify XTILE_DATA in XSTATE isn't affected by IA32_XFD
Add asserts to verify the XSTATE metadata for XTILE_DATA isn't affected by disabling AMX tile data via IA32_XFD. XFD doesn't intercept XSAVE, it only prevents setting bits in XCR0, i.e. regardless of XFD, AMX state is managed by XSAVE/XRSTOR as long as the corresponding bits are set XCR0. Signed-off-by: Mingwei Zhang <mizhang@google.com> Link: https://lore.kernel.org/r/20230221163655.920289-9-mizhang@google.com [sean: massage changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--tools/testing/selftests/kvm/x86_64/amx_test.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index cd0491cc7c8c..e6bc6cd108dc 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -201,6 +201,16 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
/* xfd=0x40000, disable amx tiledata */
wrmsr(MSR_IA32_XFD, XFEATURE_MASK_XTILEDATA);
+
+ /*
+ * XTILEDATA is cleared in xstate_bv but set in xcomp_bv, this property
+ * remains the same even when amx tiledata is disabled by IA32_XFD.
+ */
+ xstate->header.xstate_bv = XFEATURE_MASK_XTILEDATA;
+ __xsavec(xstate, XFEATURE_MASK_XTILEDATA);
+ GUEST_ASSERT(!(xstate->header.xstate_bv & XFEATURE_MASK_XTILEDATA));
+ GUEST_ASSERT((xstate->header.xcomp_bv & XFEATURE_MASK_XTILEDATA));
+
GUEST_SYNC(6);
GUEST_ASSERT(rdmsr(MSR_IA32_XFD) == XFEATURE_MASK_XTILEDATA);
set_tilecfg(amx_cfg);