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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 B8F46C433EF for ; Tue, 21 Sep 2021 16:07:37 +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 85D1E6115A for ; Tue, 21 Sep 2021 16:07:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85D1E6115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nNlBbsqQiUTBGMKAw/ebD5CKMEe8m4mDMQRNKIGw0u8=; b=2F2ZDzerqSste8 wJpwvY60mOEd4mddLL/wY5tvhh4TzCZt3ekq7/LvJaI3mavThIFnvkI2IWQq9CjG0ppV7l8q+kTPo fu/RvJCtIpYem93mA39J8oocOROz/vQFRKQhWVX8W9cwiOI4N8o+zTneIRPwbsWT1aodoJekq14Tc HmcsnIEHl1ofbfNHE1XLxXKMsKJWK0TNVfDKwkMcJmO99oz5/tZ8cikpJnli2TxWly8c7CSj3yl7i yFj1hLpqUliTWAqvMV289yExuM5BKdnME4gHgusorEMBHzxRqf00VCtfCgUiOKxBDAHRYH6HCgKWy Afdt6j3PXGS9PlRhb6PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSiFu-0054Xk-5s; Tue, 21 Sep 2021 16:04:26 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSiAU-0051lb-GZ for linux-arm-kernel@lists.infradead.org; Tue, 21 Sep 2021 15:58:52 +0000 Received: by mail-wr1-x432.google.com with SMTP id g16so40658416wrb.3 for ; Tue, 21 Sep 2021 08:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rNZaBRo6KuYpkYQWXBblrhd42cpP2Z/LzyFVP0pduSg=; b=owdSaQODCfjwam9yCa/45kwOkRitWJz6P7xw58GNzOuAi9z3vUcDQ6zYY+hKxCkGBg HziiVMWTPnEW3Rpn6kaulnon9zQlShOzupU71xnPlabFe6r2C7IFFIN9svHtz5+8OEve w99a5xLpWckDqllV6ACAFLVupF5vJI1b9Xo8cEUvMD33L05IvqXWGUEer++XtNdJb8VZ et0s9UzBjuv5ETPcV7VjpIqkBfDi4PSvkRfuEONCULtAA0rjLPLwJLA3f/QsMdx2zHyQ qxtRsdQLRxWoF3UsfCC6xTrkkJsR0y7nRjXfJr5LXGz/bON5L4+UX42F0CqRGSTgPsDU yukQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rNZaBRo6KuYpkYQWXBblrhd42cpP2Z/LzyFVP0pduSg=; b=Dq0pzuBgy9lSSfk/CDPSKFwFJIKeGd1K6JfL/l+glwE765v8eYeWYwxFXD/DW55TfS GTXlNxe+/At9F7hJaLprntG+sRyuIs7VdmMVVoHLP5MT3SA8MmeNplk11AR/hV3eXzHN epMSPvJHl7nggQM+fOI0vHQ24x01/OwnhkNsHhUbsh+UNA0d9QnoRR5efmyZN02zSrsH ZqaJTF1Kfz4A5dUJkHGCAOvjzelHpzWFMw0mVMwydTxOj2qVgYaoVARlcbL9wncybUKN uADajI1MpMFJd1Ns8dlISnvvyJPW1A9at+9DJdlYcpK+IJMPfV2aN3/jzsieMWZqoz4R HapQ== X-Gm-Message-State: AOAM532TsrW+hgLyTMYt4MX/2vm7U0hOJWO3OnqfsW1BTFjuuzurXe/x 4h2XwEkAMLlu5kYU0jEDa/Buzg== X-Google-Smtp-Source: ABdhPJzCu4pXqY9304sJsjOUOKqLOE9NZBXLU1E16vU0ec0UFC0QKS3WsIUo6q+DMz8jdf+Bi/MtVQ== X-Received: by 2002:a5d:598c:: with SMTP id n12mr35092715wri.391.1632239922976; Tue, 21 Sep 2021 08:58:42 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id q10sm3272495wmq.12.2021.09.21.08.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 08:58:42 -0700 (PDT) Date: Tue, 21 Sep 2021 16:58:20 +0100 From: Jean-Philippe Brucker To: Vivek Gautam Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, joro@8bytes.org, will.deacon@arm.com, mst@redhat.com, robin.murphy@arm.com, eric.auger@redhat.com, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, Lorenzo.Pieralisi@arm.com, shameerali.kolothum.thodi@huawei.com, Alex Williamson Subject: Re: [PATCH RFC v1 01/11] uapi/virtio-iommu: Add page request grp-id and flags information Message-ID: References: <20210423095147.27922-1-vivek.gautam@arm.com> <20210423095147.27922-2-vivek.gautam@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210423095147.27922-2-vivek.gautam@arm.com> X-TUID: Sphz2dU6TdZ7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_085850_693041_7C7B5B1B X-CRM114-Status: GOOD ( 27.12 ) 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 Vivek, Thanks a lot for your work on this On Fri, Apr 23, 2021 at 03:21:37PM +0530, Vivek Gautam wrote: > Add fault information for group-id and necessary flags for page > request faults that can be handled by page fault handler in > virtio-iommu driver. > > Signed-off-by: Vivek Gautam > Cc: Joerg Roedel > Cc: Will Deacon > Cc: Robin Murphy > Cc: Jean-Philippe Brucker > Cc: Eric Auger > Cc: Alex Williamson > Cc: Kevin Tian > Cc: Jacob Pan > Cc: Liu Yi L > Cc: Lorenzo Pieralisi > Cc: Shameerali Kolothum Thodi > --- > include/uapi/linux/virtio_iommu.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/include/uapi/linux/virtio_iommu.h b/include/uapi/linux/virtio_iommu.h > index f8bf927a0689..accc3318ce46 100644 > --- a/include/uapi/linux/virtio_iommu.h > +++ b/include/uapi/linux/virtio_iommu.h > @@ -307,14 +307,27 @@ struct virtio_iommu_req_invalidate { > #define VIRTIO_IOMMU_FAULT_F_DMA_UNRECOV 1 > #define VIRTIO_IOMMU_FAULT_F_PAGE_REQ 2 > > +#define VIRTIO_IOMMU_FAULT_PRQ_F_PASID_VALID (1 << 0) > +#define VIRTIO_IOMMU_FAULT_PRQ_F_LAST_PAGE (1 << 1) > +#define VIRTIO_IOMMU_FAULT_PRQ_F_PRIV_DATA (1 << 2) > +#define VIRTIO_IOMMU_FAULT_PRQ_F_NEEDS_PASID (1 << 3) I don't think this one is necessary here. The NEEDS_PASID flags added by commit 970471914c67 ("iommu: Allow page responses without PASID") mainly helps Linux keep track of things internally. It does tell the fault handler whether to reply with PASID or not, but we don't need that here. The virtio-iommu driver knows whether a PASID is required by looking at the "PRG Response PASID Required" bit in the PCIe capability. For non-PCIe faults (e.g. SMMU stall), I'm guessing we'll need a PROBE property to declare that the endpoint supports recoverable faults anyway, so "PASID required in response" can go through there as well. > + > +#define VIRTIO_IOMMU_FAULT_UNREC_F_PASID_VALID (1 << 0) > +#define VIRTIO_IOMMU_FAULT_UNREC_F_ADDR_VALID (1 << 1) > +#define VIRTIO_IOMMU_FAULT_UNREC_F_FETCH_ADDR_VALID (1 << 2) > + > struct virtio_iommu_fault { > __u8 reason; > __u8 reserved[3]; > __le16 flt_type; > __u8 reserved2[2]; > + /* flags is actually permission flags */ It's also used for declaring validity of fields. VIRTIO_IOMMU_FAULT_F_ADDRESS already tells whether the address field is valid, so all the other flags introduced by this patch can go in here. > __le32 flags; > + /* flags for PASID and Page request handling info */ > + __le32 pr_evt_flags; > __le32 endpoint; > __le32 pasid; > + __le32 grpid; I'm not sure why we made it 32-bit in Linux UAPI, it's a little wasteful. PCIe PRGI is 9-bits and SMMU STAG is 16-bits. Since the scope of the grpid is the endpoint, 16-bit means 64k in-flight faults per endpoint, which seems more than enough. New fields must be appended at the end of the struct, because old drivers will expect to find the 'endpoint' field at this offset. You could remove 'reserved3' while adding 'grpid', to keep the struct layout. > __u8 reserved3[4]; > __le64 address; > __u8 reserved4[8]; So the base structure, currently in the spec, looks like this: struct virtio_iommu_fault { u8 reason; u8 reserved[3]; le32 flags; le32 endpoint; le32 reserved1; le64 address; }; #define VIRTIO_IOMMU_FAULT_F_READ (1 << 0) #define VIRTIO_IOMMU_FAULT_F_WRITE (1 << 1) #define VIRTIO_IOMMU_FAULT_F_ADDRESS (1 << 8) The extended struct could be: struct virtio_iommu_fault { u8 reason; u8 reserved[3]; le32 flags; le32 endpoint; le32 pasid; le64 address; /* Page request group ID */ le16 group_id; u8 reserved1[6]; /* For VT-d private data */ le64 private_data[2]; }; #define VIRTIO_IOMMU_FAULT_F_READ (1 << 0) #define VIRTIO_IOMMU_FAULT_F_WRITE (1 << 1) #define VIRTIO_IOMMU_FAULT_F_EXEC (1 << 2) #define VIRTIO_IOMMU_FAULT_F_PRIVILEGED (1 << 3) /* Last fault in group */ #define VIRTIO_IOMMU_FAULT_F_LAST (1 << 4) /* Fault is a recoverable page request and requires a response */ #define VIRTIO_IOMMU_FAULT_F_PAGE_REQ (1 << 5) /* address field is valid */ #define VIRTIO_IOMMU_FAULT_F_ADDRESS (1 << 8) /* pasid field is valid */ #define VIRTIO_IOMMU_FAULT_F_PASID (1 << 9) /* group_id field is valid */ #define VIRTIO_IOMMU_FAULT_F_GROUP_ID (1 << 10) /* private data field is valid */ #define VIRTIO_IOMMU_FAULT_F_PRIV_DATA (1 << 11) Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel