mbox series

[0/3] Clean up AMX cpuid bits XTILE_CFG and XTILE_DATA

Message ID 20221227183713.29140-1-aaronlewis@google.com (mailing list archive)
Headers show
Series Clean up AMX cpuid bits XTILE_CFG and XTILE_DATA | expand

Message

Aaron Lewis Dec. 27, 2022, 6:37 p.m. UTC
When running a SPR guest without AMX enabled
CPUID.(EAX=0DH,ECX=0):EAX.XTILE_CFG[bit-17] will be set and
CPUID.(EAX=0DH,ECX=0):EAX.XTILE_DATA[bit-18] will be clear.  While this
is architecturally correct it can be a little awkward for userspace
or a guest when using them.  Instead of leaving the CPUID leaf in a
half baked state, either clear them both or leave them both set.

Additionally, add testing to verify the CPUID isn't in such a state.

Aaron Lewis (3):
  KVM: x86: Clear XTILE_CFG if XTILE_DATA is clear
  KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible
  KVM: selftests: Add XCR0 Test

 arch/x86/kvm/cpuid.c                          |   4 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/processor.h  |  19 +++
 tools/testing/selftests/kvm/x86_64/amx_test.c |  24 +---
 .../selftests/kvm/x86_64/xcr0_cpuid_test.c    | 134 ++++++++++++++++++
 5 files changed, 161 insertions(+), 21 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c

Comments

Jim Mattson Dec. 27, 2022, 8 p.m. UTC | #1
On Tue, Dec 27, 2022 at 10:38 AM Aaron Lewis <aaronlewis@google.com> wrote:
>
> When running a SPR guest without AMX enabled

Can you clarify what "without AMX enabled" means? Do you mean that
userspace hasn't opted in to AMX via arch_prctl()?

> CPUID.(EAX=0DH,ECX=0):EAX.XTILE_CFG[bit-17] will be set and
> CPUID.(EAX=0DH,ECX=0):EAX.XTILE_DATA[bit-18] will be clear.  While this
> is architecturally correct it can be a little awkward for userspace
> or a guest when using them.  Instead of leaving the CPUID leaf in a
> half baked state, either clear them both or leave them both set.
>
> Additionally, add testing to verify the CPUID isn't in such a state.
>
> Aaron Lewis (3):
>   KVM: x86: Clear XTILE_CFG if XTILE_DATA is clear
>   KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible
>   KVM: selftests: Add XCR0 Test
>
>  arch/x86/kvm/cpuid.c                          |   4 +
>  tools/testing/selftests/kvm/Makefile          |   1 +
>  .../selftests/kvm/include/x86_64/processor.h  |  19 +++
>  tools/testing/selftests/kvm/x86_64/amx_test.c |  24 +---
>  .../selftests/kvm/x86_64/xcr0_cpuid_test.c    | 134 ++++++++++++++++++
>  5 files changed, 161 insertions(+), 21 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c
>
> --
> 2.39.0.314.g84b9a713c41-goog
>
Aaron Lewis Dec. 27, 2022, 8:40 p.m. UTC | #2
On Tue, Dec 27, 2022 at 8:01 PM Jim Mattson <jmattson@google.com> wrote:
>
> On Tue, Dec 27, 2022 at 10:38 AM Aaron Lewis <aaronlewis@google.com> wrote:
> >
> > When running a SPR guest without AMX enabled
>
> Can you clarify what "without AMX enabled" means? Do you mean that
> userspace hasn't opted in to AMX via arch_prctl()?
>

Yes, exactly.  I'll clarify in the follow-up.