Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1150015imi; Fri, 22 Jul 2022 19:05:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tHhZ/2UqJGv5qJoZ1l1zttZBm0RVgf/pWQSt7jx5wAlU0fyDV9vsYwkb8nCyRkzD12PoCy X-Received: by 2002:a17:902:e74d:b0:16d:1e82:c8e6 with SMTP id p13-20020a170902e74d00b0016d1e82c8e6mr2262552plf.17.1658541915240; Fri, 22 Jul 2022 19:05:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658541915; cv=pass; d=google.com; s=arc-20160816; b=Yco/icj/z8yEL2zsD8ZGwTSRnGurXEhZp5Rlo3tQby1xSl4AklOrlhTOiivECvC41q DU12YvkIcQK6U6Pf54Yqj1cv0BbCQA+6Az65K2Vg5SWTU4gzIC/f87g2peFeiBgpcQPM VPOvmKsMbTzvk+PS2DB9gEn5vTRHKvdBNFQFbo1R4Bw94nH4i1bqbTzNB2fp38Qtconn XRo0yaRQAlahSC381APHZ85eTP8J477lkwGlU+O0bwLeWeGztB+UR6qlbVCWCTGNmqFh rjGi5og//7ZKJZU0sxkWAp4E8hYDOlWylJppfHkI8e2TEW45tbxfF0Iy1pSeUktkzv8F RbmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=+s08fmeYHQwQWbI+c32fc+t+tmkidMlt1+FTUev3rHY=; b=GJ+W17QzOgWQXB6Yg4JBj8Pa4UJ4gZ4uR+VH49fjxnRKbwztdzf5w9nqt4u4fVPlib 7Ap911Zq+F5fOiFjKdcSC7YPljuR0VyfWXS0GNo33xComfurzwmBv2LY//rx20lrCgfu hGuxpM8p9aUdBxEounBt6XlnbHIBSJh/DbwhQ1IzDEncsXps4BJiQX0m96wyAmHVxOvo lWXFGONV4V1MpzVcs3KLPa/rdJXoyL1jt6LCVdL2FuSJW+LqC7GKPrtdx0CM2c7kI2qe D6Mj2acsj7A2HNMzs32qER4cCpl9ZSqkVywBqH/vpypmUzp/K/QEoLPC7jF/JGBIBcBa 36LA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=bDjlerR8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020a056a000c9300b005183825722fsi8833003pfv.132.2022.07.22.19.04.59; Fri, 22 Jul 2022 19:05:15 -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=@Nvidia.com header.s=selector2 header.b=bDjlerR8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235239AbiGWCEQ (ORCPT + 99 others); Fri, 22 Jul 2022 22:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiGWCEO (ORCPT ); Fri, 22 Jul 2022 22:04:14 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782A587369; Fri, 22 Jul 2022 19:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApVh7QEBHlzBCB8EbI1C6Vyt3rjWR2Do2yKUiSrk70znaiGsA0AFYe/liEUgC6567EbOgMevtP0V/4cEP91gygoABZv6hioDeV01+r5Azxebk6H1hTbDQloJwMpJlBkj8+Jt1cBGyTzegdRAAAEvfyBKsGpLmcb6svzlvnNZsl/G+7I6oX/38guhwvh469D7/h8n7pfAhuc+bftoljnPlACX9Ply5bHXC7Xn/FUnXxVioUEpOMZeDC1QsICd0sT7zcM3r/jUZY/truvDk9kMOII/P/oKIJm3kucbkhfM1KZLOqgG+nisqpJnqBnqPrDk724t5hwFyv6kAbJ+C7mwgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+s08fmeYHQwQWbI+c32fc+t+tmkidMlt1+FTUev3rHY=; b=JY6yHixQ7mQJeufXR5l7iRP6DcXnJph9D6aiY3jiCsuQAKSdyd7+3ebc0AITsZmLffWH7/VKdXTaUErmLNNYnewz2tq8noXFLv6hbrRhgFiFMUxdHvBvLMK2rIlbZfQ2lUgE81amOttJHWX5GDjFD6GugxeJdRBdqv/APc3nQ07Z2CU71MlqDoEuDOuKOSPNTM0mGUiM2DpFZL2yAPhSRxNA1yHRrX51jOtlcxZnP8DQPCEE12lLxFhsihMhkVW5wPO8dpjDQ4m4h4NYNqqvLvAFvQ1qNGy5u2dGnZHtkOIOWV/+ALUPmffKeMFxeGnMcZqT2cKUOytdoYR6twWONA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=linux.ibm.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+s08fmeYHQwQWbI+c32fc+t+tmkidMlt1+FTUev3rHY=; b=bDjlerR8eaLv+otwwsac7Sl4IXkbx7A7qat5JtR1RZyBKQcOtKefP2N3+9Z5Rc3Sahhuy4Kxt72pec7cQ3VeYZPdFRWxVgoUtbSp1Nzsg9HS4jAdEDmmAoLysf+rsVXct1CrJ4PFY+9egeJUqAxsGDbGcoMwpplzhrhtlqsIrAyakEvhQZYdozXWBsQo3SiFTJrBGRyW49JCds9jv2LugaymaAF+bGspbzvjbP0EnIpfHNeiV8Gtja9j5M5hpihValklTp9iF0XPd1amIkgwdnoZtrtNg0rTM95Bx3NzZU+yWxqbzEkAxLPFeoBWks4EnXYOQ7cVU4inkWh5kZDcVQ== Received: from DM6PR18CA0009.namprd18.prod.outlook.com (2603:10b6:5:15b::22) by BN7PR12MB2753.namprd12.prod.outlook.com (2603:10b6:408:31::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Sat, 23 Jul 2022 02:04:10 +0000 Received: from DM6NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::c9) by DM6PR18CA0009.outlook.office365.com (2603:10b6:5:15b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23 via Frontend Transport; Sat, 23 Jul 2022 02:04:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT023.mail.protection.outlook.com (10.13.173.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5458.17 via Frontend Transport; Sat, 23 Jul 2022 02:04:10 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Sat, 23 Jul 2022 02:04:09 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 22 Jul 2022 19:04:09 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 22 Jul 2022 19:04:07 -0700 From: Nicolin Chen To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 00/10] cover-letter: Update vfio_pin/unpin_pages API Date: Fri, 22 Jul 2022 19:02:46 -0700 Message-ID: <20220723020256.30081-1-nicolinc@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ecbe653-d99d-401b-af45-08da6c4fa204 X-MS-TrafficTypeDiagnostic: BN7PR12MB2753:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2XQqjoG0WpwzlDo8NO2pK/UQvqINTG1EiQ2hVjGxKdBbQXLsO4RuAEW2R3Gn?= =?us-ascii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JiHYO7D6q1/DelAkTEDsnCV?= =?us-ascii?Q?EAOHo3gFlfyo9WHCIXnqt1ZRNpBsknm3a2MOy5gtKW35XQfxrHW7HA3NYmWd?= =?us-ascii?Q?dyNZ2ZNdM+w6zpQDiD22dWoctg=3D=3D?= X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(39860400002)(346002)(46966006)(36840700001)(40470700004)(70586007)(81166007)(40480700001)(82740400003)(921005)(356005)(36860700001)(47076005)(186003)(336012)(7416002)(426003)(83380400001)(8676002)(4326008)(54906003)(36756003)(110136005)(70206006)(316002)(7696005)(966005)(26005)(2906002)(41300700001)(15650500001)(40460700003)(86362001)(6666004)(82310400005)(1076003)(8936002)(478600001)(5660300002)(2616005)(7406005)(36900700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2022 02:04:10.1528 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ecbe653-d99d-401b-af45-08da6c4fa204 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2753 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE 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 This is a preparatory series for IOMMUFD v2 patches. It prepares for replacing vfio_iommu_type1 implementations of vfio_pin/unpin_pages() with IOMMUFD version. There's a gap between these two versions: the vfio_iommu_type1 version inputs a non-contiguous PFN list and outputs another PFN list for the pinned physical page list, while the IOMMUFD version only supports a contiguous address input by accepting the starting IO virtual address of a set of pages to pin and by outputting to a physical page list. The nature of existing callers mostly aligns with the IOMMUFD version, except s390's vfio_ccw_cp code where some additional change is needed along with this series. Overall, updating to "iova" and "phys_page" does improve the caller side to some extent. Also fix a misuse of physical address and virtual address in the s390's crypto code. And update the input naming at the adjacent vfio_dma_rw(). This is on github: https://github.com/nicolinc/iommufd/commits/vfio_pin_pages-v4 Terrence has tested this series on i915; Eric has tested on s390. Thanks! Changelog v4: * Dropped double-shifting at two gvt_unpin_guest_page calls, fixing a bug that's discovered by Alex * Added Reviewed-by from Anthony Krowiak * Rebased on top of linux-vfio's next v3: https://lore.kernel.org/kvm/20220708224427.1245-1-nicolinc@nvidia.com/ * Added a patch to replace roundup with DIV_ROUND_UP in i915 gvt * Dropped the "driver->ops->unpin_pages" and NULL checks in PATCH-1 * Changed to use WARN_ON and separate into lines in PATCH-1 * Replaced "guest" words with "user" and fix typo in PATCH-5 * Updated commit log of PATCH-1, PATCH-6, and PATCH-10 * Added Reviewed/Acked-by from Christoph, Jason, Kirti, Kevin and Eric * Added Tested-by from Terrence (i915) and Eric (s390) v2: https://lore.kernel.org/kvm/20220706062759.24946-1-nicolinc@nvidia.com/ * Added a patch to make vfio_unpin_pages return void * Added two patches to remove PFN list from two s390 callers * Renamed "phys_page" parameter to "pages" for vfio_pin_pages * Updated commit log of kmap_local_page() patch * Added Harald's "Reviewed-by" to pa_ind patch * Rebased on top of Alex's extern removal path v1: https://lore.kernel.org/kvm/20220616235212.15185-1-nicolinc@nvidia.com/ Nicolin Chen (10): vfio: Make vfio_unpin_pages() return void drm/i915/gvt: Replace roundup with DIV_ROUND_UP vfio/ap: Pass in physical address of ind to ap_aqic() vfio/ccw: Only pass in contiguous pages vfio: Pass in starting IOVA to vfio_pin/unpin_pages API vfio/ap: Change saved_pfn to saved_iova vfio/ccw: Change pa_pfn list to pa_iova list vfio: Rename user_iova of vfio_dma_rw() vfio/ccw: Add kmap_local_page() for memcpy vfio: Replace phys_pfn with pages for vfio_pin_pages() .../driver-api/vfio-mediated-device.rst | 6 +- arch/s390/include/asm/ap.h | 6 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 45 ++-- drivers/s390/cio/vfio_ccw_cp.c | 195 +++++++++++------- drivers/s390/crypto/ap_queue.c | 2 +- drivers/s390/crypto/vfio_ap_ops.c | 54 +++-- drivers/s390/crypto/vfio_ap_private.h | 4 +- drivers/vfio/vfio.c | 54 ++--- drivers/vfio/vfio.h | 8 +- drivers/vfio/vfio_iommu_type1.c | 45 ++-- include/linux/vfio.h | 9 +- 11 files changed, 213 insertions(+), 215 deletions(-) -- 2.17.1