From patchwork Tue May 21 13:11:46 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: 13669444 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 6BD49C25B7B for ; Tue, 21 May 2024 13:14:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHy-00088u-BA; Tue, 21 May 2024 09:12:22 -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 1s9PHZ-0007kU-GT for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:58 -0400 Received: from smarthost3.eviden.com ([80.78.11.84]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9PHW-0001ak-Kb for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297114; x=1747833114; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=zje3qgi6Yo6QpMtuPRNjzGkwSFQAkaBm8X4sadei1l4=; b=wiH1yt/bcydUvs+3iuGVwdHGJht3bmR6BNYZXn5QqctJEwwNCCd09RSG 4rweeq5+peKpVzKFQ0EUiX6VDzmw97bpHa8ZfO/525QirK2NS4PkqCCYr gCCYW2H5pe7/eE/5JfP+6K0AOvUeOZ+m12wejC/w+BHlK0h3aYHETagNS 4QnQn6aZizsyC0gbP1TKLkcCmgb1PW/8cJroETrPI/WmGfJJvOp6SnjVH p0CTB1636q+VsXrBhfpi15oTU1BudRAa9cCGn+mAmUdpD4fOHp0KRWeh5 OvO6iHImmFwg87GUyV1maL1hUchTgbwZGdCVuv7oMU4eoVl85ipPFhrNA Q==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13008002" X-MGA-submission: MDFN3VJJOqos4i/DrDa0vLOV3S/kmO2g+FDchilXi3GiuMsCSxJgGnTLb9ywL77YqkfUt1lPipkm08DFbuAgWpgqBUccWOOJrRpONozWf5la8VNtHkzH+KR31FDXQK65ZWPeR8s2oG8cWTjmZ/iL5IgUKGJHwkwMMk2KqmyWxfac8Q== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:48 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WIRB6lewgG2xjCPnfv/ZsxZpu3+rkahZV5MSvIF5w2W9CLs1myzd9XKqhS9xFyT4+aUyT5hiIw5WguQnvoDWv+pOUq83HM40WyWhStG7m7nGgChhYZ24GPj8fcfF9G66Rph4utYeYIEU8Qpop+imDzejdY8y/0wCizRtnUaKTDSXyOpknOGQZ1CH7BljUeVuMvfCqrneZ41vz4DP5iHNcMFE1Al83oN+gaWMGNq8YV2Il3bThDiU3Tl6QZ51oc4TXm3xczOj80C8VowDjJPVM47Vi2hD0e+OUxxk2Hmf4DfGROrBwo9TQNsjrh9n6xKN/pXaB07x1jewLSUtJlUtug== 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=zje3qgi6Yo6QpMtuPRNjzGkwSFQAkaBm8X4sadei1l4=; b=fF6zhbFaWy8z4mOXJsOGkKkuPZr+e6rasUtTa2YsrwUKUA3hRYvbXeXSlwRuD6NZdEQwWSYX4L+iP3xNUOBMqT17QA0DYPTd1rnaRhS17vhuNbHMcYIWx27VGDNzbiMG0avYdULnZqYv0iisLToEVTUcSL5sh2RpWs7TRKxWCetFpPiKBTtYQBLXeI6WRXCccczvlzA/GwNTovCdt4Qv0MMS7tZuk8Tw1RIDLxysbtTBn1Pf+oTaTAUkksU/4yhWQ0Rkx3wJ53bGay4GO6/qI1M85KhuHHMjPqeyvNR2JWi1i/hgLGSlFxkLjXka5/UrP1jMkNfTTh0HpUCIrwgwvg== 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 DB8PR07MB6249.eurprd07.prod.outlook.com (2603:10a6:10:140::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Tue, 21 May 2024 13:11:47 +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.7587.035; Tue, 21 May 2024 13:11:47 +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 13/22] intel_iommu: implement the get_address_space_pasid iommu operation Thread-Topic: [PATCH ats_vtd 13/22] intel_iommu: implement the get_address_space_pasid iommu operation Thread-Index: AQHaq4BvlzjFaZHZg0mSYIg84+qjww== Date: Tue, 21 May 2024 13:11:46 +0000 Message-ID: <20240521130946.117849-14-clement.mathieu--drif@eviden.com> References: <20240521130946.117849-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240521130946.117849-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_|DB8PR07MB6249:EE_ x-ms-office365-filtering-correlation-id: f6245577-7219-43db-1069-08dc7997919e 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?FU7ZmofuzbShTEIKo5ecvg/eES3aJpu?= =?utf-8?q?t3NrPLdF8fSKkOyRuuTuk1hXYW0vss3J6kvjoZ/44eIwNF19btb2ChwpQYk1KheME?= =?utf-8?q?byR2II3nm+q+PlYZgKrg6rFVwU3SRy2FOA8vIJ5dNLlmJzlXd8ngawt4F6L1HuEf4?= =?utf-8?q?pDpezNiT68sPfq3QXGvrsJXN1XSNCOnp8YGlbCy3vroe0COq9ivcdQfn9BonFh/Uq?= =?utf-8?q?Fl6wwsaqRw4zLlRvWrCJ6l1JMGwjcEJ82iLgnHu+nTrIqZff1NvP+mD1aBMUIFSc6?= =?utf-8?q?1KWjW/+5IxecqARh9hG83uvQX4V5fXcsQgftVY2crK1u6wAR47PaWCdoGR/v9JpBI?= =?utf-8?q?VQ8d63LI9Csobo5ONbmryZGT0O77rpg10+dAy2KnvOmWq7NoMfMO96y6L2rtvC7mY?= =?utf-8?q?wwMJxIMsfn9fgHW48wG7W8KHvlItH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Cxvw=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)(366007)(1800799015)(376005)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?pA+dWsgUtBCxoSJS8TTr8fEmlfQb?= =?utf-8?q?wAqVF/GME9of/N+5TuNeZafmxwkq3KWHgTZvvJP1KlkoGVBMo1jHyiHMI0oIhRZG5?= =?utf-8?q?pfdO0a68bpKq/DC1w/IJ1yAwaEK+9FS49Vw2pH+5qDpouTIyxUsZ4EDfHtMw0FYC0?= =?utf-8?q?Owr87fs2lwS3CWtrYVhzj+nBKmGusGMZeRGx2qQcGGBLYX8+ODcxmZ0j9TJUYBNKq?= =?utf-8?q?7H5T9cPbyx5RvieZ1874wyIUSzpy6Li9euhLZiZwHfRieA4/YB5//PeqH5m9PrGRc?= =?utf-8?q?elIWByKK0Ng+ZUbV1ueqrLXrhvsXXev/Opdne0OG+btaJD+TQsZtOU4t/Y2uhyR3r?= =?utf-8?q?WZm6F0KbNPVMdozi6FiB1aNIfaYBX4dhd6k1Zcg7JC387yUHvNL5BrDE+XLvCBjuD?= =?utf-8?q?IP8coobqMg6SFluZ6ZCD1KgPPyXb5wVsgNH+XHUrFdPn6DInGFu2b67wo7YyYnd1P?= =?utf-8?q?HrXMkmLRW2fqmFZ+XjdmF8jpHfbTZ66DOJecV7+QDn8zCNU7/Jz0upuM6NoiyAlAB?= =?utf-8?q?f1EQ+1i6TQIL/LjohAQstI868QUzy0zxOSqxYq2QtCx5EHSjBOGsYz5/6+ejRG3qn?= =?utf-8?q?lQOlfu9jQn5YW3fvmpptoFIN5wJ8VJUDxPIzQJOXKMXDm9f+zM51V42p3amAmRc3l?= =?utf-8?q?6Aep9fC5fnjKh44PGBvyJL6jhqlvXho8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U+HgPUZ5uK6xxqOdPy5O4UqMF8xjYvI=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: f6245577-7219-43db-1069-08dc7997919e X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:46.9229 (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: RQC8hmJ9uahFtBG116D3VJaTh5Oihlrrspz1KryuPKSdz5pIWTtiUeK7JNuedfGM0Xu11ysYnFoqy8efFZ1qYYyvFmPJgm/ROQENnthyIJyErlwakQioQTdpY5wO/lC2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 Received-SPF: pass client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.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 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 7d86a31bea..e83985f2f7 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