From patchwork Mon Nov 6 07:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 16276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2487729vqu; Sun, 5 Nov 2023 23:14:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1dZIpYknR4ZN9PKR3RFrEc1UFMsUi3WoCE4tUqHzkC06euh0MVNCRbm7atEf8dL9Aeat0 X-Received: by 2002:a17:902:ecd2:b0:1cc:6dfa:ca55 with SMTP id a18-20020a170902ecd200b001cc6dfaca55mr18072366plh.25.1699254872247; Sun, 05 Nov 2023 23:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699254872; cv=none; d=google.com; s=arc-20160816; b=MDIb3sEoC2zcOc5UXGOjJMiAmW0EaynDaT9TOiiJ5obAOy+LctC5o7i8C9CamiiOrk EtfUAuVqC97Wh9uQ4dm8NtdsuW6XnSXr4LwidLICrDD/59OGI0GIFrv0NpFDl3fcAa8l ojcIiTBuBDIaacMbW06frEHUKMMJcvrJMkzlkXiv6sW4UFEW64UYR1mJ278rs+SJfoAu hg801OhgJkIbLCJ0PjGK/FWSBn/vbfsVGMe+cyeg4fOZOFmo4Oqy03pvvRZF7Uks3NDP vUai/jpBd2phWECefBzAcuaS3iTYUImdSDAkeZZW0HTNWQtH1JF6HXW5SSg32jsLbmSJ hVOw== 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:cc:to:from:dkim-signature; bh=QF7KP9oottkShut6lXi56dMrgj5i6q2hwKzIZiAMkvQ=; fh=Q9/c0/1s/r5nQXfLb7W3lFTON2d/CYIL48MtbxJzpb8=; b=R+mDfcldAmvnK4E5Sw0fiWNIs2fxKSvB6FOhJMuHia4WNCCcdxpSZ0+FZs2Edj2bAL BuMDUJv6NHnOvHte84YQSF9GP4Is1L4WkbVM81yw5+P0otYqqm6tsEPXdGY+h9whKXJp G7G6Xl+aY7TDXGUUdtAE2k7g8S8bFFwjq4+OgpVfXaZmyS1Tx0UkKKKlrXnMDtZCe7lg L/WuBFgvXs0Nw1gjigcbFztQiHTSuM9PFMlb/CSOihBeo9MJEJFWK4D8i+NhO9L7O/Hz l8p8s5fJJvhvJyhX+jL0z9A9p/5ZFtHGPr0rGoe6uriMypPs8H6L99LbonXFuedt4Jzg amhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NQZxqehO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id km6-20020a17090327c600b001ca27dfde3dsi7078397plb.541.2023.11.05.23.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 23:14:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NQZxqehO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id D3F5A804C1B4; Sun, 5 Nov 2023 23:14:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbjKFHOG (ORCPT + 35 others); Mon, 6 Nov 2023 02:14:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjKFHOD (ORCPT ); Mon, 6 Nov 2023 02:14:03 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC7D5CC for ; Sun, 5 Nov 2023 23:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699254839; x=1730790839; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=E6/kgqA9Lo5JBiyk0XaJAk9Nzct4odqOsifYkRlm8ZI=; b=NQZxqehOr5giCw/JVIsO+cd6Gz6KO3yg5FbgSEA2VP51gXj5nU8zDfFq cBFIEbCFUl3KLgnwpi/TmHfwYN9G9NPLiR9D1l5H/erbJE9Vn4N1EhRhV /VyvTosKJvaGSg5VWA2dr8Cs/0Qp4O26dComYRLJfHsSFSQ0hq/0R8jTk wCGTGDu5KR4ECfTcfnnJWGQLWXjQHv1Hh+TwEVxsxKYWRm1w8pqp2Vi1G C1zGNZMg+lJureajyEe0rEKMAkTVz/B3Eq80EpHtxEw7IrjszU5t/ROFw +oepM/bzHkqyVZ03nqIDpE0nAtgoSpLF1uGIBKgwdF5OZ5x8eDkWtQLp7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="10759035" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="10759035" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 23:13:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="1093690826" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="1093690826" Received: from sqa-gate.sh.intel.com (HELO localhost.localdomain) ([10.239.48.212]) by fmsmga005.fm.intel.com with ESMTP; 05 Nov 2023 23:13:55 -0800 From: Tina Zhang To: Jean-Philippe Brucker , Kevin Tian , Lu Baolu , joro@8bytes.org, will@kernel.org, Yi Liu Cc: virtualization@lists.linux-foundation.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 0/5] virtio-iommu: Add VT-d IO page table Date: Mon, 6 Nov 2023 02:12:21 -0500 Message-Id: <20231106071226.9656-1-tina.zhang@intel.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-1.4 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,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 23:14:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781797877238719339 X-GMAIL-MSGID: 1781797877238719339 The proposal about virtio-iommu support page tables is being discussed in the virtio-comment mailing list[1]. This patch-set based on Jean's virtio-iommu/pgtables branch[2] tries to follow the proposal and add the basic VT-d IO page table support to virtio-iommu. On Intel platform with VT-d nested translation enabled, there are two main benefits for enabling virtual IOMMU support VT-d IO page table: 1) Allowing vSVM (aka vSVA) usage. Virtual Shared Virtual Addressing (vSVA) allows the virtual processor and virtual device to use the same virtual addresses. 2) Accelerating DMA buffer map operation for vIOVA usage by removing the context switch on DMA buffer map operation. (Note: this patch-set doesn't include the whole patch-set for enabling vSVM on virtio-iommu, only includes the part for vIOVA case. However, the vSVM enabling patch-set needs to base on this patch-set.) There are three changes in this patch-set: 1) The first patch is a bug fixing patch that tries to resolve an issue about IOTLB invalidation request with incorrect page size. 2) The next 3 patches are about adding generic IO page table support to VT-d driver. 3) The last one introduces the VT-d page format table to virtio-iommu driver. The patch-set is also available at github: https://github.com/TinaZhangZW/linux/tree/vt-d-pgtable The QEMU part is available here: https://github.com/TinaZhangZW/qemu/tree/virtio-iommu/vt-d-pgtable [1]:https://lists.oasis-open.org/archives/virtio-comment/202310/msg00018.html [2]:https://jpbrucker.net/git/linux/log/?h=virtio-iommu/pgtables Tina Zhang (5): iommu/virtio-iommu: Correct the values of granule and nr_pages iommu/vt-d: Add generic IO page table support iommu/io-pgtable: Introduce struct vtd_cfg iommu/vt-d: Adapt alloc_pgtable interface to be used by others iommu/virtio-iommu: Support attaching VT-d IO pgtable drivers/iommu/intel/Kconfig | 1 + drivers/iommu/intel/iommu.c | 157 ++++++++++++++++++++++++++++++ drivers/iommu/intel/iommu.h | 7 ++ drivers/iommu/io-pgtable.c | 3 + drivers/iommu/virtio-iommu.c | 27 ++++- include/linux/io-pgtable.h | 7 ++ include/uapi/linux/virtio_iommu.h | 26 +++++ 7 files changed, 226 insertions(+), 2 deletions(-)