From nobody Sun Nov 24 21:19:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1720449333; cv=none; d=zohomail.com; s=zohoarc; b=DwP2eX9oYIvClTBodLxjCMwmS4KTLrthLE8RSLNY4FollV79Cpwc231QK17RBVM5x5+u6Uxk0Ng41McrOVPK6Umxwl3Sf8SDV0RnfgPviULWvIR+e8mEkpnZtcF0rsohk5Rl6XWSFsquZXkPy36KqO/KCX616ik/1No2KhErW7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720449333; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=omqdz6LORkl10HF1VrY2ibkkdtQlMHKO6ZlqBDCrQ0I=; b=bucIaUHEg5eaRdC3UgYiI5b1vJ5FbgTLZcSHGxg1rxqZMrlm/vd2cr/RK8nnm8mMJSTfGPl5G45jdIbdaDpP1XZo5D5uyt2POTpVGncFFG8AyfXhMrK80CaumiHGHOSjruH3MoZQ3/GmZ4kU71aK5Fy/FGFWLwKIOmkvk0MasO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720449333323744.7498081314862; Mon, 8 Jul 2024 07:35:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQpSC-0004s6-W6; Mon, 08 Jul 2024 10:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQpRz-00041n-V5 for qemu-devel@nongnu.org; Mon, 08 Jul 2024 10:34:45 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQpRy-0002W3-5M for qemu-devel@nongnu.org; Mon, 08 Jul 2024 10:34:43 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687fTnO000623; Mon, 8 Jul 2024 14:34:40 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wkcas77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 14:34:39 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 468DAx3n007229; Mon, 8 Jul 2024 14:34:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407tu1r6wc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 14:34:39 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 468EXkZD037381; Mon, 8 Jul 2024 14:34:38 GMT Received: from joaomart-mac.nl.oracle.com (dhcp-10-175-56-128.vpn.oracle.com [10.175.56.128]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 407tu1r6ms-6; Mon, 08 Jul 2024 14:34:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=o mqdz6LORkl10HF1VrY2ibkkdtQlMHKO6ZlqBDCrQ0I=; b=dMrf+hnMDFUoNX3Om eDWppRsAPVkZDjU9SpJHIjwKwV9PoaHEPIDqgcg6gJgboypVp3KUz5VXMyIfdfSj gZzRMppkHXvo8qN3r9WUnoDp+2gQFf+6lupbRDwNIXO3zwIadP4j+Jpspovefv5w yPD3XR7pwlz0lMhOXlxHQstjG9YEHntKN8g/HqAZu37+fIqzEzeGky8bBZ9qV5K+ AhtpidFB2ykqNBbjXMzrzl6e9O7XZynXbw9YkZE4IjJRQCYg0Tz97xa9oGBcUPrB uzWpCV2Y5LFlmRSpfVHM0n0Ssjw/sCR0UYN8uIP8Y1BnxwxM0JXbWxCYIXwJkDTO i0hwQ== From: Joao Martins To: qemu-devel@nongnu.org Cc: Yi Liu , Eric Auger , Zhenzhong Duan , Alex Williamson , Cedric Le Goater , Jason Gunthorpe , Avihai Horon , Joao Martins Subject: [PATCH v3 05/10] vfio/iommufd: Probe and request hwpt dirty tracking capability Date: Mon, 8 Jul 2024 15:34:15 +0100 Message-Id: <20240708143420.16953-6-joao.m.martins@oracle.com> In-Reply-To: <20240708143420.16953-1-joao.m.martins@oracle.com> References: <20240708143420.16953-1-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_09,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080109 X-Proofpoint-ORIG-GUID: _HyqfmvQ3PIn2gxoSWlybGAuMma1mNBs X-Proofpoint-GUID: _HyqfmvQ3PIn2gxoSWlybGAuMma1mNBs Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=joao.m.martins@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1720449335340100003 Content-Type: text/plain; charset="utf-8" Probe hardware dirty tracking support by querying device hw capabilities via IOMMUFD_GET_HW_INFO. In preparation to using the dirty tracking UAPI, request dirty tracking in = the HWPT flags when the IOMMU supports dirty tracking. The auto domain logic allows different IOMMU domains to be created when DMA dirty tracking is not desired (and VF can provide it) while others doesn't = have it and want the IOMMU capability. This is not used in this way here given h= ow VFIODevice migration capability checking takes place *after* the device attachment. But such granularity is a nice property that can be implemented later on. Signed-off-by: Joao Martins Suggested-by: C=C3=A9dric Le Goater devid, &type, + NULL, 0, &caps, NULL)) { + return false; + } + + return caps & IOMMU_HW_CAP_DIRTY_TRACKING; +} + static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev, VFIOIOMMUFDContainer *container, Error **errp) @@ -239,6 +253,15 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *v= basedev, } } =20 + /* + * This is quite early and VFIODevice isn't yet fully initialized, + * thus rely on IOMMU hardware capabilities as to whether IOMMU dirty + * tracking is going to be needed. + */ + if (iommufd_device_dirty_tracking(iommufd, vbasedev)) { + flags =3D IOMMU_HWPT_ALLOC_DIRTY_TRACKING; + } + ret =3D iommufd_backend_alloc_hwpt(iommufd, vbasedev->devid, container->ioas_id, flags, @@ -255,6 +278,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vb= asedev, =20 hwpt =3D g_malloc0(sizeof(*hwpt)); hwpt->hwpt_id =3D hwpt_id; + hwpt->hwpt_flags =3D flags; QLIST_INIT(&hwpt->device_list); =20 ret =3D iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt->hwpt_id, errp); @@ -267,6 +291,8 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vb= asedev, vbasedev->hwpt =3D hwpt; QLIST_INSERT_HEAD(&hwpt->device_list, vbasedev, hwpt_next); QLIST_INSERT_HEAD(&container->hwpt_list, hwpt, next); + container->bcontainer.dirty_pages_supported |=3D + (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING); return true; } =20 --=20 2.17.2