From nobody Sun Feb 23 10:58:31 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; 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; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1740125396; cv=pass; d=zohomail.com; s=zohoarc; b=LOF+hZRAb5PfkLreeN4WhIbHXg/qpY9pZNkYkfjGffwIQY5QIizqWLzqzFYV1HD+KehfV7tsXXpyWwaKBmyymhZkyD3J5DMLg7WxT+HmQkOyY9u9NOi0x8XBy8FkBuZk57QORLPt/m1r9q+byBOZuN4+we5+5axAbxYaYPBfcIs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740125396; h=Content-Type: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=QfhltBH6apxt4PKk/fiqX0GKuSvhqsHT/xupMPVyhFk=; b=nGyVdZAS0MNFixKiDqO0ApLlp1KVy0R/aK1EqLpuQUIw9muub6TYE74VKOivfXmR562tpDtL8vtZEkVoZQmPukfhyOgvAkfNUcfaJ+L3ub8FIuc6HcfC2EKfTmslHAa/tikTvgN90ISPUdqhNnqaRwrUI+XVwJx8ej97xD8t3+Y= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; 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; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); 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 1740125395869861.1555663434617; Fri, 21 Feb 2025 00:09:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tlO4f-0004ci-NR; Fri, 21 Feb 2025 03:07:53 -0500 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 1tlO4c-0004az-NY for qemu-devel@nongnu.org; Fri, 21 Feb 2025 03:07:50 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tlO4a-0005lK-Oi for qemu-devel@nongnu.org; Fri, 21 Feb 2025 03:07:50 -0500 Received: from mail-vi1eur05lp2170.outbound.protection.outlook.com (HELO EUR05-VI1-obe.outbound.protection.outlook.com) ([104.47.17.170]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 21 Feb 2025 09:07:45 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DB8PR07MB6459.eurprd07.prod.outlook.com (2603:10a6:10:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8466.16; Fri, 21 Feb 2025 08:07:42 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%7]) with mapi id 15.20.8445.017; Fri, 21 Feb 2025 08:07:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1740125269; x=1771661269; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=thx/EhaMFSpCXXIfgOfxU1JCplMe9WF6IcJG11lYnsQ=; b=gsTtIgggJFjiI/rBm+UEhbttgznTjKf7451CEZfe8124GBwPr0UbAY1C XxrfvswFVEe9+b0szlfoHSfffaX2CD7Rpo6207HXDGGj1LslPxsqkrBFu nBxw3gwqv3Eby/McmdflQZvfIqWuirM/khH8ByQi0h0z6ZJKNvTu/Ijlq wwJlSpzZUfrvpUN9Edeut8zWI6iV28HoRO+iVZCBfGK67p6fp8qF9hJOe 5vAh5x3kADMbSDI8bQWmXn5y1XAT62l2gQyQOxxdSe8JwvKpH70W7izLO MDuQmzk62mtjXH7pPquPbZO8cv12OaLxkfNPzqnUYi4RYGh/oYX5GDveI g==; X-CSE-ConnectionGUID: g2VXE75BSGCFejAUCrrseQ== X-CSE-MsgGUID: UHnVoGz5R0OIdYV30DUUMw== X-IronPort-AV: E=Sophos;i="6.13,304,1732575600"; d="scan'208";a="31394143" X-MGA-submission: =?us-ascii?q?MDHFzkmhD1qEen6Y+FK5uN/UpVldkOd5F7iswr?= =?us-ascii?q?OL0whmDti5rQ+3TXkCeqWS2UFOQwi4SAsp+7O/syKEoX4acCEnbt+V7w?= =?us-ascii?q?sPzI16rT3auAwR08JaCD4aGKkvytX3qIWuavSYukjHzRTlW22bjFj8xH?= =?us-ascii?q?P3sfoKjEQA4Xt3zHHsy8woKg=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OjX6e+A1Sc/8tOOqvl3vrX/vVGXfHhsvmuQU3NptiAWXpu7f4TnGQ0gmO3pXnJordKQKl1zYF6t19WazUGaNU35UNYqtut3JsXJtt+esxlrrhoTBQcFgN0d2ixKob2LY5UnnvQQ0EISsR3lTMHicFjgQql4PvEmfZZyqP2Rc3W0gwBKLm4qQaSLTmOlBDvS81cx3J/NciNUCEJ/6sMuZr/08ufoZcV+NTtCsWE8oe9STCVLzp+UB4v5GULy3xKo0f/+B99xZE6JzS4RKbv7KJ8c3Jp9lwtlAJngsOIQ51qKILDutL2yc5RpJ9aE0CrCK05DxArXvavn2X6DAaVCOtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QfhltBH6apxt4PKk/fiqX0GKuSvhqsHT/xupMPVyhFk=; b=E22Y3dYCl5AlkILbfo85TzWNFR8RzV75AOnZsKHZM7EFy/rrl57QGO3Kn8xwYm2W3gmB3r6h9pHvLUB5Ypj8VXgxN6peHZfakY7iFLDWAf4rPUtR2vKMp/T27sgxHCKeueFbXN1xTTNw11BLYqBE0ODv04PnnmNJy6SNpy7Itq5MApA6bwEtQ8H4hIkZVvaP20dQpWX2DlmvLlvc/LPz2imgN3iH9jvvjWikHQWtBLnYVav/9SgOChTcreqVCx9BmBpfny+x04/NGQRoDibxDrEeC9mBs92wgLBryIaFbcr3FuN1DQ9wAuy05zbe4KN1DgSKp0xYNytb3uNYylgs+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QfhltBH6apxt4PKk/fiqX0GKuSvhqsHT/xupMPVyhFk=; b=P6zMvFqOkrbAWyDOZaGbZS3b1KOe1fLs24SjZUCs38fhzVWa9jN/hMKFBEYboCzKNc6C65mJwCJB9dVOOvt/FvJLcKu26TJbYhdeNrHO+92Er5xr7wf3xV6DL1PgdEY01Jr3nQa0hSCiI+5wmIJtXoeAYqNwelLHktLuKn3vekLdVci0v/Kxen27NBw46lfz0q4zPzmRNjznoGESdKyZXIsdkPcqBUPOA5YGfPShRJZrlnTE9DQaN7UJBov8sEPDFzOuuQYkz+J5mkqdis0nhHGsih257PzlrUaCEArHd03+Vty8FYgEDPi/ErsM3f41AHQepvFUpY+w/XIgr7TdPg== From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v3 16/19] pci: Add a pci-level API for ATS Thread-Topic: [PATCH v3 16/19] pci: Add a pci-level API for ATS Thread-Index: AQHbhDeulsmv/QVTtU2P/5dyiWdZPw== Date: Fri, 21 Feb 2025 08:07:42 +0000 Message-ID: <20250221080331.186285-17-clement.mathieu--drif@eviden.com> References: <20250221080331.186285-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250221080331.186285-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|DB8PR07MB6459:EE_ x-ms-office365-filtering-correlation-id: 3beef041-818f-406c-5925-08dd524ed0ef x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|4022899009|366016|376014|7416014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?wZ2YKdQ+05YWjJaHwUsSALDfBDVfjo9it+nAaFFeQOtfAmVHL8jxUe48Zl?= =?iso-8859-1?Q?gFAFUZNgjog36x001kqIImRImuycLCEhUyCln2kduYumUzoWkM8GrDU5M9?= =?iso-8859-1?Q?jf3piR3ZqnlT8OVzv8nFi2aK57K15QZvKX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?Q?H3sDmk23VqW4FtE87oW9gWkh9dmozj5FM3aExS875ZxI/N4eLoCLKFY6sh?= =?iso-8859-1?Q?zDQ04mOTZBA+oP512agbIO/8CuVAE0KRkH7I7JkhCooBmhFFgbN1SqHtk8?= =?iso-8859-1?Q?165Aqxu2gRzhZEpP1XuiY2n8ENhlqTkAKsTJOCJ0osCdHmjMrKTzUXrul8?= =?iso-8859-1?Q?I26OS3y0r9R22s+AzcA0QP+eMZlbIn+uDYobX5ClZL1n7T4XdQ4NJNR+DA?= =?iso-8859-1?Q?O8LShjt5df6tDtknMdPUpL0l5he00RBaZGScEmDRiOQHz0eZgi/U8ZM5q0?= =?iso-8859-1?Q?0JROtKbQuOo4JRCRil9g6UTiKeiYy2zG7zbKEXvQ5HNQRsNLcUV41IrFBm?= =?iso-8859-1?Q?5ssmZWeIwUKMe/Tur3t6L0ooaceTJC7xZsEXkalZUO5SuiTP910IkGaSwB?= =?iso-8859-1?Q?hiqSLlRY5xRyjM8/n9rQ9RkTqwtx9tzLLIhRdVppTTQtsHwaWU+pmh8uis?= =?iso-8859-1?Q?EB16OdF6RxIwLiDTjbPPwz?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(4022899009)(366016)(376014)(7416014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?7DDyYPBzeIC1A3DBFrS4iKKhMqXGYdR9AKfrp42Jr226miCqOkaoJLnw2X?= =?iso-8859-1?Q?I598I25NF7i1T3Njplhdtqc4pfin9ujQvjymACzxEOKNIzajJNeTrveeXX?= =?iso-8859-1?Q?AmKSmylHNEGoE1SsQUjzTpRb2dUOaJbGlBuqUhra5z4eM9AZMS0mBaAj0a?= =?iso-8859-1?Q?lVh5GMahNhqPNo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HWwTeFGCHnAZyiDvB?= =?iso-8859-1?Q?CTS9G36KymJ/zeTIsoUXBdz199s+gBPLFSOGOKIkYPqabLBAQz16Zemi4M?= =?iso-8859-1?Q?XevefozUqPExT1t/WFUjtUTveI93NvcvMS/AP/BYUX30ErN5RcEG9SUtQw?= =?iso-8859-1?Q?LcfeOtQHas+mtsZpOdpJ/FrHyKSO725pLWEM8stPouhJ3mr8UDnpaaJTEk?= =?iso-8859-1?Q?2VdtSSDyg3yqKoA/YFekganHVjn9Sclx89o0yKZg8yrUMwIbYjZMDRRDGt?= =?iso-8859-1?Q?98CeJLNfMmMKmNpropXqnKIkaEMP29zAOExoA1olcA2slKcrcRtsrB+P2W?= =?iso-8859-1?Q?DmGBYqXmgToI7dXbSZfk2+52JhLXMCRTWVntceooycUk6hfyb8U8IJf0Ug?= =?iso-8859-1?Q?wmg9CVhwcXlgoc6AwwYyh9fGkb5gzHuJeCRudOf22n/xHDizo73OdGZY+M?= =?iso-8859-1?Q?GnU7HWq0QUCxnPMWEfBRM5+gKaXt0BNislUcimjntc29sUlxezfhXiCAJp?= =?iso-8859-1?Q?A6SJDW6E6CfpMWvag0LawlmrAOcel65TxSRe0PECWlvWr40JrDsXc8WRYH?= =?iso-8859-1?Q?MPlPef6wHIwrUupGIQMkCkdrxZuMoKx5TgEdCMe71lOH6UMN6SCrk+VsjS?= =?iso-8859-1?Q?2nZu3LGiWCURXQHSQQk=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: eviden.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3beef041-818f-406c-5925-08dd524ed0ef X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Feb 2025 08:07:42.2146 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7d1c7785-2d8a-437d-b842-1ed5d8fbe00a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GcgMZxudSS5ZBq/r/2RBWKIA8Y/KIR0vNAtyin837ys9cXWnOAu9xopCaYtbeZjCd39BjijrpYEPg9r/crnIiOZ4aaS379FuFNg3i7cZry7+r71vPcaAtl3mhiXIeUUu X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6459 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=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @eviden.com) X-ZM-MESSAGEID: 1740125396784019100 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif Devices implementing ATS can send translation requests using pci_ats_request_translation_pasid. The invalidation events are sent back to the device using the iommu notifier managed with pci_register_iommu_tlb_event_notifier and pci_unregister_iommu_tlb_event_notifier Signed-off-by: Clement Mathieu--Drif --- hw/pci/pci.c | 46 +++++++++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index be29c0375f..0ccd0656b7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2896,6 +2896,52 @@ void pci_device_unset_iommu_device(PCIDevice *dev) } } =20 +ssize_t pci_ats_request_translation_pasid(PCIDevice *dev, uint32_t pasid, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, IOMMUTLBEntry *re= sult, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegion *iommu_mr =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + + assert(result_length); + + if (!iommu_mr || !pcie_ats_enabled(dev)) { + return -EPERM; + } + return memory_region_iommu_ats_request_translation(iommu_mr, priv_req, + exec_req, addr, len= gth, + no_write, result, + result_length, + err_count); +} + +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + if (!iommu_mr) { + return -EPERM; + } + return memory_region_register_iommu_notifier(MEMORY_REGION(iommu_mr), = n, + &error_fatal); +} + +int pci_unregister_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + if (!iommu_mr) { + return -EPERM; + } + memory_region_unregister_iommu_notifier(MEMORY_REGION(iommu_mr), n); + return 0; +} + void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque) { /* diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a11366e08d..592e72aee9 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -461,6 +461,58 @@ bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uin= t32_t pasid, IOMMUNotifier *n, IOMMUNotify fn, void *opaque); =20 +/** + * pci_ats_request_translation_pasid: perform an ATS request + * + * Return the number of translations stored in @result in case of success, + * a negative error code otherwise. + * -ENOMEM is returned when the result buffer is not large enough to store + * all the translations + * + * @dev: the ATS-capable PCI device + * @pasid: the pasid of the address space in which the translation will be= made + * @priv_req: privileged mode bit (PASID TLP) + * @exec_req: execute request bit (PASID TLP) + * @addr: start address of the memory range to be translated + * @length: length of the memory range in bytes + * @no_write: request a read-only access translation (if supported by the = IOMMU) + * @result: buffer in which the TLB entries will be stored + * @result_length: result buffer length + * @err_count: number of untranslated subregions + */ +ssize_t pci_ats_request_translation_pasid(PCIDevice *dev, uint32_t pasid, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, IOMMUTLBEntry *re= sult, + size_t result_length, + uint32_t *err_count); + +/** + * pci_register_iommu_tlb_event_notifier: register a notifier for changes = to + * IOMMU translation entries in a specific address space. + * + * Returns 0 on success, or a negative errno otherwise. + * + * @dev: the device that wants to get notified + * @pasid: the pasid of the address space to track + * @n: the notifier to register + */ +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n); + +/** + * pci_unregister_iommu_tlb_event_notifier: unregister a notifier that has= been + * registerd with pci_register_iommu_tlb_event_notifier + * + * Returns 0 on success, or a negative errno otherwise. + * + * @dev: the device that wants to unsubscribe + * @pasid: the pasid of the address space to be untracked + * @n: the notifier to unregister + */ +int pci_unregister_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n); + /** * pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus * --=20 2.48.1