Skip to content

Commit 04c02c2

Browse files
stevenprice-armMarc Zyngier
authored andcommitted
KVM: arm64: Document MTE capability and ioctl
A new capability (KVM_CAP_ARM_MTE) identifies that the kernel supports granting a guest access to the tags, and provides a mechanism for the VMM to enable it. A new ioctl (KVM_ARM_MTE_COPY_TAGS) provides a simple way for a VMM to access the tags of a guest without having to maintain a PROT_MTE mapping in userspace. The above capability gates access to the ioctl. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210621111716.37157-7-steven.price@arm.com
1 parent f0376ed commit 04c02c2

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Documentation/virt/kvm/api.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,6 +5034,43 @@ see KVM_XEN_VCPU_SET_ATTR above.
50345034
The KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST type may not be used
50355035
with the KVM_XEN_VCPU_GET_ATTR ioctl.
50365036

5037+
4.130 KVM_ARM_MTE_COPY_TAGS
5038+
---------------------------
5039+
5040+
:Capability: KVM_CAP_ARM_MTE
5041+
:Architectures: arm64
5042+
:Type: vm ioctl
5043+
:Parameters: struct kvm_arm_copy_mte_tags
5044+
:Returns: number of bytes copied, < 0 on error (-EINVAL for incorrect
5045+
arguments, -EFAULT if memory cannot be accessed).
5046+
5047+
::
5048+
5049+
struct kvm_arm_copy_mte_tags {
5050+
__u64 guest_ipa;
5051+
__u64 length;
5052+
void __user *addr;
5053+
__u64 flags;
5054+
__u64 reserved[2];
5055+
};
5056+
5057+
Copies Memory Tagging Extension (MTE) tags to/from guest tag memory. The
5058+
``guest_ipa`` and ``length`` fields must be ``PAGE_SIZE`` aligned. The ``addr``
5059+
field must point to a buffer which the tags will be copied to or from.
5060+
5061+
``flags`` specifies the direction of copy, either ``KVM_ARM_TAGS_TO_GUEST`` or
5062+
``KVM_ARM_TAGS_FROM_GUEST``.
5063+
5064+
The size of the buffer to store the tags is ``(length / 16)`` bytes
5065+
(granules in MTE are 16 bytes long). Each byte contains a single tag
5066+
value. This matches the format of ``PTRACE_PEEKMTETAGS`` and
5067+
``PTRACE_POKEMTETAGS``.
5068+
5069+
If an error occurs before any data is copied then a negative error code is
5070+
returned. If some tags have been copied before an error occurs then the number
5071+
of bytes successfully copied is returned. If the call completes successfully
5072+
then ``length`` is returned.
5073+
50375074
5. The kvm_run structure
50385075
========================
50395076

@@ -6362,6 +6399,30 @@ default.
63626399

63636400
See Documentation/x86/sgx/2.Kernel-internals.rst for more details.
63646401

6402+
7.26 KVM_CAP_ARM_MTE
6403+
--------------------
6404+
6405+
:Architectures: arm64
6406+
:Parameters: none
6407+
6408+
This capability indicates that KVM (and the hardware) supports exposing the
6409+
Memory Tagging Extensions (MTE) to the guest. It must also be enabled by the
6410+
VMM before creating any VCPUs to allow the guest access. Note that MTE is only
6411+
available to a guest running in AArch64 mode and enabling this capability will
6412+
cause attempts to create AArch32 VCPUs to fail.
6413+
6414+
When enabled the guest is able to access tags associated with any memory given
6415+
to the guest. KVM will ensure that the tags are maintained during swap or
6416+
hibernation of the host; however the VMM needs to manually save/restore the
6417+
tags as appropriate if the VM is migrated.
6418+
6419+
When this capability is enabled all memory in memslots must be mapped as
6420+
not-shareable (no MAP_SHARED), attempts to create a memslot with a
6421+
MAP_SHARED mmap will result in an -EINVAL return.
6422+
6423+
When enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to
6424+
perform a bulk copy of tags to/from the guest.
6425+
63656426
8. Other capabilities.
63666427
======================
63676428

0 commit comments

Comments
 (0)