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=-13.8 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 AE23CC433DB for ; Thu, 4 Mar 2021 00:14:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5DD4F64EE6 for ; Thu, 4 Mar 2021 00:13:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DD4F64EE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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=desiato.20200630; 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=31GIRP0lPj1fDT9cOFDXGIDK8/ohuPP/zkSyXMX9W8c=; b=VC/y2bUF1qWXUXd8a8rEK46Id Jqx4p4lE2mGsMjii1AtTVYQuZBjbn7hMCMcg1fjfl0EtjKha24N5wZcp0ogEA/1gOr2+O/rb7mRiR 2L7XvPyX08u51HyU7vbtPnQJepLb4HePaL03+C3ICjmN6uK/qvUzjLoz4yvxgPY/3fPifi4JVTU4W Luz2sz3ofpeHvUTVzhCc712v1bwFhEWNE1WKLg81rpvSoMtADnw4laK7zun6eJLRxO33NOra4uaqc ss4QJsr8Y8wk291Hae7fbZGIdlvngqLIR6mdz86rWYCnvFdOYsdiH4aznWfZwOLbHev/8LXekuhNo lt8M7YsDQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHbZZ-0075dI-Oi; Thu, 04 Mar 2021 00:10:38 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHVG0-005nJ4-9E for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 17:25:58 +0000 Received: by mail-wr1-x42a.google.com with SMTP id u16so6559605wrt.1 for ; Wed, 03 Mar 2021 09:25:55 -0800 (PST) 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=sTamhW9kBjxgzkEQoLRyMj5hVf4Faxe5WhEqC1E4/4A=; b=PvFI6RNC5gKkiR4uElMabw36/xB+ietKweTBJ4T98xol1ziCDi0AA0R+IDtXnc5Jsx qEao7IHKNQZLfegHpIDSWl1V+a11e0koptzY0nszPgQYWuyYf/+Doh9jF0vbrOgXMYlz 21Z7Ygx6i3E7XgJgk8INKMwhBKsm7Ca0oNMrRDvzpjSda8mtQal62NDw9tqiXVTvxcLr fElIGrLQ9ltww+SCGkRKjuCTlAVc08d+qT8iG9D9f/PybhIBuHYcPh4JbOcQgQQ8Fasf X3HtjnlV2CK5gJ1vnSd5P+azVJpctQJFhMYAwenEGER4nvRFIO6/9NXh2sN5GzhjuSk4 a48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sTamhW9kBjxgzkEQoLRyMj5hVf4Faxe5WhEqC1E4/4A=; b=h2MnW249zZzutnPQt4XBbZFlSuvRDsYRMBIroXrr4CM4gkSL2LIsJ+QAFRgJi+gCgZ vxCTLfqNWuDExZ+If5SVKu8kHlzLGMmKx4Mi81wo8Mt6mE2/MM47bH2RYWHCQu88j7PY 5FZepy56voY+5Ok3j9AZl2gVqVA8sRsAKpiS1pLn/4RxGp1puYwXCM8+l+lCjD0KOfbL jkr0JYT95MbO8km+4jN4YfKGhnL2/5a9CBwhIWXiEcvuaCxufW7/9JHKWcD68xjlxk55 EzzXVOe3nqYYYyMLecb9N3LLFo9kakg85l6vJ7H7eAzcRdScl/D9X32KED1HmcXePXIe l6GA== X-Gm-Message-State: AOAM531Y8pEKYFaRQPh1Blpz8JfEOie4knn2y5AmzkOAptvvN8jVFVuH a3W7RADzINILuhLV5wLtB54sCw== X-Google-Smtp-Source: ABdhPJxEGN1rH8+VtjTLr+Dh5jEKvGOweEYJsKpNFFpw9C+4jgIY35xjxjoSoEJ/Son74X8HB1937Q== X-Received: by 2002:a5d:550b:: with SMTP id b11mr24476367wrv.313.1614792355644; Wed, 03 Mar 2021 09:25:55 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id b65sm6127924wmh.4.2021.03.03.09.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 09:25:55 -0800 (PST) Date: Wed, 3 Mar 2021 18:25:33 +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, alex.williamson@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 Subject: Re: [PATCH RFC v1 15/15] iommu/virtio: Update fault type and reason info for viommu fault Message-ID: References: <20210115121342.15093-1-vivek.gautam@arm.com> <20210115121342.15093-16-vivek.gautam@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210115121342.15093-16-vivek.gautam@arm.com> 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 On Fri, Jan 15, 2021 at 05:43:42PM +0530, Vivek Gautam wrote: > Fault type information can tell about a page request fault or > an unreceoverable fault, and further additions to fault reasons > and the related PASID information can help in handling faults > efficiently. > > Signed-off-by: Vivek Gautam > Cc: Joerg Roedel > Cc: Will Deacon > Cc: Michael S. Tsirkin > 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 > --- > drivers/iommu/virtio-iommu.c | 27 +++++++++++++++++++++++++-- > include/uapi/linux/virtio_iommu.h | 13 ++++++++++++- > 2 files changed, 37 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c > index 9cc3d35125e9..10ef9e98214a 100644 > --- a/drivers/iommu/virtio-iommu.c > +++ b/drivers/iommu/virtio-iommu.c > @@ -652,9 +652,16 @@ static int viommu_fault_handler(struct viommu_dev *viommu, > char *reason_str; > > u8 reason = fault->reason; > + u16 type = fault->flt_type; > u32 flags = le32_to_cpu(fault->flags); > u32 endpoint = le32_to_cpu(fault->endpoint); > u64 address = le64_to_cpu(fault->address); > + u32 pasid = le32_to_cpu(fault->pasid); > + > + if (type == VIRTIO_IOMMU_FAULT_F_PAGE_REQ) { > + dev_info(viommu->dev, "Page request fault - unhandled\n"); > + return 0; > + } > > switch (reason) { > case VIRTIO_IOMMU_FAULT_R_DOMAIN: > @@ -663,6 +670,21 @@ static int viommu_fault_handler(struct viommu_dev *viommu, > case VIRTIO_IOMMU_FAULT_R_MAPPING: > reason_str = "page"; > break; > + case VIRTIO_IOMMU_FAULT_R_WALK_EABT: > + reason_str = "page walk external abort"; > + break; > + case VIRTIO_IOMMU_FAULT_R_PTE_FETCH: > + reason_str = "pte fetch"; > + break; > + case VIRTIO_IOMMU_FAULT_R_PERMISSION: > + reason_str = "permission"; > + break; > + case VIRTIO_IOMMU_FAULT_R_ACCESS: > + reason_str = "access"; > + break; > + case VIRTIO_IOMMU_FAULT_R_OOR_ADDRESS: > + reason_str = "output address"; > + break; > case VIRTIO_IOMMU_FAULT_R_UNKNOWN: > default: > reason_str = "unknown"; > @@ -671,8 +693,9 @@ static int viommu_fault_handler(struct viommu_dev *viommu, > > /* TODO: find EP by ID and report_iommu_fault */ > if (flags & VIRTIO_IOMMU_FAULT_F_ADDRESS) > - dev_err_ratelimited(viommu->dev, "%s fault from EP %u at %#llx [%s%s%s]\n", > - reason_str, endpoint, address, > + dev_err_ratelimited(viommu->dev, > + "%s fault from EP %u PASID %u at %#llx [%s%s%s]\n", > + reason_str, endpoint, pasid, address, > flags & VIRTIO_IOMMU_FAULT_F_READ ? "R" : "", > flags & VIRTIO_IOMMU_FAULT_F_WRITE ? "W" : "", > flags & VIRTIO_IOMMU_FAULT_F_EXEC ? "X" : ""); > diff --git a/include/uapi/linux/virtio_iommu.h b/include/uapi/linux/virtio_iommu.h > index 608c8d642e1f..a537d82777f7 100644 > --- a/include/uapi/linux/virtio_iommu.h > +++ b/include/uapi/linux/virtio_iommu.h > @@ -290,19 +290,30 @@ struct virtio_iommu_req_invalidate { > #define VIRTIO_IOMMU_FAULT_R_UNKNOWN 0 > #define VIRTIO_IOMMU_FAULT_R_DOMAIN 1 > #define VIRTIO_IOMMU_FAULT_R_MAPPING 2 > +#define VIRTIO_IOMMU_FAULT_R_WALK_EABT 3 > +#define VIRTIO_IOMMU_FAULT_R_PTE_FETCH 4 > +#define VIRTIO_IOMMU_FAULT_R_PERMISSION 5 > +#define VIRTIO_IOMMU_FAULT_R_ACCESS 6 > +#define VIRTIO_IOMMU_FAULT_R_OOR_ADDRESS 7 > > #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_ADDRESS (1 << 8) > > +#define VIRTIO_IOMMU_FAULT_F_DMA_UNRECOV 1 > +#define VIRTIO_IOMMU_FAULT_F_PAGE_REQ 2 Currently all reported faults are unrecoverable, so to be consistent DMA_UNRECOV should be 0. But I'd prefer having just a new "page request" flag in the flags field, instead of the flt_type field. For page requests we'll also need a 16-bit fault ID field to store the PRI "page request group index" or the stall "stag". "last" and "privileged" flags as well, to match the PRI page request. And a new command to complete a page fault. > + > struct virtio_iommu_fault { > __u8 reason; > - __u8 reserved[3]; > + __le16 flt_type; > + __u8 reserved; > __le32 flags; > __le32 endpoint; > __u8 reserved2[4]; Why not replace reserved2 with the pasid? It fits perfectly :) Thanks, Jean > __le64 address; > + __le32 pasid; > + __u8 reserved3[4]; > }; > > #endif > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel