From patchwork Fri Nov 3 17:16:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cindy Lu X-Patchwork-Id: 16227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1195638vqu; Fri, 3 Nov 2023 10:17:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtpCSc+lplUGV67Dcd2cbOXUzQ1shUop5DY7TloaGKc197eJDglp0cvU1CTlpTO8OYpqYb X-Received: by 2002:a05:6a21:338b:b0:159:e0b9:bd02 with SMTP id yy11-20020a056a21338b00b00159e0b9bd02mr22764733pzb.40.1699031871341; Fri, 03 Nov 2023 10:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699031871; cv=none; d=google.com; s=arc-20160816; b=P+VHd3Hb9war1K0LiypXpsH+7Si4phHdbB7VCAWgUc9l62SrioXVIrQCgW6Dp9I6fV or6eu6EzajwiSU2o4Tg81hf4AXCnY3bs+CL7CJ78H8nELOqCiEMzt92qhKnu7VOUkruz S5WhbRUv6dVRJz/YTBT28SbDx3mMZoYPBl91QE7UzV+wQyMw+dQ8XfPBlaBJ3nH5uEGt 98BpwlTTX1OOIuPAbHa8+o6jGrBfhQDQnm6CJw7CzN9OKHVRwki4SG6KDsc+S9ldMAIM atltwqGMc/OXiVy/5MJcF0w5N7nKAzf2TEaPK5sA5SARJcP3OxELYSaIKf2fjKNjOk2Z 9PTQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=vRd7f5G8x90QkHchEr3Lu9idWoM8f/Qc/4n6P4JgvYc=; fh=xiBZnYthZkU72K3VlivZH8ewgfrUkWRaBxXhAGtxMAw=; b=zkrzGj5et7ZYuTC4XNONFAThgtj4LUhYuvD+AM8sqkRPztsxFLckabRXas1qmX15eq gofZr2eEkNy6kWAiT+J4zrGCNxnJSgJpJMlS2xMpABTbbxeAuC82dl8zoRJmEDw78Vbb GDuraQJ7VAAksnw8vUnpAvnWGYa95QMhvlDcBgcGs5uTyjJyIuiOML15CbK3p986tNad V7unjgB+kiJjcxZI0silm+Wikm7pHEAtyZpWSGyCwPPLi7qaH2AHZoC7US6psl2OhGH4 guY4pazMn9SThj3gB7W8ewZJAGjU3BN2V6UmKDZ8NUxSlPGXADaiijK9XH1GKPzaBIQ2 KM2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PgStz4e3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g8-20020a656cc8000000b00578c9144913si1895956pgw.364.2023.11.03.10.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 10:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PgStz4e3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8F2308061B61; Fri, 3 Nov 2023 10:17:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234412AbjKCRRp (ORCPT + 35 others); Fri, 3 Nov 2023 13:17:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234393AbjKCRRo (ORCPT ); Fri, 3 Nov 2023 13:17:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF4BD44 for ; Fri, 3 Nov 2023 10:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699031813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vRd7f5G8x90QkHchEr3Lu9idWoM8f/Qc/4n6P4JgvYc=; b=PgStz4e3nzBQ84CFyCeZfcpqsBsMB8phpd92nw6Sm2pR0dzoRTsoK5f7/tIA5y8j4fsfue cXbr1wAqDp+efWaMC5O9blJ0qV4RLQX91Io9r2f2nRKIfJop4a9H1o1uQjGoiFPMOyBUy/ jouEAGad2Yt0mvkebne5LoxZXt1Uhnk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-Ae_BpGh3OHuKUFySfTAznw-1; Fri, 03 Nov 2023 13:16:49 -0400 X-MC-Unique: Ae_BpGh3OHuKUFySfTAznw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CD90848A77; Fri, 3 Nov 2023 17:16:48 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CAA440C6EBC; Fri, 3 Nov 2023 17:16:44 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, yi.l.liu@intel.com, jgg@nvidia.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [RFC v1 0/8] vhost-vdpa: add support for iommufd Date: Sat, 4 Nov 2023 01:16:33 +0800 Message-Id: <20231103171641.1703146-1-lulu@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 10:17:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781564043648158744 X-GMAIL-MSGID: 1781564043648158744 Hi All This code provides the iommufd support for vdpa device This code fixes the bugs from the last version and also add the asid support. rebase on kernel v6,6-rc3 Test passed in the physical device (vp_vdpa), but there are still some problems in the emulated device (vdpa_sim_net), I will continue working on it The kernel code is https://gitlab.com/lulu6/vhost/-/tree/iommufdRFC_v1 Signed-off-by: Cindy Lu Cindy Lu (8): vhost/iommufd: Add the functions support iommufd Kconfig: Add the new file vhost/iommufd vhost: Add 3 new uapi to support iommufd vdpa: Add new vdpa_config_ops to support iommufd vdpa_sim :Add support for iommufd vdpa: change the map/unmap process to support iommufd vp_vdpa::Add support for iommufd iommu: expose the function iommu_device_use_default_domain drivers/iommu/iommu.c | 2 + drivers/vdpa/vdpa_sim/vdpa_sim.c | 8 ++ drivers/vdpa/virtio_pci/vp_vdpa.c | 4 + drivers/vhost/Kconfig | 1 + drivers/vhost/Makefile | 1 + drivers/vhost/iommufd.c | 178 +++++++++++++++++++++++++ drivers/vhost/vdpa.c | 210 +++++++++++++++++++++++++++++- drivers/vhost/vhost.h | 21 +++ include/linux/vdpa.h | 38 +++++- include/uapi/linux/vhost.h | 66 ++++++++++ 10 files changed, 525 insertions(+), 4 deletions(-) create mode 100644 drivers/vhost/iommufd.c