Overhauling amx_test, part 2
cover Overhauling amx_test, part 2
Here are a few additional checks that were missing from the selftest, amx_test.
My hope is to append these to the end of part 1 of this series, so we have one series with all of these fixes in it.
Aaron Lewis (5):
KVM: selftests: Assert that XTILE is XSAVE-enabled
KVM: selftests: Assert that both XTILE{CFG,DATA} are XSAVE-enabled
KVM: selftests: Remove redundant check that XSAVE is supported
KVM: selftests: Check that the palette table exists before using it
KVM: selftests: Check that XTILEDATA supports XFD
.../selftests/kvm/include/x86_64/processor.h | 2 ++ tools/testing/selftests/kvm/x86_64/amx_test.c | 21 +++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-)
Signature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH 1/5 KVM: selftests: Assert that XTILE is XSAVE-enabled
The check in amx_test that ensures that XTILE is XSAVE-enabled, doesn't actually check anything. It simply returns a bool which the test does nothing with. Add the intended assert.
Opportunistically, move the assert to a more appropriate location; immediately after XSETBV.
--- tools/testing/selftests/kvm/x86_64/amx_test.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
tools/testing/selftests/kvm/x86_64/amx_test.c +1 -6
@@ -119,11 +119,6 @@ static inline void check_cpuid_xsave(void)GUEST_ASSERT (this_cpu_has (X86_FEATURE_OSXSAVE )); } -static bool check_xsave_supports_xtile (void ) -{ -return __xgetbv (0 ) &XFEATURE_MASK_XTILE ; -} -static void check_xtile_info (void ) {GUEST_ASSERT (this_cpu_has_p (X86_PROPERTY_XSTATE_MAX_SIZE_XCR0 ));
@@ -180,6 +175,7 @@ static void init_regs(void) xcr0 =__xgetbv (0 ); xcr0 |=XFEATURE_MASK_XTILE ;__xsetbv (0x0 , xcr0); +GUEST_ASSERT (__xgetbv (0 ) &XFEATURE_MASK_XTILE ); } static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
@@ -188,7 +184,6 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, {init_regs ();check_cpuid_xsave (); -check_xsave_supports_xtile ();check_xtile_info ();GUEST_SYNC (1 );
Signature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH 2/5 KVM: selftests: Assert that both XTILE{CFG,DATA} are XSAVE-enabled
In reply to Aaron LewisThe check in amx_test that ensures that XTILE is XSAVE-enabled makes sure at least one of the XTILE bits are set, XTILECFG or XTILEDATA, when it really should be checking that both are set.
Assert that both XTILECFG and XTILEDATA a set.
--- tools/testing/selftests/kvm/x86_64/amx_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/x86_64/amx_test.c +1 -1
@@ -175,7 +175,7 @@ static void init_regs(void) xcr0 =__xgetbv (0 ); xcr0 |=XFEATURE_MASK_XTILE ;__xsetbv (0x0 , xcr0); -GUEST_ASSERT (__xgetbv (0 ) &XFEATURE_MASK_XTILE ); +GUEST_ASSERT ((__xgetbv (0 ) &XFEATURE_MASK_XTILE ) ==XFEATURE_MASK_XTILE ); } static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg,
Signature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH 3/5 KVM: selftests: Remove redundant check that XSAVE is supported
In reply to Aaron LewisIn amx_test, userspace requires that XSAVE is supported before running the test, then the guest checks that it is supported after enabling AMX. Remove the redundant check in the guest that XSAVE is supported.
Opportunistically, move the check that OSXSAVE is set to immediately after the guest sets it, rather than in a separate helper.
--- tools/testing/selftests/kvm/x86_64/amx_test.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
tools/testing/selftests/kvm/x86_64/amx_test.c +1 -7
@@ -113,12 +113,6 @@ static inline void __xsavec(struct xsave_data *data, uint64_t rfbm) : "memory"); } -static inline void check_cpuid_xsave (void ) -{ -GUEST_ASSERT (this_cpu_has (X86_FEATURE_XSAVE )); -GUEST_ASSERT (this_cpu_has (X86_FEATURE_OSXSAVE )); -} -static void check_xtile_info (void ) {GUEST_ASSERT (this_cpu_has_p (X86_PROPERTY_XSTATE_MAX_SIZE_XCR0 ));
@@ -171,6 +165,7 @@ static void init_regs(void) cr4 =get_cr4 (); cr4 |=X86_CR4_OSXSAVE ;set_cr4 (cr4); +GUEST_ASSERT (this_cpu_has (X86_FEATURE_OSXSAVE )); xcr0 =__xgetbv (0 ); xcr0 |=XFEATURE_MASK_XTILE ;
@@ -183,7 +178,6 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, struct xsave_data *xsave_data) {init_regs (); -check_cpuid_xsave ();check_xtile_info ();GUEST_SYNC (1 );
Signature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH 4/5 KVM: selftests: Check that the palette table exists before using it
In reply to Aaron LewisThe maximum number of AMX palette tables is enumerated by CPUID.1DH:EAX. Assert that the palette used in amx_test, CPUID.1DH.1H, does not exceed that maximum.
--- tools/testing/selftests/kvm/include/x86_64/processor.h | 1 + tools/testing/selftests/kvm/x86_64/amx_test.c | 5 +++++ 2 files changed, 6 insertions(+)
tools/testing/selftests/kvm/include/x86_64/processor.h +1 -0
@@ -208,6 +208,7 @@ struct kvm_x86_cpu_property {#define X86_PROPERTY_XSTATE_MAX_SIZE KVM_X86_CPU_PROPERTY(0xd, 0, ECX, 0, 31)#define X86_PROPERTY_XSTATE_TILE_SIZE KVM_X86_CPU_PROPERTY(0xd, 18, EAX, 0, 31)#define X86_PROPERTY_XSTATE_TILE_OFFSET KVM_X86_CPU_PROPERTY(0xd, 18, EBX, 0, 31) +#define X86_PROPERTY_AMX_MAX_PALETTE_TABLES KVM_X86_CPU_PROPERTY(0x1d, 0, EAX, 0, 31)#define X86_PROPERTY_AMX_TOTAL_TILE_BYTES KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 0, 15)#define X86_PROPERTY_AMX_BYTES_PER_TILE KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 16, 31)#define X86_PROPERTY_AMX_BYTES_PER_ROW KVM_X86_CPU_PROPERTY(0x1d, 1, EBX, 0, 15)
tools/testing/selftests/kvm/x86_64/amx_test.c +5 -0
@@ -30,6 +30,7 @@#define XSAVE_SIZE ((NUM_TILES * TILE_SIZE) + PAGE_SIZE)/* Tile configuration associated: */ +#define PALETTE_TABLE_INDEX 1#define MAX_TILES 16#define RESERVED_BYTES 14
@@ -124,6 +125,10 @@ static void check_xtile_info(void)GUEST_ASSERT (xtile.xsave_size ==8192 );GUEST_ASSERT (sizeof (struct tile_data ) >= xtile.xsave_size); +GUEST_ASSERT (this_cpu_has_p (X86_PROPERTY_AMX_MAX_PALETTE_TABLES )); +GUEST_ASSERT (this_cpu_property (X86_PROPERTY_AMX_MAX_PALETTE_TABLES ) >= +PALETTE_TABLE_INDEX ); +GUEST_ASSERT (this_cpu_has_p (X86_PROPERTY_AMX_NR_TILE_REGS )); xtile.max_names =this_cpu_property (X86_PROPERTY_AMX_NR_TILE_REGS );GUEST_ASSERT (xtile.max_names ==8 );
Signature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH 5/5 KVM: selftests: Check that XTILEDATA supports XFD
In reply to Aaron LewisIn amx_test, add the requirement that the guest allows the xfeature, XTILEDATA, to be set in XFD. The test relies on it.
--- tools/testing/selftests/kvm/include/x86_64/processor.h | 1 + tools/testing/selftests/kvm/x86_64/amx_test.c | 1 + 2 files changed, 2 insertions(+)
tools/testing/selftests/kvm/include/x86_64/processor.h +1 -0
@@ -125,6 +125,7 @@ struct kvm_x86_cpu_feature {#define X86_FEATURE_XTILEDATA KVM_X86_CPU_FEATURE(0xD, 0, EAX, 18)#define X86_FEATURE_XSAVES KVM_X86_CPU_FEATURE(0xD, 1, EAX, 3)#define X86_FEATURE_XFD KVM_X86_CPU_FEATURE(0xD, 1, EAX, 4) +#define X86_FEATURE_XTILEDATA_XFD KVM_X86_CPU_FEATURE(0xD, 18, ECX, 2)/* * Extended Leafs, a.k.a. AMD defined
tools/testing/selftests/kvm/x86_64/amx_test.c +1 -0
@@ -254,6 +254,7 @@ int main(int argc, char *argv[])TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_AMX_TILE ));TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_XTILECFG ));TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_XTILEDATA )); +TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_XTILEDATA_XFD ));/* Create VM */ vm =vm_create_with_one_vcpu (&vcpu, guest_code);
Signature · 1 line
2.39.2.637.g21b0678d19-goog