vcpu-features.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============================
  3. vCPU feature selection on arm64
  4. ===============================
  5. KVM/arm64 provides two mechanisms that allow userspace to configure
  6. the CPU features presented to the guest.
  7. KVM_ARM_VCPU_INIT
  8. =================
  9. The ``KVM_ARM_VCPU_INIT`` ioctl accepts a bitmap of feature flags
  10. (``struct kvm_vcpu_init::features``). Features enabled by this interface are
  11. *opt-in* and may change/extend UAPI. See :ref:`KVM_ARM_VCPU_INIT` for complete
  12. documentation of the features controlled by the ioctl.
  13. Otherwise, all CPU features supported by KVM are described by the architected
  14. ID registers.
  15. The ID Registers
  16. ================
  17. The Arm architecture specifies a range of *ID Registers* that describe the set
  18. of architectural features supported by the CPU implementation. KVM initializes
  19. the guest's ID registers to the maximum set of CPU features supported by the
  20. system. The ID register values may be VM-scoped in KVM, meaning that the
  21. values could be shared for all vCPUs in a VM.
  22. KVM allows userspace to *opt-out* of certain CPU features described by the ID
  23. registers by writing values to them via the ``KVM_SET_ONE_REG`` ioctl. The ID
  24. registers are mutable until the VM has started, i.e. userspace has called
  25. ``KVM_RUN`` on at least one vCPU in the VM. Userspace can discover what fields
  26. are mutable in the ID registers using the ``KVM_ARM_GET_REG_WRITABLE_MASKS``.
  27. See the :ref:`ioctl documentation <KVM_ARM_GET_REG_WRITABLE_MASKS>` for more
  28. details.
  29. Userspace is allowed to *limit* or *mask* CPU features according to the rules
  30. outlined by the architecture in DDI0487J.a D19.1.3 'Principles of the ID
  31. scheme for fields in ID register'. KVM does not allow ID register values that
  32. exceed the capabilities of the system.
  33. .. warning::
  34. It is **strongly recommended** that userspace modify the ID register values
  35. before accessing the rest of the vCPU's CPU register state. KVM may use the
  36. ID register values to control feature emulation. Interleaving ID register
  37. modification with other system register accesses may lead to unpredictable
  38. behavior.