From patchwork Fri Nov 29 07:44:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13888450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BE63D6EBE2 for ; Fri, 29 Nov 2024 07:46:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfj-00081m-Gb; Fri, 29 Nov 2024 02:44:15 -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 1tGvfg-00080X-Ac for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:13 -0500 Received: from smarthost2.eviden.com ([80.78.11.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfe-0002nM-Jw for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866250; x=1764402250; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=xJbU31GgV03COYoYanORSYPh8xOVZXFvCKse670MbwA1T3auf6ea3uR/ b/DcsDYFQ997B/qMzU0Kee3OpN/s6xzhXTXVxZSlC+w3QlIT+PYIo28zG 22itXrJdMjDOqp9BN7gP0oSOj6z3bBlwu0kCxn2HqoMtBhQwGOKxyO+pq 19Lbzfwt/CjcaomAEV1cvmNXp6Y6olNIFnOxg6QHGATXm++/75Ukdn31Z npaT1LbAkVQwFNHkGaJFGI4gSCyZ3i4CbRm2fLJQM0JgaoS++hFHFL59P fm/9oD5dNVctGB9lQrsKDbKGrDhx92vncOIzgz87t+xDBF5qGHC9CCzn5 g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670816" X-MGA-submission: MDGDX/2qiBNAz8q3yiCuhFN6bRlJlS7XeZ2irm1R0QKfiyvycmwWdxaQuwSQFjuYxPzVabHSgQ5fOpSnvBVytxTB7RXEfxWFqkmZ8LmIMP1TX5GO1G1O6fYyoSDvl5M1RZoQ+YhKIl9Gag1eH8rQTneja1oPiUwKsnD1RjerehBTew== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:04 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MWOhvSugvkNgGBn9utqFZ4H+bsHoyiBW85jFA/sShUMFIFBFpDn1+R+bmITsFWPKZDpkoXufclPmDjRrcF9chW91g70mRi4oQvHAywTx37JWoKvxwzzGx+wcCN4M6CEN7hZl63KkgQkaH4wTbdOeGZvbdCSKTCgHw/w2X8jfW3YVemDn8PmLtvBZ6twoRakg29fTI6ucLV3purD7WTVvem3txHkudyfdHTr4E9KJUIvXpL8tWrr9WoX3XdYbncfb/ym5l5YBgmdcLU9nyvNK1M/6+z/wTYWZDyMvDlBhJlaoj8Wqfi9M1udIxKlAGQJJ3QP/dxTFT4qf0aPJXHWyOQ== 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=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=LKwSBt/9/ZqB1oIpxHc+7OG21eUC+FOBmyJ3+kqL85k7CEZNfSMUiXgank3940vwfWeL4aPGR1IOE1As1hbLgHupLSg2l48WukNcwN51PFgOmIX4hGRfgEWvw+ULm65ZnJWe9ol7qwt9H48izg41Qi0Ph4O1pFDatU2/ICyvVWWmQQ3i6W5YXGNui9Ecz3uRZb9hDtVnV1+3RsQtgxxCv4h0qDx+hF422DsYXwwNze9GQ80e/NTOhe9u3kGt/kSoRxw99KaroSY57Eptc5liNbY3OXj0IWB5/fP2hzeU+oNnXPgvN+9ZLB/stt5uvZ0X/v/IEYfRWkJ2ebCrkXYPLg== 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=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=ZN95RiaF9h8jwHjlHQdQvBDWV6lByFg0fS9LCg4XU/NT+zyvPxNeEQs49h0u+LxL5U2Wg3dzBvQ8VoKcSyXDpl8Hxw6dtx3hLG5s6uk0Wmua/kRRwwq+MJm406XSLSshbKxB3zlDfeSTvoMlb1+drpv15qvyaUltW+CISFt/iRNJp3sb6jekglsQNXC00jD3crzBSnmM2UiplU9LF7lfVbfJPHQluy+tE5MalPZeal9J65z4/4dHpwrFiIflNH0xnMoAxlV2E6o+1Q3YtNzAoeghBeVmJsduGHxUUA/e+JOeA3dsDrlIN5VnkXc+S33y5rSh1mBn3JRvYPcc2zz59Q== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:01 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:01 +0000 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 v1 16/19] pci: Add a pci-level API for ATS Thread-Topic: [PATCH v1 16/19] pci: Add a pci-level API for ATS Thread-Index: AQHbQjJ0APXgNcpLuE6g4EiGuYqvbg== Date: Fri, 29 Nov 2024 07:44:01 +0000 Message-ID: <20241129074332.87535-17-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-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_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 341eb73c-8094-41a2-0617-08dd10499751 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|4022899009|366016|376014|7416014|1800799024|38070700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186ix9LFHBx67i/JrmkZebxjQaE2AAKLhn+1FbnCsN4Yh3TX?= =?utf-8?q?jQpJHUWESLAX9IO4mcR1B4sXNv5oShDsU2YZtHLnpeGNqxJXPJ9OXyABiMcS/dZ7m?= =?utf-8?q?CPAz70PdLjfp3G9Go0k2V7AtAqjxMyIutrMviRrzGPgE1afXx+vgQAenlLy/mLlM9?= =?utf-8?q?iK9LRFretw9vcnU8JqbBiUdqqypLHpVr+gBxsh7ATK2zEwnn+XiOZoZfx8a58/zvG?= =?utf-8?q?Nzx6ihGraf6rZZOEAG36fHNzMW3dOK5LmP2Gg8oU+IPiKmtsoha05DGuBKlgvcIzA?= =?utf-8?q?xWn5OFJCC/8gsk11YtrciSl6tIiqCqsyEC4LS8aFx+EqJrvkMiSLviKQgeWYkLq5D?= =?utf-8?q?W+4M/xDbzGnt7AEEX6MpN7udFSpe4v1k+/g+gAT5jftKno6HJSsiCzdvDe0qx82G8?= =?utf-8?q?PYTVyvBT9R8hY1SDAM2EMifp925JCHdpQVR9QTAQoru8ZSWnVSVvbpviBInCsUEBr?= =?utf-8?q?jKtiU7Wvai9rmNx3YDurc/2nCabaqLgoow=3D=3D?= 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)(4022899009)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?HF0Gllb2WPVfwC18DFIW+qfN3ws+?= =?utf-8?q?vvmEcEuW3tto/whQXPe2zsjyGzbE98vHE+2VKel/vep0Og/BRIrATOOqB+WQBtsB7?= =?utf-8?q?r4+wfhBy6rXoquln/O0BPslrr2XW846kulZsSDP8xMW1aVeGkjq/uKiZtovGdwZhQ?= =?utf-8?q?s9jqoxatECcfyZwpbKxx+6b3OYNmX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FkJfPNUJRKyCX70YzQUjSSFojf+lgLJnGPB?= =?utf-8?q?w/tNvojLdOJYM26uKWKWLpiCalhGT4JfRCBaFwkZYMAeN8MRsOZso9HobBWxLZ0ks?= =?utf-8?q?dgIu3+GfzzYw90pihGhOioCdZuPHWvgWfkA9zMH1Bnkr+NpEX4MGswo/WndQ+eQV3?= =?utf-8?q?sPkOp0eyoPGD839fBPG/vNtJGbzb7g1I773D7/kWPs53etxkGSNPJCZOMzkvBBHWA?= =?utf-8?q?OFzx8ngWBbihv9QqSaXPvHD+xA7wxwJWo+mmxGsFdPBfK7S/VLX5+DoMbTy5kVNLQ?= =?utf-8?q?nax+B6PqJFMrs/x+USqERueyVzsRnoepD/RnrHh+OO2f6FYHHwf0OLUQQ6JPjlVeQ?= =?utf-8?q?jI3WTNViLShm0njQ20VMT0AopddF/+iB6POtIyQJ/AyEbR752yhVECvOj1MoFncFV?= =?utf-8?q?TvWKCZJ+y2BS4AMn/J8B8F+UmmWQcNlKg4nll4DaRLMg1D6NcA5SAVmGRGIx3qL5D?= =?utf-8?q?HUu8+xZ7GirswkbkYvY6vgtjQmrjPF37VCXtjzHjbWEUxrbPPZyrKFw=3D?= Content-ID: <632A854F651E234F8932097EAEA280BD@eurprd07.prod.outlook.com> 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: 341eb73c-8094-41a2-0617-08dd10499751 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:01.3279 (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: /kz1UkzW2ysIpqRbr1DGctv/C39obcgdUasmVqkuewAa2uwtfXuP4iwHBKS4Ztlohv9RdrqIKwWB5VX+ynqjt4oiYmdeYf9JIelhxLxQBv/ir+OWMzC+zjhlmw8eZVsC X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 Received-SPF: pass client-ip=80.78.11.83; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost2.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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément 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: Clément 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 435fcb6c78..7245089011 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2844,6 +2844,52 @@ void pci_device_unset_iommu_device(PCIDevice *dev) } } +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 *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + + 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, length, + no_write, result, + result_length, + err_count); +} + +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + 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 = pci_device_iommu_memory_region_pasid(dev, + pasid); + 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 b21448bc2a..f142e17a2e 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -458,6 +458,58 @@ bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, IOMMUNotifier *n, IOMMUNotify fn, void *opaque); +/** + * 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 *result, + 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 *