From patchwork Mon Jun 3 05:59:49 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: 13683278 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 583FEC41513 for ; Mon, 3 Jun 2024 06:02:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sE0jf-0006ht-B5; Mon, 03 Jun 2024 01:59:59 -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 1sE0je-0006gD-7i for qemu-devel@nongnu.org; Mon, 03 Jun 2024 01:59:58 -0400 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 1sE0jc-00072k-6W for qemu-devel@nongnu.org; Mon, 03 Jun 2024 01:59:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717394396; x=1748930396; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gWVNYX/MpMFgcCoU385Nd8NDwrCYBKIzBBh30rldG68=; b=HV9Ce0wRqyk/QlNU/z2+IZAtnnrhs8x8v6LeEcpDEKc2uCGG1LXv4Nir +C+imaVyurRjN0NIFApx0yQ1Dzhm7YG/Rx4/N16SUbI3G/6x/1NQTTUTj c/ikKSlQWkz01z428rV29imbF9RfhrCPpoCeJ70Mfu5kWU6iCb5iVfwQt dDX9vE3b/Q4VhBDhANhswH7mgNS37wVMAr/LbmnAzQJh5/05Vd/0dvUi3 8YA9xn4ejg4eJmdDlowzJcy+zlNRaTA1FN59/tm5oqJx1KZB3o1TWWkPZ A59r8qr9sxcDa1QTegNqOxOf/nv9yD+kOcrh9gKi2ZYpi7CUqqztBve8y Q==; X-IronPort-AV: E=Sophos;i="6.08,210,1712613600"; d="scan'208";a="13756561" X-MGA-submission: MDHdZn81XFxEB4PHTkmR8O6trXDhmpg6IAkfid2zXxRW30/C57i3cLr3E0F0xZzpT6A4Qt01dtewCnQtV4VcJM5kVugWudtVLDVepg8fBdPykGLdoyLdf9uYFhJgGITdpiDwhneNrcEyn18OyOZUTRnB6juzvyIv+NReFYlIh6YaNA== Received: from mail-he1eur01lp2050.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.50]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 07:59:53 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a69q8C8ImR+mM2QXFYDzd4WIO4h6gXXteBZnUw0g8Q1X1RJAv9PBPO+XcjfUBuNvvVk5GK2vcDNcW7QJPNyJYfwfbLNynpE4yBcvyTSgtSpoUmtjF3xGesDW3gmLqWuhWI7HRU86fFdImpsdP7LDHJlLTtDKZDX9lEK8NqcBstVSNwdBKvWyNvmNRrnTKTy9zu2RNY1U5Tt26O8XsCD0VWPcm3XGduN2L6m9ApDRBDuWwNe6sDU1X/+yKVUyr6ByikTDjntXPFKZtpAxmR5Ko/PQEhCxvIoFv9SYryEut6l9DUIsK8fcQbMYQ35xhgua4+z9Fd7WR9BwAe0W70I4yA== 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=gWVNYX/MpMFgcCoU385Nd8NDwrCYBKIzBBh30rldG68=; b=aLio07bovCobLuY4ZJYtF6qB0TrtA5SdSCt6cXQyfaqS8nCghttpI5BMTqtL8xXi27X4Vdd6HmqN2/1IAZcC7yKoA16iekVIN7WQCiDJP+49XKRtT19Gn9/OH5Dy3azgsccU67dboSgpLgI+l07Na6eexnjxXdhaRePn5u7G+khEAz7wSaxoMtVUeR0+KiF8oY2yt8KJIkxNf5ZjfQWYmUsCnfQqCcAAsD2FwZXi6W9SrXTHCMR/EleKOvJ2U2lXuV/yHWxlfiuEXljZEOcukzKz/MdDIsDTMQ9lyMVImyLfaGpnz61Jgj3y7nxvNF7j5AyQ/ZqWsl13ceYoLf9TjQ== 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=gWVNYX/MpMFgcCoU385Nd8NDwrCYBKIzBBh30rldG68=; b=jI1sAC1TANdRbgslxjxiQsvV4DQmoFAu1ByAG1SM9iqv6dHPsMhQPqet+D13YW8HZD2Ed8rctbr1BBUtGsL6gqlpm03lJcnzs2sFwIyiBK4xVA9dpyvygQS9/ue/JUsObpl/dN1qf8HWFiya7iHBR8gB8Dq+DjOhk0Vu/AdLDYUnwG5MSh7etkaPQCm3Ahk7NO8pXE4xF3cQoJQmHhT99Dy2Wk61QyEvHlL/q2kINvqz5pbzDR8z2PzbU6Uq0YqgXBOMKcAuFuPvPu/nuWwoanZ564uj1Xuao0qXDBh49AdO6ILoh2yV6coonDrP3ILINeNEJXIl5u+u8OYj9jiNmg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6238.eurprd07.prod.outlook.com (2603:10a6:800:136::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 05:59:49 +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.7633.021; Mon, 3 Jun 2024 05:59:49 +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" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd v5 13/22] intel_iommu: implement the get_address_space_pasid iommu operation Thread-Topic: [PATCH ats_vtd v5 13/22] intel_iommu: implement the get_address_space_pasid iommu operation Thread-Index: AQHatXs+h3ISnltAY0KL22WmbHxAlA== Date: Mon, 3 Jun 2024 05:59:49 +0000 Message-ID: <20240603055917.18735-14-clement.mathieu--drif@eviden.com> References: <20240603055917.18735-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240603055917.18735-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_|VI1PR07MB6238:EE_ x-ms-office365-filtering-correlation-id: 37e77897-2726-47bb-3e8e-08dc839260bb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|366007|1800799015|38070700009; x-microsoft-antispam-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/VNvehqWdlE68xAQds/kqYV4uwgmHjRUA05Zhzq?= =?utf-8?q?yGgo8g4iEXyrjIRoEwtV5kWmGr93ANYhFwCUSLTf5EZpOpxDVv6tUPS0UBwAjk6HK?= =?utf-8?q?tahulArgzSS72jKxOA49AI2fc9UEQ597BSYxtM1nv3MYVWFwgW8Z+D+31G7319XBx?= =?utf-8?q?p5GoNr8kkHYvXyWSxE8DZCxau/1KYana6qwi/5mW9D6ut8vgbmPy9v6CdGfH+clNA?= =?utf-8?q?bGgwyPv+EM0zV8Se3WP5HJHxHV38LtoWLfKeQHZfXDzY5joFl8zyrfS4X/oA0A57Z?= =?utf-8?q?Thgb4swUykkrCo8QGOzcSc9zVc7Z6qCXOhMNszyNMYqegbe7xXiYN59a6mrH3FJBM?= =?utf-8?q?GnydRiXiHaJtbxOMcL/XDwgggFtqvTNCcfijHx4juEXacLzdfuVJVU0/APJukomDO?= =?utf-8?q?7wfamnLbJUGnGQ3GqGoCAfDVCn9PNt372qQ=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:(13230031)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?wxid2d8t98NcuAZsladgF+7KQo6k?= =?utf-8?q?pNSZoJYDhnA0uYV/0gtEQpS2sOVMXqJoXBvcx09pPzHgyuS+VjiBPuEH7VGdET7kT?= =?utf-8?q?wYcUbXIPLho9+7NujdXbsBLwkadjF/lXmROhw3/fv/DNxXZybLWonQvc+iywOYLTW?= =?utf-8?q?otACLG6y0kVyfcyUSqHx3lWDEC3Zl68av7xq3nVeubKrl729mYXDoRTbdItfrdpL2?= =?utf-8?q?tvu6nCXzbUBN3NABt3HhRs7yDDputNKClSABDZmO4ng5VSSOPKQbmwv/xe2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y?= =?utf-8?q?fyIqMrcJ8Le36uXFjll2XYO2PMoz6VlWByBo1y6oXOXIUucz023YWPUdHh+1GDEyu?= =?utf-8?q?3Rph7iPCKLKWriDLBgaASgYDw6v++TcIQE2E2ZTY6j7FOOOrKwghHSb/WnrBTSq6j?= =?utf-8?q?77Tad2Fa+4WeeEtuqDZGsAhLCnHEyeeEoksti5xgeZGZPpfbpQRDifi2tFZwowu+E?= =?utf-8?q?l3vfrLP2ztM4svpXzgbmffiZc6PoevZfD3eg2FEVHWYBpfdlC3nM5zYaHGeI7nsDQ?= =?utf-8?q?HoE9jWnDASc2p1OMV1/h8Yz5nWkOOqwo22zoWXGVBKm41Dihi8ta/gS7KNZ9tgKf9?= =?utf-8?q?uy6toF/8cKR8IhchGoSt59HNOBy2JLdWWAk25v2K393Hb5vZg5ZKl8aCJQEQi6xc4?= =?utf-8?q?xG4FRNyZ7UihMp0hbgzjU3uYy7YuOB5KljihmO0VQejxV6SZBWiFyTA=3D?= Content-ID: 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: 37e77897-2726-47bb-3e8e-08dc839260bb X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jun 2024 05:59:49.0845 (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: OtgX0c1li+6eRkbZNJM7ZyMA6KpI26GmuzcNXNgzj34+otCbJAWnuxotZhglIUIngIykGY9gdwc+5TuTPyEehTqiJufcHMpSng6EW7/3HECisAHoV7ZajL/YVXAGVtNz X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6238 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 | 13 ++++++++++--- include/hw/i386/intel_iommu.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index fb6c7d1e33..6a68df0154 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5414,7 +5414,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 @@ -5958,19 +5958,26 @@ static void vtd_reset(DeviceState *dev) vtd_refresh_pasid_bind(s); } -static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) +static AddressSpace *vtd_host_dma_iommu_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, PCI_NO_PASID); + vtd_as = vtd_find_add_as(s, bus, devfn, pasid); return &vtd_as->as; } +static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) +{ + return vtd_host_dma_iommu_pasid(bus, opaque, devfn, PCI_NO_PASID); +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, + .get_address_space_pasid = vtd_host_dma_iommu_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 0d5b933159..bac40e4d40 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -325,6 +325,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