From patchwork Thu May 2 15:29:16 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: 13651820 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 105CCC4345F for ; Thu, 2 May 2024 15:33:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2YNH-0003dw-84; Thu, 02 May 2024 11:29:31 -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 1s2YNF-0003dP-Ei for qemu-devel@nongnu.org; Thu, 02 May 2024 11:29:29 -0400 Received: from smarthost4.eviden.com ([80.78.11.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2YN9-0005ys-4k for qemu-devel@nongnu.org; Thu, 02 May 2024 11:29:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1714663763; x=1746199763; h=from:to:cc:subject:date:message-id:content-id: content-transfer-encoding:mime-version; bh=RgSs0a8yt86J4qaEVtdH+Iuq8b1J6iLIfJH0jS2pGK0=; b=jGy+2nyffqchYqdQi1fi7VnxgI+zutgEYLZGbfdW1awj+DpE7KUJnpuI 5xLhVEzvDfNitNYoGhM1S+WzR/oElTXL8xyDmuBkhSLu9oqGAoxw0Ojl8 jBsITKSYFz+Esc8m2PZpUehmBo85U9HaujxWZM+Jb+XfLh6pJhGoY+61v XIFWnrmHLddCUr/apiLP9T8rCXYb3APZx6Dkxc+P8Yshfxx96Vnm0Xhjn iFv1WYUXLwjrM1iQmcN+F6qUujLIe2mFT55ViIa1Qz5zOqXQ6sl1/fx8p +WPM5UPVftiq90LRq8GraKcNFfbCuoV8OOmqkBDPh7Iz9/JU9FTa8Git8 w==; X-IronPort-AV: E=Sophos;i="6.07,247,1708383600"; d="scan'208";a="11785871" X-MGA-submission: MDGNgAkNfoImEhJWV0YcM5kL4fjKRY89EMqt+KRZ2ginw6uDIpQNG4H7ZwYo5e3UtfeRaJSnGRkDW4E3RgorHiIOYnqx0D4gL8hR0Qpxz2mvt8+MbhprJ7HB+aisBM1KAsGGhn3/5OHazfInV0qvU8UGcYV6M9+X1+TmDX/gJx7SZw== Received: from mail-db8eur05lp2104.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.104]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 17:29:17 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JznXEJdlKs4tlirAAXs7rrDzbYFmEWXaii/xIkEKWl3ohDsi5TG1JZA6MElJnafsGadEvXF4dkOgHTDenyZX4j6D9QPVzeFarKuQTBPwZYiu5XOt7u5yZkecqoB91pTR5ij3m4e57A6hByAQw+jQl3QNwGw9AuPhKgaWgJoFpszOTWxL/ipxchaiZ1VxEkUyYjzEqr8D43828AdKxxo6/FNFvTltoqVvUat0pRhCZC8NlSvnXr7aO6B4OZpGyM3u78r/JxrY2jyChFXQJMP8EibxaDm9dCHmPnAHGB1CuiYurfej5F0h8ifOOc3fAEHyC5aeJWJPkpxq1AIluYPkIw== 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=RgSs0a8yt86J4qaEVtdH+Iuq8b1J6iLIfJH0jS2pGK0=; b=M+Jna+E0KXnsQ0+W+o3HRxVnVodQ+yXfB2dx+FltsnQFW27POkEDG3CzIRythOPo/6LY0iFiSdmC45HhGr2aURqOUXdR160Y20CB0ZVCx13jNNLBY5eaMjMXUFwfIhLBYQRe8CY1LBQW+yTSxBjLVgKhIT9RvcQWJJVOlKkOChUodZ0FnxvFJ5j44KQWNTs/aEx4StVR0Bh9ToIo3Z/0YPxgKltPjpsqc0QA0L8OIO1uyf+a6dzY0iqPeNmNqiYMGT84zVjMUxtg7cQKaib9M68BwDDqE/BlIB5jrbePYPK+ilklXaZogpaU0vrD+TA4Sj5U4WlHIlT9LsSmepDbpw== 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 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by PAWPR07MB9661.eurprd07.prod.outlook.com (2603:10a6:102:389::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Thu, 2 May 2024 15:29:16 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%4]) with mapi id 15.20.7519.035; Thu, 2 May 2024 15:29:16 +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" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd v1 00/24] ATS support for VT-d Thread-Topic: [PATCH ats_vtd v1 00/24] ATS support for VT-d Thread-Index: AQHanKV+t5i5swb4vUarY95NSLhSPg== Date: Thu, 2 May 2024 15:29:16 +0000 Message-ID: <20240502152810.187492-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_|PAWPR07MB9661:EE_ x-ms-office365-filtering-correlation-id: a52ae5e6-091b-471a-de7c-08dc6abca0fa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|366007|1800799015|376005|38070700009; x-microsoft-antispam-message-info: =?utf-8?q?odW2m2v5X1Q4xMNnK7cZnSGq5aeB61d?= =?utf-8?q?VcN3W4LRiZdqCNVUu+ZRvqzZhDo/tv7RNxcHR5t9zyDc2kHlISR1B2sfWu3OeFEui?= =?utf-8?q?FeWoYdhEC4ob4UBSTqYE6eenUKYoijp8prcYLI4wBAWtuUEuP/AjU4izafBB+pXSe?= =?utf-8?q?iU8cPxe3VlFS3Lfq5/Dwd2UNc4ao1FeZO9MMU2ZMuhviRsNMzVicKrfxD5WeOGbTX?= =?utf-8?q?hZ72lT8gj1qv5g0PRRcQ55Mp2gsOIJoLyRARNWFJER/n6ciCJjye4hnzp4BIJCBlf?= =?utf-8?q?LD+l2F+eDFLN4h+YdKvUVDQQ32Et0/BN6V6BG4vrqldXV4Ip8j4bfsO/nCLqBAYYN?= =?utf-8?q?ftVcjCPo/NZ1bdwT/IxR6aGfY6cfdD5etBXbAyZlbGGVxZREI2ePpc60WJSna/o4o?= =?utf-8?q?reawQ3HLafGnHX8wHlX6M2GBxsGq/YfU8LShhJzEKIdLEnx35x701bhY7Gn5FkvNO?= =?utf-8?q?7HgWtwJ2Kp8h7AqcdbOx8KwcEV7RlGx2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; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?bnWtroguS7IQu8QYp08CKqriapqP?= =?utf-8?q?ycH1sokfcleOaTENtO6bbEFar1Wjx22reUoEFdwcaMKvDlvCK0mBO9V31FPArv93I?= =?utf-8?q?PDlqOfMPY/ZL03ufUGAb4L20ihDLkG7vKNsJ0TFji5oR9AWB54q84QtRVLrrSbjpW?= =?utf-8?q?h75ns3XxClGVdFXDmYd+XfICYjmVmcadjIXZQlL8m0qv8X3PkfcWlp/JgKZmy16t9?= =?utf-8?q?9X+MqmE+USDWduI0HaM9sJH8NX40L0aovT76ZoRJ7vemLgCnW+6uerGPQ6hOtz31Z?= =?utf-8?q?vIv0gsZH5WUfpZ6+7N/85b3o8OgJctQkHoRfXfRjYbPiqZzbdHUrVPohe3Nhikb38?= =?utf-8?q?HeaWOxa9mgBPRbN5dN0eKdKJtZbXxHuGxAi+n26G+jbpvjJ6rNKvNyDVGIdnWacqz?= =?utf-8?q?x6T6Gbql8UhtmhKAf39klq9nx58VpA6cK/3wpcmd4pDWT8opRiiLpDC7Ckrhht7oH?= =?utf-8?q?BqH8lcG5AZFVLMspydgUDu7AzffTUj6/NbNzbD2cP1gwmsov+L3/P8OozEBnAy0fV?= =?utf-8?q?aLCAF3NmnVA+pk5itIfmtflXAJj638LVQE4B4aI6ywxHpznYqP/xRWT40CDMFGJuh?= =?utf-8?q?itTb8cpZvsa+Z3GSmtgLZ8WiXkso1SpgHzQaDeMWRsMAq2fdtzMKUp0s4ZgeodaoR?= =?utf-8?q?+5PDANuOoouvek2gqNA8GeHM7w/EzHOzHYsBxl9q/Xn9CT7VF7WtqSJDmMZXPM/g3?= =?utf-8?q?6lbFeVZ5coYL6MmRS6bMhwf0mVsyDY4/lYG546c707Inb7XNd5Ffe8VNYbQTi3XJb?= =?utf-8?q?pULcdsaf2r3Jy5JPvEgt4p7HQUTSUVjl8gQeg+m8AjoP6TKRE9Mg8iInSUUliu0rY?= =?utf-8?q?aaIaCLqWD2jomL3WCEQeQQzTMIIbGYDrH1vEBiDGCvraYoWmQy7eiTGLdubHXZ8EY?= =?utf-8?q?PSaJYe2gL8pMMjS4O+UlphglryMQE3wLFF5a9xgoMU2n2tXcdMJNWBO8IO2qHY1M8?= =?utf-8?q?dAy5+XF9S4ntTukNMzzWx0PmVIooIgla0RPdWPEHk65r81MFT9escJUi3f65BFP6T?= =?utf-8?q?ZDNgxRX2OPsPs62/MUOWCwbU1bKNtHRZSRLrXx9DkGYKzLesNEza8tnKnQT6zUJGZ?= =?utf-8?q?It0MfRmOFkpCiF9cJNiejVVoN0f50kgVJD1Nr1p5KVsui9Wpm5Ddggvd/ci6aTseG?= =?utf-8?q?6K84LV8fTyE01XEXKVVdrwLxgZWnzailRTFNpqa9J2T4q6Vk3NLcoAA/TnLOhXLdU?= =?utf-8?q?leOHvz10+85ofKRou8nkBiwZ/h/udzjollqwg1NDu4J4AgUiOFLVD43Mbj6+FhL2J?= =?utf-8?q?BwPdHrJwwQmh20dLdvGohT1/N4DiEWUebKFIfxAMbfBxE8iTB2/YnreMTrtxJQzv2?= =?utf-8?q?V3oYV+arLK3pTtOb3WAtJJUBNEDiJPPzd107TcPIIrrYfqLryz+ZO/LLgNc5K4Jhc?= =?utf-8?q?kNLYMYZZRSKNemyYiyKgs92OJ8N05Jt9zt7fL4o0SWKNKft6u/u7w6nJgI+aaacw7?= =?utf-8?q?yoUPEVSK9dWu0iilKvlVTtC8D3Jwvhx9ccgaoFYvUr0GYxdZa2HtzhBM7K3sl6QpV?= =?utf-8?q?gghiOxfJIyM7r19eCZe51mhbxj14Zj8koin9XMFm2uRu7SZ9EQeA27E=3D?= Content-ID: <3D53094CC3557741856A566C76F2A282@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: a52ae5e6-091b-471a-de7c-08dc6abca0fa X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2024 15:29:16.6574 (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: r1RNSZAaTUpHSIwTIEKnGX20AX6lcivNQBfvZ5xJDaqbX1Ny8JGVOTluAqhNqpP8pV42RK7ryhgqk9SRWNk9ocmgCH8BmylmU2BrnZ0LjBDwL7NuNeGXDnTLIBR6siZJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR07MB9661 Received-SPF: pass client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.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, 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 This series belongs to a list of series that add SVM support for VT-d. As a starting point, we use the series called 'intel_iommu: Enable stage-1 translation' (rfc2) by Zhenzhong Duan and Yi Liu. Here we focus on the implementation of ATS support in the IOMMU and on a PCI-level API for ATS to be used by virtual devices. This work is based on the VT-d specification version 4.1 (March 2023). Here is a link to a GitHub repository where you can find the following elements : - Qemu with all the patches for SVM - ATS - PRI - Device IOTLB invalidations - Requests with already translated addresses - A demo device - A simple driver for the demo device - A userspace program (for testing and demonstration purposes) https://github.com/BullSequana/Qemu-in-guest-SVM-demo Clément Mathieu--Drif (24): intel_iommu: fix FRCD construction macro. intel_iommu: make types match intel_iommu: check if the input address is canonical intel_iommu: set accessed and dirty bits during first stage translation intel_iommu: extract device IOTLB invalidation logic intel_iommu: do not consider wait_desc as an invalid descriptor memory: add permissions in IOMMUAccessFlags pcie: add helper to declare PASID capability for a pcie device pcie: helper functions to check if PASID and ATS are enabled intel_iommu: declare supported PASID size intel_iommu: add an internal API to find an address space with PASID intel_iommu: add support for PASID-based device IOTLB invalidation pci: cache the bus mastering status in the device pci: add IOMMU operations to get address spaces and memory regions with PASID pci: add a pci-level initialization function for iommu notifiers intel_iommu: implement the get_address_space_pasid iommu operation intel_iommu: implement the get_memory_region_pasid iommu operation memory: Allow to store the PASID in IOMMUTLBEntry intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry atc: generic ATC that can be used by PCIe devices that support SVM memory: add an API for ATS support pci: add a pci-level API for ATS intel_iommu: set the address mask even when a translation fails intel_iommu: add support for ATS hw/i386/intel_iommu.c | 313 ++++++++++++++++---- hw/i386/intel_iommu_internal.h | 21 +- hw/pci/pci.c | 127 ++++++++- hw/pci/pcie.c | 42 +++ include/exec/memory.h | 60 +++- include/hw/i386/intel_iommu.h | 2 +- include/hw/pci/pci.h | 99 +++++++ include/hw/pci/pci_device.h | 1 + include/hw/pci/pcie.h | 9 +- include/hw/pci/pcie_regs.h | 3 + system/memory.c | 20 ++ tests/unit/meson.build | 1 + tests/unit/test-atc.c | 502 +++++++++++++++++++++++++++++++++ util/atc.c | 211 ++++++++++++++ util/atc.h | 117 ++++++++ util/meson.build | 1 + 16 files changed, 1454 insertions(+), 75 deletions(-) create mode 100644 tests/unit/test-atc.c create mode 100644 util/atc.c create mode 100644 util/atc.h