Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1817782rwd; Mon, 15 May 2023 03:34:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JJau82KPvGJPlgNsPPIhnYD/e9RFXpaiX2QOvLpcXZ+ZnY5B7AcUCG10nPvnDMreqiyJV X-Received: by 2002:a05:6a20:6a2b:b0:105:6d0e:c037 with SMTP id p43-20020a056a206a2b00b001056d0ec037mr5842316pzk.38.1684146871254; Mon, 15 May 2023 03:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684146871; cv=none; d=google.com; s=arc-20160816; b=iO+UMRX2rhajf3iqOK2FTkJzpjktXWag80GtLtPduct7neyBBYFVBU9G5hXtJQmMsg cHw32pGiGURRGGKYWsPVTZuJnEbCuwBfiR/FS6W2OLEXdshVomAvsg3dSNHY4co+xB2k WsQDFST9Kg/1TEMsClOqjWZMoDh1+91y8iGWuI81NEs6PZtquFv7/wQovjMWmM1xs4Z9 teGgORzK+OQxpc5euWBdRvWhAlVM1NpT+QWCA5b8J1w7dlpO3imVkvv/dejs8VpQ6w7l LFQSJPYe1xypOjxTVkCbHRnqQIQJS8N22kNhMg5PQirq6miX7MtRywvL7IwEtTM70UOB cSfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SmOMWPo18vGFDtTuraejpVVU9tOcfMjTbcnb/sRrPI8=; b=HA23ZpeEIWOm4qJsgGzW4j8blRHa+WEkdQ4PijEgRXKEn3bW7Oala7x8fQWMGE2Qc4 y2ZTOOYU1tjlwlSRDLVIXZFUAfQUd7riTheZM5k1tBR5M8D1dqBmvUbsd8brwI6Pr0u2 /FRmsBU3QkpK5JMHJvcTKChlcGiU8qw6pkBTce3yARRWPEaaGdmOkbdPNhBdwo43RdtX BpBsd56ajv0WFtcVhCIsgAxAkaTumtTnXVibb+Nd8e+EmxgzoI/HzzLuesHklLA2gfAu bu5joOeKOx/KkzV/nf1E4N9AmplqNXjYDG3XGKrI69ew+C45YwenBDKA4V411r/TWgQX mc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IZeLFC15; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a63b141000000b00502f4fd0c16si16170777pgp.653.2023.05.15.03.34.16; Mon, 15 May 2023 03:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IZeLFC15; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240860AbjEOKBL (ORCPT + 99 others); Mon, 15 May 2023 06:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240519AbjEOKAj (ORCPT ); Mon, 15 May 2023 06:00:39 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D39198C for ; Mon, 15 May 2023 03:00:38 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-61b6101a166so58910656d6.0 for ; Mon, 15 May 2023 03:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684144837; x=1686736837; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SmOMWPo18vGFDtTuraejpVVU9tOcfMjTbcnb/sRrPI8=; b=IZeLFC15oPqxEGdYJHzx4HmxTfBqxd8j+LKyVXLZn5EORmXMF23ESuLRHbhr53Pdgc +749Y8OWBrXIGmxIYIdQgxJxv50F1QtQojUg/2sJpaV6pKUCsTiKiN2Os6OYE73LPR0a 4Qa5M1pOmLKLjwdk9g2KY63Y3/aGdi0nCFVuH9UFxK8lrpD8WPDTYx+9Bmjr55Pi7n/n XWGnV71Vdx/pzv9mHgTPDCnu69IFDvoX5H7Ks0140HsLmaVv7hojjwBSkvKsbDjmUbFL QY/62CMl1SNf4v3I+/E++w4hJ3YHu2OtpMcEg1V4MIAcyyhEuyMrG1hyq7JPUvO1Dci/ nd/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684144837; x=1686736837; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SmOMWPo18vGFDtTuraejpVVU9tOcfMjTbcnb/sRrPI8=; b=Wu2uBuFXEOeuIXo7yrFvWIJT7nKcbnPFIhi6ESFdeYlUaIFh+PttAho/MsrhbNP+4G JFHvcyxj6Ee0A7MkpCMU1OZsNyTkat3HAs8urgmDj2Ch0Q/b1LfKTKJyZbU1R4lmOFe1 S5EJWiL4mJr+chDHrej7NBndZ+ux1icl9YLfu8Ch4Js1wmKRgvrNF9Spav9qkhA4VoI8 RihmSv+eJEMkC7zH82DkOkwObosnt60dQa2/8SisBvqAXgmC3cGLu/dwMVGgBbB/zf3F rVRF1qACkTpw2/r2Trhk0tYP1hiPg47cpmdZzCTjiRM22P0RS5FkoolSi4YT5yf0OcMq 0aog== X-Gm-Message-State: AC+VfDzbWdSj6AvjBZ3k/nUCNz/6+d/JM1gpjvVN3Zvn5FfcNp40jmwi kqEj/au1mqa1aq8iIm731UTK0prm9z4ADjEPW8Sp4w== X-Received: by 2002:ad4:5ecf:0:b0:619:152a:b99b with SMTP id jm15-20020ad45ecf000000b00619152ab99bmr53895082qvb.6.1684144836989; Mon, 15 May 2023 03:00:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zhangfei Gao Date: Mon, 15 May 2023 18:00:26 +0800 Message-ID: Subject: Re: [PATCH v2 00/17] Add Nested Translation Support for SMMUv3 To: Nicolin Chen Cc: jgg@nvidia.com, robin.murphy@arm.com, will@kernel.org, eric.auger@redhat.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, joro@8bytes.org, shameerali.kolothum.thodi@huawei.com, jean-philippe@linaro.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, alex.williamson@redhat.com, yi.l.liu@intel.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Nico On Wed, 10 May 2023 at 11:34, Nicolin Chen wrote: > > [ This series is rebased on top of v6.4-rc1 merging Jason's iommu_hwpt > branch and Yi's vfio cdev v11 branch, then the replace v7 series and > the nesting v2 (candidate) series and Intel VT-d series. Note that > some of them are still getting finalized. So, there can be potential > minor API changes that would not be reflected in this series. Yet, we > can start the review at the SMMU driver specific things. > > @robin, the hw_info patch still requires the errata patch that you > mentioned. Perhaps we can merge that separately or include it in v3. > > Thanks! ] > > Changelog > v2: > * Added arm_smmu_set_dev_data after the set_dev_data series. > * Added Jason's patch "vfio: Remove VFIO_TYPE1_NESTING_IOMMU" > * Replaced the iommu_get_unmanaged_domain() helper with Robin's patch. > * Reworked the code in arm_smmu_cmdq_build_cmd() to make NH_VA to be > a superset of NH_VAA. > * Added inline comments and a bug-report link to the patch unsetting > dst[2] and dst[3] of STE. > * Dropped the to_s2_cfg helper since only one place really needs it. > * Dropped the VMID (override) flag and s2vmid in iommu_hwpt_arm_smmuv3 > structure, because it's expected for user space to use a shared S2 > domain/hwpt for all devices, i.e. the VMID (allocated with the S2 > domain is already unified. If there's some special case that still > needs a VMID unification, we should probably add it incrementally. > * Move the introduction of the "struct arm_smmu_domain *s2" function > parameter to the proper patch. > * Redefined "struct iommu_hwpt_arm_smmuv3" by adding ste_uptr/len and > out_event_uptr/len. Then added an arm_smmu_domain_finalise_nested() > function to read guest Stream Table Entry with a proper sanity. > * Reworked arm_smmu_cache_invalidate_user() by reading the guest CMDQ > directly, to support batching. Also, added return value feedback of > -ETIMEDOUT at CMD_SYNC, and reported CERROR_ILL errors via the CONS > in the user_data structure. > * Updated data/functions following the nesting infrastructure updates. > * Added/fixed multiple comments per v1 review inputs. > v1: > https://lore.kernel.org/all/cover.1678348754.git.nicolinc@nvidia.com/ > > -------------------------------------------------------------------------- > > Hi all, > > This series of patches add nested translation support for ARM SMMUv3. > > Eric Auger made a huge effort previously with the VFIO uAPIs, and sent > his v16 a year ago. Now, the nested translation should follow the new > IOMMUFD uAPIs design. So, most of the key features are ported from the > privous VFIO solution, and then rebuilt on top of the IOMMUFD nesting > infrastructure. > > The essential parts in the driver to support a nested translation are > ->hw_info, ->domain_alloc_user and ->cache_invalidate_user ops. So this > series fundamentally adds these three functions in the SMMUv3 driver, > along with several preparations and cleanups for them. > > One unique requirement for SMMUv3 nested translation support is the MSI > doorbell address translation, which is a 2-stage translation too. And, > to working with the ITS driver, an msi_cookie needs to be setup on the > kernel-managed domain, the stage-2 domain of the nesting setup. And the > same msi_cookie will be fetched, via iommu_dma_get_msi_mapping_domain(), > in the iommu core to allocate and creates IOVA mappings for MSI doorbell > page(s). However, with the nesting design, the device is attached to a > user-managed domain, the stage-1 domain. So both the setup and fetching > of the msi_cookie would not work at the level of stage-2 domain. Thus, > on both sides, the msi_cookie setup and fetching require a redirection > of the domain pointer. It's easy to do so in iommufd core, but needs a > new op in the iommu core and driver. > > You can also find this series on the Github: > https://github.com/nicolinc/iommufd/commits/iommufd_nesting-v2 > > The kernel branch is tested with this QEMU branch: > https://github.com/nicolinc/qemu/commits/wip/iommufd_rfcv4+nesting+smmuv3-v2 > I rebased on these two branches and did some basic tests. The basic functions work after backport iommufd: Add IOMMU_PAGE_RESPONSE iommufd: Add device fault handler support https://github.com/Linaro/linux-kernel-warpdrive/tree/uacce-devel-6.4 https://github.com/Linaro/qemu/tree/iommufd-6.4-nesting-smmuv3-v2 However when debugging hotplug PCI device, it still does not work, Segmentation fault same as 6.2. guest kernel CONFIG_HOTPLUG_PCI_PCIE=y boot guest (this info does not appear in 6.2) qemu-system-aarch64: -device vfio-pci,host=0000:76:00.1,bus=pci.1,addr=0x0,id=acc1,iommufd=iommufd0: Failed to set data -1 qemu-system-aarch64: -device vfio-pci,host=0000:76:00.1,bus=pci.1,addr=0x0,id=acc1,iommufd=iommufd0: failed to set device data $ sudo nc -U /tmp/qmpm_1.socket (qemu) info pci (qemu) device_del acc1 guest: qemu-system-aarch64: IOMMU_IOAS_UNMAP failed: No such file or directory qemu-system-aarch64: vfio_container_dma_unmap(0xaaaae1fc0380, 0x8000000000, 0x10000) = -2 (No such file or directory) qemu-system-aarch64: Failed to unset data -1 Segmentation fault (core dumped). // also happened in 6.2 Thanks