Skip to content

Commit 7042ef5

Browse files
suomilewissean-jc
authored andcommitted
KVM: selftests: Check that the palette table exists before using it
Check that the palette table exists before using it. The 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. Signed-off-by: Aaron Lewis <aaronlewis@google.com> Signed-off-by: Mingwei Zhang <mizhang@google.com> Link: https://lore.kernel.org/r/20230221163655.920289-13-mizhang@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 08f63d8 commit 7042ef5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tools/testing/selftests/kvm/include/x86_64/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct kvm_x86_cpu_property {
227227
#define X86_PROPERTY_XSTATE_MAX_SIZE KVM_X86_CPU_PROPERTY(0xd, 0, ECX, 0, 31)
228228
#define X86_PROPERTY_XSTATE_TILE_SIZE KVM_X86_CPU_PROPERTY(0xd, 18, EAX, 0, 31)
229229
#define X86_PROPERTY_XSTATE_TILE_OFFSET KVM_X86_CPU_PROPERTY(0xd, 18, EBX, 0, 31)
230+
#define X86_PROPERTY_AMX_MAX_PALETTE_TABLES KVM_X86_CPU_PROPERTY(0x1d, 0, EAX, 0, 31)
230231
#define X86_PROPERTY_AMX_TOTAL_TILE_BYTES KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 0, 15)
231232
#define X86_PROPERTY_AMX_BYTES_PER_TILE KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 16, 31)
232233
#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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define XSAVE_SIZE ((NUM_TILES * TILE_SIZE) + PAGE_SIZE)
3131

3232
/* Tile configuration associated: */
33+
#define PALETTE_TABLE_INDEX 1
3334
#define MAX_TILES 16
3435
#define RESERVED_BYTES 14
3536

@@ -120,6 +121,10 @@ static void check_xtile_info(void)
120121
GUEST_ASSERT(xtile.xsave_size == 8192);
121122
GUEST_ASSERT(sizeof(struct tile_data) >= xtile.xsave_size);
122123

124+
GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_AMX_MAX_PALETTE_TABLES));
125+
GUEST_ASSERT(this_cpu_property(X86_PROPERTY_AMX_MAX_PALETTE_TABLES) >=
126+
PALETTE_TABLE_INDEX);
127+
123128
GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_AMX_NR_TILE_REGS));
124129
xtile.max_names = this_cpu_property(X86_PROPERTY_AMX_NR_TILE_REGS);
125130
GUEST_ASSERT(xtile.max_names == 8);

0 commit comments

Comments
 (0)