Skip to content

RFC KVM: x86: Add a new attribute to control dynamic XSTATE components

Chang S. Bae kvm linux-kselftest lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: x86: Add a new system attribute for dynamic XSTATE componentarch/x86/include/asm/fpu/api.h arch/x86/include/uapi/asm/kvm.h arch/x86/kernel/fpu/xstate.c +1 more+39 -05 replies
2/2selftests: kvm: Use the KVM API to enable dynamic XSTATE featurestools/arch/x86/include/uapi/asm/kvm.h tools/testing/selftests/kvm/lib/x86_64/processor.c+17 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] KVM: x86: Add a new attribute to control dynamic XSTATE components

Hi KVM folks,

While documenting the ARCH_{REQ|GET}_XCOMP_GUEST_PERM options [1], I came to think of this new attribute as it can provide more consistent way of enabling dynamic features for QEMU/KVM.

== Background ==

The new x86 arch_prctl() options [2] help to support dynamic AMX state enabling. As the VCPU permission should be separate, additional options are added for the userspace VMM like QEMU: ARCH_GET_XCOMP_GUEST_PERM and ARCH_REQ_XCOMP_GUEST_PERM.

== Problem ==

KVM has already established a set of ioctls to control VM attributes. It has the attribute to expose the KVM-supported XSTATE components [3]. This interface, however, is not necessarily compatible with those arch_prctl() options. KVM may choose and expose some of the host-supported features. Then using the host-provided interface may not comply with this KVM policy.

== Solution ==

The patchset adds a new attribute to control XSTATE permission:
KVM_X86_XCOMP_GUEST_PERM, and it is available through the KVM_GET_DEVICE_ATTR/KVM_SET_DEVICE_ATTR APIs. The KVM AMX test is updated to use this. Then QEMU may switch to keep using the KVM API, which is more consistent.

[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://docs.kernel.org/x86/xstate.html
[3]: https://gitlab.com/qemu-project/qemu/-/blob/master/linux-headers/asm-x86/kvm.h#L456

Chang S. Bae (2):
KVM: x86: Add a new system attribute for dynamic XSTATE component
selftests: kvm: Use the KVM API to enable dynamic XSTATE features

 arch/x86/include/asm/fpu/api.h                |  1 +
 arch/x86/include/uapi/asm/kvm.h               |  1 +
 arch/x86/kernel/fpu/xstate.c                  |  6 ++++
 arch/x86/kvm/x86.c                            | 31 +++++++++++++++++++
 tools/arch/x86/include/uapi/asm/kvm.h         |  1 +
 .../selftests/kvm/lib/x86_64/processor.c      | 22 +++++++++----
 6 files changed, 56 insertions(+), 6 deletions(-)

base-commit: 1c23f9e627a7b412978b4e852793c5e3c3efc555

Signature · 1 line
2.17.1