Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2452474rdd; Fri, 12 Jan 2024 09:46:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn30CeWT8CmACLuZ5zrYINQA96CeoyzjsS8+SfUjKiBw+nZAO7nujduojO+2KkfIg6P03Y X-Received: by 2002:a9d:4d87:0:b0:6dd:e885:804b with SMTP id u7-20020a9d4d87000000b006dde885804bmr2010018otk.77.1705081587930; Fri, 12 Jan 2024 09:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705081587; cv=none; d=google.com; s=arc-20160816; b=CUDwK866injIbf4VXPHXqdOL/ydhcQ62146jo+rMkdv7wmGiqXsRgT+SDinXbBOWz6 /QkAZFwrKXHX922f+orTtND4vulDJKpd1eE4DqhHA00QuX8RGiTuCfBhWvdN4QeJ14Sc wuxt/t+LAsvDQQH0cx5KGyVICoDzwHPvNHHnHMcNNDCzBEmb42KpsIa2aeqfqZIgMIaO +B7a/pNf5TxVnzS5Syaae4v6JAk5vUSZU+a64+L9bHPo+cxHNNAXk/qB2AVVqILEw9JY vSSc33TT5BPx1UV2o7wdp4vFXR+rng2Rx/jKHY6sB98KMX/R68Cj6F4YAVz6ltZu7u3F vUMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=cQyVD05fbzKJXFMei8QVo7LbsJBMZOsRzc2Z5L4KlmQ=; fh=ipk8T5B3jpdLpHBY7MRg9Fn+Vsh+s+b9CO9qvTUenwc=; b=La95vteAsuETMClR/rCnmY/bM5AS6ig1j9j0txXxc7VjGcbooSIto/D/X+g2EoWpcO pRhzDnRyzCiet0NgVw0bXGKm51lOjZJBhj4dkFUgpuv6C4TBGLptBYKd8SUr0KzZkr3e u8Cgwqi8IKk7PgHM309MQiW8ZRkvX8h7ntkb3tp6z886MqD77IdjTrnquXBno5XZqRiH FKPQ71HBNC0blkMoZQwZ6UceUrE7yye4t3ZJwdN+lX8GlZhcnM6qFCRMM4+Wi9BnbuQi fE8fJUQm01lumiPx0nd/s8R7nMTx9GqETCfmGPaZLyeyGSa/Di7tn1y31bIbzb43NW02 LNCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k67-20020a632446000000b005cf268595besi3660330pgk.157.2024.01.12.09.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 09:46:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 90A1F281CD9 for ; Fri, 12 Jan 2024 17:46:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DFB617C80; Fri, 12 Jan 2024 17:46:19 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A200817C81; Fri, 12 Jan 2024 17:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TBTRS1S4Bz6J9YF; Sat, 13 Jan 2024 01:43:48 +0800 (CST) Received: from lhrpeml100003.china.huawei.com (unknown [7.191.160.210]) by mail.maildlp.com (Postfix) with ESMTPS id 30698140B2F; Sat, 13 Jan 2024 01:46:14 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by lhrpeml100003.china.huawei.com (7.191.160.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Jan 2024 17:46:13 +0000 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.035; Fri, 12 Jan 2024 17:46:13 +0000 From: Shameerali Kolothum Thodi To: Lu Baolu , Jason Gunthorpe , "Kevin Tian" , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan CC: "iommu@lists.linux.dev" , "linux-kselftest@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2 4/6] iommufd: Deliver fault messages to user space Thread-Topic: [PATCH v2 4/6] iommufd: Deliver fault messages to user space Thread-Index: AQHaB7erJOXV16DWQEa9TDH5jPoMHrDW7X2w Date: Fri, 12 Jan 2024 17:46:13 +0000 Message-ID: References: <20231026024930.382898-1-baolu.lu@linux.intel.com> <20231026024930.382898-5-baolu.lu@linux.intel.com> In-Reply-To: <20231026024930.382898-5-baolu.lu@linux.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 > -----Original Message----- > From: Lu Baolu > Sent: Thursday, October 26, 2023 3:49 AM > To: Jason Gunthorpe ; Kevin Tian ; Jo= erg > Roedel ; Will Deacon ; Robin Murphy > ; Jean-Philippe Brucker ; > Nicolin Chen ; Yi Liu ; Jacob Pa= n > > Cc: iommu@lists.linux.dev; linux-kselftest@vger.kernel.org; > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org; = Lu > Baolu > Subject: [PATCH v2 4/6] iommufd: Deliver fault messages to user space >=20 [...] Hi, > +static ssize_t hwpt_fault_fops_write(struct file *filep, > + const char __user *buf, > + size_t count, loff_t *ppos) > +{ > + size_t response_size =3D sizeof(struct iommu_hwpt_page_response); > + struct hw_pgtable_fault *fault =3D filep->private_data; > + struct iommu_hwpt_page_response response; > + struct iommufd_hw_pagetable *hwpt; > + struct iopf_group *iter, *group; > + struct iommufd_device *idev; > + size_t done =3D 0; > + int rc =3D 0; > + > + if (*ppos || count % response_size) > + return -ESPIPE; > + > + mutex_lock(&fault->mutex); > + while (!list_empty(&fault->response) && count > done) { > + rc =3D copy_from_user(&response, buf + done, response_size); > + if (rc) > + break; > + > + /* Get the device that this response targets at. */ > + idev =3D container_of(iommufd_get_object(fault->ictx, > + response.dev_id, > + IOMMUFD_OBJ_DEVICE), > + struct iommufd_device, obj); > + if (IS_ERR(idev)) { > + rc =3D PTR_ERR(idev); > + break; > + } > + > + /* > + * Get the hw page table that this response was generated for. > + * It must match the one stored in the fault data. > + */ > + hwpt =3D container_of(iommufd_get_object(fault->ictx, > + response.hwpt_id, > + > IOMMUFD_OBJ_HW_PAGETABLE), > + struct iommufd_hw_pagetable, obj); > + if (IS_ERR(hwpt)) { > + iommufd_put_object(&idev->obj); > + rc =3D PTR_ERR(hwpt); > + break; > + } > + > + if (hwpt !=3D fault->hwpt) { > + rc =3D -EINVAL; > + goto put_obj; > + } > + > + group =3D NULL; > + list_for_each_entry(iter, &fault->response, node) { > + if (response.grpid !=3D iter->last_fault.fault.prm.grpid) > + continue; > + > + if (idev->dev !=3D iter->dev) > + continue; > + > + if ((iter->last_fault.fault.prm.flags & > + IOMMU_FAULT_PAGE_REQUEST_PASID_VALID) && > + response.pasid !=3D iter->last_fault.fault.prm.pasid) > + continue; I am trying to get vSVA working with this series and got hit by the above c= heck. On ARM platforms, page responses to stall events(CMD_RESUME) do not have an associated pasid. I think, either we need to check here using IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID or remove the check=20 as it will be eventually done in iommu_page_response().=20 Thanks, Shameer