From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 911BAC2B9F4 for ; Tue, 22 Jun 2021 09:45:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61CF961026 for ; Tue, 22 Jun 2021 09:45:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61CF961026 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jU6tCC8aLFOIkwmUj5hdPCTp22qCXqq384IuKHocfD8=; b=Umh+M+GprpqNyT fJEdu5DCcKyOKSjjqtGEUVm0mmusIti7GfE+/Q94nxq+kA7mWdj+h4ZfsL9VsThuNGH+0Y93v4Toh cuMstBz3qjwnIjIxmAp84WfUiaZJkfXhO7pkMg1IkTK0MVDJ27i9HQ6Lqb1UPc258X6nfpwhsztnj Ldi4znXRPwq+nFs3UwHiqlhPG5OflaR+4deejKheKmazxvuo+3UlCfINEAnH6eOS5ysYTZesEWGx4 1ygiEc04tP7zP5qLv0KY6YmRD8BAmlNkznFva6OGv41Mti+A3loOyagkQerfPYqGgtpboH1NWW/hm tq9rbWRf8crNwq91d2Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvcwF-006URP-MI; Tue, 22 Jun 2021 09:43:23 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvcwC-006UQI-6y for linux-arm-kernel@lists.infradead.org; Tue, 22 Jun 2021 09:43:21 +0000 Received: by mail-ot1-x330.google.com with SMTP id v11-20020a9d340b0000b0290455f7b8b1dcso7689104otb.7 for ; Tue, 22 Jun 2021 02:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mOZsVL4W9RtqKElq9uj4H6IEXm0Hjxy6DO7qW7nF8+s=; b=ux0YEZplnfIscu7weLF3XpMoCtMnkNmS6hVSWuN56okSLW/zGV1P+guRXMFRqRkbf7 Orp3GVpNMWhLy8UtZep53Z6pymX+WaeuKiMBhSvFvW6/XyhpgTlktM+RQbnkC8iI/O3J SNDkBBMrMo+ywAPTzu2X1V2oRTSHHVxXL0N6GZQ66fkZMVbICFky94VQxIOgL1khTDJ/ 10I1gamEP+yLZDLwjGD3OLmFleSlcamkg+L3gTC5dl81NSS/qNHiLNYAALAy1X1kjFhq ep/UgbeZLCglgQHlqBhfpYHMWUpBPmett/7lXuSbLiI7EYBc+8nCCO8QEvWc/dd2Xg8E FkFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mOZsVL4W9RtqKElq9uj4H6IEXm0Hjxy6DO7qW7nF8+s=; b=Gwgdnf2d4WxWsykiYay9spt5MvuVM4mC3YpBa/Su0Qva9rGx21VERKbeKOgXVA9Xp+ 57fNseljFgch8s94Fnsod0OJVGTHCvk0+hetN4bFPKLu0ltR8Ipims5iRkTYruufLmOx bYdkdLEOqRs3WMO/dI0mKb84KfGYByIZf8bHs3gqopFzjCavGp3jtxehbXpq5fQigNm8 lREwDXCbQrS2+P/gQh3W50YbcDXTvD6T/JDV3cXVCxwlOb6N+K0yZ7xLnD/5QNoRRI+/ EUdXHzdMESj2nA1+eDU5IjnkFGsDMUETuqlyBrBMNLcJfor2MUJRnPJKfRsZ9EFolShi 71zA== X-Gm-Message-State: AOAM533bvUxLBe/NLt9PFW7gjfqTo2iOqouSepcN7SFNDuS4WzdFSh7M 2KHnt4eimQALRKiFAUAXUQBSHIH+RVp4OXdpy+jwUQ== X-Google-Smtp-Source: ABdhPJzlIDoe2rVjsQdnkHJBL+8HQrVMGP+s17mqW1WIzdE5TsTe6sX5gcHWH9dUwFLCPfuFLUMJObjVJ+/GHUBWjfw= X-Received: by 2002:a05:6830:2315:: with SMTP id u21mr2367474ote.365.1624354999094; Tue, 22 Jun 2021 02:43:19 -0700 (PDT) MIME-Version: 1.0 References: <20210621111716.37157-1-steven.price@arm.com> <20210621111716.37157-7-steven.price@arm.com> In-Reply-To: <20210621111716.37157-7-steven.price@arm.com> From: Fuad Tabba Date: Tue, 22 Jun 2021 10:42:42 +0100 Message-ID: Subject: Re: [PATCH v17 6/6] KVM: arm64: Document MTE capability and ioctl To: Steven Price Cc: Catalin Marinas , Marc Zyngier , Will Deacon , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org, Dave Martin , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Thomas Gleixner , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_024320_337563_BE11918B X-CRM114-Status: GOOD ( 33.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Mon, Jun 21, 2021 at 12:18 PM Steven Price wrote: > > 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 > Signed-off-by: Steven Price > --- > Documentation/virt/kvm/api.rst | 61 ++++++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 7fcb2fd38f42..97661a97943f 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -5034,6 +5034,43 @@ see KVM_XEN_VCPU_SET_ATTR above. > The KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST type may not be used > with the KVM_XEN_VCPU_GET_ATTR ioctl. > > +4.130 KVM_ARM_MTE_COPY_TAGS > +--------------------------- > + > +:Capability: KVM_CAP_ARM_MTE > +:Architectures: arm64 > +:Type: vm ioctl > +:Parameters: struct kvm_arm_copy_mte_tags > +:Returns: number of bytes copied, < 0 on error (-EINVAL for incorrect > + arguments, -EFAULT if memory cannot be accessed). > + > +:: > + > + struct kvm_arm_copy_mte_tags { > + __u64 guest_ipa; > + __u64 length; > + void __user *addr; > + __u64 flags; > + __u64 reserved[2]; > + }; > + > +Copies Memory Tagging Extension (MTE) tags to/from guest tag memory. The > +``guest_ipa`` and ``length`` fields must be ``PAGE_SIZE`` aligned. The ``addr`` > +field must point to a buffer which the tags will be copied to or from. > + > +``flags`` specifies the direction of copy, either ``KVM_ARM_TAGS_TO_GUEST`` or > +``KVM_ARM_TAGS_FROM_GUEST``. > + > +The size of the buffer to store the tags is ``(length / 16)`` bytes > +(granules in MTE are 16 bytes long). Each byte contains a single tag > +value. This matches the format of ``PTRACE_PEEKMTETAGS`` and > +``PTRACE_POKEMTETAGS``. > + > +If an error occurs before any data is copied then a negative error code is > +returned. If some tags have been copied before an error occurs then the number > +of bytes successfully copied is returned. If the call completes successfully > +then ``length`` is returned. > + > 5. The kvm_run structure > ======================== > > @@ -6362,6 +6399,30 @@ default. > > See Documentation/x86/sgx/2.Kernel-internals.rst for more details. > > +7.26 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 creating any VCPUs to allow the guest access. Note that MTE is only > +available to a guest running in AArch64 mode and enabling this capability will > +cause attempts to create AArch32 VCPUs to fail. I was wondering if there might be an issue with AArch32 at EL0 and MTE, because I think that even if AArch64 at EL1 is disallowed, the guest can still run AArch32 at EL0. Thanks, /fuad > + > +When enabled the guest is able to access tags associated with any memory given > +to the guest. KVM will ensure 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 this capability is enabled all memory in memslots must be mapped as > +not-shareable (no MAP_SHARED), attempts to create a memslot with a > +MAP_SHARED mmap will result in an -EINVAL return. > + > +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. > ====================== > > -- > 2.20.1 > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel