Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6687035rdb; Tue, 2 Jan 2024 09:47:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQ8Sipkrsqdsanhc7GWoGjYRwSk+RxHxYAPq7H+oruA23r7X+ntrLMP/L+WWXHgeMfHp8Y X-Received: by 2002:a50:d482:0:b0:554:7aa2:624 with SMTP id s2-20020a50d482000000b005547aa20624mr7060561edi.67.1704217620940; Tue, 02 Jan 2024 09:47:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704217620; cv=pass; d=google.com; s=arc-20160816; b=Rdwco3iXqhhbAsuSw6KBL3HCUPR3pl2GgMU8IJrN46NPOTUxKAO6MrSRO8Cis0Fxqn a+5APzbIqAnYEiyoO5xYP00Il+ahowinZwYQz4WWdCWH4/NNlh90GL9QAaZ1mcoWG5TK e3yadhVul372w7XoZLbf9PV3AiDg71Aw893Rh61fwJ3Fm8HNj/WR14NbcY6o5M6mkQgi +YUx+WolDeWe0MeLH2OYIkQoKIwT8/CvJPErhRR7svuT7sKR9Z4Pr5u8CZqxva+2eT/D sh4ZlGNNmsLES+kB7rxqpEzL0sFJYpXcVMd9sCnrmX7DTxsPdcCwBaHZjG0rBB+vYLMb X+Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:content-disposition:references:message-id:subject:cc:to :from:date:dkim-signature; bh=eUKDGRnFIPSJ0LRN9R4WG3OzHsTXLIeocX8kxVP6t0g=; fh=bNRMms8bHg1YK2tHa2FHj9wOejOM2THExSKSfpKJt5k=; b=jnjrxx3ABOTAskLIo4x87w/SjiGILBm6gHFydAatOIX4M0zthhOqSaWc1qbOKMzpeB zE1L0wQZ48n2YL8RfaWql85+LHEiCMhHOdupO8RsE/hsuq9Kd9S9S7ja2PWeFAJ82FWb sNn/aC3y2vGp/iPaBvK1fq+D7HHW9hZXzYPAeMYTK1fjBRcpgrklOqcYtinNxUcmQsaT Y+Sf3HHo0VJFVOY/Ef4T+xMf+XZi0RbVWd9ns1xG3NZK1HLiZneySHO6uT2AFu2MedEb 37g73U9Uij18EeThCLalBu+Y9/xbMgLnJhwHynrxgs/gcZov+7KCBwTFE7ElQGnp4opM Ssmg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="BtT/bkPn"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-14673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m10-20020a056402510a00b0054cd3ad8197si11246238edd.306.2024.01.02.09.47.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 09:47:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="BtT/bkPn"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-14673-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14673-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7BF911F2311A for ; Tue, 2 Jan 2024 17:47:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78B99156D9; Tue, 2 Jan 2024 17:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="BtT/bkPn" X-Original-To: linux-kernel@vger.kernel.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2040.outbound.protection.outlook.com [40.107.96.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 276E5154B2; Tue, 2 Jan 2024 17:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GbwIJA4jjOXJjxgFPWM1YpJKQljBXNaRoSR+jNy4dFxeye3SG1BObyknjg+639wc7RzRD4IC5/DsZFoTf1LKo9xWCwgBYgutzc5hqd0N/a1iawSOuv2P7Ls+20xMDL8QtjPbVlWrEcSqsmGfzgji/DzOERyojcMza29ZTJm2hH04Ii6eo4XgR+qLOrIQgcoYFuXWWVxszUIpB4zkef9Xo+X4tfGqsPLG6wNyVgI5kJtRND84mv2OwQW6YOtf4PJhN6fUuuoo7qRLHkKHlTbjV6JI0O6bDs2D56tqoj38t55rEiVhUYx2mCxZKn1SnCQQw7MfjKbYwIJ04wZJ0YJMwA== 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=eUKDGRnFIPSJ0LRN9R4WG3OzHsTXLIeocX8kxVP6t0g=; b=M0p1c7KVRIAOyTHO0Q63PNMO7V1HHkGjdpTRYZHx85mnekugWkrUnl2d2q+6zVdZMOSqzdNwFtM4lXdOQDZLTe4Tq7ehYcQOnKZfZUlPfDJDtkINIOlbxcPaLdc1LEB1R69zuJDArpjy6gf75rC/HLwpagAyElepzKe7j1OxL8KyAY4Fy+CUfoHdAAxJ9ZEXENjs8RIg9fA43v7gfREzFQ46vl90cWcRK2a72BzyjujjVoJpOFlIaB10ojWSuOKxPvfWc/E6YTFplihAz4kqult4u1UFIEvYvMjYcRAV2eVIDBo25M+zP+wxzaU58w4EkfTs7XqKUDyVmCV94T05cA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=eUKDGRnFIPSJ0LRN9R4WG3OzHsTXLIeocX8kxVP6t0g=; b=BtT/bkPnKyzugicjUg2ecLBfYAxGluOZkMyJik3GTBLMHoEDOAT+qn80lTXh9pRGsZds5AK2CIeZmVoYiFi6hGsSOuDEXaG+Jkqys1izs41JgzJwm4uNLNbWgQ4pCtASsqU37Az6tO/DMjrqGMzEvgt+O1+vIsCJOKxNyW8Lrs4JgASYQ4jfTU52m7jUDo9+Mmies21YLER5NWL52c2ZgViHxfDriryxTxq344M+NgAvUmEQA3V8d0IOVv+SiRqIMJ5Bfl/tbIHy3q0h3jiiitMcyY4OF85sAOk3VrMHZPHZ1N63sgzITncxSEMki6H16i94UfW46gRsyF1KZo2mgQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SJ0PR12MB5405.namprd12.prod.outlook.com (2603:10b6:a03:3af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Tue, 2 Jan 2024 17:46:41 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7135.023; Tue, 2 Jan 2024 17:46:41 +0000 Date: Tue, 2 Jan 2024 13:46:40 -0400 From: Jason Gunthorpe To: "Tian, Kevin" Cc: "Liu, Yi L" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "robin.murphy@arm.com" , "baolu.lu@linux.intel.com" , "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.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" , "Duan, Zhenzhong" , "joao.m.martins@oracle.com" , "Zeng, Xin" , "Zhao, Yan Y" Subject: Re: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation Message-ID: <20240102174640.GA171005@nvidia.com> References: <20231117131816.24359-1-yi.l.liu@intel.com> <20231117131816.24359-2-yi.l.liu@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0338.namprd13.prod.outlook.com (2603:10b6:208:2c6::13) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB5405:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c802ba9-64e4-4ed9-200f-08dc0bbac74f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MABMqP9OROM1UWOalIBn347H0uS0J/lOQC9lJIHoHbSm1KTzNxyibZmsvfrwTfNYPvmQxwGTqpPiYIhB97mBKoM53cZ1MrrdplSN45VBMKFajPjghEfv7Rpr7uJBbNlpYgZOCowb8r+AV3ajS0rNFvJLuUWD3fqxVnZ9dt+ptyuS7LrWaCW+1jkjK4+/X59cj4Vf36rhuPQCpeUWtDT40rT84fUAgTp9WwEONkzdcTvf283XoI+J/9RjkqLgPBqRDLTkZOZucZGJ1Y3MDObEeRVDQTFrvfJ8n5Da6AnOCpXiz+WIguA/z5PzTlTPBJX4BQJiZMyWTHD1feD7SONo7B5hFL9sSQht5tVu+u/6/EO416tIFmmvNaWFf5JE0eP9EZ4rKLZOkB1pv/jlkwLKhRMkqRD0Yb4ikkENdMWK5w5fRSlf9eXWCmXADx8YFNcMn/1qY49OWWE5MA0vIohKOtwAEhN4n2aTlt4R+B8JbRJJ1JkChYu6RH7KVTwbeWo/+nOy2uFcfR34o0xjOsyB2vE9PLerQnUTpj5jIVD6PN8MjxVWFintzQB360Ob/7yZJgOxiVhEki9EWAWhH0aHt941YAiyoD5CNDvzv7+yuFaEq2gbvmY7BU1Ia7DSaGJF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(33656002)(83380400001)(2616005)(1076003)(26005)(6512007)(6506007)(478600001)(6486002)(41300700001)(66556008)(316002)(6916009)(66476007)(86362001)(54906003)(66946007)(8936002)(36756003)(4326008)(8676002)(38100700002)(2906002)(7416002)(5660300002)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?IzjYOORsvPkkzDpdoRD+Kgi8Q9pD1fyEEsSDGT6YBzIzMfvndtiHLHy/heKN?= =?us-ascii?Q?gj7beS8jRUic5AOny8+FbzerLXjoTJHmnxp8kbwLUFqoNXcl626bNCZV1T1v?= =?us-ascii?Q?XBEsnVBSK7E2IEWhQk1wbPub1IKkRL7nVZ/dm9bzyzqUIVP0ihl7uLkmyKdG?= =?us-ascii?Q?1qEbJTPFFC9B7kmFdPPUmXZpa+D/rgjLSakXNlX66mK+DWQ8e8Sosi7yM3qi?= =?us-ascii?Q?pCF47oGHknTgEn0j3kxjYZpA62xxIAyrq7e7TT31wfeYncxQGjK4WOdkU5US?= =?us-ascii?Q?BcvdWlVRn4JewIiPo8aEGwA/JTccckWOjwuoS/7UDi8Z+n6VE1FDjLZ33vNp?= =?us-ascii?Q?JkZKs6hyc+puDqAMQZKDFUBmPzdwxPwbdO6TbViGbaaHVU2ufyQLQenFVY6T?= =?us-ascii?Q?cyonCVU7nzzGIcspjAzTg7Z+0pcx7/dEaBK6Im0U2GFGKCLBjtg5dmgsceYK?= =?us-ascii?Q?n63LBrpB0d864l3wafgcpU52oBo5c9yfPMW1oElrlncnUPOf00XiMlbw0K2o?= =?us-ascii?Q?pp3YpWFwsuAMegMNhZP/4u7y6Ixax6IBfAT77RdvM9p51ZxoDLN9nlqPFbIu?= =?us-ascii?Q?yP3CbslvLhsn1eU3h8ANkHHDis0WtCWFMseADnaSRWuwbDI84xZ8BAMw8xuY?= =?us-ascii?Q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s5Enns3Ss6P?= =?us-ascii?Q?6hgsNlepFQ1lz05fPeE=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c802ba9-64e4-4ed9-200f-08dc0bbac74f X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2024 17:46:41.7249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: htsGWAgAth3edLmxdFo3T680mJ/nP+lfCBoa0juL/3I3f2iitjSfdjuVg9vOpz6m X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5405 On Fri, Dec 15, 2023 at 01:50:07AM +0000, Tian, Kevin wrote: > > - Reuse Nicolin's vRID->pRID mapping. If thevRID->pRID mapping is > > maintained, then intel iommu can report a vRID back to user. But intel > > iommu driver does not have viommu context, no place to hold the vRID- > > >pRID > > mapping. TBH. It may require other reasons to introduce it other than the > > error reporting need. Anyhow, this requires more thinking and also has > > dependency even if it is doable in intel side. > > this sounds like a cleaner way to inject knowledge which iommu driver > requires to find out the user tag. but yes it's a bit weird to introduce > viommu awareness in intel iommu driver when there is no such thing > in real hardware. > > and for this error reporting case what we actually require is the > reverse map i.e. pRID->vRID. Not sure whether we can leverage the > same RID mapping uAPI as for ARM/AMD but ignore viommu_id > and then store vRID under device_domain_info. a bit tricky on > life cycle management and also incompatible with SIOV... > > let's see whether Jason has a better idea here. I think v10 is OK struct iommu_hwpt_invalidate { __u32 size; __u32 hwpt_id; __aligned_u64 data_uptr; __u32 data_type; __u32 entry_len; __u32 entry_num; __u32 __reserved; }; Sends the invalidation to the HWPT which matches what Intel wanted where the entire HWPT and all its associated devices are invalidated. No seperate per-device invalidation. For error and event reporting they should be returned to userspace with the IOMMU dev_id indicating the originating PCI function. The VMM would have to convert dev_id into vRID according to the vIOMMU instance that the device is hooked up. In iommu land we should never have a "RID" but always some kind of device-specific "device ID" which is the index into the particular HW table, and that ID is naturally scoped to within the IOMMU instance that owns the table - so it is very much not a global ID that can be used alone in any of the uAPI. The uAPI should use the iommufd device ID to refer to specific devices. Jason