On Thu, Mar 02, 2023, Aaron Lewis wrote: > On Thu, Mar 2, 2023 at 8:34 PM Mingwei Zhang <mizhang@xxxxxxxxxx> wrote: > > > > On Fri, Feb 24, 2023, Aaron Lewis wrote: > > > Check both architectural rules and KVM's own software-defined rules to > > > ensure the supported xfeatures[1] don't violate any of them. > > > > > > The architectural rules[2] and KVM's rules ensure for a given > > > feature, e.g. sse, avx, amx, etc... their associated xfeatures are > > > either all sets or none of them are set, and any dependencies > > > are enabled if needed. > > > > > > [1] EDX:EAX of CPUID.(EAX=0DH,ECX=0) > > > [2] SDM vol 1, 13.3 ENABLING THE XSAVE FEATURE SET AND XSAVE-ENABLED > > > FEATURES > > > > > > Signed-off-by: Aaron Lewis <aaronlewis@xxxxxxxxxx> > > > > Sorry, I did not get the point of this test? I run your test in an old > > (unpatched) kernel on two machines: 1) one with AMX and 2) one without > > it. (SPR and Skylake). Neither of them fails. Do you want to clarify a > > little bit? > > The only known issue exists on newer versions of the kernel when run > on SPR. It occurs after the syscall, prctl (to enable XTILEDATA), was > introduced. If you run this test without the fix[1] you will get the > assert below, indicating the XTILECFG is supported by the guest, but > XTILEDATA isn't. > > ==== Test Assertion Failure ==== > x86_64/xcr0_cpuid_test.c:116: false > pid=18124 tid=18124 errno=4 - Interrupted system call > 1 0x0000000000401894: main at xcr0_cpuid_test.c:116 > 2 0x0000000000414263: __libc_start_call_main at libc-start.o:? > 3 0x00000000004158af: __libc_start_main_impl at ??:? > 4 0x0000000000401660: _start at ??:? > Failed guest assert: !__supported || __supported == ((((((1ULL))) << > (18)) | ((((1ULL))) << (17)))) at x86_64/xcr0_cpuid_test.c:72 > 0x20000 0x60000 0x0 > > [1] KVM: x86: Clear all supported AMX xfeatures if they are not all set > https://lore.kernel.org/kvm/20230224223607.1580880-6-aaronlewis@xxxxxxxxxx/ > Understood. Thanks for reminding me. Yes, without the invocation of vm_xsave_require_permission(XSTATE_XTILE_DATA_BIT); VM guest will see a partially enabled feature (XTILECFG without XTILEDATA). Reviewed-by: Mingwei Zhang <mizhang@xxxxxxxxxx> > > > > > > Thanks. > > -Mingwei