From patchwork Fri Nov 29 07:43:56 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: 13888446 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 62250D6EBE5 for ; Fri, 29 Nov 2024 07:45:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfo-00085M-QK; Fri, 29 Nov 2024 02:44:20 -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 1tGvfc-0007zE-9t for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -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 1tGvfX-0002mK-Hn for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866244; x=1764402244; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=UI+wnTHf95zBFzL9yNBfBDGCIwnOJDA/ZvcEIJiXTnNGvjKGR1t9MHNL EAuvbaI0h/MnCXbLzAsgUuy5MDSOFd+EqFG2rAechfMqSiT1r6Z3UdPKF iGtWkYgnQCCe801SR3K0PP9kL2bJpTPsqisTwTeh+5idRV4fODMBAyvLK jLOZ4nxM1i5Vdjy6rPgYhV8Y9XfTSFFlLHygw8jLrMsQKv7mhVcsXy+ON JE/V7I0MFdlQyUNOLR4qvJDYTdSzGsHIbLsNhvBtC8p6/IxMlZPWKGe8v sbmNJ1iYA8P5rR1ZcH1cLoEaqI+1l7a+AlOTR49pv3dAK072a1NhX0QAk w==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664406" X-MGA-submission: MDGtBwjA5Nw44xfKT5Lzr3q5Gjp0txOBOCy2VwJVfBu0PmHA51M3AhPwk6TLf1pXG3OaQen/fdTz+h2GKc+BEJO+rivQ9qldY8ic6i2xq7wMvWGf8dp1McLg/AqJf3prsSzVv78F3vmuYvjuTwx43ygdvoCgwx2rQOBViEBABw/kIA== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:58 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dp8wDQWjJWNVAjcF2hxnVf5aU0EVNpJ24xhZdLM44b9sc23zeoU+ElWIxauo5GmBt+dJU8fmMtLLSeAE3BEmwI5YOka0ZFueJXr4akmMzi2AWYPN3C8v4AyeozHYQOEx4iq247aaV8QSmSM+a+Y+1SMRgNHH5TzFkjGSH4SH1pAU40IhTfkXYEgJRO2rkdO0cnvV3p/AuJt7PS0nAdX9ylww+daN06Ofdfe3DE/z7GGA1MyACKCaPuA9OPQ9kEgBRbnGuvmkR2dVkU4OgSxWnzuUyLfpKPABmGPFIQKHfzML+f0i9PJP5j5lvZvvcprN2p3anzMATOfcebjeEI2DjQ== 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=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=st+zP0ger25GRaE2ie2CtQIjQffkAZoo9zQTdIuJtuE6qT4urcMwETa/oANnGccJB0YyBi4W5cUNsbJodxYdD5pfe3L6TW/uhlfP+DldVw4QWbiwmn9gQdQyqlVhZEX9JuYIG24KCCD+jKtaZ+DD/Si6NO6hUbTokVzqiAG0Lm0fclNb+bAxHzzH+qqpGZ6f8805arVXRHG/2GZlg+p2eHKZHv49bEzM89wAo2BFpbJC5PxUFSc2FKFbC/nDefcPqI2GKOWcZ0hvRq8LnDwtQHXoMP7QqaIEMGVHFtIQaTBF1LWNm8I67Hz3pCO4/qinsM5GevpHwLQHvJ7OxkgapQ== 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=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=MGIF/FuoKTf/BR11JXoQ7gNkqaActgrp2+nuAQ5Un1ZcgYbVgfxdF7wCALfBNv0yo//bQAQtCtbxeYWQS8/oOi0YZezODUwNDRhi1NpfYgAGE800Tga513ATYq1wRw6UPUsRE7Rdu8R2Xth76u9fircGr1SKywDzTe1P8kKjOzeIGDdVF4zzHkBSPXMH5tgdXWU4HIPwQrWCgCt9vulwhE4H+HIOvxCaGzgdam37GKoT8tTuoaSJE43QmBTdZ6PLSN6t2HBiPamHyYHFvaqlSJBw5OD8br1Uzp1z2VFBa8wWEtwWQTnLcT3H2j46s17jNgFTov64hvv/cFfcUWwuXg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) 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:43:56 +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:43:56 +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 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Topic: [PATCH v1 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Index: AQHbQjJx30tXT3ATwUiFDB81CRnjhg== Date: Fri, 29 Nov 2024 07:43:56 +0000 Message-ID: <20241129074332.87535-11-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_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 37c0f1c5-f8d3-4a30-8e3a-08dd1049946b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?qgyyVcYvShSfrO9TH8jBnVYwYihC/P2?= =?utf-8?q?FyESvox2lHWvxMaXj8ss242aQWTv4m9Tcw+a/foZhmbDLNtzlKpuyWNWa6G0Y3zWj?= =?utf-8?q?cJQJCYFW7HPbroffS+aywqb2GGvK5S2ADTXdIT2RxVGTkxsgg+OUYtkaDHTjXJeVC?= =?utf-8?q?URwdo5dOwoxlAmaS6MhzflFdZiaf0wIg4iKkzqanoi5dMdFB8L9vgMbSnVI4woBtW?= =?utf-8?q?VmYcEtT7zO1V9ipJccHg8cRgE33NvE/IXG9kiRii8s2z+BqSpz2nkUmSvkDfide7k?= =?utf-8?q?v5rpf9TjTNhqs5PWPcCigi9NWBB06iKz5ANu9tw8T8L/GWqkb6MsNolNK+ayyxh10?= =?utf-8?q?T3LlfGRst4uMvkCm9klOsGTugd2ffjNBNS49YZKA7p9KiUq2zyhtMs1mmH0Kog9w+?= =?utf-8?q?4hHJMVx8QoJg5M2vnkZyJykjklE5j4OvzjPAxzlV9c/9J9Xt7aWBfxl7UomxHCz0h?= =?utf-8?q?a9Sx2DkHypnMdR/qkPyxjjE/o+JRszKSlNutd6kJ8S7EzZJ1So8PzDdnNLrtUiZ00?= =?utf-8?q?wJFQgfKrz1x5a4GTcR+RGyjyIzbduYCLLxhLZ52IPfcgvR4yPOwQifZfOjw7FIhBl?= =?utf-8?q?sLBUUAm2xVmi/yMgPhVvHgBzD1f0/m0Kpdxe6om0w+jTswyoG63bztRlAKlI4GMK1?= =?utf-8?q?VKD88qgjYB0c/LUHFEJhnSLL8mmcuPGdLr5HDQ/m+50GEFtIGijn9Obb6pbUJf1YL?= =?utf-8?q?rUyxbOzYe4OaGu+zq6l9+X6nHgLPh53fgF6kJZub3RJyNzquT9hHuSZ4cjZrkLlCq?= =?utf-8?q?wOqfKhFOoDNCBUJ/Ys2DycBHULNYPPbTekHnK5AKmkeFxNfcMoYZqqUKpDCRL7V5F?= =?utf-8?q?PKeE+h4YPFamjtTbgrNrp4OieG0HuloNU+2m345hIeTrtJMEBSnYzTywILgyMyWTz?= =?utf-8?q?94YzanvALLfu2dM/jiVwrfUt/30J938h2Jixt0FTAjoS8YhCrW8g/QyxDwNrVNTjQ?= =?utf-8?q?ZfSvStpHqM0lDhn5ZRtf3WR7kspHVhg3v9OC8HWajAWe6eTLqGXUkB0YRskZpPWQO?= =?utf-8?q?f1A1qAaSCntwvWX7/dwOj+Vr9XjXJ7E+C6gSiKv936vDv10pZ0NkkmcxLZY6xyj9C?= =?utf-8?q?tu8zveeGgIh8Kir8nbb9NE0TIOwLnMdU928ets5aau26ahFA94QRbkcViglEy3eob?= =?utf-8?q?rbZ4H5X1NBTNKxP+keC1Wgfv2HHp/VAt5eYx7dXAKCUZlsXKmzpyKbujv6b/RxFW6?= =?utf-8?q?XDxWkX5x59BqTXIYwP3rp5KD2VhTvm4cOqxyvt2s2lHYHncR9u3xHojfwRXQfEW0o?= =?utf-8?q?MjGOSfHolYkfqNqXvpScVMJ9inDPaprSVypsQxlh0JrS93bdygx23bjKC6htu+yii?= =?utf-8?q?jguW6p08Th/l/ihazekbqLwDn8x5ERfJXA=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)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?nLc95tJ6/AniTb5KzKGakdwVIDTm?= =?utf-8?q?ULQi79N7561BOEYuTZHAMJnGJX+wgOyYSdlbFJJCgVKaByesXFl/0YBI3y1jNhRkS?= =?utf-8?q?G4MiY71avDYgE6Q0NhUyBrpGNNij3bfgHyETbWnKMYKWwDr96p4bXcW8EIRYcWfAb?= =?utf-8?q?Hl6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oQMf+bkNTNxsAv1po1Nx6+p6ZNrQIXjldSjlmKYwlSb32b13eotFyhN?= =?utf-8?q?lcmxjSSSJHPNv1iR5QCsCdgja0srJLZ+GTyVoT9F7YFgrG5c5OxsobwmK8ZMayz73?= =?utf-8?q?3IjE/g2KTNfpXX3xRPRmEdwjVSyGmAde8xcb8skKvbBWVo631TsAgMNv5VnwR4iV+?= =?utf-8?q?hH4MsuqP6e7FhIHDLDRWD/MxrMIkvnTrDjNuy89LUgG/dbO5sr1AxDQDWIqRG9O00?= =?utf-8?q?6kS1j+qVvJV7B8t3JyyQ8fR+z4Q3WFDaEkaak+CpDsnWvH+NsZy5yKBPp5GLI6Rjy?= =?utf-8?q?Pg401rV/I57OjjRg/ZBvx9IzWjCzQJO0bEr1vGinneYzuTms4sFSrPVR1ddgTtIWn?= =?utf-8?q?Gmow0rM4wU7DYOj2NO4f2WWv1wFonn9CdMEEcvrtdXtxr0qZb9GVbE0p4ocYaoK6s?= =?utf-8?q?gFGn8WaeHHG6hnfKRsCyBGuKZ+tRjv191r9yMC7MG+ye+4hWiqmZLLh2ffxaRbOaX?= =?utf-8?q?7AOpYWe1hKHGGy2E4yna4WQfSYgPME5HAqDvzLyXrGZ9Udm226dlbyQ=3D?= Content-ID: <66038F5E1B650D4D8F6EEFAFC7DDBCC0@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: 37c0f1c5-f8d3-4a30-8e3a-08dd1049946b X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:56.5081 (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: U73fHSWNQyej6D9CPYyZoKVeMHJLk15JJIVvpNttsHYo7VKVVJ9+72mu+KErnozkbRi3l5Jt6rnr1xtXQI3sfpJKcIB2cN2KPKYejpoPHqMGCw3otE1epbE7Yx+VGe6p X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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_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 Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 17 ++++++++++++++++- include/hw/i386/intel_iommu.h | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a92ef9fe74..7e8676efb0 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4209,7 +4209,7 @@ static const MemoryRegionOps vtd_mem_ir_fault_ops = { }; VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, - int devfn, unsigned int pasid) + int devfn, uint32_t pasid) { /* * We can't simply use sid here since the bus number might not be @@ -4726,8 +4726,23 @@ static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &vtd_as->as; } +static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid) +{ + IntelIOMMUState *s = opaque; + VTDAddressSpace *vtd_as; + + assert(0 <= devfn && devfn < PCI_DEVFN_MAX); + + vtd_as = vtd_find_add_as(s, bus, devfn, pasid); + return &vtd_as->iommu; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, + .get_memory_region_pasid = vtd_get_memory_region_pasid, .set_iommu_device = vtd_dev_set_iommu_device, .unset_iommu_device = vtd_dev_unset_iommu_device, }; diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 1a4a53053f..21f7f8a07b 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -324,6 +324,6 @@ struct IntelIOMMUState { * create a new one if none exists */ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, - int devfn, unsigned int pasid); + int devfn, uint32_t pasid); #endif