Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp86662pxb; Tue, 2 Mar 2021 20:12:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/DrYSMM6jisgFHT4Pf3C+7/7cfLIEvWNZkpOv1FykCMicrysJdHQoCG8tMB9L0Tg2Ubu1 X-Received: by 2002:a50:fe08:: with SMTP id f8mr20864176edt.217.1614744741313; Tue, 02 Mar 2021 20:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614744741; cv=none; d=google.com; s=arc-20160816; b=ZDR8Ls9TgcoKEMI2ODM/y3VA3u85raz9ngKmEJvIIbC/mWnFjlKDhuAQig0jCmFG+l QfUUbOpeWFsF7qvJEfG0IQPN/iCtkaCAoj62026E2XLDOVRtLrKQa7fCWJy4JPbvlw5M 2vKv3649O0GTgzIyXPNcGUmlhMY/fQ7AFgeEZX1FZItTVJHOZtlHa790rJAoPHwmiuj3 t29CO8fgVyrwdWaR69+IrbGZxuXzkeRONyXckwzt//uhFBEA6cZGWq2iheFNUcm9oS37 0SUc6QW4vMoMsTI+TQSOp4ce9kZD9pydjhrrar0He9ii99doeKokoKsL9LI0cOyrhZwY 31WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fQXtUglvKm+CEooqZyO9tHltVcL+pPIoZ/xesPCs2FA=; b=LzatuqT9PHFlklhtI0Ld9s3JpHa6Kpum2ODyAbnpkeTsUgnkYEV4jfKwY2K0pZ69pA twM5+NfJpv6FECSoieIoP204sENWAdWMeULNdcER8xL6p435Z+ewCNrKNOg/8YvNtyJt 24srqY8MdiJuCjh3UGsm5OE+sORpdIwdeIYb4u15+EfsHEmejhrctvWI1b8bfhE8lUq8 VHA6/pJfjQB8ZV4OB9LmXcYYY+59U6MC9A80XcLf0pHClGEWN1VHJWis9zoXG9tkkeyW B0DV8Dv15idb/JICwLX2l+FcNoQjITaXNaESPUJT6TLqRV5CzZkKDUA2BLMxqT4Y49bJ /9Jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si2911695ejf.255.2021.03.02.20.11.59; Tue, 02 Mar 2021 20:12:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235804AbhCAO1G (ORCPT + 99 others); Mon, 1 Mar 2021 09:27:06 -0500 Received: from foss.arm.com ([217.140.110.172]:59112 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbhCAOZW (ORCPT ); Mon, 1 Mar 2021 09:25:22 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D1B61396; Mon, 1 Mar 2021 06:23:51 -0800 (PST) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D7D13F70D; Mon, 1 Mar 2021 06:23:48 -0800 (PST) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Cc: Steven Price , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Martin , Mark Rutland , Thomas Gleixner , qemu-devel@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Richard Henderson , Peter Maydell , Haibo Xu , Andrew Jones Subject: [PATCH v9 6/6] KVM: arm64: Document MTE capability and ioctl Date: Mon, 1 Mar 2021 14:23:15 +0000 Message-Id: <20210301142315.30920-7-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210301142315.30920-1-steven.price@arm.com> References: <20210301142315.30920-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Steven Price --- Documentation/virt/kvm/api.rst | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index aed52b0fc16e..1406ea138127 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -4939,6 +4939,23 @@ KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO Allows Xen vCPU attributes to be read. For the structure and types, see KVM_XEN_VCPU_SET_ATTR above. +4.131 KVM_ARM_MTE_COPY_TAGS +--------------------------- + +:Capability: KVM_CAP_ARM_MTE +:Architectures: arm64 +:Type: vm ioctl +:Parameters: struct kvm_arm_copy_mte_tags +:Returns: 0 on success, < 0 on error + +Copies Memory Tagging Extension (MTE) tags to/from guest tag memory. The +starting address and length of guest memory must be ``PAGE_SIZE`` aligned. + +The size of the buffer to store the tags is ``(length / MTE_GRANULE_SIZE)`` +bytes (i.e. 1/16th of the corresponding size). Each byte contains a single tag +value. This matches the format of ``PTRACE_PEEKMTETAGS`` and +``PTRACE_POKEMTETAGS``. + 5. The kvm_run structure ======================== @@ -6227,6 +6244,25 @@ KVM_RUN_BUS_LOCK flag is used to distinguish between them. This capability can be used to check / enable 2nd DAWR feature provided by POWER10 processor. +7.23 KVM_CAP_ARM_MTE +-------------------- + +:Architectures: arm64 +:Parameters: none + +This capability indicates that KVM (and the hardware) supports exposing the +Memory Tagging Extensions (MTE) to the guest. It must also be enabled by the +VMM before the guest will be granted access. + +When enabled the guest is able to access tags associated with any memory given +to the guest. KVM will ensure that the pages are flagged ``PG_mte_tagged`` so +that the tags are maintained during swap or hibernation of the host, however +the VMM needs to manually save/restore the tags as appropriate if the VM is +migrated. + +When enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to +perform a bulk copy of tags to/from the guest + 8. Other capabilities. ====================== @@ -6716,3 +6752,4 @@ KVM_XEN_HVM_SET_ATTR, KVM_XEN_HVM_GET_ATTR, KVM_XEN_VCPU_SET_ATTR and KVM_XEN_VCPU_GET_ATTR ioctls, as well as the delivery of exception vectors for event channel upcalls when the evtchn_upcall_pending field of a vcpu's vcpu_info is set. + -- 2.20.1