From patchwork Tue Oct 24 15:06:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 157547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2009575vqx; Tue, 24 Oct 2023 08:10:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcVgx3QZW3C1iM53ZNMS6Kfxek9PG7dqQudOYaeQZN/1br9aypUOgn3lii/5p1UppswgbN X-Received: by 2002:a05:6a20:160e:b0:16b:f8f0:1c0c with SMTP id l14-20020a056a20160e00b0016bf8f01c0cmr3267594pzj.0.1698160210476; Tue, 24 Oct 2023 08:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160210; cv=none; d=google.com; s=arc-20160816; b=ZtjxbsrQ/6Jk+k3D4XLM+nmy3C1xMiOjdCmydvPiPuWtWm4Ol1aqEiNL49sKv4vf5u ss/S/G74FmZ5yXAN51IihSXVW4UESn7R59qzXa67p/BSpVG0OXWxmAUcqfvjwl+n7B/U 5SoJ4OSLeaRGjzZbP/bsFB1MKZS1hdipg2LKNeCtaqYv8r7qQTf04nshPonVKKSTIkxC joJujM4NQ5lVOIaYfVD+1j1yNCDa+TRZX01iJs3zsz3aAhvdx3xN/LWyKQZzj85kCspN AK0o+Uxk/Er5srXX3RfMA/vL64Zzj7YC2cQ15XXbvfsrEDzQ6TWLAupQJNUo2sXNE99E HRtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qMdjeUMrlo2enxH+Dc9D3PIv9hOPhYkzidR5hZ8iwZQ=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=jRNzkEePRr0lv98l2TLz0hxTNM5knPrwpCQFxCuXcl1NXAuDKngvpbY3TZR9E2pYBm q4DWlwtWq63vjvfpqB8Pc1d9aCclozDisNCiUIyyKX/7gY47BId7XOfwewxx/vOpKKTR ZUdKlyWpIRrKIT/5ua0uvXhkn/bWXdYBdpLCYlKVApgsbGONMgXek1F1I5okNZekz3r5 p5Psg8RJpvkBaTchIXdqUgCaLPybLTGz/OJ8o/+K3OZz/S33/Qgzbkp9Pb/RpUsyeKQv qEC1BosOXtWTDfA/HX6jsmneggIGIZ+oV73aEE38P7EUMVHq48qK7YotmeB2+qz0+ZlT YQPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MGcCk8Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i191-20020a6387c8000000b0056a1ed17deasi8405485pge.675.2023.10.24.08.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:10:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MGcCk8Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2F0E180A791F; Tue, 24 Oct 2023 08:10:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232862AbjJXPJz (ORCPT + 27 others); Tue, 24 Oct 2023 11:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjJXPJd (ORCPT ); Tue, 24 Oct 2023 11:09:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF5F122; Tue, 24 Oct 2023 08:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698160172; x=1729696172; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3/cuCSmPN9+p1ALZO3N9FNZbz6Rb0G3ZJUXiS9lXF40=; b=MGcCk8CgVoZpxfkBjxoJWyHGWxwAvNdC+bU1LzdxD7eIv/qMAPieXP9E LkNGPo2/ScSm7toDMuelTLgXtZax/DAnT3IqwZfrFl3eVh4na0MwaD8XS SoxTubtantL+LAhDyhyL/n1I+WY6Wcde4YpnwEk4xgUyB8uQkL7KAm4ul NhPvstEMlHmYyjQ2Z4dPEQfEsHBPYinqPtREZYt4Ti7wgTyORIJxqVopN 8iiglGaLXZKiIK+S58rSUXOYKXI7TC8Y1AdL2tQgVOiTPDzVAaCkiC+fg hjiECRQH571EbxKTP4yhdlpOxgrIseRntUCsWjE/YMwloVPztqlksvShP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="418202791" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="418202791" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 08:06:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="6486144" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by fmviesa001.fm.intel.com with ESMTP; 24 Oct 2023 08:06:06 -0700 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com Subject: [PATCH v6 01/10] iommu: Add IOMMU_DOMAIN_NESTED Date: Tue, 24 Oct 2023 08:06:00 -0700 Message-Id: <20231024150609.46884-2-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231024150609.46884-1-yi.l.liu@intel.com> References: <20231024150609.46884-1-yi.l.liu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:10:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780650041094984552 X-GMAIL-MSGID: 1780650041094984552 From: Lu Baolu Introduce a new domain type for a user I/O page table, which is nested on top of another user space address represented by a PAGING domain. This new domain can be allocated by the domain_alloc_user op, and attached to a device through the existing iommu_attach_device/group() interfaces. The mappings of a nested domain are managed by user space software, so it is not necessary to have map/unmap callbacks. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- include/linux/iommu.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1d42bdb37cbc..becfc8b725de 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -67,6 +67,9 @@ struct iommu_domain_geometry { #define __IOMMU_DOMAIN_SVA (1U << 4) /* Shared process address space */ +#define __IOMMU_DOMAIN_NESTED (1U << 5) /* User-managed address space nested + on a stage-2 translation */ + #define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ /* * This are the possible domain-types @@ -93,6 +96,7 @@ struct iommu_domain_geometry { __IOMMU_DOMAIN_DMA_API | \ __IOMMU_DOMAIN_DMA_FQ) #define IOMMU_DOMAIN_SVA (__IOMMU_DOMAIN_SVA) +#define IOMMU_DOMAIN_NESTED (__IOMMU_DOMAIN_NESTED) struct iommu_domain { unsigned type;