From patchwork Tue May 21 13:11:38 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: 13669440 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 540C9C25B7A for ; Tue, 21 May 2024 13:13:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI9-0008NJ-2R; Tue, 21 May 2024 09:12:33 -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 1s9PHO-0007dw-MG for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:52 -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 1s9PHL-0001ZU-S3 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297103; x=1747833103; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=s/okrwVgXn8VNFlR+LfdeLdln6EjEFerCZiHAQA2Uvs=; b=rLRexdmAVTChdu2SJ0fjRKMKkDLky0rlyX0e5rBjUMAh5kHt9QmhM93w PNr0o/n3LzCtOTBEw2q3PpeVoDE7wzhdgEwkJC6WuAORpykhY75t6BsaA X4fLh0XWUi2h14KRalViTzHqGi0YybaAyUoLY4Kbr286//o+ItCwzGQc+ P1RgnAB6RfujslA/w+v8jbS+1lsknU9f8iwwzYUgwRqpzj3E0k5lzjgBp sfiXQQVBt6wf4M+1ShjEms39sgT+qSYWVyNlhRlF8v6hEPb+liAnWTbON vxoXXc+cf7x2GXYVy1l0XSTyP3Z67KspsHjTKVGPQh3GpOK0og6AxdCNu A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13007988" X-MGA-submission: MDHbPYWDAmPTWkT+dmbCcja8qy0ptaUnIoKtcsztt8NyzPIpheEox1ugqQYCDV9606heUSDOHkwEEuzn7jPIo5MJrHCl019pFBnQCTGSo6OAXtw03NdTPVMCdqdVlQjXlMGoWrWUmb5WnEaO1gzaCo2fW8azIE790K53uklah9pPXQ== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:40 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W0bycLx6ZlxzL9Q0Fir4ySxtCY9+NXi5WQVeD9Gno1VRVFTEhAMWBTCNJKoCrPzgNV/rqPPyQJNnVbjXpM7ZsehasAMiY01GR6XhjCud7P1o+bWjJP6Cz8jWspUz0NSlcVD9u2Ts31D9/AKZw4OHboRCkQs6CymAgHe/OZJ7SRDEcPTqtJpcz8da/vO+BKVCR5AXr0Etb8su04E3EgHhqzraau8iJ1+I34mS9tQGfm6zibHFgSyqmcvJVCrorc3L7ixwlh5T04TVIl09L+o3P1rJn4FdcvMKpLcJ66N+kAiVFv0pyI+olPl+jWi6oBEALKZ2acnLSm38BkJ/nbkzSg== 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=s/okrwVgXn8VNFlR+LfdeLdln6EjEFerCZiHAQA2Uvs=; b=b+LIZrapoEc4Snk7vAbZlvwo/IzVd5Ob1e9fr+mVQqAOHAn7x8qVPpOc3/8XL6WbkBBkuGEqV8eOF6AmI8oDEguJ34Gsh6WLFyB8HdEc4i774MDlhxil3m1+CNOT3InqSVREzZkwajY+pzYyQh1SJ9io+cQwB50RtCmMWGoofPDw2CHWWZ3cJ3lSNie0ctB/CCDUn1R+T8E//FoMuI31WB/v92uvmd+pfuJQ4jmav+4UY6bE3jSAyqxSbjFlQ4f2WTsMa25reVos4eDUNtjYOb4aI5jvCQHplgB7nxAYkffAOwLImWAsrAuQaAGDcbP/XJBk14xPJkF2anWcjyFdXQ== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:38 +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:38 +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 01/22] intel_iommu: fix FRCD construction macro. Thread-Topic: [PATCH ats_vtd 01/22] intel_iommu: fix FRCD construction macro. Thread-Index: AQHaq4Bpg4eL8UGtfEKvRSZXOcRINQ== Date: Tue, 21 May 2024 13:11:38 +0000 Message-ID: <20240521130946.117849-2-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: bd569a4a-2a99-4fa8-30ad-08dc79978c75 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?ipCamOqwvb9/h7FXgoOZXLRYX29yAxG?= =?utf-8?q?adhCJldQ/auMQpHnYb9Jsud952ukYzWeEVBQubx74YppyfrOOQPGM3M6ls5Re5kTf?= =?utf-8?q?95b6c1v2ADEkjZmVCWg3UcrDp1yhcGCLWbtp+XHazbJ9hKTL1KceToFuMiP5G77/z?= =?utf-8?q?H392L5uGvqHueqneNxEbKNoY+Kyc3zRG3IyLz6F8A1uXVIg+4yDC3FuOGAC8CJ7iy?= =?utf-8?q?0hKngrTmtavKqbD7VXVaQ59C0i/U+r+i5PLTOuvdv3skCDX/FYg924okkSmw9pE7G?= =?utf-8?q?US1JzYfFBx1s+BSW3WC8b2ufma3u3BiRrCdksKp840fq7UvhTTE/WHrlTDBXd6aGJ?= =?utf-8?q?dNVnkDmVPv8kK246GZlDfEwElseq8uMe514i2wOJAqR1qgb2Ei+qXcpBd7vPozP3n?= =?utf-8?q?CeSxE60USK0lkcHcPi+Jkk7hhKDYhUvGxeouFr+wz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efront-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?31KgmoTqgTz14fzya2OdGlAKe4QO?= =?utf-8?q?ahIW8sXsgSahGMoKInajYKmpwGtewHrMsk6NiRpsDUofLD6jPW9D6gHEUqAnNZLmz?= =?utf-8?q?I59xIVMvfaVIoqTyZzyB20JAYI+SpqC5R4VVfekYmS4vODbL+WnfrYOObe/qX9FmN?= =?utf-8?q?wrfZCcT2gAjZuv9B/76OTqBFxVPNIXT4fntrhkkGiFSziej7NNqBnqHx8WtzNJGBM?= =?utf-8?q?+35OAVcpLKQj5/J/N/5W6icRiGtooV7gbpqwzxTCYgAmZegFD9nL8HVy/SDJ9xY5p?= =?utf-8?q?LJGu/M710N67/rcpGqoDRqkfWdxwLZ5h8+Uh2ffdI+n7BEtW0nXartQDqBN95l4y4?= =?utf-8?q?C0w6JGIvHpken83K7MC2E/w87cfBAnhwoNU2Y85rEqYOiq8uWjClavfJrOkgMLpK/?= =?utf-8?q?D74g+uq7CJu3gsDY+pjigjD6k2VFgh/qJ327eARavoELdDHAWDiIluvQD3hVgvZz3?= =?utf-8?q?KC9hB3Yook0cnlGqUFtGVmLsmo/5s7p4GlCdnGM36HPpNoFWeC18dqYYuf0d+vGtl?= =?utf-8?q?3DvyCD8jtFv3jtKm3FHy1nPah8xLB2EqJzTDO+bPy1aWxxlp1FcB1k8k7m10Uxnei?= =?utf-8?q?5T+12Uk3JeS8FWKJS3vhGzgxbMk16qD+67yRAHg6R02lw1YapEoceVXLohMicC7qO?= =?utf-8?q?V3YvAfU56I2iciKVUr6loCMj+MkSX5wsD7EjApbisshziK1j86Bo60CzwFZVGZD+Q?= =?utf-8?q?vv+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: 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: bd569a4a-2a99-4fa8-30ad-08dc79978c75 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:38.3243 (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: 1rnL44jYkT21cHuIYRpHYNVhFdiTYo0owsv9r65O++zmR8Jn1dtSAY+dkJFF4vIYdarNaOOULw1FC1kR8sAbeLGMqM2d/gO5W+gWsq5SBbQbHpJlNFO7hkarfWm3KDG7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 7d0420e15d..1e37b98c65 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -272,7 +272,7 @@ /* For the low 64-bit of 128-bit */ #define VTD_FRCD_FI(val) ((val) & ~0xfffULL) #define VTD_FRCD_PV(val) (((val) & 0xffffULL) << 40) -#define VTD_FRCD_PP(val) (((val) & 0x1) << 31) +#define VTD_FRCD_PP(val) (((val) & 0x1ULL) << 31) #define VTD_FRCD_IR_IDX(val) (((val) & 0xffffULL) << 48) /* DMA Remapping Fault Conditions */ From patchwork Tue May 21 13:11:39 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: 13669448 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 8CDA9C41513 for ; Tue, 21 May 2024 13:15:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIA-00006T-6C; Tue, 21 May 2024 09:12:34 -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 1s9PHU-0007i5-JW for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHQ-0001aP-0l for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297108; x=1747833108; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gogYq9bIMph+X6X2cL9HJLg/M0kvP6UJCrNM9EgvxWI=; b=PoLEN/l/fFOcxW2vpphkj2lTkUTkeU1995F0CxYWRwHBwqwl2MRO0PM4 +CnJef2npKCvHLPVehfk3e02cp7973x+XHsuYaufZ5mBowZ0HUndD9sk+ WnBNYP02QGqQsDdfBw6O9X31XdY6n0TYjDaXwvbI+Ms4Km507WkNYkJ5+ D5ZLGEQaU9G+nZUT/6m9ppCcuoRqm9gUeN7EIt2pqRPkbiGOvTVeO/PMu HW7BX3U/ZqiDDaL9AGEPaGtp6E0EYn1c+raeS8DGHypRHfpM5Ao6D5xTQ uC/YSRWvArCXXGsDFgkqr3Jtg2qP9eezhLpochcwx0t7vW0pO3RMnXBv1 g==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13007991" X-MGA-submission: MDF+t46JSy2INbCKVkeiLjIuxG+MdU7esKIcv9tiQfCuWskyVavi0QYZbdpdf0UA2HSnxOEPp9ZnzC8/y6HZBD6WwGD1ZZh1xXy5vpjgQSoFZ04d1Zjz7y2h1Twf6AwaxRXLrD8wwICL3X75gMHyLjQCqpGlRUgsF0dNeJ8UjS+97g== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:40 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBwpdSAwZ9ij62Z22z6HKg2koDYm819pFlgsTlnlT7mF4TT5JQzGzZOnNQ0+p7fRfvl4KCE1KSwKCQVTWm8v/XOrnalkeYN6yn4TYwCeHPn+H0A5z8eFaTyj1CdmqgUCTdqKeEeopO4RsAlHRiG/F70kHapTCwNSyS7H1SlToi473ZBCD37+4IzhF1b0mqMyPOwALfQo+6UxoAKCfdsJhhdobsXdmenGQs9RgdlTeuo5Ow8FwEZzJyq71LxbWC8EndbA0OxkRR7tdKDdNJvNT1mwZyLfxSz6dxBkKQTV6pa7Ao8+aZrcjl5ih0+i6YN4/QmBLRSLOmzrCTK2dIAzYw== 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=gogYq9bIMph+X6X2cL9HJLg/M0kvP6UJCrNM9EgvxWI=; b=JFLokBlGT5ATauK+ym59v5l19KM8d7JHVc+tFB46QDU9deo6tsQhiqlLKmeXqed3oEklxEdpcsxzh3/fg1vZQg662mGAdvIrGOGX56OnoLz1oHF9HuaU4x7yVlNeADuUbEmuO4MEt638+/OKig++elf9EhdZSi0OC8Z3jFpeJylmcta1j/AG6GaIpZVT89I3pRMtolnyj2q3ep/cb7rpt2RPWpQKSD8LJAbZ7MvWnQubW9ywP7YPpM5OTEstQ0RIpVIzLeIPJG1f/NyJy0TeLmmL9r5HRWFmPvm19VZhyDGEZXWnw0yQjMyDUGZhNkTyKIPsND78Gi4YbAqvUpk1gg== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:39 +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:39 +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 02/22] intel_iommu: make types match Thread-Topic: [PATCH ats_vtd 02/22] intel_iommu: make types match Thread-Index: AQHaq4BqDI0m4GPHTEuIK2r15OBdQA== Date: Tue, 21 May 2024 13:11:39 +0000 Message-ID: <20240521130946.117849-3-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: 8b8052db-3298-479b-c042-08dc79978cfa 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?Xrtrp611AuV0yQ00MsxYakmE62F+T5A?= =?utf-8?q?ncCeYE6x9KcVSIfJv8wNKU/iLzn2o7TgVy6rHPJfJsbw3e4NDQPRqxP4GI/SzLPp5?= =?utf-8?q?TOb3Ta/uU0WNBY8o9oeFg3oYZfzOU4vfLB7ZrRhuO4EIsoxbKLHtpMDGvXGSkksVV?= =?utf-8?q?MDB7J6e8g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+cUtcPk8CVoliPhNkOJt7L++VfAPI1CaoVbmqX4rP0z+o7YZq3XtgZgCzqvc?= =?utf-8?q?vEDIsasVDeQhqiZFhGE7wq99fXpGzpEf7b8tznrzSHARTCC+Ffe0SGTMxLJyIDlms?= =?utf-8?q?QPS4hXtBYsXjxySCs3URYVUBpDKrIQXMCbSVTdlMUM6cqD0wgSlMxIQ2bCAjPjk9i?= =?utf-8?q?oae4YytSernkHn14RIz3Zj/cdg/yUl50RjJVCQaoMpmYB9zWbXro/OQYEAg/xEjD3?= =?utf-8?q?khlPqU2ntWhNHzxAxARpTXxyyHqlAcPjrNA=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?VYnIpPyl6U+mwV8Bl+aXUUURxbGc?= =?utf-8?q?JFDBlQATdxsoOhQdX1XWwK2j7hI8BSNEVCUOxSL1p7IHwPAINpq3wXUhsjJBRONjG?= =?utf-8?q?9skd018ubj8/G6F3rfH9d1OXx6oeez25up5xfBMI/uJLVhU9dhkzep3FULb5mQjsA?= =?utf-8?q?zky18aNvgNBGemKWAOpN0t1wNyJwAH34IPdeBxLMgsWAna52VgZnaEuJ8GgD72n5E?= =?utf-8?q?jedc8ENXKiNW9wg4YuXZbVCiepfb3aW2fsYsbXZP4dl8KhlcPwd4g4a4UIA6c9ezR?= =?utf-8?q?OdX5eeuyQfSdmpZe2Q+TMueTYUVFT8k+bSCdkdIjI1g2zBU302NMJl9NiJqYjusxG?= =?utf-8?q?aYaPWr2xm8mscuRsC6HSguXdx+z+SSfuiBqQ5Haa2XM9L1C9ZXpNveX8LK4gDoaxC?= =?utf-8?q?xO5ge9BZpNeRPDrR1Ybs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kvjIqJR/0MM94oHr7QKNZRlhWFUjFpc3XMDIHYuik?= =?utf-8?q?RlkvKI4ZPBEj1QLZBLdGRSGqUk6LTRtyQ1/juMATnbNN3vFgo8azncfIeteiBVZVr?= =?utf-8?q?p7bsNruEjv5/bdoj7+mlE3nCSQvOJMlD5lZfA6ucJwb9dPUvqRhQ5syVUQg6ywSpO?= =?utf-8?q?tKZtWsYtkNAL6HPrGxMY7DV2OL3FCeilguOZcuYoAoU2XLQNaUpJd3CjklOxM3KCe?= =?utf-8?q?LFUTwQuIooNMZjBdnB19ncrjLH88izcgAfwzgPQg4+Q90NRQzKnNCtI=3D?= Content-ID: <05092B6E552A1844BDC6E58B62E34B5B@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: 8b8052db-3298-479b-c042-08dc79978cfa X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:39.1616 (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: Mgvs2Uwxt1tvBrVx7OF5J+pkzOcUxMpbXRyUcXlEzYLBa4BfK5CLB5jTtwVPrpTNjM1hviYwm5Zn/xs7I86Kj8Kv9V3u5BJJmQADzXQ6CETywQkVqil5+CTgbCjS+SV8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 The 'level' field in vtd_iotlb_key is an uint8_t. We don't need to store level as an int in vtd_lookup_iotlb (avoids a 'loosing precision' warning). VTDIOTLBPageInvInfo.mask is used in binary operations with addresses. Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 2 +- hw/i386/intel_iommu_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index b4bbd839d9..fc8890f4e6 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -395,7 +395,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; - int level; + uint8_t level; for (level = VTD_SL_PT_LEVEL; level < VTD_SL_PML4_LEVEL; level++) { key.gfn = vtd_get_iotlb_gfn(addr, level); diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 1e37b98c65..c9a673585f 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -488,7 +488,7 @@ struct VTDIOTLBPageInvInfo { uint16_t domain_id; uint32_t pasid; uint64_t addr; - uint8_t mask; + uint64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; From patchwork Tue May 21 13:11:39 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: 13669450 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 85055C25B74 for ; Tue, 21 May 2024 13:16:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIA-00006a-6n; Tue, 21 May 2024 09:12:34 -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 1s9PHW-0007id-4i for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHS-0001ak-H5 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297110; x=1747833110; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=t5mVqTcx5EuY4FPFmulO8TLnQw3iEaKvV6PBbG7z9y0=; b=RK17mXXRFAwQjYPEqPQJMimvAWz8a72mGI0xMbdIiCKiv0YTsaLQSll7 Yu4VIJbnACqbgQLFxqOCp74j/89BRlKfnELotfem8VOX7tx1ZFNEyiZab 5ZeL4R3+gABM4RoLqVmR6wEVBTIpnhYE/AmcVbPo0z+c1fWm37bU7IRiD wHk4MayTLT6+cMvHaMAtG1SZLL8yvxhNE0c9CZKfuOon3CaNof3VumGeK LgSJw/ruslLzw9lZ1LoUqkint9roCzHYwKRJu8dzpILATC+S+YdEBRVfj ZSf81rlGcgA6lSwlE9otsXXaHr42232FJikK/6tfvM85qofK2zXY2zKIQ g==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13007992" X-MGA-submission: MDG3KGaSd9eXyJfGcnepW5ktAhIYgAcijKwSUnlUy/QvENqA9BaI3XMWqvrWDeKT9pCf4dFCpurFWnCCQ2eNd/dfjicgmHrrzIo8eVZYhkS47HJI7rl7aqImgU7gkCeimFPRTgBWHlMMxVz08TuHrCeNvMpCsjpTyloS1Lixo5tzww== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:41 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UjHSGFxwsj5r2jrLDiBo+VOlTrAy5XytEU3DyvgVBYHD+pFjnLGS840SW6t1kRz8RDqgrOPAWNBXFDP7oezfn5DVf3iLQAO4c/vLfcT7ZTw7aZfT2JFJF+A1C4rsgwbWXtvAIwAJHuC5fJ993gmBbpjRAR83FOXNaICtfH8yFfr4sL7ZZ8UxbQvBZ/ssl5GYe1Dzm0esMBviIvkb5qAXjvJ6+JsGpAAW/xZpzFg/gYt8ZOvKNoAv5rQ/mUoau//+jgIpdFFeAVdo2jjcp5hD6+EEHIQCuY2lXxqpft9fxAdB/vvUYO2k2x6dfannSfKfdQXcfFe2+KMsqEUIQd1zgQ== 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=t5mVqTcx5EuY4FPFmulO8TLnQw3iEaKvV6PBbG7z9y0=; b=jrhQ8og6xmLsZyyjugWqGKGaSrmn7F95E4MW6+p88qNxDE3+2jPz2n8n1A3/u3hascrB74DjHHQF1/hK405ZQPfvZEM5bCq3miZmxkbgukZILCZX8adqj+o00DMGerLw4ZaZnZy+ogu6iw/y3SyijPaca6SwFVsyPWXEdGy4FpRUkuyMidq/e0XP6my80jDCe/K+6vJ/zfak5n4eS+aK5gJVU2yIudP2LcoXGavCbeJUiZdrmAaOLDSw2l5CqUjE1qAVg3oWolNPe3vwlk1szwowhrdNhX23j8s/Zabnulp6ftByBo2B7pAX7GMXbHhBJ9U9re7Szvs+Qhb0nD5IVw== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:39 +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:39 +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 03/22] intel_iommu: return page walk level even when the translation fails Thread-Topic: [PATCH ats_vtd 03/22] intel_iommu: return page walk level even when the translation fails Thread-Index: AQHaq4Bq+GxgjpkMDUSei0iYZLnFRQ== Date: Tue, 21 May 2024 13:11:39 +0000 Message-ID: <20240521130946.117849-4-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: bbf1ddbb-f278-45ef-550b-08dc79978d55 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?9p2np97q2B+AA+etCl0EfbGVcGAeEyG?= =?utf-8?q?3HVTn32EnmidGJxdsYsJ3k68DjaOKXVng1NE6XWPdDxtq81eLINWCoHYFTllYfsMH?= =?utf-8?q?J2zpTNZT0te3gY8jbdHgOuNcnUUkOYjs8Uf5HO4dzOrT4lQbQye37NEk/RxxyjHwz?= =?utf-8?q?fl1fY/jJfNGAFPnTykpZfjmfu56fv41kgnqyEIy9ZyXfZUP/yZoXLt0h3qhpfpuph?= =?utf-8?q?wtiucYPAVHiXPfktFDPfMbgSHbyC35jWHhwhdbjLTZUQNi4G1ubtE6S7TAczEuldq?= =?utf-8?q?UUD8fyECT7Qa9hwPc5SyyKvV4M8koqHS70M+UHmp/vm+n4wU0jXpN7xE1K/iprqk0?= =?utf-8?q?OitTIlSOhxiGTrqTQQoF3PoPSHjORTg9lvYmHMZOBxZk8OGoe+ZwpKeZnP1N3qK2Y?= =?utf-8?q?4UJrDLzxgDOd7m50J3xAe1cDI19uZPtY0KuPGVvHjtVEtF+ENSF+3iRRppGIOcGEO?= =?utf-8?q?e8yE6i0MN5NaGN6WwE9/k7Hb22o/C0voYxFMUHEs0Bsezt3TBv7qhnozCtQVOYWOc?= =?utf-8?q?bvwj8GHefqgcL3WrVSFQCWyYyiLBtRhL21qR179tihOK09rG4QDT8MykQ2QlnXAj9?= =?utf-8?q?Vr52GMmdZJTaXCGfXIt6MilH6QVwURbZNoRMH+zW0WtpFEdIfXAEeiBbjKtEeIFMN?= =?utf-8?q?Mu1CykF1YdhdjXHCFI8gv2TqrbMHYhr9IkVEW/CBPH0oD5F49EdQdcsc8Y0MUbtqv?= =?utf-8?q?6kzvvJaY/A48XB43cYLfYBdyryellEqVGqyJm175YWceHad6j9deg787LndjaXUtS?= =?utf-8?q?RpqLJDUjidzL4Q9aM1qYjhOXQxOIfJFARNVsLsWRaAgcbW0XXgPWsCpBf53cSCY3k?= =?utf-8?q?vabwUlA/B/71RgcXG5fDrDfmsP72dpfNu/3n5to37dF4LxNCIygLOlUfhtrlh81BY?= =?utf-8?q?uQRDksx1C8v4UFJm0S1Ae9Ig+F7tYMpNXgdMsUFSs3Vx0y9dFak+cRmyD5Ch63evR?= =?utf-8?q?3i1gOY5TMcqas48qnNNXc7AOaRu5Z+ZxAUfYdY3abH9/K5dHfot0gicnlmpDck7wY?= =?utf-8?q?QGoD26qpt7YFDwBnbGpXsCUPEtKaejiuNETAZklm6GApiCk5+yUOPDL1xluqMF8IW?= =?utf-8?q?Sggx1yzFS/uR6WpnC7b8UGrRlPUD5TosN1xjHMRcJb3DemkVlHWuG0hC/m4rUgsJb?= =?utf-8?q?mJWyK1G0fXhZ9C+DmihP5Wna0wBtCPeOlV737dBCO/dfEXpZ94HY3zbimzdnblxp3?= =?utf-8?q?Vfch7n65Kz80aSz/N2+V43OipwL/kUByryCcGd+nCbePRUFV32Qm5BZbjWWINpY/f?= =?utf-8?q?N8OFjj1MlFkgtAx3ZtFlD5ajBSWGEV66v+A=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?blylXfRtu9uHqjSPEtW3GNCf7mIq?= =?utf-8?q?wdXugxq6bazz418otGrfVje5M/8bMbtX3whR0CsUkJTy/6LXNR6opDlndb0+OJua+?= =?utf-8?q?J0vWzlANzH7HQKnRs4B8Xq7op4dA1YzrwnQOket+RByCJ4pQg7lYp3N+VURXqNmDH?= =?utf-8?q?WO5qDL3zdWrjFDzZxpksNr3TUZlud/vX49rzEUlPCCgp1+XtARtg2XPNMGcvImxf4?= =?utf-8?q?hg5bCvFzQgG3MK9XTVjAGJPjrnOm40JJ3TS2ztd0CHqL1fMUU18tFH4JngIttSR5X?= =?utf-8?q?QX5gXomRkC0q7H5RY8cCKxZ1exYwPV1dzOKfPhBK+mwd2Q9Q7K3oxHMQoQ6mMqiy9?= =?utf-8?q?hRiKhbO82qjOO2KC+fFXte8IYDPGBRcHwrKzdm49zSSWsfEix3isx9yQCDjbeErFu?= =?utf-8?q?faGX4iOpS/z6ZOAq2gIlECDWfNemGYHUgMprBchEAJI40HgY0rYWJ+PjeH/ob5N3D?= =?utf-8?q?sNre4pWzKZi+oIG7uCn3W4KhUV7JTs5ZpBr8dY0AVUBHT0Kzfjl8UgtcgoKCMQ261?= =?utf-8?q?ucBEKENSGOKcDq6vLXvKW/rCzrVJCO5lWgstd1cpWIEjjv/rVdSh8dlMZ6iSxU2r1?= =?utf-8?q?bwIchxBXOGvasdtn2THnO6H2PhQkj+qAZAjRUEPHRPi83inZNiP1za837q3QCgOzc?= =?utf-8?q?aGuBDnBcJTvIW3swsRQqEHocUEWGs6I16ot0OmMkOcJYQ5v5GyWa8GcDb/lgs7HvU?= =?utf-8?q?PAxzuw+cQZqbSifZXSuW5hRvEjZza4hTc0Ucoru9YaEMWdURilbt1R5TT9bfUXAOq?= =?utf-8?q?stxc/nED6fxyKNe25fU0Ds8p+MncIr7mVao6oOpdqj/31hpIswI2gASUAtAENFNhO?= =?utf-8?q?YUfPxj30Sj4lnMCpJP5rRpBCNTZhzrXI4RYx/53D3Sq0yb4IjTXpIcSJx3bYMC3Ug?= =?utf-8?q?J3gTwWTpb+2x8cB0drlgq4AAWwlsO3CIbpivcLZhKtEcOr+K5M5xqJnBhIddRWXPj?= =?utf-8?q?72beKP2EGhToXdlRHuHI3QrW/3pGfYY3TRWpkQxoiFJkVXM/39Dvybe7y2K3UGIev?= =?utf-8?q?djc5dv1X1YMVcvVLV8YhGBWPgpybJnCclxgAc9POHzAqmMUdE5fg2CZCdOc+zKyM4?= =?utf-8?q?CcIzWiKgwJ4P5Sbwne6dQcErXSFd7qYt5WINpiEvWsU8PE04t1OTLO6A3YLEsnxrc?= =?utf-8?q?5z7dsgrWHb8cAf5K1e68BnkOoKqcRVolowdnHeLyRXLCWLJslT7K/3xl7MG22fre0?= =?utf-8?q?/H7uFyRwC++Q4eNIw09nC0z+9HRVch1tp/AuV1Xw+qW/VXkyyZGrF+kC2ZLGS0V8y?= =?utf-8?q?2OyglH5XfLSuWjKBftQr8V7Jp+5ag27a0ed7AIK+mQzYFvpE/pVl04TrwxDb3H+8a?= =?utf-8?q?3inYiJ28SalYqP8AiB77Sv9THU8FVsRf4ehUEJE0FcVdcJlOd7GHM+x40GzqhsuNi?= =?utf-8?q?2qHO03N38lIS6ogcQLjlwPvog0V6EX3/i96ehbjPfGIDUWjoD8jMp7NJlZ6AtsTtJ?= =?utf-8?q?hmWIAlUCu8sXE5VqH+wqK8fvxpeGlNVee4HF/8v765cyDQh//8619eMXAW1E8caE8?= =?utf-8?q?XmW7+8vWU27+x33Y0bO77YIP35kG1c2QfM/2FeRpnjrxau/05cTY5o4=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: bbf1ddbb-f278-45ef-550b-08dc79978d55 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:39.7770 (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: 2b15sFV/mJMGzVT2m3uBjbb1mSeBbcfovUg3mfbufwYjHRU1fl1HXdsGWJO6lhGF9R1FNB0YedVP5vWFS3W8i27XphuDVUYLm1jZVpdH8FIpXW0qRD29Gv2DynAnBC6u X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 We use this information in vtd_do_iommu_translate to populate the IOMMUTLBEntry and indicate the correct page mask. This prevents ATS devices from sending many useless translation requests when a megapage or gigapage iova is not mapped to a physical address. Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index fc8890f4e6..a2b275016c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2078,9 +2078,9 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, uint32_t pasid) { dma_addr_t addr = vtd_get_iova_pgtbl_base(s, ce, pasid); - uint32_t level = vtd_get_iova_level(s, ce, pasid); uint32_t offset; uint64_t flpte; + *flpte_level = vtd_get_iova_level(s, ce, pasid); if (!vtd_iova_fl_check_canonical(s, iova, ce, pasid)) { error_report_once("%s: detected non canonical IOVA (iova=0x%" PRIx64 "," @@ -2089,10 +2089,10 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, } while (true) { - offset = vtd_iova_fl_level_offset(iova, level); + offset = vtd_iova_fl_level_offset(iova, *flpte_level); flpte = vtd_get_flpte(addr, offset); if (flpte == (uint64_t)-1) { - if (level == vtd_get_iova_level(s, ce, pasid)) { + if (*flpte_level == vtd_get_iova_level(s, ce, pasid)) { /* Invalid programming of context-entry */ return -VTD_FR_CONTEXT_ENTRY_INV; } else { @@ -2117,19 +2117,18 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, return -VTD_FR_FS_BIT_UPDATE_FAILED; } - if (vtd_is_last_flpte(flpte, level)) { + if (vtd_is_last_flpte(flpte, *flpte_level)) { if (is_write && (vtd_set_flag_in_pte(addr, offset, flpte, VTD_FL_PTE_D) != MEMTX_OK)) { return -VTD_FR_FS_BIT_UPDATE_FAILED; } *flptep = flpte; - *flpte_level = level; return 0; } addr = vtd_get_flpte_addr(flpte, aw_bits); - level--; + (*flpte_level)--; } } From patchwork Tue May 21 13:11:40 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: 13669449 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 78CC9C25B7A for ; Tue, 21 May 2024 13:15:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI6-0008Gx-TK; Tue, 21 May 2024 09:12:30 -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 1s9PHX-0007j3-94 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:56 -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 1s9PHU-0001aP-VT for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297113; x=1747833113; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=OdoSWUTa9ddjTSMitoGhaOWL+giZnUC0wKZ/HGPO8cs=; b=cOwrdBR1zaDTpwBkwMs+n3cJ2SWZWMfMNGTVvK9giYklD7p5DhV8Y9Ie 5IVUMQ1HyC23EeBJud/jEjUb9YZS/4EfLpqd8K5r4h/5FWrOvJdFja/kJ 1VZd+1uPPWaZrx1nDNaTY6l8aGuSacQu763fKZhgfUOONRcnxrSRdjQ2P SA2DYi1d3r6WYCA+HyjuFLQe14NL1oCRYh/+aZTRtWk6c5PP+PCnGCQsQ 53GsiQ+t3aTqp/CQSUMwG68PCp7bGGc9/+WhDM+gC4PfCh1QbhTefty/k VshLYDpklBbYvNW7lwMHGQT9GD7Ns8lZrInZQzXW4S/BHPcsfAtbAMhRV w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13007994" X-MGA-submission: MDGNhRK9jPNimaYx1YbthKwrNoZunb2sl4B97nhxMoqaHfsRyddSr4+Fm41BA11IL5wBI8vlMFfsD5TMxx4eKC3SriyKUwZY8gbEktDucLxkwyNOszJVLy+pJNVHX1Mw0xVzSQHU7tPae1x0mtZzcT+K39mxj5iKvSzDuSz+6hrTog== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:41 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQPDoNYaGuhSJt6S4RHLjD4qKlNsRFWB1ewsmxfChdW2rzvz98gudJQreZ4luFAr4OCq1nZ7hhofJd1BSiumUltFJOmxPYCQdLRpfEXMPsTUNtjFOv3sd1BwEl6+VXV+2Dxj5Q2I+XKylI+CKSLh5djQR3Up2FIyPVPzsbjkBYKlxXD1BK7ZYpgOU1A62vDVPvk8Dca703Io8Z5MactW4WKuoNHOBhNXQYFMgpXmxYN+ETkZ/M6531AMXoraOs7lRqZdEwtBtX47U4mfH91fwnrqLade/Mw8XhwDXny1IcujzfjR9ji1n5Hmb9rYUtqB49K00U45lv+85XJfUo27NA== 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=OdoSWUTa9ddjTSMitoGhaOWL+giZnUC0wKZ/HGPO8cs=; b=mNjAy6lPmI2owi977ljDjUTPrtQgnYBgLbZjnLamk5tmq7PJW/YdpH2mqak9z+vGnQ/uUodIRimVYgC0eC4VtKEpQCOrdRP0V2h+iF2u+BnlgT0MaKg13Oub4UZRtT91ZSmVm4WQ0h6Bd2AEq07H5Y33PxYJ4bGXvSU4Ck29MTCviASvT5jenaPlUfs4Q5tUxihzc9BuS0JZQIRNwvGuBQATvzk6wINFHLu72XqfBorWBSiIrDheil4HdqEla7F28gjFg6cwABywmlUxBv9WS8Skc4eAx5AtbRht2uD0cL3i+kBdAzU0tV01pdt1F04WAroMV3PVTzpk1x4lrmOgQg== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:40 +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:40 +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 04/22] intel_iommu: do not consider wait_desc as an invalid descriptor Thread-Topic: [PATCH ats_vtd 04/22] intel_iommu: do not consider wait_desc as an invalid descriptor Thread-Index: AQHaq4Brm3Er4wjTZk+767IR2JUSug== Date: Tue, 21 May 2024 13:11:40 +0000 Message-ID: <20240521130946.117849-5-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: d04919dd-939c-4392-c243-08dc79978db4 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?rRrDpBUeU6AFDv0salHjAVikxPVQMpm?= =?utf-8?q?RpkQD+Yz+BJhjZgliYgVWPHDkfnMXK+qLYzhM1RVvGdZdoLNYR/zEZiJwiRPD131j?= =?utf-8?q?ioOi7cmfZrypF1G6Pythg9lDtZl9Fi6RXcShFziJ+2r12O1niwLXOidfY0rAckRBP?= =?utf-8?q?pa1yHgqWINpDiW3nDWbvxpMBFdoCFG40BujL1LHwhjhw+5aKdoOWfLabYVevFJdRG?= =?utf-8?q?XsHiClMkoMWeYhZqsLgjuKmmQcblYeqkw0TnGeVqlX2fmaeSfmXbCfOPSpO/koHvF?= =?utf-8?q?OtPdejx1LT3SLesAEb4qEp4XYBSt4G57Z7XlsihQ+sjOIHUhc6lIZEcZKF9u2Ji5S?= =?utf-8?q?c9PCFSTpJjaP9hYSYj5jChXJtYTfKeVBacyYt2sTKGx4LW/dyuUI6D21TGK34Stw9?= =?utf-8?q?gNYynNupy0fo40YQo+rEYoUBfih2FP/PpBFNhmYLgkFN9AYvIg9AbC804asnpZf+R?= =?utf-8?q?M4slZeKAWsBjliLalafZCLNGtfbgq4B6oIv2t5RMoI8t9t3+TGKVOCrw7ixwH4OvX?= =?utf-8?q?kiKDMu/bK3XdNX5EBx2NxFgUkq7B8rAoSorT65xlz7UZzHol0xGspwiY9+C4H1YFk?= =?utf-8?q?BHGRLfMMsPZiTkQ2QZ4q5vsotveUIJ3l5tSvTOnMWlqO8tZiqnQJbYNy9mMu4R5fA?= =?utf-8?q?5S2AXI6sydakjRmuhEryqM9173BU/Kkq1G3SntggOAEqrVQpn7dizYADFULDknIly?= =?utf-8?q?s4i2k3eaAWBSmSv73KixF7z2k0S4LzE6I0NOHfzw32L5lvE0ZzYw8MU25DvfTeG3S?= =?utf-8?q?dEvTdd3Ve5ijUuHVMMydye4SNWeRKjSznPT4EZ1pVuTVkOZzXoY4L27mNaYjguXqt?= =?utf-8?q?cRkyjCelLDoAE0z5jxO3pxzKPN5o9N3jSxMbhx5ivDlrjXo8RLKLy4kIXXSIARHVr?= =?utf-8?q?ycuGCIxt3sb6qm/pZ0Ww1WdIKQ5Iv8eMzi2iKgSToQkZHaG9LwY+NLE0jFMfPfmY2?= =?utf-8?q?dCYZyuJIXOMsw6cGTtBDFYI9FHq+xXmYHM9gu3V/BHbCwqCJv1BfqiXXlV2Soqr9v?= =?utf-8?q?o0KgcvlnTxbhM4HI853r32nxDYvIhYwO0MiNYzR4GqSzAbwH3tR1Vxea7UiWQM8ca?= =?utf-8?q?lhgjWsmnFlBb7CT9NhGafxLy8VUUC/tn5KUZriKGe8D8AFHIIaP/OSZUC5ycbIAfF?= =?utf-8?q?NLQITLA9fBm353EslgDbWF2ridma2abYTmOGcAkNj4yMp1T8JoUPwkACjmv4c71nL?= =?utf-8?q?bPRh8BUOAsFC2ntjE0JzrPGa5CNI3hd7ebZuLW71vIxQ1Di7HOhPieBqYZ/JraB37?= =?utf-8?q?Vfro/4GfoHqF0?= 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?v+54uhS6csdC9/1593ak5b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?utf-8?q?K46s704iWxPKTEXPqo8OwhgXTW5PM3tUYGFaTHLa0xsUpvbz26kPpDejaoCuuC+ds?= =?utf-8?q?nrh8O+3LChha0CJnmHDzu0OwJtKukNJ46rSBihUW1hSZpmo6Qh1JDZ9ClFREaNT1y?= =?utf-8?q?/h25KdZONHn9ywNDDHqFhEj9SrlGrOvIy66jbzGG2vqePzJern9Wgzu2gBZ5MEy1h?= =?utf-8?q?V8eFozWrvlt9lAjoX2kaAXIj+OoDYM7JUh5dSGy+9AIqrwJpFvvVj7OVnHCn5kjyh?= =?utf-8?q?2LjwdZAt1U8c3HGZASoUXLxDNPXKKxd53ZoIqlOj7bvuv5RZWmqnzGufrjdNtiwap?= =?utf-8?q?Z/nAfYKpRUsoIvQuVzGhF9sVGrlmprbNdhnj03GtQPTSkRiAAZwwmALckMhjOfrDL?= =?utf-8?q?RkAcLg3mrDe22uliGX6H6mEz+bRQQtRSeF7rXQsouZFVVNVASoy2jK87sexguh9BG?= =?utf-8?q?SrRrXY3QwK2w5UMKjw1TuH1lZFJOIMOHYo5Vftqzp8Xd5kt3fUITnQWL02dcf2keH?= =?utf-8?q?PKMUpLNlwkaRBOi1p9Aj4hzHhnWDLCQHkt9J3E8rN0Tn+KQsbTDB0yLGWPjSer4V/?= =?utf-8?q?BO/CbVf9JIPZUWGViZQgKre0H6Ga+nnbUBmNTiRYAaR0wi388RIX23Fy+xK7oIahF?= =?utf-8?q?yMUPaXHcKBoOYPRglGScMMO+TkqgH24MZ1X4ujcGk5GondWzkL8Jy50=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: d04919dd-939c-4392-c243-08dc79978db4 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:40.3880 (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: rBVBqRtMurVK5BdvZ0bnReyxQdDABthkCLIvQVxub8sE9+gwp9NuDll/2brt3jMb8lL6cTD6x7S5Da52rRBe++FJSZjiXUo9l2kOJ/FS0YS1VAua8DE2Ur2C+47CMm0O X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 Reviewed-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a2b275016c..f71c04d370 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3476,6 +3476,11 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) } else if (inv_desc->lo & VTD_INV_DESC_WAIT_IF) { /* Interrupt flag */ vtd_generate_completion_event(s); + } else if (inv_desc->lo & VTD_INV_DESC_WAIT_FN) { + /* + * SW = 0, IF = 0, FN = 1 + * Nothing to do as we process the events sequentially + */ } else { error_report_once("%s: invalid wait desc: hi=%"PRIx64", lo=%"PRIx64 " (unknown type)", __func__, inv_desc->hi, From patchwork Tue May 21 13:11:41 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: 13669443 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 0C66DC25B7A for ; Tue, 21 May 2024 13:14:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHj-0007tv-5Z; Tue, 21 May 2024 09:12:07 -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 1s9PHP-0007e3-RW for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:53 -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 1s9PHN-0001Zh-0e for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297105; x=1747833105; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=tIM0BHg6yThMkhqORC+BUeZDUMynoBvXIlaRATWvIhM=; b=pBCyUZDKY+cZf0lC2wb6xMSA5lE359V9+m1OBL3beIPWmxL8A0e2jNjY Xc3SgEze72xFyyrWQowfW1s8Hbh4x2bUfEXZneBpQeDCQCTQTj5wQXhu9 RrXGY3Po+cwEdMc0zqdndpk/GaFppb31bHqfBjDdcbvwE/AVptYzf7MVa i3sgx5s+P1f8e754PxjKpV7So40zgQaGKCeBcNF1AFjl5GyDQm2a1ZM1D Y40BhT9okFcZOot4VdLSpE3DandUL4Te8KW4kIY+O1BU44z6ck2w74Uqm qslZszSl7lbfGtHDENmOFJodxkotEfV35j1287k2L8vj96LlqFZIQArk9 w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061498" X-MGA-submission: MDFGfMax9gt4oByEnWpuEkg42rartscyw/UmjY0gNUmz2r+/bL+YQ1/N4t2yjzgyAEG3gj8sq63hw0x2TtUk0reLJAl2KzXVT5hKsQpyyk0FFEfibearhyRzZVZXX95PDQ7xXfTXQyMCvgUHAaYcPUe/vvTjwHwrD8FjfCDUBHhW7g== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:42 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcRr4R8KOh7ZxfL50Re3DE3ckW78jo7yQsrtUeFc54C7BDcBpVGC/92/EHUASSuHqfowzmU3rT0+ThITVME5WkrwMVscmiEU99s9KN+01aEtIaV1OjelTlvT1oG6P/MtgD1UXguu6XYWSDTIMmssvFPREbEwnIKohYnxLCjFT7a17rzY7/NF5/wv5Zbl8cEzXoUXs/by/MRUjdu2ON9Woirm2PoCZyel0CdWCh26p0AycziYAkm1S+87JCHH/zN5KOXyDYSuLBVJBQI2FIPgSBzCEAJwR5K8+jg1t2kul+dqua9jjbGg2v0FSFIbvcYwVRB0r7vhz76vbRmzMMWM0w== 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=tIM0BHg6yThMkhqORC+BUeZDUMynoBvXIlaRATWvIhM=; b=T3Q7s2g7x4F1riGiMADAuMVuaZo1ws3h/kLcsk4ZtarjY72Ob3Tm1tGGCdQCPMZNiH4a5o+h4N7Y0WpL3ca9/Va+EC2h0ky6Lfnoo7gc07VnJvIn6RPyucBwjEiPV/SQc9Izcj3LdzXWndiPt+UAN3QAPca17vkTEqWFCGjLMMLaEgRWBafi5nMMdwmoxL/EnhLIopSmkKKHSYkepYaQ8iqDfdm/J/fp7Mn4DLqGJ7BIH5mte3+XMgr+AOXjEq93AYGkaZnHjXRHK5kpfzdT92sQwaf7x393ew8eDvIna96A5JoRjmveJmPV4NaB4KtGKVZE1ufzgNOuITa27F0naA== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:41 +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:41 +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 05/22] memory: add permissions in IOMMUAccessFlags Thread-Topic: [PATCH ats_vtd 05/22] memory: add permissions in IOMMUAccessFlags Thread-Index: AQHaq4BrjVcZ9I524kuvkvI+pg0RuQ== Date: Tue, 21 May 2024 13:11:41 +0000 Message-ID: <20240521130946.117849-6-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: c1b4feb5-3167-4bb7-d694-08dc79978e1d 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?gF+RDd6XqRnLceHUicmNEah3dYGY0+A?= =?utf-8?q?0JoL/36y38dI0ZHezsFbM0D+2GmUp5jW/PIKa/cbOtRYeeOuypy1lT+zQz8hEbdbG?= =?utf-8?q?opL650AZiP+abi6GUXOfmrMFm92tXmhgi6Gn848t+A/D838nz21C1fxBcZ65W7jcw?= =?utf-8?q?U4me1gnSeBcJd17zA5kPg+3E5zuKQpb535MXZytRQQIAGf0g8MGUZibgWdlADzGkU?= =?utf-8?q?b3mqfqZquC4sA0PXL6V5Wq1RbjsJDO6bVfFDyFOpGvAPBFHsZGVl2m56en7iLMNg3?= =?utf-8?q?wVKOpz7NSWkHT+Dl6/SWVTABD7XtmJPhUVfrEo+woUyqCRiEgn1jgF5YCl6MJrLJr?= =?utf-8?q?rQToUZyPiP4R5fhSjWnOV94KqvEkCjrb8guKwih8dbx3FWHZ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utf-8?q?UH+WZdAVcKr+6NKd49wXA35GOr7E8NixMAw=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?99Apb0DAPlCjAj5b99bkdKqhgM5K?= =?utf-8?q?o3EGHg4W3cK4Y/rF80uQyN7cH4l7uKh8uOcOEXbfcCsblZ4z2kUg2etRzlv/Xbuif?= =?utf-8?q?ebcMAkAsx955qfgKGaGwGK44FZjNqlkEiZ8OHaqwrwLaPuhXoEvsTO2Sr/G3AYxmd?= =?utf-8?q?X62hUORam9TDOH7T8Y2drFLA1OUNFNFLyhaaKgQNsmpCXXvkak3SZxQNl3hgEkRmb?= =?utf-8?q?53GZ+ir2Byej717ml5O5h+0u7dwTzuFWkG3MtqoKkw1FNe/wftDgroxMxHyT/Gqmn?= =?utf-8?q?qf6YuczU7is2LWrIE9/+l25cIE8s48YCvZJtLR9KfKXIJuTMDMDHpDJlX0yV4CzJ2?= =?utf-8?q?3LDFjBmhm3rxtaRqqWFwmDYQByzHOFI3xX/H7MdeA5h6cTC7nZTQP/mAvqeJ21qMR?= =?utf-8?q?1Jf26fFmECqqt4QvYpJgaWMCztFeCOItYpxr8exYPjWzN9NmXKOPDF1b37JPZSmrV?= =?utf-8?q?OnK7FOfynd8dvIQMlJqgz3yWGSLsnfXoUjzzXOR8yVSaKv8u544fhv1hlfLDuu33V?= =?utf-8?q?/nEhkEquIZ4r29XKGbDDHldpO/X3tA/9jzCNKoq9BSKbMmT4rTjPe1Miz6S77fZmk?= =?utf-8?q?ObksIdNNdjS2ABLXvshNRvGSSa8ZcAS79R9JasqSVp8RpHOJcIXuFay4CFF8+15P9?= =?utf-8?q?wUiWwK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?q?EW6ZjRc2Dlc24lCgYzO3aDBglo0qJZcALmVFn9RiULIMMWb8EbGbCkQ=3D?= Content-ID: <9DED61B897366F44B800F3F344ADF684@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: c1b4feb5-3167-4bb7-d694-08dc79978e1d X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:41.0279 (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: 4k+VeVuaX/iox+dSqEsKZdW87htQWFTYPItV+5Q1pjETRgDTcYKVRul+uedavD/lB36Y0exdSmY1UkKLTErEsx2VnCienD3GdboRqDCTPKpaA/uv0mAu9hvZN8Z9qdcz X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 will be necessary for devices implementing ATS. We also define a new macro IOMMU_ACCESS_FLAG_FULL in addition to IOMMU_ACCESS_FLAG to support more access flags. IOMMU_ACCESS_FLAG is kept for convenience and backward compatibility. Here are the flags added (defined by the PCIe 5 specification) : - Execute Requested - Privileged Mode Requested - Global - Untranslated Only IOMMU_ACCESS_FLAG sets the additional flags to 0 Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index dadb5cd65a..0067b2266a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -110,15 +110,34 @@ struct MemoryRegionSection { typedef struct IOMMUTLBEntry IOMMUTLBEntry; -/* See address_space_translate: bit 0 is read, bit 1 is write. */ +/* + * See address_space_translate: + * - bit 0 : read + * - bit 1 : write + * - bit 2 : exec + * - bit 3 : priv + * - bit 4 : global + * - bit 5 : untranslated only + */ typedef enum { IOMMU_NONE = 0, IOMMU_RO = 1, IOMMU_WO = 2, IOMMU_RW = 3, + IOMMU_EXEC = 4, + IOMMU_PRIV = 8, + IOMMU_GLOBAL = 16, + IOMMU_UNTRANSLATED_ONLY = 32, } IOMMUAccessFlags; -#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | ((w) ? IOMMU_WO : 0)) +#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | \ + ((w) ? IOMMU_WO : 0)) +#define IOMMU_ACCESS_FLAG_FULL(r, w, x, p, g, uo) \ + (IOMMU_ACCESS_FLAG(r, w) | \ + ((x) ? IOMMU_EXEC : 0) | \ + ((p) ? IOMMU_PRIV : 0) | \ + ((g) ? IOMMU_GLOBAL : 0) | \ + ((uo) ? IOMMU_UNTRANSLATED_ONLY : 0)) struct IOMMUTLBEntry { AddressSpace *target_as; From patchwork Tue May 21 13:11:41 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: 13669432 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 CA099C25B7C for ; Tue, 21 May 2024 13:12:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHl-000807-7h; Tue, 21 May 2024 09:12:09 -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 1s9PHU-0007i4-FC for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHP-0001aH-MQ for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297107; x=1747833107; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=JJToM5aUVZELZtQhaipfZSocc6vx0ws4JjCmNvITMS4=; b=Q4ORA9NQzvt/9qGsZ9NsecRk1oRlnQPuGSjQc/a/Pn1skVBgL26ybrtK 0KPrntxOrabZlrLTnw7k1L4OUUGZbqYciTjGSppBD3MUjvz0HTC7z6xZq WmpQI7eJPtg3ZgxuWsUjLg8Qnf8r28NIx1vUv+r1nm5H5itON/HTNHuZb DTXWzMyjrApZfRT25uk1UlfCyAao8Qd8sqCB6KyZCfvQ6g0qUL8tkheEc yuLtJd+CwM7hSn4lfGoYqsJusau8Y/1XTmaSwDHMeAstcbF5GYQ/v9C6k SVhPrZXKCZIAHKHmqlRVywD96bz8q1UK6kWE0vgV/3+s8MsJSQus8E8zn A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061499" X-MGA-submission: MDGGmiUBTtPJ58NJ3am1XcxCnTVKvHX9z2M7Zb68JTmXlydljWyvft7Sm5CVtmJ/EZellkdczteT8VVfZ+n5jRFC2pxw5JcfGc9+HZDZEFY0xm0pnnf3UqKQ3549K3yQ7PbrgWA1U1ifSvOvcooiQ6MHa9HwwwQlYqbYmCfci6cDiw== Received: from mail-db8eur05lp2105.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.105]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:42 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PVqjDoiaN5fLIVimr0e/TAcbscvVjwz39szuZOhf71/yzbppimVUs6TA/FUsugN2X6i48CbCKdpwbX4WBnIGVJ7Yb7JOZlpDpoZCbNhMpe3a8DEohFfaDJQp6IHzJMXq3Zb4uqMvGuPrWpVIisIjIE/qpurYX4L27vCV6zmvENtKVURxiGeDjN+v84o9DEOOhAxm8h7bRw/8zfHn4DtZGba9Llx3owq82lTeKa9pvK1N7buU9M/9uP4sTOG3zXLHmeckdB+4R2xPbJjwU7QLoEBUoaBLwE/nzLXlepOCFcoj4lMuz2FuiwEJSwPInWnVd7aAxrIeSJKi+KfmgVQEyw== 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=JJToM5aUVZELZtQhaipfZSocc6vx0ws4JjCmNvITMS4=; b=Taq9Lwr2dFpCIF8fy9Ul+bxt/Wm6eMeqm/D++C+M8oV2rdGBd5Cl7gCLCeybGq7xpba77VplJSaGBU3N2bkOwcYnnPTQrd11sDYobyCO5lgsh5oAhCzB3xul6P8BHm1Tm6qPA4BAJ+vztt9uFaT/+/Kyr9INIVudGDfHZ65qT75gwZcPkg/I9XR9Jd0T3FrcpoU0R5Ac0iixNUGoBGsFrsuEzqZpBlVRZVhm3gtlP/y6S4UHRwhYmrn34hgcYwByIB9Py7+XSKIq/i2yjZSmlal77nTFJEC5RaLvL62H5Zp45qxRc5m0hCn5RZWNsC2DwLthOjIu5gxUj2o+yEiY/Q== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:41 +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:41 +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 06/22] pcie: add helper to declare PASID capability for a pcie device Thread-Topic: [PATCH ats_vtd 06/22] pcie: add helper to declare PASID capability for a pcie device Thread-Index: AQHaq4BsddIhOUtVnUa3KEFa1N4Zig== Date: Tue, 21 May 2024 13:11:41 +0000 Message-ID: <20240521130946.117849-7-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: 2cbb2d2f-5b03-4f81-814c-08dc79978e86 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?8JQochH+45kDhjJ9gcMRK4/4N9Bukao?= =?utf-8?q?BPgqajZc5QuA2jWSMZF5mTvUktHCODgDuqcfhtiLOpAVz1MoIAoIbkd31cfV4PilA?= =?utf-8?q?PVGdhbO8x2sNl1X2ebnbfZAWsicLwp87Whm1/bPNqNlmxEy34BypeZBGeE7XVl+2j?= =?utf-8?q?3OqoRPTsXOKTh7LRrCnGJ4YuDG3IPUqxzTDB/tDzEIgS8tYwmVxkIr51W19ZLxivo?= =?utf-8?q?M1kQt7Z58gBV8mHiWMRJ8kj5ytYxG0hqT3oKX3JTSvsYw9TvxGEt0vfBiHfJPoMvj?= =?utf-8?q?FjIpm5TZqc/tBoN+UKBlftkZPhlfQSCnTDZXZeL8/2QWO08ScSHNtwNOgRD4+yeuW?= =?utf-8?q?trWj2lQI4W51NzPFgnTbEyykeeZM/5ojetFT6kXBa9MhtMdwZTayKK1AOz0kDqCpN?= =?utf-8?q?/xkTmvqM3XJg66gb6gg62zBQxWLcFVtlUbWaHBCVcOkIgH8Um5+n7g7a1c4mjnRKc?= =?utf-8?q?Tl4JzrwBxlHyCCcRL0o9+zmTmOfF1kadW7hj3OoJM2n896MxmZYbdu4VMGM1BsKIw?= =?utf-8?q?jM6UJ6XGt+zgbJQRDEDAjrYJwNDdJML5BU9yAYQANDlMgBe6EEZ+OGGEzKa/mys0F?= =?utf-8?q?m9PtAgRDO2mTG+xERU/87mUSFJDUBzO2TB+baFw26iFpUt5HhKBU/dn0NVXZb/G6H?= =?utf-8?q?KjApKTYm7xir8X+RJtnCoNxM5chUXahbx4theQvS3h2bIs4HdvcEblUMt6iidfPGY?= =?utf-8?q?MkJzuk4aE+daXOwCpx9uMQR/7+JhaJroQQx9IIDVb/rfZbddqpyvzX0MLwDmuKmfD?= =?utf-8?q?zixAgqomNKk2VeP6vHYbrqceK8zS58eIbubMEStDoKbwKAdJRAK8ZM/su1YDJVioe?= =?utf-8?q?kjDufQ140jDpsrFWfHQe3KIiUvRJsBNs4pNO4hvRgST60n7m5L0N3J9A1N+TrE/W5?= =?utf-8?q?8Rnu1vjndpF2+/AF3k9199smwdhBTrTme19jmbIWNTVNThC2Z8AOcHXWDp6NYTLdu?= =?utf-8?q?9V1FsavfEj1ndLOdfETzCvnAIIqjY0Qy8wSqpe8HQZoyiIcZ2J5Nl3w9JpIWq9X2N?= =?utf-8?q?uFlwlitUkatQXCmGMaWzpArtuK5BMkWnctV+xzlH6iT2NTfnmE16dQ6gnFEgKgKRP?= =?utf-8?q?kMEKlD0TTJPe3bVChnlz3U/UCW3v0FJW0xlRr2LHhOEH/bF/Xr1GfrwS0/LFlKfCl?= =?utf-8?q?EO78+VPvkX44UIzFJadWSHtbo0vAla19RnBbn5xZ/VmmX1czJjlcUl8gNS9m5SvAw?= =?utf-8?q?N/zd8qyx81VaEgvcq65D/IqCIlFt6VzJ+jDUEp327ZzDYmoIJHF/6MQTnGEyQc2SZ?= =?utf-8?q?6Ve2RjTgzvtQFIVCPo3PhkYT2BAvV+tZwAg=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?vtf1jaTJ2L3/9nBOfrHuBH6Hv04I?= =?utf-8?q?JckISOI4OE0pxyA2i5e92jNH/uyYu8SaHEty2ds8O9shUQ+//hfP5gUHZ2lVwsdpQ?= =?utf-8?q?ZmjjvhozT9kk6ezk9KXZtmy4wR8rXzY4IIWCXGoXKMk3ZW4n5pplOcYpiEzjT3Smv?= =?utf-8?q?AcZU2EVZVfxDMA16Knu0VFQ64HmD/nnkVHSxG80ruE7bsOCLHSXJWgViytIxs59Wt?= =?utf-8?q?DITpTY5V4j2XhSBIP2x39JTbtNwTRolf76vPo4VITTcgIZavsp6vGiEVKJmscTT/k?= =?utf-8?q?tCf33dWurkuLgGnahzec80G7aya0oRh1g+fozps/7KHJluIBzCvfAJjrWiH142sLz?= =?utf-8?q?aGtLFbSXTW4uZkcl/w7tNfRY9sxm1FwYe0sftQMOH9GZt+zZ4Q+VRDU2G14BHM2+H?= =?utf-8?q?hA6UER7MyQ1swWSZxNPh1WoEyW31i0weuEjuREQwXOMJuZZ1yLnRkWMmFWVIWqZ/C?= =?utf-8?q?Ecf6R+P9Ki5EvFBn+C9ej7iO0ZObuUJxSR6AQSyJNTEJcHP3wBE9f9hHWh/Hyc1c1?= =?utf-8?q?T4no0byAUOV/LTx/MbOdIeoe+6yNC/j5qOwp7gC8s2q6pk25ZiP68jMuToZ2QSh8k?= =?utf-8?q?R2fN8KjIpiqb7Rx4D032t5fzYXCK9Q+YiuKxtlralHivrJHyD3m78C44knIi3kM3A?= =?utf-8?q?zaAdhf0XW8wMC41kZrFhQfnfc1lDQBe5czNYlbl102LlJOW/OcDEXuPf2+1hA5uVx?= =?utf-8?q?obJJ/LT9qgUODruam1rn7+Sx8nkC8xnLF1voMriuRY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uthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cbb2d2f-5b03-4f81-814c-08dc79978e86 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:41.7446 (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: ZMRGYmhClema51FExHKXmDWGnVVZdqvdFnIt8sqY8NTBuoXx+zfuzDfvQl9aY7cO/G9rGOHdr1MXBEwtBfYFN5+3QFCyDOH4BO4pQ/tiUn7XLUOUBGbtY3yxHKEkIySk X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 24 +++++++++++++++++++++++ include/hw/pci/pcie.h | 6 +++++- include/hw/pci/pcie_regs.h | 3 +++ include/standard-headers/linux/pci_regs.h | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 4b2f0805c6..d6a052b616 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1177,3 +1177,27 @@ void pcie_acs_reset(PCIDevice *dev) pci_set_word(dev->config + dev->exp.acs_cap + PCI_ACS_CTRL, 0); } } + +/* PASID */ +void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, + bool exec_perm, bool priv_mod) +{ + assert(pasid_width <= PCI_EXT_CAP_PASID_MAX_WIDTH); + static const uint16_t control_reg_rw_mask = 0x07; + uint16_t capability_reg = pasid_width; + + pcie_add_capability(dev, PCI_EXT_CAP_ID_PASID, PCI_PASID_VER, offset, + PCI_EXT_CAP_PASID_SIZEOF); + + capability_reg <<= PCI_PASID_CAP_WIDTH_SHIFT; + capability_reg |= exec_perm ? PCI_PASID_CAP_EXEC : 0; + capability_reg |= priv_mod ? PCI_PASID_CAP_PRIV : 0; + pci_set_word(dev->config + offset + PCI_PASID_CAP, capability_reg); + + /* Everything is disabled by default */ + pci_set_word(dev->config + offset + PCI_PASID_CTRL, 0); + + pci_set_word(dev->wmask + offset + PCI_PASID_CTRL, control_reg_rw_mask); + + dev->exp.pasid_cap = offset; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 5eddb90976..b870958c99 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -72,8 +72,9 @@ struct PCIExpressDevice { uint16_t aer_cap; PCIEAERLog aer_log; - /* Offset of ATS capability in config space */ + /* Offset of ATS and PASID capabilities in config space */ uint16_t ats_cap; + uint16_t pasid_cap; /* ACS */ uint16_t acs_cap; @@ -150,4 +151,7 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); + +void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, + bool exec_perm, bool priv_mod); #endif /* QEMU_PCIE_H */ diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h index 9d3b6868dc..0a86598f80 100644 --- a/include/hw/pci/pcie_regs.h +++ b/include/hw/pci/pcie_regs.h @@ -86,6 +86,9 @@ typedef enum PCIExpLinkWidth { #define PCI_ARI_VER 1 #define PCI_ARI_SIZEOF 8 +/* PASID */ +#define PCI_PASID_VER 1 +#define PCI_EXT_CAP_PASID_MAX_WIDTH 20 /* AER */ #define PCI_ERR_VER 2 #define PCI_ERR_SIZEOF 0x48 diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h index a39193213f..406dce8e82 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -935,6 +935,7 @@ #define PCI_PASID_CAP_EXEC 0x0002 /* Exec permissions Supported */ #define PCI_PASID_CAP_PRIV 0x0004 /* Privilege Mode Supported */ #define PCI_PASID_CAP_WIDTH 0x1f00 +#define PCI_PASID_CAP_WIDTH_SHIFT 8 #define PCI_PASID_CTRL 0x06 /* PASID control register */ #define PCI_PASID_CTRL_ENABLE 0x0001 /* Enable bit */ #define PCI_PASID_CTRL_EXEC 0x0002 /* Exec permissions Enable */ From patchwork Tue May 21 13:11:42 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: 13669447 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 D9D55C25B7B for ; Tue, 21 May 2024 13:15:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI7-0008JP-Hl; Tue, 21 May 2024 09:12: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 1s9PHU-0007i6-OD for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHR-0001Zh-PU for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297109; x=1747833109; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=uArRsAtZO0QeDOuLsYInkvN90lliPubzGjvNNTs8OpQ=; b=DrQU/LKv5jOenlEoyZoLQN8+ID9egfTYE2/5s8v2gJtkBcNUJ2PHPRY8 g24dMzkVbyW2gc+gZEt/UxOs1N4d+Cz7HZiNPTblBmfATAs4xbbHFFhYG OP0VLtOUUi26Z2yhJnO6iqAesFOTgRAucJPUg0XzDwzr1z6JqhnNo+rdU 1Dh2bYNxohxe+ypAK3Q76YAPyIG7hUstVW4nrmTdoIVNQlW4gGG6dfRK+ +qA5LULP7CmrSpRt45Hhx4Y/2IsMu0HuYXDZqnG4JNWdRq54N74cDeyS6 vfrgF5uaRaEy7aGJENoJ1O3VzBbo29ZyNvo+ikTfeUEZGtIlJ1jnSdIrm A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061501" X-MGA-submission: MDGLMDEiMuA9tmwdR9S42jc2p4jF/cXqufxVRFCeFuNXiavCb2MY1w1P6t8MQknTPA/fkuvlBS1v5JEekaczTK4JdZetYv8hwYfbb/nRJuVGdAAqbxK62Q9ld2sEgwHtIYXm3WLjvMdwBMpnFfLR8rVuXl+qPFSDrJfvDROsquyiew== 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; 21 May 2024 15:11:43 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xx6D2ID6N4aHqYLUd7dYrjb17gGbR75OU93X0+eTyp3pc5yvupNPOmq7q5uSWW5TTrRtGVxtgtKaxeaaXvLE8IJiyZtPIGn8VipHg+LPqAXJZh0VZCVqiZuj5Osht+X/aVDf1zlgdeebi/NUxDvpu4xNimMr/7HBf/s1tArKgKd/hX1t061d/UgQOeUKsalWfrETrIO/REh4AyNu3jRjHRGPlSpfzUuJNo9G1T3zhyKZzlbk8Jh9l9cAPaxL7BVsBq72VbKOqferlXdlFBumaxwATlGhRA9feexrYVUvEK4PbEYLBdKJmC7f3ko1GkV7gwbmZwDuK4ee7Znh5Ii5xQ== 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=uArRsAtZO0QeDOuLsYInkvN90lliPubzGjvNNTs8OpQ=; b=gze1v9EM++qwKT3/L56vz9Lim9T5igYcPn1wQvRSKre0KlW4gbC+ouyxEdCob6Y+EMfKyaIUPqKT0VBv9xKJTnd2e43ArTg61+2DO2IJHuY976MTu+LxN9HkNKKABTr/WXWM+ba93abcF8Hpn13+EloKzdcS7BVr9MXJwncZewQSLUJfYW+bQ3+JodqhQmtbKjb3pzRmn7njN0s6MYUHEZmVGhGYicWyPSC7zJqvN10QnmxJpla4RlLSxlKb9f/J96G6YMHAjBfGw/5XrU7WbGrxk363w9eZBNtmhSJg0ToHkPH73w2ok1Qe2yMwMI0ncm/i1JMUPDayFuM++pKajA== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:42 +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:42 +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 07/22] pcie: helper functions to check if PASID and ATS are enabled Thread-Topic: [PATCH ats_vtd 07/22] pcie: helper functions to check if PASID and ATS are enabled Thread-Index: AQHaq4Bs64wl4DvR/kGSdis2w1PqIw== Date: Tue, 21 May 2024 13:11:42 +0000 Message-ID: <20240521130946.117849-8-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: f629a2fd-e705-4687-6aa0-08dc79978eef 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?NPW7qCF6o/A5lKXExg52YPfUTkJZWFG?= =?utf-8?q?8/3URmNv5ZxAeip8IF1G6Wm48fTS3rPWqVV4/frjsP1WqHSPSJlm+NIArRsIX3aw/?= =?utf-8?q?Ynle2kidlqDZzkzYKrglNtv19usPFCwfD1UixuG6DuKRlioo68iInunEj1J+HvfE+?= =?utf-8?q?5ZwDpRF+xO9Kx2bRsNNOSSLk4RgtrIKcvSnO/JZN8ih+MyTvB5V3/CkJH0cHpLLGY?= =?utf-8?q?7wfYazJ1eaczkG6XTwQaX/8qQ+v08vQwlzmMWGT2otmZ+L2vzGdYtST7GqPCYBTKs?= =?utf-8?q?muYK1PSCsRhA3k0nOCvMjfzEPZLVCjAmltI1DYsSqSexzfAIQMyBDuad2chvUHZmc?= =?utf-8?q?TBrp4t3KwyVXrw3f2/HAG3cs40lrANNPqAjXC3m3hPQfSvl4SYnelgrFm5aGPIfXu?= =?utf-8?q?0KAPyH5EWPjVVs5aqqJeBYYQJzBA/9rcnaeBgV9c97l9pFYT4laZyy2yE9+Gex8Wj?= =?utf-8?q?ScDpb4TOfjq3SGZNpMvOgqeQtXiS7h0JCRS0O/krXXi7BeMdAWt2Cfk6UgJzKBTWs?= =?utf-8?q?vv1TQ7f9IJBGmHVyIUssSz8d3ML6PzI37WtXMiB67Wgl+H0pqu+pR2J287angvM76?= =?utf-8?q?/DW+7KUoTkvltNbqjgnIhsYGPs3BoQ0nS9G0XfLfVLQyFGUe+qDsfYvRWxy9mUxzy?= =?utf-8?q?R6RgnEgcfhdNWHp7vWCasYlloyjtUn2jJbcbKZbxkAzavXjpo+oa84a4IkxlgKWPe?= =?utf-8?q?7gM6WG+ouOjUQMkdaiv85KAP1qI4+RMsv0/a/XYe55QclYreS5Ii9YR5JAVycCHvy?= =?utf-8?q?luWOgQw+SUPUoHMeSmEd3xnxcCY99gvEHWGs1Tz32Jomi3yz9W4DqAJP3gsSWeTaZ?= =?utf-8?q?HSOPl1GrO8YDZ/NeidIjryHfQVTaI6hSsUHnQq0vDHDMlURDeKCv4acmrv6qa5wWh?= =?utf-8?q?Rg6CwoCfo0yuPEmEcqtPFXQG3ar+lmCAdeIP3oLl6E8p4tsr6CuSu47rhTTEpdS30?= =?utf-8?q?pMBHwPgLqdmTe4uSwGq+sYufc4GpQbLUt+Pk70xNCbECSvwUEMdq4HPG28GOs8dO6?= =?utf-8?q?ymVVi9Kr4ox1PlnHr51lyyNf/bqYFcrwiAPq43ivvUyzBh+RBnLIoJRYukKg7loBp?= =?utf-8?q?OYxSjNWf00IDU2cnqbo+27wkiPulg6ItQMj7nRsahjlMVb0vciUiHkgbIBgt9kMYo?= =?utf-8?q?lQg4wMOtPJtEU7r6uMsCT1zG2XBLcuy4N9D+ChLjw7mAHKVcHhVveEvtw3HjPGg6O?= =?utf-8?q?axll5ujVAq4tymfe8MsLQAPrrQvg7gNT36+KvT19xcLM/AdHQE3Jf8G2rTrLnHBVJ?= =?utf-8?q?VjVOeHsg0BRFWit/UyAI8kMYKbGpEE0hrIQ=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?gpm3q4zvDns2am8qJi8t/3PxlfBI?= =?utf-8?q?Dw/197vmpXJP3s6EuG/KfaXD1/hBpCq1BbDS4zUl5jxuPWRQyiwDd6r4hJIefI485?= =?utf-8?q?focLFzFvbxc1wED3kzDanmmPOQJnko3sB60nMRpnIvkh3IKP44R7msVvbcYKaFghR?= =?utf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jSUOA8KrQM5GXyDgkMzJ9KXY4T/aY0B6nILlPlUfwGCC5g9Vs6Vi0?= =?utf-8?q?ixzP2FjOYXsoY1s3KEnTq5BMca61uZZcyQ70nohZ8qAQciW0xwQqt+BPEHo1VAGba?= =?utf-8?q?RC12quGYMrwgPSMU70ASCwbmLtFl5umyeMJ5Ot0NdyKcMgqN9gyN3/2JI2HL9syf5?= =?utf-8?q?5KM+JYAJF6twcWcZNUSj2vjqcYavPQltkNWEokpPclZ8v5Yxvhyrjual2r6Rt/Nd/?= =?utf-8?q?zXb6X+/eHE1IGmsmqn6IawfsvmcRb0w3diPB6TgNrXX+SFzBkCYOFz8GigQO3KnJI?= =?utf-8?q?f72PNlQ1/xhDMtPA1y8osrT5i3q34VTUMZzhoJn2GBIoJVNOu4nT3Humgnp3yBJh5?= =?utf-8?q?rgPdjR1zh3NZ7yTuwDLZyLyIbQUj+QO5AdXwdC378G4/upgngxlL8TXgNp4euZelv?= =?utf-8?q?+ZBo83kT5XLk7qS95oZMXa4CPmztJC5m4SEeAYTyNBBVW3iwwtkGwFe3gSpvzXUa+?= =?utf-8?q?gDdskAHF9necqsQNu943gnZTZ0BS27J2BbF50ZYGCzqZmyQYbcVBB3E=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: f629a2fd-e705-4687-6aa0-08dc79978eef X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:42.4223 (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: AOjSLVrAJEWxhhAqGwsKjlaFOuAUvlMYLyZ4ggf1eQzv/DXWuKyMJHuH8JC5Z1qqWHb45h/y3o5Jmnsl0yT1vU0ZUtWUkt9TrWTzDw6IRQoiKnXUEGUDnoUXgnPF9L+/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 ats_enabled and pasid_enabled check whether the capabilities are present or not. If so, we read the configuration space to get the status of the feature (enabled or not). Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 18 ++++++++++++++++++ include/hw/pci/pcie.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index d6a052b616..4efd84fed5 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1201,3 +1201,21 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, dev->exp.pasid_cap = offset; } + +bool pcie_pasid_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.pasid_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.pasid_cap + PCI_PASID_CTRL) & + PCI_PASID_CTRL_ENABLE) != 0; +} + +bool pcie_ats_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.ats_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.ats_cap + PCI_ATS_CTRL) & + PCI_ATS_CTRL_ENABLE) != 0; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b870958c99..0c127b29dc 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -154,4 +154,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, bool exec_perm, bool priv_mod); + +bool pcie_pasid_enabled(const PCIDevice *dev); +bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */ From patchwork Tue May 21 13:11:43 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: 13669430 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 93D08C41513 for ; Tue, 21 May 2024 13:12:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHg-0007s3-Vz; Tue, 21 May 2024 09:12:06 -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 1s9PHR-0007fZ-Vi for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:54 -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 1s9PHP-0001Zt-OH for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297107; x=1747833107; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=FnPgbHkC17ljlEVDc30FuyLZ9hqEYmiwbjpX/Fru8IU=; b=FRGxHm9Kw5wTtUaMQLEqgFz5BCkIXR/UFIV3pZ7qD/4ZP70lTkNX/HTK zHCCFt5YHGw6B1jrSP3kUvrPk+bQ/mEZDy18OZPYG+TYCalDxE6JwmVaO F+WTqrpA6CwO53pM902qcYDorlbDa3edRPYVFDDwfmbe3o3OkZSF4LtHr CM9HlbOFbMdE8ODYGfgdaeqACYAJuK8ShQA0qWXatpytGlGSTravo3Q09 L+CpJIQEZkfBbE+DznN5eBB2wc7B9+y/m/AdYUxAkvYFZOYe92YkLP7yZ 2px5ZaT+wHl2z7Q1ld48X9yA6udvLITCaIWIko3kDiRBCrfyG9jm2HE5i w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13004102" X-MGA-submission: MDEj2JkUrBop8uMRj8lln2EQXWm4iilFzeZHCWqi2Ec5ed9pENb8IOm190D4CPe/XIX+FzqNdi/F4r2HHbgOHUosMBO/nQmDBwOLGz7hfS/ikR7orEuL1fN7gUT5sdN/e3BrV8Xwgc7Wwtjj8L8g9r36pOAYTx0/0qgrtmjWWylbCA== Received: from mail-am6eur05lp2104.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.104]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:44 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lz795raY1HEtpDEbbQi7qbiKkS4ftilrRj2TLrPXucniVPHI94vBmjxplFu5+Mjs+XZgGq5Kjjg+PpWqM4uxFIfXPMmczTGOj+2zKVlNRoQoUj54IpcPpCPrSbNC1omsdrI8Mc99nzdJ5z5Qt9D8kYfO0AsV1PkJD8UKnkHRxZVIJxqzLCe/AjgbqLrTgd+5hd8ngnjrLqxL77iJm5Oqy3tx5NoAh20tenUFTzHu34tjdMrzMmYUeMB8Q2POj3hdfrwFnDiVEzxXVQJ2ar4k5dsdCBqrUU/f4dfk2fBws7uNdZKjS8RpWrmSxWnpmI44GpK7TIeoYLdZYgh/CLdrxw== 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=FnPgbHkC17ljlEVDc30FuyLZ9hqEYmiwbjpX/Fru8IU=; b=LtkBgud/A77Enhf+OPAZM7hgCRlnKtZT5WR3l5UUdGUXIDGOVAJaVrT74xoNCQb/yvHgY4XyplAEs2J20eyKxSGD8iCTYf0Ii5jyyXK8DnZHybVmURA4FInZFS5g/cmg+qYg85Co1PXrnWjc+EZl8nONjHpgABZPVuXqzkugIFciv6gU98zO1gbaGFtKMDV40NDqzU0MxNd6z3X55G4btYfAzxLMMfIXQnrQsBnvx4MmwjV/1a9CijKznnsydX95t+drhy5xSMh7ofIVL7hjJES3q1nw9iSqn1Dzf/J5mpd0GRpnIeG8uQoicf7rPzYIGnnq6YhvE/kkofQQXNpicA== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:43 +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:43 +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 08/22] intel_iommu: declare supported PASID size Thread-Topic: [PATCH ats_vtd 08/22] intel_iommu: declare supported PASID size Thread-Index: AQHaq4Bs2yEvb1zyt0O4idZ0yyytdg== Date: Tue, 21 May 2024 13:11:43 +0000 Message-ID: <20240521130946.117849-9-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: d7b47cd2-a6f5-469a-cd0e-08dc79978f4e 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?8LohJs0EY/r0QNI4ySFnoRxRdrrHUGJ?= =?utf-8?q?N7OpzZIhG7+MMvQMIlzCiYAGFnKiA9pDP00Q+tD5YmnEJI8vpmSyTBMC6ydK6EoYI?= =?utf-8?q?GG+mg4jNCs3jMCp6qb1bptaSBjHICjXkgqgYBUuHUi84XRlAaq+DdEbrRZb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B1?= =?utf-8?q?Iu4OmCxBNYkkPReGXNtKhxooCBLZjxvlOT/L+Z6ACxQA276FviDMt5aJJTcfATXqx?= =?utf-8?q?qBPSkJk4IWctSaqGHjj+aG4C+VgmPSKIsaH2Yf1XtXxRKHFgg/z27CpvgRGmSoJ50?= =?utf-8?q?BvL5F3jHUoDKxc5m99eOUEeX/H96+hVsFqvfcJr3jLmRoUgjLrtp8ed+1R4ENyYwd?= =?utf-8?q?KZD/7xInOVeG2Ht9+qw5Ec08VHGAmiufcgsliPohLDihULGhQNwQV8e9tw8nUgu77?= =?utf-8?q?FbRmIrLYZfJAg/UdG/SLM1mvfwHDSFMjdew=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?3qI5bSnrjB2m0ocVvtCR/TysITRr?= =?utf-8?q?4AxjwsZmHEKVLZIT/sbYocusOdetISRFmD3tOnytd+GUWrE59WtRhczg7+DS8AQGb?= =?utf-8?q?pG5wafgFFjGeeSMrKmMzsE3Z/iHqkJxZk3rpe3LUt6+9/3hohgFNVxXrmmkeWh/Qi?= =?utf-8?q?zahFvyLF1oRCDwB+Wu8lMFJ7EcuWktDXK/jUbgBMDk8AAegQ/ZYzCHRjZyukoRGBg?= =?utf-8?q?iHrCqmlCCVJzGf1oI1fBQzz4qU6O+6HcnHne1ksmUePVmruJYW2RvItDXIm9NyHUQ?= =?utf-8?q?05jYUozb7yF4DuFHanvPcsGt9gI12xyodLIm5m6Zf6U9jGFMN3+Exsae047EDQvQv?= =?utf-8?q?SZ2yHQsGQOFm9S9OqdjwqdZDB8zOYFNv78sGbnKza5QuuFC+P48NB2nUFYLgjrmmV?= =?utf-8?q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9vDVz1Csa0put+ffrBuASrzq4UfnmSsewq4ltTiIPTY29ezEUNhD7Py2lnUpRkbUz?= =?utf-8?q?/ToslSXYhcJmr9XkJCYjkht8YvRAGPyJfHReowvtehuXvo6p8ylbuybGRyGfS9mi7?= =?utf-8?q?P63tP33zr5VR8JfwJngXKGDXvSoFfeaCd8w10RRw3Uu7lzTyxjJCzO5amyCAy+E00?= =?utf-8?q?bM6yX2k3KwQXHUOfKNl6spJinly6CVHUJ3Ih9CYupuRKB3wQiVWWchL01PhvDRC7a?= =?utf-8?q?oYgYYgrffSewVjuuN5L1s95prC/4rK1d3GfI0g+iIhv0RLwwKjqomuA=3D?= Content-ID: <7CE2E44260B3C64CA8DD1EFE3E8F669D@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: d7b47cd2-a6f5-469a-cd0e-08dc79978f4e X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:43.0530 (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: XYq8OjzzHSyK12DNRmdq/b5vKWXxCJj0ECHFtMXea4YQbRfpCBVl3g1ndGlmKsw5+BLC3CltOKj0zXeVAwlgQFM7XQj8nBOSvtH4aik7q2Uqmjn1zSJRC7bFYYu9exfK X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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 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 | 2 +- hw/i386/intel_iommu_internal.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index f71c04d370..7d86a31bea 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5838,7 +5838,7 @@ static void vtd_cap_init(IntelIOMMUState *s) } if (s->pasid) { - s->ecap |= VTD_ECAP_PASID; + s->ecap |= VTD_ECAP_PASID | VTD_ECAP_PSS; } } diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index c9a673585f..1b0d8958ad 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -194,6 +194,7 @@ #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_NEST (1ULL << 26) #define VTD_ECAP_SRS (1ULL << 31) +#define VTD_ECAP_PSS (19ULL << 35) #define VTD_ECAP_PASID (1ULL << 40) #define VTD_ECAP_SMTS (1ULL << 43) #define VTD_ECAP_SLTS (1ULL << 46) From patchwork Tue May 21 13:11:43 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: 13669429 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 91EBDC25B74 for ; Tue, 21 May 2024 13:12:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI0-0008A2-D7; Tue, 21 May 2024 09:12:25 -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 1s9PHU-0007iC-Rm for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -0400 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 1s9PHP-0001a9-MQ for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297107; x=1747833107; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=CKam7zb8e546M/TrGYyCxbXf0VqOaiRtn7XcC+gjZ+8=; b=EzrNN85aeRGupVcuLLnKfvyeaj0oQLeU70WJ5cnuUzD7chRfnwQRFrA4 ywSGWpiiIM5nvp2dKsKPR+F3hzjQFND70u1o8GxVViST4XW19ynpBCpOB Cc4jYO9/XGv9poxBZxYdDNHDiaSFO4fameqewJAWGycq0fboJboTSc2E3 aALhp3vaAkUmI4I40s6iCJ4O+9Oltu4JaGSnHj1hWjsNWEAfiJxdzvemM mNCTGat9uTTpoRcBfvujhDbqLLokX/Hnk0mq0v4wDM75RzcTw7srRyHvv BT6C/vbjk/VRFbTFGgS37HLnY82SCi4nVG9D50pOdCe/HddKpc2I9BvMd g==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13011524" X-MGA-submission: MDELFSXt+lGXbIMvEN48Gstb8L213TGh6CoikoJ5zmPAbRet9PT+6o23E+sIy9Q1/zmYQrksGWHw8/CzOkMsSEaATDNsknm2wpE8IxsUKnAZlgHZ/JU2gzLAjT2Z/iMHNgF+Uu7xoaBZEFTmGE0BgF35XnxV6NUnwYuTkiPcaX7FDQ== Received: from mail-am6eur05lp2104.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.104]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:44 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDGyB2jmbBR0ouRLgSESkwTx5HXL04ZtS1xfrGLmZM4hXSLOdSSXaVnasQ+5d2hMzrzVph71eiCkZJfJwJ37Kfv4vUV9OYPeNiyvPfccoify2cjqvj4x0/Q8jgdEat48BxXN4u/63A0lSJwN7Q6QQiY8rcc9leXJCPbKqjB/7uWgI0eUaNQZtXjA0WOaima9GdSzfM4Tb1KP+FXYAffCyAtDGgerLWnwZCOa57YDdoDguPxBwHhzxbPgNi/1eCHFGrSX6Cb0ZQ9sddvStheuuglFsrXKq4NUrAaLgHdKemmiENupRItY2NzUH0idgWOvwz1V1shWw61vHbDnybJzpg== 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=CKam7zb8e546M/TrGYyCxbXf0VqOaiRtn7XcC+gjZ+8=; b=noXeSnSmDI4zd8ymeN07HdRPFqbLhdaXC6sbgB9PxHGz/89PdBr7hDQpyKWsFNUAgEbKzaHxEWS0FsFS0f1DUhuWMxN3OUGeCZfdLj//wzObikui6MdRQdcSJ6Nf3z4iD8eAI2xFfnsG29WB+epFc5GbE1nFF/7PUY4+FUTLQXlc4SueyHuCRzj4FJ66jswni8YyONiHOynChTA6ASkpcnoLnc6bJoZ0mINhMi+MWtQf28pImQ/Bj5uGalZE0EekKSCZ9He4pHBUJ8/SCfOYIsvbxcXfYlqNYwNE0DXEPO+KqqHjZDU4IMiIBKuhHiJpGKhkEWmHsQhY0Qk5/gKw+w== 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 AM8PR07MB8148.eurprd07.prod.outlook.com (2603:10a6:20b:323::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Tue, 21 May 2024 13:11:43 +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:43 +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 09/22] pci: cache the bus mastering status in the device Thread-Topic: [PATCH ats_vtd 09/22] pci: cache the bus mastering status in the device Thread-Index: AQHaq4BtCDCpPNoyckSYkgx7CPioGA== Date: Tue, 21 May 2024 13:11:43 +0000 Message-ID: <20240521130946.117849-10-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_|AM8PR07MB8148:EE_ x-ms-office365-filtering-correlation-id: e15cc6da-fcda-428e-acfb-08dc79978fa4 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?6mDAmV6VfUdQW+56qvMPN7oOJvovVSt?= =?utf-8?q?Rp+CYcH/klrrtQziHsb1BMNBu9LUQdfLwKlW+u/q/M98CCUck5A7E5ETowre0I/yl?= =?utf-8?q?UTjJ8idVmvOoBmJaSA6CxwPi7m077jlIDA/t0qXxMghDc/wqeMFbnYoL7LjVu+6zr?= =?utf-8?q?/iuhlTB3rB8/5q/AMVfJ8TIn1hlBvha4kZNXo99dLe8rAwZkEPBYfV6b7WDY4+5b6?= =?utf-8?q?q+mRVg0KrQvusThI6m/dYFyiNrLnUkf1TS67Cpf0YgvsBRvAwm1F6VRfJCVWSTJlB?= =?utf-8?q?7fXUnaORgwEnj6UHWYk7Uo9GA9bvp016NxXJPp9/lrdrEBSMCXWuaNZqgZ8MJ0Q2A?= =?utf-8?q?DOZ9OrAOSx+bY/gPq4knmKrOEf1jJp5w4lblTTcAAxpRx5a80/a2QBHs160n2HJTH?= =?utf-8?q?rnRwpq1Gl5xw6NfoMbCoJBUpiUqnesGyQ00Vk312cL32FpQ/kJeDpdLkXwFwM7kTc?= =?utf-8?q?bSxL/S+RrXmWTwJuQ0oSy4rznpAmnr0WNq+fitB26xyD9dAervtBj6XCLFBDnO/eY?= =?utf-8?q?aL4LNEZl56ivUskq67ygXTmXeLarvZZ8glRGZiDp4KSoqcPjZxPFFaXgSXrENdncT?= =?utf-8?q?N2vEufFnhRDUnPPtAhlsC4UQvBqBJujnTK2H8+A4JDJreSyO2b3LSXZKrbc++ctX2?= =?utf-8?q?JHa8JCZrZ0VdQFEV4cua9ckcWDyHhEk3eqyleHle1WpjHZMmDGNYsb6JCVbm/6+tO?= =?utf-8?q?Y0XqpYrLWrCaoDPplE0PV/c/6ffkoQXkfNee1n9vEC5DL16cTotkk5YpPYPJydRBo?= =?utf-8?q?QJXA/Hi+5dYjSGDOmsi2htLmrNk3NmQjSTN7Z1aFLSQyUXDlBxM/LeaW6kxoiohjo?= =?utf-8?q?JadW6c7czwVgZFO+30da3tlqxvC5h9hmCFgeRiLFMDFDlfptbXSRJar5+gnKKmA7d?= =?utf-8?q?fGYZf30pHjcz4YjRPsUfg9rO4ljdi5U7x9QVN7LbYSr41yrQoWIIvftvNY/y2IdPB?= =?utf-8?q?iZSVPTWz9H0GE5kjQU66f5hiS7GaDvp2CmlkFeOIei6N/YXSG0fRAWEV0NNRC/HCE?= =?utf-8?q?s7YwyvHJOh5nanHn9ozYY3eWuaIHy7RekMg9WhtVc8rDASKEUAdi86kSu7ae1JbBe?= =?utf-8?q?T98hXABDzrkrnCHwgxhrSrRas/0UVXdJ6msd3tQcRJt39CQU7D/CqWJODujsOKOvN?= =?utf-8?q?LTtIabMeRmDznidUe8zDGZGagmf2sJNZm5rtPmi/UIwYtKy9TnGAnSAiiraydThC9?= =?utf-8?q?f58Yg58jQWTNZ9hajMb01Xk5YXeDMNDBhlNViv1JShLkP1xRRt5yrEgmllwIYaxLl?= =?utf-8?q?mAJVC0WL21ZcTgPeQ7iHlhhlSsgY37MCYLg=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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yvom9/+ddynApo1rqS3EbPNyuzzWRFWRsDzIuOV+IrD91UeINR?= =?utf-8?q?Gi5P8hxPBH2/g0Fci/pER6pj32JdUCQvmeC8ECeo+6dyXt4K9CmFQj9NrN/g2rBaX?= =?utf-8?q?Pug2oxyB6YjjbVAMFvisJkfbLxuY6vrdr2tCmRUXRL5vwYeFKCdBM2CDf9xokQinh?= =?utf-8?q?ga8CNhbN8k0l8czI828qEbFgZTnmC/JCxghiwZS4zI/5AUu1KUDNqJzIl903My24u?= =?utf-8?q?oskDr+TDd8vzIXi9kb3MJJAg3mrY8tkq0AMPEkapWCvYQhTN9UsQrmoE5a1n59siZ?= =?utf-8?q?A8D7Ti2fpEGel2FixCofQMEjkrYvVl6PETNfz4wIN4Iemm8/r97wOsKEEnfY5hnuC?= =?utf-8?q?/zOBJsqLvUZnxIV/fKldSRo92O86eIlTYDMfSu+Y+sKO33fKyXdOjLdAu2WSMXOG9?= =?utf-8?q?J28C8ZlNvFwEIowgTLbK9xMP/P5bjzqBhlJzqk2e2tl386VXjWMbOMAWM+LgUBQoM?= =?utf-8?q?oMmNnsQT7Sqw/+09Z/kcNlX0O1nmByugHtO3s3t6wmAcY/D9MEIjiFiepgi9nVHIA?= =?utf-8?q?ZvzUInYloP5f2c4Zc1RjNN0rMoH2op2cpg1l0mGRZACQCOIbpYdX4aB50c1euKs+C?= =?utf-8?q?99hOq0f+ew3fhP6P/phoDoqxtyvLnBABSYlNmy03Ejq/RDU03kaDJYK6XUBGG7J2J?= =?utf-8?q?46shQw6CwI8fl4mytcqijLDO4jdOQdQ43dMYzBerh1A44USs1G7gn6c=3D?= Content-ID: <7561F19B2814E945AC1BC4EE055D1EA6@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: e15cc6da-fcda-428e-acfb-08dc79978fa4 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:43.6658 (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: pa5f9pQXLZzOmnYmtjZ1hHolt0tGDHz303oxSHNYbeQcEG+OqW+aJRsgU2cTp9Jwds008HYqbUSQxvfPUMkjov0OXX9s4pWANMtVq2qV00DFckNRlMftMAXLA0y/GIRj X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8148 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, 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/pci/pci.c | 24 ++++++++++++++---------- include/hw/pci/pci_device.h | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c8a8aab306..51feede3cf 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -116,6 +116,12 @@ static GSequence *pci_acpi_index_list(void) return used_acpi_index_list; } +static void pci_set_master(PCIDevice *d, bool enable) +{ + memory_region_set_enabled(&d->bus_master_enable_region, enable); + d->is_master = enable; /* cache the status */ +} + static void pci_init_bus_master(PCIDevice *pci_dev) { AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev); @@ -123,7 +129,7 @@ static void pci_init_bus_master(PCIDevice *pci_dev) memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); + pci_set_master(pci_dev, false); memory_region_add_subregion(&pci_dev->bus_master_container_region, 0, &pci_dev->bus_master_enable_region); } @@ -657,9 +663,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size, pci_bridge_update_mappings(PCI_BRIDGE(s)); } - memory_region_set_enabled(&s->bus_master_enable_region, - pci_get_word(s->config + PCI_COMMAND) - & PCI_COMMAND_MASTER); + pci_set_master(s, + pci_get_word(s->config + PCI_COMMAND) & PCI_COMMAND_MASTER); g_free(config); return 0; @@ -1611,9 +1616,9 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val_in, int if (ranges_overlap(addr, l, PCI_COMMAND, 2)) { pci_update_irq_disabled(d, was_irq_disabled); - memory_region_set_enabled(&d->bus_master_enable_region, - (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + pci_set_master(d, + (pci_get_word(d->config + PCI_COMMAND) & + PCI_COMMAND_MASTER) && d->has_power); } msi_write_config(d, addr, val_in, l); @@ -2888,9 +2893,8 @@ void pci_set_power(PCIDevice *d, bool state) d->has_power = state; pci_update_mappings(d); - memory_region_set_enabled(&d->bus_master_enable_region, - (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + pci_set_master(d, (pci_get_word(d->config + PCI_COMMAND) + & PCI_COMMAND_MASTER) && d->has_power); if (!d->has_power) { pci_device_reset(d); } diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index d3dd0f64b2..7fa501569a 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -87,6 +87,7 @@ struct PCIDevice { char name[64]; PCIIORegion io_regions[PCI_NUM_REGIONS]; AddressSpace bus_master_as; + bool is_master; MemoryRegion bus_master_container_region; MemoryRegion bus_master_enable_region; From patchwork Tue May 21 13:11:44 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: 13669431 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 CA05DC25B7B for ; Tue, 21 May 2024 13:12:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI6-0008Gr-Sc; Tue, 21 May 2024 09:12:30 -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 1s9PHW-0007ie-5u for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHS-0001an-Cy for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297110; x=1747833110; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=3fCaFwfQGrgfgVmWEfraFRxRnf0Uq2+4zgU97Hu//68=; b=FxXprDypM58Fv+2fVgDwnfi4Detzeblh/2sa32IlvBVFIkuzSwCZU9Uv r1BSkcNxYHVtBIzJNGXhM5n0626m/oARDx6F/D7TlMYhDEnDsZZ5ugjIE uSVLF6kVYWb+jalO/CnKDmmzrxSf/tBkqnRTkO9VlWV0RBZ64bw/NktvL zVmIEsP3Fx/T4WVm+Df6yBrsPVN9KaqZg2ideNkCwiHMfcQYQPHXGeJn2 C+LHKRlGQFF3W0ZQNz/Y05Tx+U0IE2gsGod71lqCXv4oc86vhnp2s2AZ+ iRn7fNg3ZOlMr2rSsGk5UFFu7ihvMlBkey80SXFsYyrKJK2TSQ17S4MFK g==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061506" X-MGA-submission: MDGtbafTfxr6W+lytm0q9PlnLtGNa92s91gC8mD7cSpxrwq2t8cf/60yNH9sIbbcn0WC4rkjL3B+G8c0r+pJKpzi3u9YJ8f/uDd2YUDgf2ofg285NQ0C8vrJEyv3FD+vCWzfDSCHAGxjhob0xRdhkwEpqsXWY4tYXVW8hr3UllutZA== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:46 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNaGI7trFtK/3iS+7Xo+1SIwAM7h11sz7cXb6D/JeJYqr8RtBh/5KBudMW3XCjPzxOFAK5iEennjAOzf7ODd2Sbmpjuy4aiwPi0AqPUaZCzQfEXkYZIPqDrjiSAm0laNG/2vXeFy2M2dO4m+34cIEccKcbx0juOqNPImc42/XAuOTyjRWk1Xc5/2iPylJAxLPQe+ymdxkKbyP3loXtlPH3zZd0OW/0ltnzCg9sQGMqCEwd5KhA08pMHwCy1+8EjkEye4wZrJKjO2FZsa0r9WCuvVfLo1JSkJrjyYgacdMj/aC7/bhqT4cBUj8f76AOwWCjBJvDJwn44RkbTFLnvpXg== 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=3fCaFwfQGrgfgVmWEfraFRxRnf0Uq2+4zgU97Hu//68=; b=inaqWLOiOYdQW3nGfvKNtJLVqxTXldDXk2D4kLHIPzzzxwDI1hekFgDLUJf1koDAER//Rs35YiW8b1ykEEfzrai8RiJutZEOE90vl3UWWFbabf7u39iDsy/VXHiUVC4mgBjjQQ+8mD2qL5yxtJ8d3UugP0O9j6z8jHfMlWQCKXNABrvnUNPy5AEzLiLB3EGy3ACOazyMHNuj17yofwzB5uATQ4Hhj0j9UArtGllaNL4o9t3ditV8Y7IBoDPFAa5kL9hZd2wHb3VkEkZiPmm3+8cqfcwbvMhBFJ+6LtJynPR1QZxCxNvU2faco47VoC+e+x+1bE7X5hsAAEJZ2hImUQ== 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:44 +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:44 +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 10/22] pci: add IOMMU operations to get address spaces and memory regions with PASID Thread-Topic: [PATCH ats_vtd 10/22] pci: add IOMMU operations to get address spaces and memory regions with PASID Thread-Index: AQHaq4BtilJD6RPkfkmwyxJZ52pxwA== Date: Tue, 21 May 2024 13:11:44 +0000 Message-ID: <20240521130946.117849-11-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: a52fbe34-9bcd-479a-ad27-08dc79979033 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?ktrIqbEiMsf7gzdOoX4x17c3ElR3HdT?= =?utf-8?q?LuOhpbUG66lUNJXfZ2U1vp59GAuRYpFTYr8cERTanhMLITOem9kDfUkAms9llKdOs?= =?utf-8?q?lUR7erYcJXmGrfyTbBcNMFLw6+KOCdYQpL1RagWH0HO2HhmpdbuVweapsf0dvrNhw?= =?utf-8?q?wMgH2guQNHSal8GQlVxksKqwzqXvYHwxD2TlQjusDjpSjuMyVKkXPQo9bkgkrPmJw?= =?utf-8?q?cw7SAQa2mAV5SvHMiV4bRC7jv7HvCHtCmhpCJA57v2+dcBsVwVJI1AcE1Bv1Y/Tb6?= =?utf-8?q?ck956C9VFcLtfYa9+n+1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GCl00jo7ofwT41bom4pcykqsgj/hm2spYdUzTjJk?= =?utf-8?q?ERDcUc2kI7d/9x2gVV+yQjslbPPArMOck+R+ndjL7k4c28Qn3wPN6SJilOm2v9RtV?= =?utf-8?q?3vQ9x34AZOt/NR3ZmhpfEBQPZWVFYghIx3A=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?dUsWu3yROdoLUmE20rfeL6avPOJz?= =?utf-8?q?8PR1l0Lgr2rp3e0TtpJe7g6VneiOFlaJEkbSvA2Opj/myeZVdNw5R2wWcCIZ0rIX6?= =?utf-8?q?nIWj0mzantw3T5i9QUMNZr5YA8UXcVLsfPfUonxqvVk9HeEhTaIoHifdFPi5aPYXx?= =?utf-8?q?1yoYY1L3YmGwfnRZPHLekeDMo68QxzWiGPiDO0FRZBQjMZZknF9L+yg8NzigbzJu7?= =?utf-8?q?uGxtvBU9TP/P0b4cCtMwcTRxWpl7fmBsTtHLbt7TO2CPFT+qWjw2kO+ngnIGQTj2/?= =?utf-8?q?KiUQw6FxP9/UQaR0mh8CBoy+es1aNRMgHPaRPNK3f7w5G1UU1TcB/LEzV0WxgwIYR?= =?utf-8?q?mQGBNHXeX+UKAa2YF2R5m9CGqRM2nv/jSFCtCeRAhjvmXNBYpNWSm/zDUV+GUZfiv?= =?utf-8?q?hhiZtWXAYt8N20+Lhrh1uiWpzmyMA6kXeetijf3XbVTkw+MysxXxyluCLiNps9aVl?= =?utf-8?q?aNsvBOmS8bIWr4qn8t6a04XmqD4lbF5dIJdA0hDoxj9dFVVMYtHZiU8LoSadXyb/c?= =?utf-8?q?g0Q29FLGT7Zy6mD0lUTVfTIijpfSFt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EAd9t+xTPHa9yxnJffd9ugt9nE8NrZdZAMSkvnzx6bAHMNL?= =?utf-8?q?zGD+mW3dwm2CJifQI412r/gavQKgrjNMxa49bM7JjKKED241R90QEK1KMt1Wi0hk+?= =?utf-8?q?T2lO+IbnHOMpnZDKwm03+YbaN8UbfndqhYdHdsh2DC4sSCkkLhaF8cg=3D?= Content-ID: <1D8919986CC53C4D9298509CB75EEAF4@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: a52fbe34-9bcd-479a-ad27-08dc79979033 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:44.5708 (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: N+cdNNKT3sf224fwfkKY6m/E6dbSCotR/F/KwvQ1EWeRAm+NrOEF7VjQ2E+MxPaoWqlUumzdKEvJddg2QVcHS/YKMmkZchX+i+ktfvAKdi364Yps4SSOoZu5pYMnsrfk X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 Signed-off-by: Clément Mathieu--Drif --- hw/pci/pci.c | 19 +++++++++++++++++++ include/hw/pci/pci.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 51feede3cf..3fe47d4002 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2747,6 +2747,25 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) return &address_space_memory; } +AddressSpace *pci_device_iommu_address_space_pasid(PCIDevice *dev, + uint32_t pasid) +{ + PCIBus *bus; + PCIBus *iommu_bus; + int devfn; + + if (!dev->is_master || !pcie_pasid_enabled(dev) || pasid == PCI_NO_PASID) { + return NULL; + } + + pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + if (iommu_bus && iommu_bus->iommu_ops->get_address_space_pasid) { + return iommu_bus->iommu_ops->get_address_space_pasid(bus, + iommu_bus->iommu_opaque, devfn, pasid); + } + return NULL; +} + bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod, Error **errp) { diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c84cc9b99a..6c60f7a7c5 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -385,6 +385,38 @@ typedef struct PCIIOMMUOps { * @devfn: device and function number */ AddressSpace * (*get_address_space)(PCIBus *bus, void *opaque, int devfn); + /** + * @get_address_space_pasid: same as get_address_space but returns an + * address space with the requested PASID + * + * This callback is required for PASID-based operations + * + * @bus: the #PCIBus being accessed. + * + * @opaque: the data passed to pci_setup_iommu(). + * + * @devfn: device and function number + * + * @pasid: the pasid associated with the requested memory region + */ + AddressSpace * (*get_address_space_pasid)(PCIBus *bus, void *opaque, + int devfn, uint32_t pasid); + /** + * @get_memory_region_pasid: get the iommu memory region for a given + * device and pasid + * + * @bus: the #PCIBus being accessed. + * + * @opaque: the data passed to pci_setup_iommu(). + * + * @devfn: device and function number + * + * @pasid: the pasid associated with the requested memory region + */ + IOMMUMemoryRegion * (*get_memory_region_pasid)(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid); /** * @set_iommu_device: attach a HostIOMMUDevice to a vIOMMU * @@ -420,6 +452,8 @@ typedef struct PCIIOMMUOps { } PCIIOMMUOps; AddressSpace *pci_device_iommu_address_space(PCIDevice *dev); +AddressSpace *pci_device_iommu_address_space_pasid(PCIDevice *dev, + uint32_t pasid); bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod, Error **errp); void pci_device_unset_iommu_device(PCIDevice *dev); From patchwork Tue May 21 13:11:45 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: 13669439 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 2F610C25B7A for ; Tue, 21 May 2024 13:13:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHk-0007zk-T3; Tue, 21 May 2024 09:12:09 -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 1s9PHW-0007ih-IL for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -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 1s9PHU-0001aH-S2 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297112; x=1747833112; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=1KP+zeK26x+doh2isKWRxN6rm1DzgfpKS4lDIjc+Dro=; b=Z4NvI3mVhBJq3qkXFTxC7fetvtZpzI642v4bMNLE2dcoFJUle7OziMjS FeasUswgYoDDOTuFoXrH3mPZvPVQ00ky50mIPoDUTpq5W+vvIlcwq3ZG3 thdrOHHCa2g3pmZfAqNJLAuf8uQ8AoHEwvdICFcMaUc4XrG0HjWPQkMht /TRZN1Ri1s0mUyeiScHWAmmBGhmQU0nUWKYYNc3H0E+BEaUx4wT+WAeDj DeJV7xEy/pOJCGHdTLIfk9eh0NEvQvLjq4ZJUxjec/ZHeEd2/ivM15vzp flqx7aLuJDPRMpE9LiSi2HVYb+idG+MIFVfq3iAGUV5uL5Lkhcc2A1U1S Q==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061507" X-MGA-submission: MDFTAb4y57vFCnQNzlJRHyL6rfgX+uPtyWF8N7RiIni/BgHazqgYbT/oAQutPB16I48K74vb1HdMwHppw8WQcBhPMCvC01p5YZC/jkcQsXYrkH1il2OSDttU/1VKPkKR83ibnRgFmzMS7wTCptEAgzeCLsRx0yuq+jB28YuFTEh+EQ== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:46 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N1VxaiidyN8T8IKzWgu4ODk9t+C4A4gl0HsIYnGAVxO/kWwje3IdtlBwDImSfa83M8TkcxgVYkHWYMYW3OG0Y9IRdemh1y4FQSsMlKFVIRk1+JMiKUs3m7JGGHPWKQ5yycSlHgdLFyYMGDJ7bhqTji437CPxrXkr1QD08+RML/bMEevVZp9p4+yjkjIXSxTITF3Ie06xs3JTJom4ppmP509J7o1CQUai3PGo5aHUZyccFSCP9dZ0KjVOrz+JyBqlw7bpX1F7RxHN+YSX5MQl7fZWD4+nbABEMJFeYmpQ+WSn80CwmXdyq+KVd3lABE0Bpx8aOmi98KoUJtdssNXi/g== 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=1KP+zeK26x+doh2isKWRxN6rm1DzgfpKS4lDIjc+Dro=; b=KfX3RcJvuULU3OdCKCy0NN/Fh/kjtgKFxNMgX/unJ3mIc3qCpxXhHIaCfqbFpwmJ1uNZM+fZBsJAEfAUDWE7Mf4pw8VwoCNah9iCwYHKoJxfFMTwX4YdEyOxgZxLkO1nxap5m+5zzK7FlAw4iccAb9Q9CrNWyXt0zlI+ggnMDHioZCxNi2749NjoVWajqM+x8P4dSCTu/QOZ1eWuNuwswkkt+ykRGHkjv2xhPkpZiHeD5KjJn8YHPlGydNtbY4FXrK//VgODZ9WRFOtilC5BoIgxCYfHuH9jTao6PhZowve3zo6y4J7JjLGYpA8LXDFoODrnP31luLBaRWdeFI+Udw== 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:45 +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:45 +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 11/22] memory: store user data pointer in the IOMMU notifiers Thread-Topic: [PATCH ats_vtd 11/22] memory: store user data pointer in the IOMMU notifiers Thread-Index: AQHaq4Bux/vp8d1aW0iFdkcO/MvXEw== Date: Tue, 21 May 2024 13:11:45 +0000 Message-ID: <20240521130946.117849-12-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: 72894d0a-45cc-408b-2250-08dc799790a6 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?AB1VpRLow6Qw/IbxANIhpIGUSDCYByQ?= =?utf-8?q?m6v+CMPlVlKT7+HP9bOZDnZeclo/7dSm8MMEIBUL0/vz/l/3+eEb4BztVKtAgC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zuNu?= =?utf-8?q?ceBV6YsWE5rRrHDa/mC/vx0qeWRfQYtKuy0lpKmcyHOb5vw+vt3Emc8ISFmCY0mvv?= =?utf-8?q?dhrgosq1HhUHUu8bo0QvIGcmbDCJI8m/ZQiNI320+s2h5H+2V3FLhcLt0A/kQJYig?= =?utf-8?q?azhcEHDeCt8CMh0zNjiKGPX1VA3V/PVwrK0EvkKWBmkU+JBQhGP/u+6qwCkcwMqm/?= =?utf-8?q?LIC0ygO6IOeF42OhJ2db+C1fhqdjNSxkRP77yet9Jq/jpAqGqMztJjDRvjKGcbhcJ?= =?utf-8?q?iEWPXdY7Q+ozniMrtLDCsotrte7witSptG7ahKbIfCIyI8Kwv6CjGqo3MhxsFCQoY?= =?utf-8?q?PGby45WevZtnoruw7BjCTQnps23tYYOpK8Q=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?Xiu4NNn5Tj9JhYndjMLZyCJv0pFR?= =?utf-8?q?ouRhWNIl88VEuIz+3xMvJpOdgrq/2UdgIOTnoOS/UmeKOfRHoFtM+5XdSwXgJvWil?= =?utf-8?q?1dY1nxu5R0s09xi1ig0qE2ln/7cPwS8ULPRylW2exbVbLO+QiHvZGvVhW6gUEHJ0e?= =?utf-8?q?eN9A1o/982f8mNsjVXah+S9phg7fvvjMKCLqHgYEwsWKAr4ALHuVY0FdTODu8EcA1?= =?utf-8?q?tHU5GC8OMBWgbOm2dPow+XYzt0ieQOUfTtV+Z51L/bgzHxPQY5STYh9xSfBC7Bsz4?= =?utf-8?q?2rTp2AzcOFEUMWD6IaV+mAq4POfnLU/VSTtRHfdcxpH/t4sGaBnyx4cgnxie/iW60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jon5SXxIj7?= =?utf-8?q?P8paL7/MA0nUI05Pq/PVKnUUJwrkPi6FZpuzBzzWlJIF7mHIQ6nk0YEXrznt3mrD9?= =?utf-8?q?zf/SjG6wR5ogX1dalkhP7LIt6fY/dhnPY//Hk9ZCmDmH6TXanjfBEnQN3AqzU8MBl?= =?utf-8?q?oGuG3uFAhhpkei2Pqo/QJLb0V6tlNYNaktf8u4UhnUNmQWpsFBFta4Z9bUWOPsYy6?= =?utf-8?q?TCcmmnArAPkJKbNk4esvD6ujn2KIoKyWdKWVuxxgFvSPKtwkFzCPPQcn/P4CECW+z?= =?utf-8?q?yPxnN9xJ8YzL3C+rn4zqAH1I1VaDnORjeV0tZblYw5XraeyHyirjL0XQCqe4+xFdH?= =?utf-8?q?2dzE92HeSUFPTrefEgRg+amgy9iBvv5SlaeWOgb5OiahAdHfumDP58k=3D?= Content-ID: <3B1EBFE97BC06346BB98F0D3C817899A@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: 72894d0a-45cc-408b-2250-08dc799790a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:45.3337 (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: 5ZcviH9BLRnx5Ab/EUAoa/7DAONcmM5sPTd43vSlPugnyCSSoYj30qaim1Sq9dq9yHoo6ZRtTi8sDzLLg/awIBIEciZ1j9HbATt9q2+VM/giG9UaSmRd7IfCmnOMB/9A X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 will help developers of svm devices to track a state Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 0067b2266a..359bca2ae2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -203,6 +203,7 @@ struct IOMMUNotifier { hwaddr start; hwaddr end; int iommu_idx; + void* opaque; QLIST_ENTRY(IOMMUNotifier) node; }; typedef struct IOMMUNotifier IOMMUNotifier; 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: 13669445 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 47BD4C25B74 for ; Tue, 21 May 2024 13:15:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHo-00081T-3N; Tue, 21 May 2024 09:12:12 -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 1s9PHX-0007j4-Il for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:56 -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 1s9PHV-0001ZU-9j for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297113; x=1747833113; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=8GU03lMLg26o1svETtJlIBqEUa69Gidx+p5JjCEJw4o=; b=pNYY1y+svE8M0v3ADhYd3OoSBY9IaXGN1ZNgVkpr11v/Nk2Z8ACgo1+6 uxjjOWmWh5YI2DevxVbcq28UfAu9g8wUUabakvhiktg/qWaHzdqFOtXqW 2jmaI1P26x0xt17MxSL5KML3Mwo3WnAH95si7H0ENs9BaH9ZQeA9m22HK E7RYXLhIlDBhyham9BEwkcOLd2TOpmV6KxaxS7SrQNH6DJueBbh1d1clS Cb2Ent2Zl2FZTbwWCQfWG8Oqv26OyfW3Sg2TEVxHmpNk1w9dtBRJQw7JN +FVH1E8+xskNPx4NMjdKxpVjyzeoydHzFkfAgNdEMGVbR3lT8jNZYMSZK g==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13008001" X-MGA-submission: MDG9qdn3Uyn/Y7UYQZwolynDeoy6s57ew4fIMErye0JCeA64twQk2W96vDNTdcaBh5X5e/C521o3x6/8j1UlEoeZ4tNz4qyqbebNeBsADuFBkgkQ3+xVsaApJjpNnfOYV1+dJYlrSl1FCY85yd3aNokIwxQk2JSMVnpyzFUZKgYjyg== Received: from mail-dbaeur03lp2168.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.168]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:47 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XONUUh3ILGm9RX0Fq6QAv2u4BKP5VIbl/zqY82nijyZJyjVq9kMLgANPuaEgqn+a5aC3n3IYuKaCxx9ylTpaqxZNBFistEF8chFhCEY91S8npzGha72c0q4JqYXu/NKKKqa4rzgC+NA9Ov+ME+caQyQYy8viOfHI53iYHeYkfcEPbXGl8vqapjc/vhjfxqG5cMdHoyXjKJgRmppiyUnDccSsWASYahSRLdFQUt2skyi7JEm9pgHmyEN9izSIPr/21FQSy/ohUDOfZispv03Cvj/jtsTHqTcSnLIiuRDhJ1j2KuFKediZcoM3pFFjhWRhE+xS5sCbimTbvbWghN1jkQ== 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=8GU03lMLg26o1svETtJlIBqEUa69Gidx+p5JjCEJw4o=; b=f6js85/VWNiG164qr4NV0QxstjR5ftbav/Yxztd7l+BqSwGCLcaGfRUe+WuU0hdBik9gfH/NJQ9NDB2es5GY47grUnDKT/uS3+U2h3FinoQIXBSNttnr17mafZre6V7vc6H4P4aLQ4sWwSxThwJ2M5V+8EdRK8fvqYqCGUsUiCRTQ0liMATZBh+K3ktd2zGL0BKzSBqWurKYncztwmgCfUnP7F0bEBFIE9ZqZ+ojjePHRUWP8owBbC4y7UeRLNchRGHWMjS2YXM5O85Xw5VQzRBSHZUyBjTuVswPOAK8TKLKg0MgvAwEbRiUaffwDs5yE0mxmcH/3JPsxEFCcv2S2Q== 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:46 +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:46 +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 12/22] pci: add a pci-level initialization function for iommu notifiers Thread-Topic: [PATCH ats_vtd 12/22] pci: add a pci-level initialization function for iommu notifiers Thread-Index: AQHaq4BuIH0I4A4DJUyHT8GkQmNaSw== Date: Tue, 21 May 2024 13:11:46 +0000 Message-ID: <20240521130946.117849-13-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: 74c113ac-ce04-4578-13e8-08dc79979122 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?a4le2eXC+PDt5J0C49I+2Is91Ga5yIS?= =?utf-8?q?s9foRKqcvKIv1HFUhDWu2AK9enN1MpzUZVzwiSUP7cakFiwUb0iCZ53e9SZvb/TjH?= =?utf-8?q?u7lhDDytbQ1vipyQ7D1075RhpAtL4CTaTDXucWog7fV7yuuvZD0rd2XcSWO8NnrB5?= =?utf-8?q?UmS/5YFttw7j/yIFdtx997PZgpkQpcm2XJ4EKDVVcriHk0Gd5+0pJ2DrKbXbwVBdU?= =?utf-8?q?YZSjnCGDBscFw9Y7I2OBIGlMPUiYVwjO1FY/qZkGHwVfSufwmcsd6vvc/Ai4fHY8U?= =?utf-8?q?w5s+ajjmkIZw30AcAunVPYSy09+eQJIMmBiTm354dd5Hln5lvnUmZU9y2E1ei4sOf?= =?utf-8?q?BBID5c8aLmMwp4DALczMCysEBupK2Wz9tK2m4bLPdmeaXnwdL+13h3ZacQqwTcCaU?= =?utf-8?q?a/0juP7DE8kqPpJh9JTkmhzKFh6CSLH49y7OzAQcJlBBku2AT5+ZJWeGwoO51HdNe?= =?utf-8?q?iquR7SIxjCyacUzN3A5TNhx38NI+ZsClGBHXOyGpcFUGwVdCyKd6MV9z7w+uEjRZn?= =?utf-8?q?Ask/8HFQzdIIkflsu4oHqrWSJ30Fw3gmBRppDoqifam6FwbeJtKmmVf8cRSv/u2jn?= =?utf-8?q?5yjO6ZCryCntXlngddTHk0Uq3LAva7kX1zsFsBGxrhOEwgvfke756zLjnyG0+iMVQ?= =?utf-8?q?xBFwfksOhtm67zOJkIfNt2fyJ8tFbxz8SW1uL47F5rvi4VoK+B3ntlpOV3UCtdXeC?= =?utf-8?q?8yIlbOvDqiS+YLhteib8bF83fokAWryX8jx0j231UMk1vWbr5c+wRNSRro3GYVUZ7?= =?utf-8?q?adaOgek7YR6hqKX9yyO+GhEYKa74gkTZRP2fvQ4XQdRWZIEe+IkZR/6LoV6M0rv6t?= =?utf-8?q?V04RRzpZ270ycRh8wKMqbEovmY18xvRsPy/tObq6R4Jb/Pudnaf+fBh38hCkS3tXj?= =?utf-8?q?S30PVPV3G9SDJHx3+RVMn3qLS8wfI2q8kgHytXC6rrh+pZTBD6PtPR18LBqllq9Ef?= =?utf-8?q?wsCcO0vWCVQfS1nS6AKSv+jpFhmd+0+pmI+scUzVd80hkarNGID6dsfoQGFgaF+wm?= =?utf-8?q?5oL+tz20JhbiV/yIvxAUrKwqhKXCpqpZsQrYUysxsJ/coDrDhNM2VCrWmyPr9vgpw?= =?utf-8?q?HO9jFWoXZPtJ8dsbaP/G3V1YjGUle27q6Q+mqc6w8SDo09hRoorkBykNAeSg7c4Ca?= =?utf-8?q?QHrOQv6ZF3K4lShqxT5wpwP6KOGDd5eYTk8mF5bty6LwTLxemW0jMgWdpkiXMOFyv?= =?utf-8?q?oeXVIdMEYPzBAJ5JZjDe2zt1Ld3zOXsihRbpC1lq8tEC8W0rtqHzsH4GiM7rvjlKi?= =?utf-8?q?FMlL5kYWca16pxqFyXcLfJU7Unvyp+dT++g=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?9gQ2lzLCUoNzMQrHeEbWOfB6oho/?= =?utf-8?q?ddq9zaqb9huiiQiom+2RZ0aJKOe3h18ANTSpSVSKTj+o7bVhiSZSDy9wa0dcLhTx7?= =?utf-8?q?uD+Bwuq+anCR7eMLN+orDjGTUbu0ERt215crWOHlW9RBJWWuWSyazGLypV4AvHrGt?= =?utf-8?q?tm+qzECWCR23xK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79AAJsYo1EZqtzCfY1haBL5AsjBZq0mJDj0mXqI07SWv00YepAfscuzwBccNmS?= =?utf-8?q?OIJvAcMHLKQr4Lr0C5oH8mQUnoM51WzyYYqw72IwS/rftkjiM3/iyiouAQ1ZJmiEe?= =?utf-8?q?9K6NZ45k0axCW5nIVx/OWHsLnjkAL+1U4Ok1YwFlExQ7SDl8CnO7V168ODgqPAKMg?= =?utf-8?q?GRVbQuvbq2QQ61RzgZakBU3VTCe3g+PO0yduxWTeFz+Tsjk1W4qjBg3Ql25S4C8MW?= =?utf-8?q?ZHENAHfaEfZP+WaTK2qe1pnwZ3Bq0N92q8fB2nuBMXATrbl9mXU7q0y7X0LTEulpC?= =?utf-8?q?P/wnhkcsiSYbn99dMEREaYgQ/PnBo+hZ0APa3juFtQcvFQk2UtNmRfky8OVAqCH8P?= =?utf-8?q?ipt4Uy/FfpH1tDrhjikco3dfLObD0jl4QEem9vvVM2Dqlzn6YpRYb97meyrdzsi/m?= =?utf-8?q?qx6Eq1vo0OU3aOH3j+dT7tl/kuI+k+dbhoNpCpIC86nAXJI67qSe2wMr3NBkgPjar?= =?utf-8?q?AT+2j2kcSj/8xwX5F2gzawwib/IfRiOrDWlnJG5NAd5z0lGv5aalqXE=3D?= Content-ID: <81569FAB2078DC4D84B676C8B7C99CFA@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: 74c113ac-ce04-4578-13e8-08dc79979122 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:46.1263 (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: 5wVz3ykZjwVZRfeQli12TkNPKeKzWlyc2pN8GWYnaARcYjCJy8xJQcXqNtvmPKH2aEm9MDWB22+2duFHXNJz/FiVdkGVRlHf587rbNj//AikAkTwuHuzmWYkW09phvDq 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 We add a convenient way to initialize an device-iotlb notifier. This is meant to be used by ATS-capable devices. pci_device_iommu_memory_region_pasid is introduces in this commit and will be used in several other SVM-related functions exposed in the PCI API. Signed-off-by: Clément Mathieu--Drif --- hw/pci/pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 15 +++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 3fe47d4002..0e14ef4ab2 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2747,6 +2747,46 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) return &address_space_memory; } +static IOMMUMemoryRegion *pci_device_iommu_memory_region_pasid(PCIDevice *dev, + uint32_t pasid) +{ + PCIBus *bus; + PCIBus *iommu_bus; + int devfn; + + /* + * This function is for internal use in the module, + * we can call it with PCI_NO_PASID + */ + if (!dev->is_master || + ((pasid != PCI_NO_PASID) && !pcie_pasid_enabled(dev))) { + return NULL; + } + + pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + if (iommu_bus && iommu_bus->iommu_ops->get_memory_region_pasid) { + return iommu_bus->iommu_ops->get_memory_region_pasid(bus, + iommu_bus->iommu_opaque, devfn, pasid); + } + return NULL; +} + +bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n, IOMMUNotify fn, + void* opaque) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr) { + return false; + } + iommu_notifier_init(n, fn, IOMMU_NOTIFIER_DEVIOTLB_EVENTS, 0, HWADDR_MAX, + memory_region_iommu_attrs_to_index(iommu_mr, + MEMTXATTRS_UNSPECIFIED)); + n->opaque = opaque; + return true; +} + AddressSpace *pci_device_iommu_address_space_pasid(PCIDevice *dev, uint32_t pasid) { diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6c60f7a7c5..2147981423 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -458,6 +458,21 @@ bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod, Error **errp); void pci_device_unset_iommu_device(PCIDevice *dev); +/** + * pci_iommu_init_iotlb_notifier: initialize an IOMMU notifier + * + * This function is used by devices before registering an IOTLB notifier + * + * @dev: the device + * @pasid: the pasid of the address space to watch + * @n: the notifier to initialize + * @fn: the callback to be installed + * @opaque: user pointer that can be used to store a state + */ +bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n, IOMMUNotify fn, + void* opaque); + /** * pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus * 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?wwMJxIMsfn9fgHW48wG7W8KHvlItHdTK2LzK34ZKv8fD4KMV3CIXJwjEbH9W7O0YB?= =?utf-8?q?HEkBHaYljVKKG0OG+4sjCnbR/H0GEzPhYSeGqzpZmXTs1HnMBU58XS75vEad1+jJz?= =?utf-8?q?0Tg4c679jo5fxusxEJFNqKSU9xwtAjwyXnoqLDcvZQhtedjmXDPfgVHwJlkaOKIH1?= =?utf-8?q?Mgqs3ruBKYDNcFGy713JHkrVx8j3uJfOjDg+8sAb+CB54dlAcIPZLyXFYDNJbl5R8?= =?utf-8?q?TY56cOSPZG9QfY2qaqA4yp+X3eCkmNarJvPgUF3M24an8vceaA37GmCzAkwOooSW9?= =?utf-8?q?hXuD5AIauA7vZM3NuZyiL9eoUq7EfB0MZMrhq78FcQyhy9SkQ/Piqdy6hJOoxyiO3?= =?utf-8?q?KJTE9XW6/JxTrJuiBZhudn8HWYuZQfgsCIT1RL6yaor3Gdn3ucLeejKJyhDvMoimu?= =?utf-8?q?m70yZPWEpSlxeQe9y8bQB7pcMONu8hYz5g2E5LbFF2Ga/5/mMmABbqWCGXZPowhHl?= =?utf-8?q?hnXuB3oBkQ5+iCn66kFATNk18Nt0Kcl6Wb08V7tyrxviZewFy5RjUVlh8PucIkFLQ?= =?utf-8?q?OuJJr+1KUwW7cVfx/8Nkgrm8pref6Ath5Kw2tStTvbCXUakscBoVObLwbAaCQaML+?= =?utf-8?q?P9Mcqa6XzWoslsLhNIuDbUZHlqtYasB12/4kgQlfhV/6SKraxvTlJuq7FbX6U2N6g?= =?utf-8?q?gKIps8MrD8FrkTjHYbDOdYcjsj6z+tjIZHrV3vtTy88LxSyhMfjo0J3nuGszKkFPq?= =?utf-8?q?mUOwTXJJdboS4XwBh24WYTyGryw/Z1yQFXpAVIywnL8NajboX88Kj0Tvf7rtG+EZb?= =?utf-8?q?qP89tsnlSHz3LCZ+uhjmyTv2vzEVVl89CHanLYIFfzTXfXlbJbGZOFVVq3Sf4uk5b?= =?utf-8?q?zzSy1I1IC/LoiTmc+9ystLI5JVwKZEGCxvw=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?6Aep9fC5fnjKh44PGBvyJL6jhqlvXho8Lm+ttxDfOW5q5OC7FDmNh2NVDTcOV8GyB?= =?utf-8?q?lH265YFjV8hLuDfPJOGbJYCEb2KQd2gGpSl8TI7OFjuJk/UDCJ6cfHi8UwyxUZy39?= =?utf-8?q?Q7KDkmgRHRX2hd8LKPKxrI6VtZfybjZKoRfMWpCx5VzilG2wmqM5TuKxr8vRJz1AB?= =?utf-8?q?HN0ONorsZK4qXfs3ITcfmmaK39GMMh+YhOVpn0tsWWKw4cpzIB5DSwdIXv5J7Onz/?= =?utf-8?q?mZ8+jF4aH6Qx83vlPXVRfYL3/buUShPCYx8oH7r69Nc07Ic0lH/X5AJ1GB6jI3xn8?= =?utf-8?q?NO/KI8oTI/RB7wM6N37lj16nJ1zG2ULIueDcaxmRSD+JtYe5iNGDsDhf+GC7STP3F?= =?utf-8?q?10ELXw1iOiWDS2E8ocITnVWXdTA3Q0xLrMtptSaYTqrg6XBPCK1YTEioYv0ZdfZay?= =?utf-8?q?09Cn2U4L+pi6ifySskElE1mBsDLIgw2iwQOY9PxI8VZonVDwCPqSWOsfumUp42AJw?= =?utf-8?q?ZgJBxRpbcIfsBxK9FyhFn0HT/FwwaSJbsA2dq7W8iNmR7cFlVTTShyiBzLUcT7hEP?= =?utf-8?q?HjAHFM2TKhODl7yLf6bv5qzMMn7FTtWDUEJSh2v27Coreei/VkILQ9yWL+y5cYtbp?= =?utf-8?q?AA6IljaFyM5Dw9+KHcPigvyjCusqqJHcN7IHq1gUcFUfAy4XH3ioS74b/UKfGoKiI?= =?utf-8?q?qTITsqNq7H+XUFbTL7LwGwtYJlrDENwthNq4FpUcZ14F4/oVPMCbEzz4hy/UjTTad?= =?utf-8?q?6o3fW8DuhV3gVDlBaP3Ov7s7DPrrxCmjI1DN5EVEwLOJ2dwxq6OevVkRp15xcD8eB?= =?utf-8?q?9uQ+aEerg24YCTS8LXX8fd+wGesCjLnnGEsl9CqECjhlszT2XSbZJvPAa6vZaNTUC?= =?utf-8?q?3IspCWHUSmOF3YDXCtsuJJOeU+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 From patchwork Tue May 21 13:11:48 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: 13669452 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 65B9AC25B7A for ; Tue, 21 May 2024 13:16:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PI7-0008MC-TY; Tue, 21 May 2024 09:12:32 -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 1s9PHk-00080I-Rh for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:09 -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 1s9PHX-0001aP-Jn for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297115; x=1747833115; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=DCiJkhq21aLilYfmazBpuY1RUfcOG8K07TIGqnYLIIA=; b=xO/veNJoRZ7S6utpdlVBTLEGHsnWnPAZiiJeVv40Xghcb95Cq/wf3m0P AUT4o8zfv7jemswo8pMhGbTSRvGJyKDLDm8WURxoFbW1BR55qcx7RHnQw nc+7UFBe3QzEihKxc5mRtPn08ivj04fNbr4LEaWoR1ZnTa38TqgJSxlo/ I/1qt13yZHR5ZWB80VjcFvmvM7LAnUYWZBZgoDhpsyo1tLrCG5xhC2Eqj tTAJUOku4FZG9L4L4ioRPd/KW/bC0iMF5JjvUPArBn1kie5MWPPWaAHav 7rz/4ZMNsZ8Eeo/+RESJqZGcWpRCyOuVGYRiSgrd9tApt3UTaT5L0hNdG A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13008007" X-MGA-submission: MDHmFhhalvjWrzQ0fRygSkGcqSE7GLc4sCcutQk7xsrOgK8IdFXakGlcISYnQoECxYBVQ+UAbsWCKiy4I9G9BddpY+JtayA0odMub8+ii9bIIp3wSJb+0mBUHT808JcQEypRk8YQtExHPyMwqVWTEIMQTkHo531AGoHheBWssESfmQ== 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:49 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSurGjSpYJECA4rF5phkaFv9S5/FehR9YSEOqmG5dvKKHbD9BAS/mABy+m6fcEOm1BPA4tndT/dvdjQQtwd3Da2L48oWAoJORhzA9i3NTIZBxR2yHOWQiVE/IGPbgTy3Bl5spj//EoxwS8zFGN3mve6DVuf16TBIJbngxVkd2xPuyWSmCJqlr8mMziuDiVx6IF9cyYnoLWahQpep20ymEk0ze05pQHwuOXR58DILg/ZfXRLpao+QQtU0l6VemYpqaAGwX9mut4brCuebMGvSH/Pq0IZEU+Drto6f3OhwiVySW7uSk3DcyzwmAyhgeDIlSnCQVe95gz4ip5VQtfUaUg== 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=DCiJkhq21aLilYfmazBpuY1RUfcOG8K07TIGqnYLIIA=; b=Zi8MhFCYW6HjQO4INFy51gKSThX8dMshjGCDe10c1qD8awmJ6phoHvOi1BnCuhhQ6ySPSO9i8aMs+fNff4pQvarjiSFzb5jQUKkkDD7zz9v1eR9DOhQcIG9unbijMgck/HoOd4vKESn6biAQcXgfuaFezVJTmFCwqb83n3vAqwKS2zfK/xNU5tsX6RKvPlyHJMbF5OeutvKflFIn03gpOgoCHtiPyeMmTy1DDtsQrlTDJgvBJNtV4h9lWErh63TaWS4zAg2EfzYPBD588RY+SRQDMVTjVzM8BA5JqMVNhAcpK3TxEn9ZkM3abTu3wt8C6d9bdeMnWJbQPEjBMmPsvg== 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:48 +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:48 +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 14/22] intel_iommu: implement the get_memory_region_pasid iommu operation Thread-Topic: [PATCH ats_vtd 14/22] intel_iommu: implement the get_memory_region_pasid iommu operation Thread-Index: AQHaq4BvLD9RdICWlkC5j/mZ2ctG3w== Date: Tue, 21 May 2024 13:11:48 +0000 Message-ID: <20240521130946.117849-15-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: b29a5b42-be93-4a89-b206-08dc79979241 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?/gga3QJDVB1z9VB8dmfPa13wNPV0qMl?= =?utf-8?q?UpmNd5LS2dmzm2dzrjjHV5ZO4b6Wk7JoypG9+Q5uD8eR+wQ+d5VM5knVB+a9CjVlw?= =?utf-8?q?nzArK69lmJhaKCP+nLXh2NBkVJhys4yw5+1slCEdh+y+rKFccILHZDAxdE/UFAAVz?= =?utf-8?q?fJNxv8xEsMkjAivDsBvE8fziOfhu1TLkXA+Igt5nEc4IzMHRiMgsYXJztgYlPpKkS?= =?utf-8?q?TgDN0U4f30ZmRobI1+daRYVwtikFYTjndcvMytWp5AOlVZohnkGNIWZk55qXpxUFF?= =?utf-8?q?MKHYF9cnmS8AalwJ9075FvbksKHdMepwcbbIrTbfr7/N3uvlDqP78hkas9TwnwIwi?= =?utf-8?q?gUnpFXXnH+f32zMs6ThflN7eWLt5zLfLDpcEhwknYogk4Xg+nmqx53JxsMEs6Om/Z?= =?utf-8?q?UhCl/FUeE+rIbt2IwI3Vg7eP5/PKMG8QlhYJFskUed/xd6ONtNNLCmrYtDdL2Htbo?= =?utf-8?q?5ELr2tnnuFcM4Rp2cMkE3jiwjCZW5OWTukz0JTbcEuse43KhFQ6FRW02G6mh6s3qc?= =?utf-8?q?xVaqM2K+32oCUpkMyK15Uu8i2vpgExFCVN1qfpH8EY2H7FKh+pHdsgUhS7LpAkag3?= =?utf-8?q?QwneVOJxbh3/iwQKrrzzDNEQR0Iu0vbgcxgy6Osy5z/kcZZY653IFlDhcVIhKPfan?= =?utf-8?q?hz27z0KK7IBM8cZx8d67MWmNs94B7sZIXnOKD34ECColjkH/2a4v07qJxO5oBNdrE?= =?utf-8?q?qFrrisLODqWX9vtIgZOM/9h1+4QvY8OBen80URv6j1iEEyxUpY9fL8uXEJq7N7D23?= =?utf-8?q?OF0tPo/BxH+aZ4blLgYvPPXxtPDJ1h0bCt/VgtDyNKraUxtLPehUxjl8nAmHg5ctG?= =?utf-8?q?yElMBO/HR7hnxR1ii4yhzGCDHtxI6Y1D4FDdmtjOISTpT7PXBwsIVpFMAdBGLGBzz?= =?utf-8?q?/CcxVz9AvON0BDkckV3Q0XUBdDnGTqjImsVHOl8RSBv+8o48dk1kYaa62gPcrTjls?= =?utf-8?q?t3Gj4ojnhGtTOlgjkf/8T3sEtBXtQcDkKuZvcIz4Wd6xzw61dXhy7csR5YHozAX7+?= =?utf-8?q?5tEY+CI7Y/sq0LCGVENuwCe9S195a22V0LXgFb5VyqPPNnM7smVXaQnbq9Z+Qz7bm?= =?utf-8?q?SF1t/HybUy5mvlPFh87EV8tak3hfRaHpWuw2iio6nWBqc1qXg1tozxUwqc/9a9mCY?= =?utf-8?q?apYXnXPrkOs/4ZsKP49S+jLEdCm5yVAuRx3tvayvtsOpv807JaTLY7vrSJ74qP01J?= =?utf-8?q?TrrtO5N0sO9ZgvxNt21J2rQrHaLX92nROof80blFX/UvYUYW/0abDZBIxi96bj/Wi?= =?utf-8?q?tp9dLUNssaNLw3EnTi6+y7CcadzhNgMSg4w=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-exch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?utf-8?q?Nro7x7msxeF37wgGyW3igsBXuHr01viLsWafZ0Spn9xOIftYlnALAqJcH5wB+bAyD?= =?utf-8?q?TvXoHSr4jz9kYC07n65hgCyIYXKYHMiPIoPxOokKhLlvFaxG/Xd99A5+qtfcUG41L?= =?utf-8?q?NynOJfQCTB0v7uDDn/pKPTeiN72AyaWvj79asK8kTjQHoqi0wjG2LhI+L1up5ieQs?= =?utf-8?q?ogZ6vCsM36Sd8IYytm4NGO00fn66Ni61X5GSL34RGi7ESPtnCytlnyx7FzJi1MWDy?= =?utf-8?q?17rp5VCkjIOvUJSYgRCmG5OzTaF4iGSWy0W8KvSYU68RHyoy1dzpLuZx+L8E+XxYu?= =?utf-8?q?sWAEqQvCE8CjRlHTm7icWKr9M00HelNoP2g7wzNMImBQH+rZgHObRF7fc4pEHRaaS?= =?utf-8?q?LDN8yh8hRigY+rINoUjUzrQinV+8emOAeK5QDhzs8NRxrH0FGMMHPKk0U/RBQhLc4?= =?utf-8?q?gbdlFFPAULbvq3UPCfL2cWexy790h9aXzhQbWxQynWJ671Ker89QcqONhQXCyWR4k?= =?utf-8?q?853MlLQya5vw4ghRXUFcW4Abo9eXRgqR2Lig7Yzi1dC4n+tUSTAbajl98BC+jr5Kn?= =?utf-8?q?4Dq+nuKfGEmWMyGd+mLZzdd5bUveRK1vH10NoqTKlfhkYJJUIkbBFLiIoxSLApZu3?= =?utf-8?q?F87TM25KJdc3efjCjQORmWLzAPWoaZL0rCEOP7oz98ULJEHoWNFyr599lmKT5uAGV?= =?utf-8?q?PEnQBmyeYpM2hPJx0Jcz4FyZiBz6e12GwfY/2Wvqm7R3CD4cws6ttIQ=3D?= Content-ID: <6DFD8BD61FA9454FA18183404D15A7F7@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: b29a5b42-be93-4a89-b206-08dc79979241 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:48.0177 (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: zdTMM+A4ni+KszHu0fn/fP/DiRR2EJ9Avw+YVmdIZfn6n82KWjyfrk2hwc496CoFaucBcJSCFsIJhXE3ZGLqYaloTlgevq7JRl+OOnChKB2AEI7aYMZKq4VzsVTg+xpS 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e83985f2f7..a42938aacd 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5975,9 +5975,24 @@ 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 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_address_space_pasid = vtd_host_dma_iommu_pasid, + .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, }; From patchwork Tue May 21 13:11:48 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: 13669434 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 9B0A8C3DA40 for ; Tue, 21 May 2024 13:12:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIB-0000Dn-77; Tue, 21 May 2024 09:12:35 -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 1s9PHX-0007it-4P for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:56 -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 1s9PHV-0001Zh-5D for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297113; x=1747833113; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=l9bNcp34tf8qesLcsVgJklrBtutAApnNrmDyzOeqyZY=; b=EUKVoQUzNQA4x6xcY9Wh/WidqfQ9cO69YQ41EzgtEKWwtJaux5u6/VTo bAGH+/CbJZ3QLHUliW5QWBToWzAAHZ/mPTpJR9H2u8vhzvJ32uQxIjp6e dWtwsyPbq/+01/Jp1bLXoaAbtm4ROHlK93ct3kPbIRhfIla1Bti9lraX/ pK051gNSYXmbA4Fa6FT0EUSlFlFHVzUgyZrJu2pXYZCsUWOaSfz7ewKgM 6sIZOF+OFPYO7iA4iT5O8K41+riennEdw8qYItF1lenLM5z2TO9cyvo1n ltGjnLQQRvR/gFyrxph9BbDbNEv0fgsip2H2aO8GXgYum7PHNJDkvYKkV A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061509" X-MGA-submission: MDGeQrvyXfxkoQAnmOavVki1omy8P4Vl5LuINwww29b7lYci8Q5FI5c0OttXmyDIaCBkv9cXkOaUtQFRs+HLpQ1udkhNMKlSwke1zlAqGWDEJXEJMN/nbzgNb6i5ayjCTW8g5anPPJ3XzjUUsGqOxsADE+8zWELpOjnMo5woW4mVYQ== Received: from mail-dbaeur03lp2168.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.168]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:49 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FDHyqTfPNULPPy8jS2GVsibyubxSVtWgtMqbhmC+1SDZZECQSN+Epb0vecMvhE65smEq/9KN/hmCi53HtiWTBK7QuQMvIgtCGceH3NA449QMgA27n3Adw5S8fKDzFYl/U2bFC+lG7Xf4Q9U5NXetr8wF5ZqUaj35gccvCfQsHAPxR/OEaqPg722EuY697Gnlhp6R5/LcGA0nPbCHOMpH2dxVvK8AIs7rSc15NBDQWMYEN8Cm4WH+glApbzvEGcndP9m6RHfxUIGB1q5A17K1tWL3zQ4Ni2IZqnuBycirAX6TgHBKXCol7bsYHUwFsVrrCB847044BR3OXIEhkNvsNQ== 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=l9bNcp34tf8qesLcsVgJklrBtutAApnNrmDyzOeqyZY=; b=NVKT+ym8oIro7p4ZJ+Xp283UDcZDOyUl/boqrhb8i8UqC6y8ifyGgnvr19koG0Cy16HojO0h/oEyNYr05HMcF8M/pwj4ICm9Wu49OSNbbCTntxQiOCn3rXhiXyr5sT1GNsi9F+kSGOb0JWVTYV2aeZOBwrJ8+KfAdGkZZHGQHFYdmkp5eeAqdpIFtk/2J2HQRVOw4xkeXXd5kVkLVULXpuI06IR+zT3pkxwmlhLHKisu9hcjQgzHgOX5F6rQJbs4NYMl5XrMkeiJSQvbqaFtw1JHf8FFjYplxGSJyshRDnfglzz8F0GFsXd6kmFS2cEIhGkhBl3Cp+KDOmsB7Dhp4A== 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:48 +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:48 +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 15/22] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Topic: [PATCH ats_vtd 15/22] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Index: AQHaq4BwMKxyUNJbN02mJJyi62Xrcg== Date: Tue, 21 May 2024 13:11:48 +0000 Message-ID: <20240521130946.117849-16-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: 39a9c922-5dc4-490c-79c9-08dc799792ab 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?JMNWei0bc7f2Al/wo19nJcqlDBYsXM7?= =?utf-8?q?FHBBN9OYkAsIfgv2lDl47qfNgzkdTHakr6zOQVTkiP8D3ZJvLzc9ffJQkXZD60Moq?= =?utf-8?q?si2qUQvx9Yk24xDRIvv+X1Gp0HetuirPWRua8Nfb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CMjwlM2nn1G7941D1NPeBkWMpTmFVz7T0Iy0IX?= =?utf-8?q?1Ng4l1kWHH3HyOL46wZBUqtp3o5X/EVRUJ3ptTkv/EThXJF3BMIPBYRQyIqg0j1Rr?= =?utf-8?q?+EsLebHYsgPonhhq2eTq0TCMOdhJ/ud+3UJQZZN9/e00qPygpLCzxIrDT2hOuzsg5?= =?utf-8?q?4oPVFP24r/dakaU3nIoMt+L+LeYimQasJ6Q+fgtKxK95X1/pDEyoaDOJ3vOgFIHLm?= =?utf-8?q?Af3KZ7uuB5xAFyIOJt6vGFl2/KQZpIAjJbbibqzGeUZkYNk8OCoGMjz423gmmYLEv?= =?utf-8?q?0Y+NfYPs8oU1plI5EzHIbopZJy++zfc2elw=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?HX4iw9D5VjhyXLFOOcfFgzL0w71X?= =?utf-8?q?SYI5mOREceEio2ui0nmiqiKBDzn0DwSM3RqybbTHlPvNcaDv8Tbai32J7xOSG9gSI?= =?utf-8?q?zwf6il6ouDpqlrcF6Af/EKopmfvU1Qjb1Dv9ZJBCvoYdDRwJfaNl0PveWu6qhe2qS?= =?utf-8?q?tuoL+sw1IvAFXI0DFZagiFoPWk4wH0bMXHvIJOdqoQMcJaO4N9yht7mxtfaLwm5T3?= =?utf-8?q?zHyc7pXfaby2bZ8ynd6weGeTmlGkg+Y8HyGnoERt1IpvcwfdkjxraaTf/IJIxjBpc?= =?utf-8?q?YlqJRamGlzqpQylRSTm/3v5C4RuhCP4idFdDN9xwUFXvKcNYLVYSwOoQnNacTR7g6?= =?utf-8?q?dUS4Lek9qgKTcMpNd7c+4HPOEeSs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6JsFrxwP0pJZT8GibJBEGWLYaikGj1JMYcynOm?= =?utf-8?q?/Y95uFphGV4cuc+trEIyMJ6lpC60DX9hOrVMPdwYifbWWfeLBmJ6DIywwA79r4AkM?= =?utf-8?q?6WqekD8C5ZQklL6BZnARrhnHPoG3AVPhf0a7YQ0oiI8FZl8FGmeqjh4/j+dvTxh7z?= =?utf-8?q?vtCthDN7o2wSvYMglIadS1WY+Dj7O6k9TansVfCBIX0eLSk4Es0K3ko4F3HIyPd7I?= =?utf-8?q?Een1wTecqzD+IWTxG5ZPfsS2AcuR/bC9j+5v7LARKgU4bNxK7+5EMQKmpXHQGWmvM?= =?utf-8?q?HJm92xhpmOslozbB6PqlGy2/hKGQwQbIIgIF4SiiQ5w7G9rRugsccvY=3D?= Content-ID: <4C99E2DA041A9A47ABCBBCDAF3FE3086@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: 39a9c922-5dc4-490c-79c9-08dc799792ab X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:48.7370 (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: 5svMXyfaNE7HXrffuymmBBxkwrw4mqQIvp1Ikxf5uZKPbwR2rexHMFjy+XWgwYNLPJ1Hur1ten5mjr1wOi2elNoSwoU1owG9TeYavOc0K7sBot3GSDyBrOAQr1cR5My1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 will be useful for devices that support ATS Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 359bca2ae2..56ef48780f 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -145,6 +145,7 @@ struct IOMMUTLBEntry { hwaddr translated_addr; hwaddr addr_mask; /* 0xfff = 4k translation */ IOMMUAccessFlags perm; + uint32_t pasid; }; /* From patchwork Tue May 21 13:11: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: 13669446 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 74C64C25B74 for ; Tue, 21 May 2024 13:15:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIE-0000Tq-7k; Tue, 21 May 2024 09:12:38 -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-0007kT-GX for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:58 -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 1s9PHW-0001an-HI 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=F9597oN4TImrsU5O420IR4+7xZpXTaUNA2KVmchYngs=; b=GUr+7l3HIkFKwoAa1OjYF8Ezs14F6OVIOpkeLEJvdQD9qJyXMHFGI9kb ucewf97aJ8IMGYj2kgrcTSiP9HeItOk/cY+9oSoHzwfo6ra05zvzSQTpI Z2z03HvaXcaA8f8O6n8xaPr4FFoP3IaCrzT1uxpbvhe2SvDE8TTFRlNF+ QJOwt+dWdSr7PqFwEPK35ZrYc2slCiPMXINEdVRUSuOCgGIJ86a2Apayk JOMeM280ySLYAmxLelI2NUBcIUmPN+HtQuS6sQbPftzVl45h0L2o1OU4Y MIJxmh1FdMokwQI69E1yay+Cnsf6MGDm/Vc6rIEM6OJT3ruEKY06DFHA5 w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061511" X-MGA-submission: MDHgTBEcqe9PCFFeD7O+RCuGI/MhRbsSodYDDEPfm+Xbt8xtA6pspqnXJt1s2j7dSb8bBS42m6BkAwGrDZhGDczf3KRdzwz3qRTZUGljqD/ERg5ygW/REjZ2HV71eTOGgTa/UqzeWg24FvkGYVy6ojN+sGsYnzlVTVXj/MeZctvpQg== Received: from mail-dbaeur03lp2168.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.168]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:50 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBY4kLXqi2x1kwk0PWr7Zdga7gGtTXx+6ve8+Z60JVf+7hE/uYjsOo7O5mCXeugjBiHwZIHrddOr8/B6R1772GsCVjUaAgFCReXWxgtrb4N0gC9hpMw3qIqZemY5yENaIOFPNWgtk0OftvqKxE0e5F4O0+0zj7IekxEZFtDzzYhf9RFEgVOzBeVn350BUzoC9zJoBrQJs6YQT5Fh0rcZIDBITmTGfn4+0Bl6cD0Ddbs4dSrTKDGMC/s91B0Rb0gHcmd9SZIuAxsZp5YJdtIdPzdFXa4ldMu9ezrNUSWQI+zT/mDCXrUPqztQ+GuzpnC6ryHALpYp+VB+8omVlSFM6w== 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=F9597oN4TImrsU5O420IR4+7xZpXTaUNA2KVmchYngs=; b=ZIHIlT/UTmq72PnO2P15Iof4OtcKdZ/KCFCaCPu5ue9CD1+1jYL3zdKKESwfEGt4o4vbIGCgnbrsrYy2J1/OE70iG6J5+ZB1IZg2rgkbDMbWICCveoj9sKNQlU4LE7u45mwi7eb6BbVm3frpru7zTmt9xAFoUq+I9xYjeZpyJoD2qonbPA99/hhz/L6+P4KjpxKIgdDA60O6UNX3kKqLULoR+3CAW/bPaKl3Xd1ZOr/r5tkOASFmwJ4d7BLIr54FfnRSOqkmnpUBxALsLAL2hrFn/fFO1h5YRtDr8GEq6Cyze1+kSA94klRhdb8/e6uGuNYR4K97DO24gzVa6njXUw== 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: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.7587.035; Tue, 21 May 2024 13:11: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" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Topic: [PATCH ats_vtd 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Index: AQHaq4BwdWnqJ2m6gkm86Rsix4ClAA== Date: Tue, 21 May 2024 13:11:49 +0000 Message-ID: <20240521130946.117849-17-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: 90b40d72-9a25-4326-7053-08dc79979314 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?YNjU2uhJfOW3zdCgwtTyeVOLr2SI60N?= =?utf-8?q?n17jMSEN/qXA018/k2JUcmxVGbalBCcWeY7Jty+8tGA4u6O9g92slKg8uK2ua5kPo?= =?utf-8?q?3+QfRdkWl0SokvIAb2ec+3dEFpDIFbnzHlcu4VZhufLSj9OP37cTTDYO6S6/mp8/d?= =?utf-8?q?N94OdHeruXGScT0uVz2r1nzqWZW+PwF23ltfpn3crnUqvhc01Mc1UFF/SmhmLYkcL?= =?utf-8?q?6yTIbTCMch+lhM7y4uuDFX+G4/0oH5gTVB9Fmh/rSgnLWZe0QDvN7UTD8+CJG0DUH?= =?utf-8?q?Jok+VrLLM9dB7p/v6KI9bTLr1B1/u+LNpOD3NpdoPe1enuAUVoUYRQvfjvxVRKk1K?= =?utf-8?q?c76zPdvdgqN2QTQDt1tMOHCnOdhDPNGr10m4b22TQ+HG556Axkgbrt6s/Gy0cPZuR?= =?utf-8?q?CcShe4EqaUFEw5lt/kntXmXg6vGoDArSLz9NA7+fAm8fmmyMHGXq5SJdTwCWHtEUx?= =?utf-8?q?JpE+q0/azOfBc+LENBa9zBAfKN+TsfgqEjpvSw6Fmn98xbLnOy1X6gOvtHLq729y3?= =?utf-8?q?D1gKb0kLyaAHXY5QVgXJBEeetvME47mIwX4agscsC4052lwqYBCY5sn0mWsEiIknp?= =?utf-8?q?JcH6ovBw2+e2NJy68JAX6tOY0G/qJMe/a0TScb6C/6CmXKLWEPXv3cl3Dt7eEPefz?= =?utf-8?q?Y5W0R7rl5NjvzUXXkkAQmqX+mABRm8YXWF2V1dSEu3ZU9teie+HzX44e9YxEhKe1v?= =?utf-8?q?11tXk31jO0Fnx75HWoQ83ZDWOmDNRdHm8nbI0yG6zvgCt1yX5mrXm4kuAB6KYHIhy?= =?utf-8?q?2S4ZrjtB37E/0TJHIKkUFLupwFtp1xhUghLHbwvYWYEtOgcCod+KlEcYHUey/vIMt?= =?utf-8?q?z4S1wXRrmLA06Umc8JYUVbfzaVk9zK68tv3126qVGJFbspslZwuFgDq4xjq9jowag?= =?utf-8?q?Il/PY6/7S82xYhveG/uu9gSm0mOOoxgJOVdbGzSMkv1bviF+P7+b1eXFljTYFRfJH?= =?utf-8?q?TYtbm89flIJLcy/FbuvwwlcUmEyf4p5Eu+s5Qo/4RARBxhmqLTeHia4bG+1e3aNSo?= =?utf-8?q?Xjyk2t7PDrM3nzhnXmpABpNYWOINvQcpcW6P2g4oJohhzngtpGAtAu1NrgX8QweIw?= =?utf-8?q?DrK0/xLLiliQLFN54KiBw2H1YaOMgvlQpGS+Llv3P9i8ZRR//F7tfecPIVXGkaJIW?= =?utf-8?q?MAZCWd6jU1sU/hABpbGU8Ju4mqlRozStuxyuRW0ZVJR2/RVXaRxx54teqnGhuqdlj?= =?utf-8?q?Zrkht2wEzFiMe3A92ZqYExXEIzZ4fihvWKaUNElVMC41KddUZP0PQYao26rUcmSQp?= =?utf-8?q?hZgHOCaYjLPe9H8Wpd39fNF7ddK4N3nmfag=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?NXjducJOl4Il2BuQVPHK5IFfKkvS?= =?utf-8?q?F/vcJ4EtTXc0dfQqjXcsrxhABtNZXxqTHuSVDXEHLrlLyWsGHKEylC8kwTvgJtna5?= =?utf-8?q?wCVUw3beJXgIhh5jG5t0Eo9rwYXI5hmt4vdVyMBZGGCsj/gr94nt41JP1Kw41ewlu?= =?utf-8?q?Pa0tmHBearzuRhMHQj9TcfsSMBnMgajIse4mnxrekpzmUm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kcU2/s4cwEJTF4hNn?= =?utf-8?q?GiBmwIIeYUX4UmRNaTK1DsS1vqfBypFXvhX8uYJSQhoCMpwwMlaLBT64odwQ0re0p?= =?utf-8?q?xDXfSwfyYFs75fZ/OrhGHW27ToNPRF7nzLAZikR3GIV8D2ff88MTgavuHzqBQFjp0?= =?utf-8?q?ialZXo1eQgq9I37woT1VMTxQ0AeMDqO5KjukKTfb1zqfihzA5kiGcrR5QAWqp0fG/?= =?utf-8?q?pjshe2N1VGXyDqTHKTMk2GY27ZESCrxjH6eNHDbFbtEot510lOpof5cYMY0mONGOE?= =?utf-8?q?B0dR88Fj9eOs3+pFcbET7qKeb6MbvBQ5uI2hpa+HV0ka6OtAOO3xygXFOonfqVjn3?= =?utf-8?q?sQdBP+gUTaic8zSu2U/yGZEwF0Fd0Mzv/ZRM+lvdJlS/zEUGgTsBzT1w1T+qO9CHK?= =?utf-8?q?4c9hZn7qEdPV7E4mEcGyVL9qJofZdY0LQ17vAl/12PtEuh9HQpJaLJwkSZyRuZe+O?= =?utf-8?q?ou/EpCvg2Dfafztyyy/RcLZ6LUR3aPRs2Sz5vfPyFDOnlDUgzrrLiYI=3D?= Content-ID: <12D940B8BED9454AA5FAC6F3C26FA2BE@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: 90b40d72-9a25-4326-7053-08dc79979314 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:49.4174 (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: ny3WKEyqcowag4vLq5X2BSYhBS39ZI65jiPi0CCFlb5ZwLRWuxZ//l9RctFjIZNh91cMIRL2ycoanOzrsWGnE5kcIoAKmP0XY4PyRlGni9EENI4tyzD2Dr2qpmXc0Vet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a42938aacd..f08c3e8f00 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2187,6 +2187,9 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, vtd_iommu_lock(s); + /* fill the pasid before getting rid2pasid */ + entry->pasid = pasid; + cc_entry = &vtd_as->context_cache_entry; /* Try to fetch pte form IOTLB, we don't need RID2PASID logic */ @@ -2304,6 +2307,7 @@ out: entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; entry->perm = access_flags; + /* pasid already set */ return true; error: @@ -2312,6 +2316,7 @@ error: entry->translated_addr = 0; entry->addr_mask = 0; entry->perm = IOMMU_NONE; + entry->pasid = PCI_NO_PASID; return false; } @@ -3673,6 +3678,7 @@ static void vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, event.entry.target_as = &address_space_memory; event.entry.iova = addr; event.entry.perm = IOMMU_NONE; + event.entry.pasid = pasid; event.entry.addr_mask = size - 1; event.entry.translated_addr = 0; memory_region_notify_iommu(&vtd_as->iommu, 0, event); @@ -4320,6 +4326,7 @@ static void do_invalidate_device_tlb(VTDAddressSpace *vtd_dev_as, event.entry.iova = addr; event.entry.perm = IOMMU_NONE; event.entry.translated_addr = 0; + event.entry.pasid = vtd_dev_as->pasid; memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event); } @@ -4896,6 +4903,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr, IOMMUTLBEntry iotlb = { /* We'll fill in the rest later. */ .target_as = &address_space_memory, + .pasid = vtd_as->pasid, }; bool success; @@ -4908,6 +4916,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr, iotlb.translated_addr = addr & VTD_PAGE_MASK_4K; iotlb.addr_mask = ~VTD_PAGE_MASK_4K; iotlb.perm = IOMMU_RW; + iotlb.pasid = PCI_NO_PASID; success = true; } From patchwork Tue May 21 13:11:50 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: 13669442 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 600FDC25B74 for ; Tue, 21 May 2024 13:13:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHj-0007wm-Ls; Tue, 21 May 2024 09:12:07 -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 1s9PHd-0007mh-3a for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:02 -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 1s9PHZ-0001ZU-1F for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297117; x=1747833117; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=rG+Bw3MmmndtbJbVWq6083592qHj2h+NjpwqB0a2mhM=; b=GYnSZSWur6WHft/WuKn8U5jNAjo/54NBmSelwQidvq/DwKdh/l/IMNj6 4Tod3iTQ8bNOgn8Vz3Bf8mFL0+c+ePFKGzgf9kRPrhex4OucIc6aEqjOz 161X3xOu0B4QCv45+E2KQo9ClacEdH5UFTHbGwddkO0ovT/RYqLs+tW0g t99TBtebPCMpX3/nK/oShFcgmWZOLZAR3gx9mGGf2rJOLUkLErLcYehJi 9+JKYwFUqJ3U1vZFuwr2Oiwasr3n/kRsVtUU/Gelg68ni5NcXzUuG5ZES HnZr2GglXUI6Zh5q4U2/SbaD1+C8c12dC/nw8QIQUKegdGl0yobt+KNhH A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13008012" X-MGA-submission: MDG48rgx94wLZo/3EO67I5dIktNJtDeikG8/t7MYO9KNuD3beOhD3Y+L9dEmZ2kaeBkKVsBAiwRKxWB53w7SJJAqx4hMCbvuI0vtq/8ttuLlhL01PF/2B5W7MzkNRwdOGaIjPUlz0eeMdrIq62t1CooIwVYEgSwhGsYZ4K/9R4pCVA== 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:51 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oBaTJS7cxUZsWe2m/MiymtJhz6azvBZucI2LaVABQePzJklbGPHAT7wb4+QSl25hkeb5dPvXkoqPC2d1fRGqH7V1q/zMfL3G9bNt7UnojfI7AVkRVBWSuiBxmL5/HZ2/xRRMIreuQWLPWKxnUz8NUNGAXwBTxiXu1Wm3kxBbbx5rHH7xTDDoeBhRw4di/gDUjhHfsZk1fWOhPhcr5QY0M6/OSPqqbsXic5rI5koNVjVImA0Cm0f88+q7MVccVDHA7bK6p3LzIcmxUEzgNyAwAbetSM/igmZtxOj0ROaggNBmmyvbOd80JWF1N+IT56M2hiDkOd55H7Xp16F9+jPX3w== 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=rG+Bw3MmmndtbJbVWq6083592qHj2h+NjpwqB0a2mhM=; b=Q9deFib3E+KnbcAVdPfWnKIfBKrueTAyTgMnGtgjWvw3RP00eRmhwLAiaADmfE0yLtBMjlphHWo6rok3K4ZJEz+2+6ZmRzIVD6UxZ8fycZeqUhAmhRQh0iEY+5Z/ZI6S0V5+CZz5Vfmbgvg0cFrNHO1xUdVs+z9aSW5MrwgxNQSAgdA5X1Mw5nigfsNXqIlzQvAiwE4vYzrnjmWyyO3zFk2fQpXmIOrzXvZmJzXy9RdfpV+uSV8jTXXSTqHtukNBM8RHdLPq4evC9jQ4YMyFgV5cRdw0397nB93tmJmJodrSqai1D3NJKFCJdXh4iENecV6M1kAR1hNx4mhmYxiqPA== 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:50 +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:50 +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 17/22] atc: generic ATC that can be used by PCIe devices that support SVM Thread-Topic: [PATCH ats_vtd 17/22] atc: generic ATC that can be used by PCIe devices that support SVM Thread-Index: AQHaq4BxILxnhaztEUGv0ZSpe4izZQ== Date: Tue, 21 May 2024 13:11:50 +0000 Message-ID: <20240521130946.117849-18-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: e4b58842-519f-45ba-e76b-08dc79979399 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?L0IqHn3frpkqFLRxkubcpFJhAazgsVs?= =?utf-8?q?Hejmy4G6Jb0QSOKActXC3H0I+AUZRlIYzAteHZ3RXhEXaEQACec34/U0ht874VG+r?= =?utf-8?q?R+BuoBDfbHr1t4+j1CyCvG00Ne4Pjd0aMnYzVbGTtBfy25yQXaswMjqV8nM6UvOJq?= =?utf-8?q?vS/hcgL3iNeuIhO1V80GqiXVHlCVO1s2XTbsiGheWBmIDxW5iepTK4f3BW9aKRkSN?= =?utf-8?q?iEZk+6eEA7P4f6ICSuqqL/UIDxmOZNddBmy7/TMwlK1mD6mxMuxJ7DeiS/ojWGOGI?= =?utf-8?q?1+zXuAhdIDkiFwBp+qHNnE8IZCMzWze7lAxHhw9Xl+mp+1AAONzmd494FfFaNRx/R?= =?utf-8?q?TlXh/4BnvR/mZJnI+vBrgaFoEQWQG3A9zQvif2JNxIK7cuO/JYEWYRq6S33VEdhbW?= =?utf-8?q?tkOu2lhDiWovydmMHPLTZHgb2kpipDnAd3Dcc+Byx24vzNPkxRASJFV3/rbyvXVkA?= =?utf-8?q?Ao0mWXasMoRkU9wsU+uTI7mxE7IctaYm7ct2kn8/0HmyfHcieDrdLfMTMXBguip08?= =?utf-8?q?fz34yjQYuspbsZW9suvGUzUELlTnmxRFBtso3Diiv84v1JavdU4eoRGc6vQHMbBYW?= =?utf-8?q?6aoa2rlxu7mB1CBmx4gsaz94KRD/2Bcrov/Zv5qSktqq7Zgp5tth07M/RzTLsYbnI?= =?utf-8?q?cGiKdqqhpUyAfB0podVpYS4VlkEPywEmghk0ZwoSfpxI05B1rmaNu5W8ypNVhjMtv?= =?utf-8?q?0kUUk8Xssbf56ZQsYmagVdkYmQfdhwQCxXXcwrKmZm95JT1kk+YtctyJF3Vig93Mb?= =?utf-8?q?6nvcVn0CIz6olZ1zLwLAF1APUHbRid4g3DwIvqiizPQXfKnKLRo+r+IAvB6nfg8H7?= =?utf-8?q?NwxegzDhWJxx41Bwz5Z0FR8iL8K/psznNXC82rVMwE6nxz/t7zMv5iVV1K+3BUmFz?= =?utf-8?q?yXDOdtPHA/nlnwPv7fkgTK3V6YYMRVc9QcxApQWqSYwpNA9qamxfoKZZEyyxzMuzo?= =?utf-8?q?0rQ6RSJ06FS3EEsWFdZE+55W0XjrebJtydGfHLvyB12r1TGVR61unj0IgHJUn4bZL?= =?utf-8?q?OQJj1RvDwH24AoHuB+XVGV2pV1To71OpFXrcDNRncoZMCeNWAZMqO24Wmgnvtd++4?= =?utf-8?q?xnvASH61tDZEvrBaFP0gVR+dcD0/E3JGOqtsjfTEugGJQf+43BhDMqUmezg5dkhBK?= =?utf-8?q?gYFzgdm3d7HC8xaaNWcZPTZGrLWRsJnl3kIDykWnSaM2upir6DuqBX98O3p6ysCfp?= =?utf-8?q?siqtjZ2Pt+ExB5EGvpZoFljDPiIFXl74jHbg=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?BACUy0+ZJQDt1wxjzAq5pdNAxP1j?= =?utf-8?q?3BnBV9Vb50xGJepz+S1rIKXL/KcgpLsBlDPy9Ga9UzpSYYFdEnNCac43oirso2XyF?= =?utf-8?q?51BPlcKh3ypvUsEfHjBBC6RrHGRLQMNadH2lo2UDajDfuS91aQTSWfgR5P/ZyLS3W?= =?utf-8?q?KGzHQgCGSvb7D4TjyNyG2dU5qfClhYqUAxQXOHWeVJKa/iJzTIygcgMvJS8oIgp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=?utf-8?q?NvsjO/AIvpCpS7k6Es7xEwGfzhf8fLdgL1luv+ZjeFr9/MCxlJ6YgS1FxghR8l1tZ?= =?utf-8?q?FGZAbOGp5JbiZ69b4esvVr36YlAyPbeYEif6GWUZwyLd8jB1oVqUFxAMdicSAivL5?= =?utf-8?q?ckaeXStuI27dw92zAxZ67BlvheoQg06SE9zLmy0uzPIVPdIS1R0a6dGuWyMJko0Q3?= =?utf-8?q?j5mOuoWavZNplw7rJUpBiuGivOSBqMUBFp5zHKG4KD4I8P090k5d2cDwnU/Kbw9K4?= =?utf-8?q?N/m0HRnHZk9QN2wKY3is/gnwIW+oZ2nRRDih8K/l3vBQnXzpDPhmKNX3GOHj+TUQr?= =?utf-8?q?obfKKAq6iV/um0v5sBGGFlnk2MTfSOw3z8U/+nrm0lOMFMrdkZ6vxq75TPtcrxY3J?= =?utf-8?q?1F9mPZ530MTkb7K6rch9X4rFC/jeqmASyh8/4Zl30gnEBLxp7v40hRd5ntqhd/WbH?= =?utf-8?q?sWYiaoM57g3W1bWpOXlSkohK/0HV3Il/d6YD79L9kVL95g38n4X55uc=3D?= Content-ID: <4E4E46386A911F43BE9B36D2683FD9E3@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: e4b58842-519f-45ba-e76b-08dc79979399 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:50.2827 (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: vAb5aDYq1VbZxOft3Z1+hzcowAIl3dzK79EfJkJGrNbuzhtOWwOaTXce5JkuLn7BQ8dPh1QBYBCjR7L6K2MZBV3cM0XX33Jw7qosvHGy/m2sq7d6HmEMHmvT9E6Lbkdm 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 As the SVM-capable devices will need to cache translations, we provide an first implementation. This cache uses a two-level design based on hash tables. The first level is indexed by a PASID and the second by a virtual addresse. Signed-off-by: Clément Mathieu--Drif --- util/atc.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++ util/atc.h | 117 ++++++++++++++++++++++++++ util/meson.build | 1 + 3 files changed, 329 insertions(+) create mode 100644 util/atc.c create mode 100644 util/atc.h diff --git a/util/atc.c b/util/atc.c new file mode 100644 index 0000000000..584ce045db --- /dev/null +++ b/util/atc.c @@ -0,0 +1,211 @@ +/* + * QEMU emulation of an ATC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "util/atc.h" + + +#define PAGE_TABLE_ENTRY_SIZE 8 + +/* a pasid is hashed using the identity function */ +static guint atc_pasid_key_hash(gconstpointer v) +{ + return (guint)(uintptr_t)v; /* pasid */ +} + +/* pasid equality */ +static gboolean atc_pasid_key_equal(gconstpointer v1, gconstpointer v2) +{ + return v1 == v2; +} + +/* Hash function for IOTLB entries */ +static guint atc_addr_key_hash(gconstpointer v) +{ + hwaddr addr = (hwaddr)v; + return (guint)((addr >> 32) ^ (addr & 0xffffffffU)); +} + +/* Equality test for IOTLB entries */ +static gboolean atc_addr_key_equal(gconstpointer v1, gconstpointer v2) +{ + return (hwaddr)v1 == (hwaddr)v2; +} + +static void atc_address_space_free(void *as) +{ + g_hash_table_unref(as); +} + +/* return log2(val), or UINT8_MAX if val is not a power of 2 */ +static uint8_t ilog2(uint64_t val) +{ + uint8_t result = 0; + while (val != 1) { + if (val & 1) { + return UINT8_MAX; + } + + val >>= 1; + result += 1; + } + return result; +} + +ATC *atc_new(uint64_t page_size, uint8_t address_width) +{ + ATC *atc; + uint8_t log_page_size = ilog2(page_size); + /* number of bits each used to store all the intermediate indexes */ + uint64_t addr_lookup_indexes_size; + + if (log_page_size == UINT8_MAX) { + return NULL; + } + /* + * We only support page table entries of 8 (PAGE_TABLE_ENTRY_SIZE) bytes + * log2(page_size / 8) = log2(page_size) - 3 + * is the level offset + */ + if (log_page_size <= 3) { + return NULL; + } + + atc = g_new0(ATC, 1); + atc->address_spaces = g_hash_table_new_full(atc_pasid_key_hash, + atc_pasid_key_equal, + NULL, atc_address_space_free); + atc->level_offset = log_page_size - 3; + /* at this point, we know that page_size is a power of 2 */ + atc->min_addr_mask = page_size - 1; + addr_lookup_indexes_size = address_width - log_page_size; + if ((addr_lookup_indexes_size % atc->level_offset) != 0) { + goto error; + } + atc->levels = addr_lookup_indexes_size / atc->level_offset; + atc->page_size = page_size; + return atc; + +error: + g_free(atc); + return NULL; +} + +static inline GHashTable *atc_get_address_space_cache(ATC *atc, uint32_t pasid) +{ + return g_hash_table_lookup(atc->address_spaces, + (gconstpointer)(uintptr_t)pasid); +} + +void atc_create_address_space_cache(ATC *atc, uint32_t pasid) +{ + GHashTable *as_cache; + + as_cache = atc_get_address_space_cache(atc, pasid); + if (!as_cache) { + as_cache = g_hash_table_new_full(atc_addr_key_hash, + atc_addr_key_equal, + NULL, g_free); + g_hash_table_replace(atc->address_spaces, + (gpointer)(uintptr_t)pasid, as_cache); + } +} + +void atc_delete_address_space_cache(ATC *atc, uint32_t pasid) +{ + g_hash_table_remove(atc->address_spaces, (gpointer)(uintptr_t)pasid); +} + +int atc_update(ATC *atc, IOMMUTLBEntry *entry) +{ + IOMMUTLBEntry *value; + GHashTable *as_cache = atc_get_address_space_cache(atc, entry->pasid); + if (!as_cache) { + return -ENODEV; + } + value = g_memdup2(entry, sizeof(*value)); + g_hash_table_replace(as_cache, (gpointer)(entry->iova), value); + return 0; +} + +IOMMUTLBEntry *atc_lookup(ATC *atc, uint32_t pasid, hwaddr addr) +{ + IOMMUTLBEntry *entry; + hwaddr mask = atc->min_addr_mask; + hwaddr key = addr & (~mask); + GHashTable *as_cache = atc_get_address_space_cache(atc, pasid); + + if (!as_cache) { + return NULL; + } + + /* + * Iterate over the possible page sizes and try to find a hit + */ + for (uint8_t level = 0; level < atc->levels; ++level) { + entry = g_hash_table_lookup(as_cache, (gconstpointer)key); + if (entry && (mask == entry->addr_mask)) { + return entry; + } + mask = (mask << atc->level_offset) | ((1 << atc->level_offset) - 1); + key = addr & (~mask); + } + + return NULL; +} + +static gboolean atc_invalidate_entry_predicate(gpointer key, gpointer value, + gpointer user_data) +{ + IOMMUTLBEntry *entry = (IOMMUTLBEntry *)value; + IOMMUTLBEntry *target = (IOMMUTLBEntry *)user_data; + hwaddr target_mask = ~target->addr_mask; + hwaddr entry_mask = ~entry->addr_mask; + return ((target->iova & target_mask) == (entry->iova & target_mask)) || + ((target->iova & entry_mask) == (entry->iova & entry_mask)); +} + +void atc_invalidate(ATC *atc, IOMMUTLBEntry *entry) +{ + GHashTable *as_cache = atc_get_address_space_cache(atc, entry->pasid); + if (!as_cache) { + return; + } + g_hash_table_foreach_remove(as_cache, + atc_invalidate_entry_predicate, + entry); +} + +void atc_destroy(ATC *atc) +{ + g_hash_table_unref(atc->address_spaces); +} + +size_t atc_get_max_number_of_pages(ATC *atc, hwaddr addr, size_t length) +{ + hwaddr page_mask = ~(atc->min_addr_mask); + size_t result = (length / atc->page_size); + if ((((addr & page_mask) + length - 1) & page_mask) != + ((addr + length - 1) & page_mask)) { + result += 1; + } + return result + (length % atc->page_size != 0 ? 1 : 0); +} + +void atc_reset(ATC *atc) +{ + g_hash_table_remove_all(atc->address_spaces); +} diff --git a/util/atc.h b/util/atc.h new file mode 100644 index 0000000000..8be95f5cca --- /dev/null +++ b/util/atc.h @@ -0,0 +1,117 @@ +/* + * QEMU emulation of an ATC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef UTIL_ATC_H +#define UTIL_ATC_H + +#include "qemu/osdep.h" +#include "exec/memory.h" + +typedef struct ATC { + GHashTable *address_spaces; /* Key : pasid, value : GHashTable */ + hwaddr min_addr_mask; + uint64_t page_size; + uint8_t levels; + uint8_t level_offset; +} ATC; + +/* + * atc_new: Create an ATC. + * + * Return an ATC or NULL if the creation failed + * + * @page_size: #PCIDevice doing the memory access + * @address_width: width of the virtual addresses used by the IOMMU (in bits) + */ +ATC *atc_new(uint64_t page_size, uint8_t address_width); + +/* + * atc_update: Insert or update an entry in the cache + * + * Return 0 if the operation succeeds, a negative error code otherwise + * + * The insertion will fail if the address space associated with this pasid + * has not been created with atc_create_address_space_cache + * + * @atc: the ATC to update + * @entry: the tlb entry to insert into the cache + */ +int atc_update(ATC *atc, IOMMUTLBEntry *entry); + +/* + * atc_create_address_space_cache: delare a new address space + * identified by a PASID + * + * @atc: the ATC to update + * @pasid: the pasid of the address space to be created + */ +void atc_create_address_space_cache(ATC *atc, uint32_t pasid); + +/* + * atc_delete_address_space_cache: delete an address space + * identified by a PASID + * + * @atc: the ATC to update + * @pasid: the pasid of the address space to be deleted + */ +void atc_delete_address_space_cache(ATC *atc, uint32_t pasid); + +/* + * atc_lookup: query the cache in a given address space + * + * @atc: the ATC to query + * @pasid: the pasid of the address space to query + * @addr: the virtual address to translate + */ +IOMMUTLBEntry *atc_lookup(ATC *atc, uint32_t pasid, hwaddr addr); + +/* + * atc_invalidate: invalidate an entry in the cache + * + * @atc: the ATC to update + * @entry: the entry to invalidate + */ +void atc_invalidate(ATC *atc, IOMMUTLBEntry *entry); + +/* + * atc_destroy: delete an ATC + * + * @atc: the cache to be deleted + */ +void atc_destroy(ATC *atc); + +/* + * atc_get_max_number_of_pages: get the number of pages a memory operation + * will access if all the pages concerned have the minimum size. + * + * This function can be used to determine the size of the result array to be + * allocated when issuing an ATS request. + * + * @atc: the cache + * @addr: start address + * @length: number of bytes accessed from addr + */ +size_t atc_get_max_number_of_pages(ATC *atc, hwaddr addr, size_t length); + +/* + * atc_reset: invalidates all the entries stored in the ATC + * + * @atc: the cache + */ +void atc_reset(ATC *atc); + +#endif diff --git a/util/meson.build b/util/meson.build index 2ad57b10ba..e6ca37a4b1 100644 --- a/util/meson.build +++ b/util/meson.build @@ -93,6 +93,7 @@ if have_block util_ss.add(files('hbitmap.c')) util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c')) + util_ss.add(files('atc.c')) util_ss.add(files('iov.c', 'uri.c')) util_ss.add(files('nvdimm-utils.c')) util_ss.add(files('block-helpers.c')) From patchwork Tue May 21 13:11:51 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: 13669435 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 DDD84C25B7A for ; Tue, 21 May 2024 13:12:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHq-00083L-5H; Tue, 21 May 2024 09:12:14 -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-0007kV-H3 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11: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 1s9PHV-0001Zt-PI 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=VbrUOIfc8U2UXrs6qL7PQ/+HQEYub06zah43XKt6V9I=; b=rRkpe5Wk2iUPB4fu9PeYtRR7N7/1BrWpWcKPRpCmLzLY7AUmw2DxTxZd 2wTYn1p08oDqoGuEyESbasDhpj4VM7PuBbf8s+pnc261Ggh80O204qSpx z/ISdzZp9p0T9MSqG6mlGIIZ9wsPGICzN2LFH5stUZt2qGvYMgM1NvPjQ eszkkLUuRgx7zfrP7vhO+inUJjz4Whrqqyqa1qe9RRr0ipZKE4SZjxP+d tQkJZ9otdZvs7/RcK32bZPokRoKCLKwuLX/LKMFoN9hJweGGpbvj6A8GT iF1/6/6SoWg6Rre6vZAZt5Urgr1TczqM+KcoHbAPL0haUzeTj3Mt9SdsX Q==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13004109" X-MGA-submission: MDFxsB7xin/uDNOsIDkr3O5BEHMrcXBudKGn8VcsQNaXUcgBcrtbNb7arztuMVCcQh5CeeHUc6DFcjdQB1ZrrjwnnWsu9z4Jgyn4CWL4THOMPHSN311R57tWbajHV2+sv9K3rNZokqpY7Hk0YOxzOPgabKt1cSct1Vat90C6bhdtWQ== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:52 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XWqMOzS9Ci0oBW8cecDfgp32CUjNt8LZrYvr6f5YoIJ8cmLKovp2XdktLzYjbOVexU8DJ/3wONKXVZGKU/cloOX+qaY9nTQ+HiuIeQb4E7PAxkpQ4k+jW0+iz+JB7SwjSE3iQLh5Ussups9c79A5pOqB/M60AB4w8uZQEEynLK+UB5qH9OXEdqwWmTHxkBONdsdT15rE/T1tFSSW5yuwGlMbeupwU3EJAZR/Rwtq8GkJV2BXIWNcQ/qlBfOQR+lCedlmAaacEynlxsnWeesu1QzpCLcBXNJC/Bqpta0e1Z23VDtb/SbwWoTbbBmY9Bzm3Tf5z6yxQg/5ABdx0VCuMw== 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=VbrUOIfc8U2UXrs6qL7PQ/+HQEYub06zah43XKt6V9I=; b=eyb5mSV/TOC+DGXEyrFxNu3+ZCxnsfOXK1SBKxQkP8Xhza6qO2FUWZgEXHvEYFrgrYly1Htv0AIUUk1Sa4Ow9JRYE1Jh706IqDuuUZo/qKZIZNBnoibFqxB99ZYjmy1bm+ZAyMDFAuqMX9t58J9aP3OPfyHhslGUtM/NuZ7UZ12HSRk4eLiwCaVACk3OrW9YMjuUA5gCoQGiIHq8XkaJtLWSFrCQEoGeGrGGZhBW0FPVxmJvnxKGvt0Gde1qbn5kd2UQlpQ0p5sMZSmUFfyFmYTEyJUdwQAAeoLsqRQtz6xYE90SwRmae0vsyqlAY9RVOX4MTU+F68pRULlcU7cidA== 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:51 +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:51 +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 18/22] atc: add unit tests Thread-Topic: [PATCH ats_vtd 18/22] atc: add unit tests Thread-Index: AQHaq4BxokQ3ac59N0iT4f1OV0wt4w== Date: Tue, 21 May 2024 13:11:51 +0000 Message-ID: <20240521130946.117849-19-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: 76efda2a-dbfe-4acc-6faa-08dc7997941f 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?4tIAz3AUAjsClRDCJQ6WKwo2QXcWLaw?= =?utf-8?q?R2jlEaiPMeDhOj8cD0NBu3Rl4EfR5jzVhXbAD4yGDC4TEu1iZcqMhgUmWJAtgADi/?= =?utf-8?q?cl1ohOZAgx2CQneBL4vNucsR1LJka2SwAnUEVICF0e25+BCPnAxa20RwZ1cqSZRYK?= =?utf-8?q?tLB53XXtTTpgzLLSEpXwEGTwKFpj3B4Ygzc+tWr3lWjc/ldpfJupnZzfq8tTeCz1j?= =?utf-8?q?It4Vnpv3rKKU834eglBDPZLAkrfsttBa1ha2HqnCwTPGsl/pvAJ6DqeqZQmwWTFgw?= =?utf-8?q?56dDTPqDv+/1bmlLHUFiEagbl8liJNrdTGX3zBYrCTyF3jj7EvhVoRzle9+XiktCF?= =?utf-8?q?7BtZtutwXXmbA34u9zcAWY2AVDiw/YBNbfPMWv+pw4paEK2ni441i3CjrU/7DzcJp?= =?utf-8?q?8XzS5jX8lJTIldKD2uznJP4ac5T9WJbKeq0nKgCDepgAMWAjD0BvjdOjlfTZU+OxX?= =?utf-8?q?m6HBkheLkAJzyONHO0B1vSsP9Gy54+mXr7HrrkmiB6062u+aeE4GeB+lhlCXogoxv?= =?utf-8?q?StjfZAVGiXMDywNyoztKLK0njcb3GpSbe7ZlAOoq3hbPxltdPS24KuOBZzTxaWmLQ?= =?utf-8?q?HthkEijzyfynk54joz2tr1n/rWPo4fYJo/V6uaVhZmC36Ppp4e5k5iX7NsRBcvt3K?= =?utf-8?q?8ipj5D3jLAqyhXOphFEItrUPVzTklszKahPR+RhNdJ+cLaShlSU3ZEq5StGnIXE4T?= =?utf-8?q?Ji5JlXCzN/rRbNeYWH3jaCXRBWRo0di0sHubKyqfBucsD+g/rkJrxi6aIKx71imjs?= =?utf-8?q?CmD3izmhDFagynSyZxHnhYF14wpUHqW8flF/XgCrLHfCtTn/5HazfWgSYqdTE/ytt?= =?utf-8?q?BWxtOil3KvfNXu+wjxxWiKj4HJnAp2U+63IXBXDaRPNEn/dLcNrdJ2vkEi5TFRArC?= =?utf-8?q?9emcQq42VX6Se98xY9PDTlyHfQGiI8Uyzqq3jUU1wbsfF7x/7EqmEkFpwVzik3+D0?= =?utf-8?q?6HNb3tsxlGCEnmW6KUemznQb7wNj5NFbuX9hTwlK6elNMAfBdoWr+9wbLLFjqkeTW?= =?utf-8?q?wR+zfq2Mse7cC2ouY3gnjM1zRC5WHa+/hrEm6qACMpg9kGCzx1Lk0OHX8WFpf9SmU?= =?utf-8?q?MEugJYi2FzwCd5ciFdnHuo5ipRQ/Z7Uvd46jrb6ST5lEnXwQ681aH5YEyEJwJvIfa?= =?utf-8?q?wS1z6bhOnB7/UoSNz0PWodaR4spszN4sP+8M53aKy0XgeHxe4fuKbuYe8zpGInf8Y?= =?utf-8?q?zZSkPrfHoZoxVXgtQYNrtgtPeSeWBFGmFmTw=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?arsBq3AJ471ERjqyKM5P4ZHKiprF?= =?utf-8?q?h2ulJ/+yx8dTU7AqeyfRNO6LQQVhAktkvem/prq4Q2rPc9mVf83lDEHZXMqcLIQOE?= =?utf-8?q?RiVnLjk6oGs1wWzKlwmp55JnyszfQtRx58RYJCjV7nEIb6cU8+xbbg1HQxvo1jq5w?= =?utf-8?q?weZ8MBhApXigroKVTyXxeHBS0cj+DjGegJrM64Fvss9GeP8/KknWAH0IcmfKYRalI?= =?utf-8?q?dmooVMNHq8ChmjMs+rFZ0ZkugNvG09WSq0DThBysFrl3MVqY9Tjvh63D3rSYyMeGd?= =?utf-8?q?6uENa53WGUuo54g5BJqlq9M7aMLSptPJ5zLDVbr2hdq/9ZAryyvzyY8ZG15TEwZ78?= =?utf-8?q?sJoxXd0kJatj7hn+zg4WptWhmn3zoGNphv4ncp7VwtQzPONWNvjJ3F8tTtR0issYN?= =?utf-8?q?cOIFwRemDXKrbaj8WcJXNkpcgAzl2pBA01zLO/va+TpagyQ7uwqQoapyG0/obhgnH?= =?utf-8?q?25MXcVgULTN2sbp7e5svECJYQFbUnAnHckON2cmAHUtcE1T4YUstlkWvNxr3Or+c0?= =?utf-8?q?P3aSMrnnAippzKFN/kFUymE5WApXFZG7lQC2qCY1W6vgvSkgoPAFj7TXjhPOH7QGl?= =?utf-8?q?rKnNTSoDnAFMZUFCsqsq14BuuJulEFsYIKUWGWDa3wCQ7xGAbpogjjxHwzytpusS1?= =?utf-8?q?Y1CJLXPwHuk+KwKtMkgBT1GM5DIu7GPeYui8S3r3BnmExbNe1Wsb7ndnwCvJtjSm0?= =?utf-8?q?sH9Vmtcx/u4CBX/FqWqfLMezKbCvjmVBF3MlR2jNVOjBYxa3bJRDQgoMrBQonTj6p?= =?utf-8?q?e3zyFUUcfkAbwxdDFpF/BwPulpeolbwCky8VuyQiv40GkOy50mnfOtU6rdY8aC0tH?= =?utf-8?q?rK1Ep8y4L8qtqUOJuvRu8JSqvGBHtm+/5Ohq2Qh4b710reOImROWlA2Kyn4zuU65O?= =?utf-8?q?l48hcc/SQfH6EUfOFDHUVrCLZa4cWuFy2M4zpDcQncVNYI43OLdOPQpn/Dt30I5st?= =?utf-8?q?anTLdaDkuWtsSv52uNLX+GQ5LGXdoBLorPySC8RJUupiHXVLvAGEslgiVpWJYaWit?= =?utf-8?q?odOO/AmSc5gmew1PxQXihmKvPiXhA5cmwEsE9vUcWCjmpWLVxhRKYpdCaAXAp8vjP?= =?utf-8?q?lmKWqgXYAtGBNF+8UNY7nuyq4sPEhOfshv2k4KsFf/1wnqfX2i5GaMIPkQAghdGhu?= =?utf-8?q?RCTB8TesXi+Cfa8wHwGkjTDvJVWelBtXlLMN0DEWRu6fZVeTsSAIzwV3gYgqviK4Y?= =?utf-8?q?RdljI2L0I+Kkg8kFAR4yXUPwoinlMcYf5lUEF/iT8cBIXGFPSkKJJYdF0NgHw/T45?= =?utf-8?q?+joxstV7/6Q2h9HrQCGc0ZvmfM6wUs/+Vh12Vk1C7WTpa+khI/Hce19VbMn5aH726?= =?utf-8?q?b6XPtjKL+NawPTe02xD9WjBpaANOCzIo9LxXNTaO7nsRVKWZsG7+PWnqQCcxBbq2A?= =?utf-8?q?POwugkoQ4iGrtZuZ3Mgllc5dgZDNq8IQ9FTnOYhGaPTImpUoxlIf7v02X7JidSZ0J?= =?utf-8?q?f7JnKJZDXxZRuWBPIT7B3T4rhdrBQy3oGjozT7Tz286uzZg2nrgu+DUUFt77hKE2b?= =?utf-8?q?FCLV7RJ7m1ZXdzAW+dmtUC/iObacka3Ithrbi8F8K5V318a5SaTeRuo=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: 76efda2a-dbfe-4acc-6faa-08dc7997941f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:51.1322 (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: OEjyhf9cf6v6cVmB/H8dCH0h9LVrTxJm4a2nvOOP0y5bX84h0shyvD7EcFtj88ItnUs0msS9NJ6HOBZ/NAHWIAd8QBr5tSh77Ko3lmWE+47hOaix29VyA+vkxoNDj9my X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 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 --- tests/unit/meson.build | 1 + tests/unit/test-atc.c | 527 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 528 insertions(+) create mode 100644 tests/unit/test-atc.c diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 26c109c968..d6c6c574de 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -47,6 +47,7 @@ tests = { 'test-logging': [], 'test-qapi-util': [], 'test-interval-tree': [], + 'test-atc': [] } if have_system or have_tools diff --git a/tests/unit/test-atc.c b/tests/unit/test-atc.c new file mode 100644 index 0000000000..89378f7f63 --- /dev/null +++ b/tests/unit/test-atc.c @@ -0,0 +1,527 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "util/atc.h" + +static inline bool tlb_entry_equal(IOMMUTLBEntry *e1, IOMMUTLBEntry *e2) +{ + if (!e1 || !e2) { + return !e1 && !e2; + } + return e1->iova == e2->iova && + e1->addr_mask == e2->addr_mask && + e1->pasid == e2->pasid && + e1->perm == e2->perm && + e1->target_as == e2->target_as && + e1->translated_addr == e2->translated_addr; +} + +static void assert_lookup_equals(ATC *atc, IOMMUTLBEntry *target, + uint32_t pasid, hwaddr iova) +{ + IOMMUTLBEntry *result; + result = atc_lookup(atc, pasid, iova); + g_assert(tlb_entry_equal(result, target)); +} + +static void check_creation(uint64_t page_size, uint8_t address_width, + uint8_t levels, uint8_t level_offset, + bool should_work) { + ATC *atc = atc_new(page_size, address_width); + if (atc) { + if (atc->levels != levels || atc->level_offset != level_offset) { + g_assert(false); /* ATC created but invalid configuration : fail */ + } + atc_destroy(atc); + g_assert(should_work); + } else { + g_assert(!should_work); + } +} + +static void test_creation_parameters(void) +{ + check_creation(8, 39, 3, 9, false); + check_creation(4095, 39, 3, 9, false); + check_creation(4097, 39, 3, 9, false); + check_creation(8192, 48, 0, 0, false); + + check_creation(4096, 38, 0, 0, false); + check_creation(4096, 39, 3, 9, true); + check_creation(4096, 40, 0, 0, false); + check_creation(4096, 47, 0, 0, false); + check_creation(4096, 48, 4, 9, true); + check_creation(4096, 49, 0, 0, false); + check_creation(4096, 56, 0, 0, false); + check_creation(4096, 57, 5, 9, true); + check_creation(4096, 58, 0, 0, false); + + check_creation(16384, 35, 0, 0, false); + check_creation(16384, 36, 2, 11, true); + check_creation(16384, 37, 0, 0, false); + check_creation(16384, 46, 0, 0, false); + check_creation(16384, 47, 3, 11, true); + check_creation(16384, 48, 0, 0, false); + check_creation(16384, 57, 0, 0, false); + check_creation(16384, 58, 4, 11, true); + check_creation(16384, 59, 0, 0, false); +} + +static void test_single_entry(void) +{ + IOMMUTLBEntry entry = { + .iova = 0x123456789000ULL, + .addr_mask = 0xfffULL, + .pasid = 5, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + + ATC *atc = atc_new(4096, 48); + g_assert(atc); + + assert_lookup_equals(atc, NULL, entry.pasid, + entry.iova + (entry.addr_mask / 2)); + + atc_create_address_space_cache(atc, entry.pasid); + g_assert(atc_update(atc, &entry) == 0); + + assert_lookup_equals(atc, NULL, entry.pasid + 1, + entry.iova + (entry.addr_mask / 2)); + assert_lookup_equals(atc, &entry, entry.pasid, + entry.iova + (entry.addr_mask / 2)); + + atc_destroy(atc); +} + +static void test_single_entry_2(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xabcdef200000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + assert_lookup_equals(atc, NULL, e1.pasid, 0xabcdef201000ULL); + + atc_destroy(atc); +} + +static void test_page_boundaries(void) +{ + static const uint32_t pasid = 5; + static const hwaddr page_size = 4096; + + /* 2 consecutive entries */ + IOMMUTLBEntry e1 = { + .iova = 0x123456789000ULL, + .addr_mask = page_size - 1, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 = { + .iova = e1.iova + page_size, + .addr_mask = page_size - 1, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0x900df00dULL, + }; + + ATC *atc = atc_new(page_size, 48); + + atc_create_address_space_cache(atc, e1.pasid); + /* creating the address space twice should not be a problem */ + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova - 1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova + e1.addr_mask); + g_assert((e1.iova + e1.addr_mask + 1) == e2.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova + e2.addr_mask); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova + e2.addr_mask + 1); + + assert_lookup_equals(atc, NULL, e1.pasid + 10, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid + 10, e2.iova); + atc_destroy(atc); +} + +static void test_huge_page(void) +{ + static const uint32_t pasid = 5; + static const hwaddr page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x123456600000ULL, + .addr_mask = 0x1fffffULL, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + hwaddr addr; + + ATC *atc = atc_new(page_size, 48); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + for (addr = e1.iova; addr <= e1.iova + e1.addr_mask; addr += page_size) { + assert_lookup_equals(atc, &e1, e1.pasid, addr); + } + /* addr is now out of the huge page */ + assert_lookup_equals(atc, NULL, e1.pasid, addr); + atc_destroy(atc); +} + +static void test_pasid(void) +{ + hwaddr addr = 0xaaaaaaaaa000ULL; + IOMMUTLBEntry e1 = { + .iova = addr, + .addr_mask = 0xfffULL, + .pasid = 8, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 = { + .iova = addr, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0xb001ULL, + }; + uint16_t i; + + ATC *atc = atc_new(4096, 48); + + atc_create_address_space_cache(atc, e1.pasid); + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + for (i = 0; i <= MAX(e1.pasid, e2.pasid) + 1; ++i) { + if (i == e1.pasid || i == e2.pasid) { + continue; + } + assert_lookup_equals(atc, NULL, i, addr); + } + assert_lookup_equals(atc, &e1, e1.pasid, addr); + assert_lookup_equals(atc, &e1, e1.pasid, addr); + atc_destroy(atc); +} + +static void test_large_address(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaaaaaaaaa000ULL, + .addr_mask = 0xfffULL, + .pasid = 8, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0x1f00baaaaabf000ULL, + .addr_mask = 0xfffULL, + .pasid = e1.pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + + ATC *atc = atc_new(4096, 57); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_bigger_page(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaabbccdde000ULL, + .addr_mask = 0x1fffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + hwaddr i; + + ATC *atc = atc_new(8192, 43); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + i = e1.iova & (~e1.addr_mask); + assert_lookup_equals(atc, NULL, e1.pasid, i - 1); + while (i <= e1.iova + e1.addr_mask) { + assert_lookup_equals(atc, &e1, e1.pasid, i); + ++i; + } + assert_lookup_equals(atc, NULL, e1.pasid, i); + atc_destroy(atc); +} + +static void test_unknown_pasid(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaabbccfff000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + + ATC *atc = atc_new(4096, 48); + g_assert(atc_update(atc, &e1) != 0); + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + atc_destroy(atc); +} + +static void test_invalidation(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xaabbccddf000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xffe00000ULL, + .addr_mask = 0x1fffffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0xb000001ULL, + }; + IOMMUTLBEntry e3; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + atc_invalidate(atc, &e1); + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + + atc_update(atc, &e1); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + + /* invalidate a huge page by invalidating a small region */ + for (hwaddr addr = e2.iova; addr <= (e2.iova + e2.addr_mask); + addr += page_size) { + atc_update(atc, &e2); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + e3 = (IOMMUTLBEntry){ + .iova = addr, + .addr_mask = page_size - 1, + .pasid = e2.pasid, + .perm = IOMMU_RW, + .translated_addr = 0, + }; + atc_invalidate(atc, &e3); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + } + atc_destroy(atc); +} + +static void test_delete_address_space_cache(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xaabbccddf000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = e1.iova, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + atc_invalidate(atc, &e2); /* unkown pasid : is a nop*/ + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e1); + /* e1 has been removed but e2 is still there */ + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_delete_address_space_cache(atc, e2.pasid); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_invalidate_entire_address_space(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x1000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xfffffffff000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0xbeefULL, + }; + IOMMUTLBEntry e3 = { + .iova = 0, + .addr_mask = 0xffffffffffffffffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e3); + /* e1 has been removed but e2 is still there */ + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + + atc_destroy(atc); +} + +static void test_reset(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x1000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xfffffffff000ULL, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0xbeefULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_reset(atc); + + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_get_max_number_of_pages(void) +{ + static uint64_t page_size = 4096; + hwaddr base = 0xc0fee000; /* aligned */ + ATC *atc = atc_new(page_size , 48); + g_assert(atc_get_max_number_of_pages(atc, base, page_size / 2) == 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size) == 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size + 1) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, 1) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size - 10) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 1) == 2); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 2) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 1) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 2) == 2); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 3) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size * 20) == 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + (page_size - 10)) + == 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + + (page_size - 10 + 1)) == 22); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_func("/atc/test_creation_parameters", test_creation_parameters); + g_test_add_func("/atc/test_single_entry", test_single_entry); + g_test_add_func("/atc/test_single_entry_2", test_single_entry_2); + g_test_add_func("/atc/test_page_boundaries", test_page_boundaries); + g_test_add_func("/atc/test_huge_page", test_huge_page); + g_test_add_func("/atc/test_pasid", test_pasid); + g_test_add_func("/atc/test_large_address", test_large_address); + g_test_add_func("/atc/test_bigger_page", test_bigger_page); + g_test_add_func("/atc/test_unknown_pasid", test_unknown_pasid); + g_test_add_func("/atc/test_invalidation", test_invalidation); + g_test_add_func("/atc/test_delete_address_space_cache", + test_delete_address_space_cache); + g_test_add_func("/atc/test_invalidate_entire_address_space", + test_invalidate_entire_address_space); + g_test_add_func("/atc/test_reset", test_reset); + g_test_add_func("/atc/test_get_max_number_of_pages", + test_get_max_number_of_pages); + return g_test_run(); +} From patchwork Tue May 21 13:11:51 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: 13669437 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 80FA7C25B74 for ; Tue, 21 May 2024 13:13:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PHq-00083X-4o; Tue, 21 May 2024 09:12:14 -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-0007kW-IM for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11: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 1s9PHW-0001by-NO 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=0dE/fO+DHZfygGNvv8Lx3q8Dt93nwgJmL7gxtEqEPQA=; b=c/j4I7bhSuKLF1i38R74cJRFh3GpVRhdvwCnCK9o+WWv/0O9vhuzHY9y yoRVP/cFcfFGam4Ri5vklY5sOtJ/JV5CaYDOvx/ebx1JGUneP2tNXwnhh 6rRO/ZGE+01xApFSB2d6P33/eAoahgI/jFasPfHS9WiEY60QcRKuu5vM+ P7GWeuuoSGYmSVan6HO/HIMp2iJEZtY4cFXmXeqvMZLUvMx0Uy4w4mJWb M0xU3Hsn/HJx67ExTS5ztbBUCrkjVXgRpcxkLhJD2ohldcNIkmr+wAGwJ Gr2KrL3F5lLPmWND7sV6GlCny/UxA1ek+DIZLF6Gv1n5FIXBk47NzylRl A==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13004111" X-MGA-submission: MDGq8+OYkkOKG5+DJmqOPG8PEpenaY6pYbuyD+Ap6RQ2Hbe+2Q1ANRCkLmb2Iu7V73i0SCtWFjYKT0JIwcP5cCo3kPzB6U7aQV5tGS/a9qkjjEAlp8sBVvEtHGzSC0a4AMxSsAV/I/FPVuVi98/V/SOvtFqCzvjPi34uxL1cu0HK2g== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:53 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=So5HxPW4MaavwqEFJLCKCVhkGx790Wydd2gPOBXv2iRlLwy/Uwn1+dtavxtJyfivf2SvGdUvXQcbYcxdjho+tmOVP+yZc9gtg8IX2MICIKawH3TrrNzGsbGDgWOi0EL8QSNOAbQMCvVEioRLdwuVsmalVMzhyTBIyNSJUKhLQ5Pqj/9qyNUkr4HMGj0LDFGIEDNqqzV0PHrKG1YltAkkMnvgSGrToZUEkAr4vDZ8+NWdZWfMaevLYT7AM4yin5vU/gi0xhFYVp7ZKIe/L7xSWbk7eunl9UtfGzjJCnuUhrw5/gc93kTLjqQXhwrLx3vwmPsY0xn+4U29FF/JKKFpWw== 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=0dE/fO+DHZfygGNvv8Lx3q8Dt93nwgJmL7gxtEqEPQA=; b=XafJC83IpvbcXr/Bhq3DO2/9fu5mIwktaT/cWExmqfFhDHqhYC3daaxXKqwh2qaHi0AlSMZKlM0NL8Tg6nDLowPkftm2tOqUsIoEYl0Q2zAb6mEqa5qR5Dg6v0cfF79zuI4Yd7LTlXszdSaJ9Bg5BPw08x/ktufRLRhH6rQMNEURdkvpNffs+Ts5NkYs0kbrs3JSxv9+jZ1K5HXx74ePNdsm3EeYD+Tgq0/nJRzmzXVZMlMeur2hqACEmfqo6xksgaDP6d3FSv2GfMJDNU+Gf66N7Ya2WMadTFkSzA+60zRx3xtguMl5hxR3zH0fdFDigXz5OItgcVWWFsNkHbgWIQ== 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:51 +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:51 +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 19/22] memory: add an API for ATS support Thread-Topic: [PATCH ats_vtd 19/22] memory: add an API for ATS support Thread-Index: AQHaq4By7GJRtLEAU06I3NQX0IDNRg== Date: Tue, 21 May 2024 13:11:51 +0000 Message-ID: <20240521130946.117849-20-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: 123c417a-4e6a-48a1-e56b-08dc79979491 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?uQKeWksHp1aSXyEqsDcZMJjf4E7waY1?= =?utf-8?q?vzXZ+zwv73JY4pMaLvZG5uc0N4UEbgCis6uDqtiYhV2GCu7ZV9QFExCOW+iqFI6wX?= =?utf-8?q?JW9LCyjOZ1r9IeVK/659PvIzp+KBNvcTnBtUe/ZmYz98vSn4soOSLpcSprIW68pYp?= =?utf-8?q?pcPijQQVPOfCDI+hW2lvfy6wcdvLFyvxsx98jrBPa1wbS6ZS+NMhjjgVtnE3I7HVJ?= =?utf-8?q?UpLYFcGEfdjXL1ZaSLI6hQQzGQ2efgdBPFdKl6gGNvbEeLRNAG3cOMXNyg6ddTeB9?= =?utf-8?q?t81p+Xwqa/o4Qg/2qZQadkOb1j0MNhOil8Z8C5ox42AM3ENt3du+DspPyP8ZgSbSR?= =?utf-8?q?WUoH7Otg2bVCQyemdzpEvzUoQG/wP6z6QJ3o0AyLWA150OzglUxgBePNAshkX8dJB?= =?utf-8?q?IwP1BDHnQvFfccoqd/OmFo5bNdymTSHA89akGxjpu4eaJ6g9ipooNWU742dtMxptx?= =?utf-8?q?lcPZlfX9xV0JTWvVEsVjgKZAL+xiWZsCrpuybGKkXL9j8CLtWAg1zxyHK7EiHUGgV?= =?utf-8?q?+IzsSdcJKYiXRcObzxHYOJj+iJMZThn9u8RZtcGtMtE/zzuqLb9kMY0Q61XWb0zZS?= =?utf-8?q?rD+Mb1do30R/UFNyOIrneKstPqQa34fb3/1ghA+OLj7gfixkwWvgUmi8BKx+CGIK5?= =?utf-8?q?igNRIz/qAfQ9jdASgp4MosLBQhM6+XlaWlHhKeSGjj/2ZDWmig8ImzLrOmtRJqqnO?= =?utf-8?q?EBJHgrmLhK/8PaymajoD8Bc2zdM9Wtn6YFQoaA57rZTAhgCJCtDOkxtO7m810u+Ve?= =?utf-8?q?cUXDGLnQP4jJ9/fVs0GkoXvfZy47RZ19GQXYABPZYuGonkghL7RcKcd3CJ4UvkXzh?= =?utf-8?q?/Viq7iTjp9R09yo9l0N5gRl2yTrxWjhpTkjI22JhHVLmx+f6Jv2UcgLJ56dsWtGz5?= =?utf-8?q?DslUgNI+60IAluPrskGha6EwK5AZG/FJgs5UjuXQHPnZ7Pc+zIX3hUyKv22Q3yffs?= =?utf-8?q?uQ75wwTzNohJh/vglwRKof91B8m15RS/hmUVGiWDJ6fvzkBi8ZoAYt95sYljpCemT?= =?utf-8?q?RZ6RmHN2JTgYhJsucY7Nrp/clmS8vE8xFJYAZqHpkBvdkuVM7nfp2po2+j8QCUUCJ?= =?utf-8?q?X5bLBsf6A4KLTHkejMmvg7kcFp9hgzAIHPPZ68M24ej18RE1t1IHaFNkCzq/eSdje?= =?utf-8?q?SK/i5jPq9xyZrwwFlzbGJLkIzGB1stPJL8fvD2xe9M55LSz8GUd7jugiYjEJqYIPr?= =?utf-8?q?1Ttfa7v7LmQyPzZT7tw5QIHIPVQpj/qlklgrqzJnEvLrc0bt/yi836hXQPDAzrXSt?= =?utf-8?q?ttAHtmSuIMYYYDOQWzrzhK3WD5YsUcUkvaw=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?ZF5sksiASxJ4gALYPRV4R4Ev2CJb?= =?utf-8?q?BYPAIk5wFNoqtstpC2kCp8NFPYipyEN6BzUnhOU5FhnaqOM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HFGsOs6TmoFVme4/N6pM7?= =?utf-8?q?Grx53ImQc/tfJB701GcGl3kbmlfjbz/Pwhk9/dESSJjxUapADd+upVKLUQH6pZxSk?= =?utf-8?q?AOOSUXP0ncsd5n5HRTsLpo3KVmR9+vWFiFH6qYNblFOa9w4OtNlqy5/ir3iMP51fb?= =?utf-8?q?M448HiXLC6RP4u2fP23vKoGZ4wNQSflrhbtO501qt5iYM6jWcTAbiyb6QUt07fsHC?= =?utf-8?q?fXD9XIf1ezs0Bqe1NwPLnts/tNqib1fHTraaRPtspXArwRvo6lvTIANfCrUWfTANm?= =?utf-8?q?g9Pt+sMmqC6PSpFK+4Wp8s2mMP2PqfxEsU89QRGaorwgzQWKf45tFiGnQroJDUDLE?= =?utf-8?q?KixLourKbi8QtkDfTmsCCnxLov42Ha3VEUBezNs9fMBrBOp4g27rKPtwT5fGNQNQL?= =?utf-8?q?7ZkP926iZJPIUN2iGYO48fxtZNqN7Ug0NVWFaSxMkUwsGnDw7vG8gU1fm6QhRX/iV?= =?utf-8?q?YEga+b/ieWKenDMhuMmRKLC7or5iyrvJx1zKyaeuQsXg9LIDITm//OPFoSHyFSivX?= =?utf-8?q?goA96VS5BcXTsp4jNm1GYBFFX1NwRwtNwPe0pwoxnvSW9sCva6KiSStizoVdN5hiO?= =?utf-8?q?MjCRhHtc3CTs9UwblKhVW7HJSW0EZxi4YKp4FwnS9w3rZ5NYFGFkpKY=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: 123c417a-4e6a-48a1-e56b-08dc79979491 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:51.9146 (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: IWoqWKhHDysmLTuizscQic5ySeyh82m5AzW6LBZl9bfGPcTsNGbEvDV8sR9kCL9fFts91szZzUex0abkVrxcOY8rp9Lvm4pJRgLBBaTQ28CDOgetutiAdY93lvot/0dn X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 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 IOMMU have to implement iommu_ats_request_translation to support ATS. Devices can use IOMMU_TLB_ENTRY_TRANSLATION_ERROR to check the tlb entries returned by a translation request. Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 26 ++++++++++++++++++++++++++ system/memory.c | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 56ef48780f..0ced7c33b1 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -148,6 +148,10 @@ struct IOMMUTLBEntry { uint32_t pasid; }; +/* Check if an IOMMU TLB entry indicates a translation error */ +#define IOMMU_TLB_ENTRY_TRANSLATION_ERROR(entry) ((((entry)->perm) & IOMMU_RW) \ + == IOMMU_NONE) + /* * Bitmap for different IOMMUNotifier capabilities. Each notifier can * register with one or multiple IOMMU Notifier capability bit(s). @@ -571,6 +575,20 @@ struct IOMMUMemoryRegionClass { int (*iommu_set_iova_ranges)(IOMMUMemoryRegion *iommu, GList *iova_ranges, Error **errp); + + /** + * @iommu_ats_request_translation: + * This method must be implemented if the IOMMU has ATS enabled + * + * @see pci_ats_request_translation_pasid + */ + ssize_t (*iommu_ats_request_translation)(IOMMUMemoryRegion *iommu, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count); }; typedef struct RamDiscardListener RamDiscardListener; @@ -1888,6 +1906,14 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); void memory_region_unregister_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n); +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count); + /** * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is * defined on the IOMMU. diff --git a/system/memory.c b/system/memory.c index 49f1cb2c38..d9d66ae2e1 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2005,6 +2005,26 @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, memory_region_update_iommu_notify_flags(iommu_mr, NULL); } +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, + bool priv_req, + bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegionClass *imrc = memory_region_get_iommu_class_nocheck(iommu_mr); + + if (!imrc->iommu_ats_request_translation) { + return -ENODEV; + } + + return imrc->iommu_ats_request_translation(iommu_mr, priv_req, exec_req, + addr, length, no_write, result, + result_length, err_count); +} + void memory_region_notify_iommu_one(IOMMUNotifier *notifier, IOMMUTLBEvent *event) { From patchwork Tue May 21 13:11:52 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: 13669438 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 B194DC41513 for ; Tue, 21 May 2024 13:13:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIB-0000E5-Cg; Tue, 21 May 2024 09:12:35 -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-0007kZ-Q6 for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:59 -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 1s9PHW-0001aH-Tm for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297115; x=1747833115; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=lokuilwH5N8vJsvnP4ToLvsgvaPjW/Dc0GK83AImbMY=; b=wsLVx3XrXhLo2oqHonW9iidFHrYBTcFbnbSngd7hjmqVt/xNVZc2ejO4 bodveJuqsW35tkGDeDvdS62+vYlAcHP+g8nXmFPz8XS+34dqZW43rUTnN HAM7wwlOHQXocz+n3IDgdyYY5TU1oDIhKf7G8cotR86eQnvRuT9oZ3OiD JLg4m+M52EL0vXCDLydziRCGhnKIwhdBwZdakmRlyliUP9z/JD8CVNbXJ M4kikbt5BBlszrZKGc2cP2Anj5ZCA6KvNXxpVJpCxg+3BxcOxCiAKRELl c1P50M01D4l1b7taz4BHgDDLT3xl7XtQDLZyTP5B2LkNHVKg0LQJE8cy6 w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061517" X-MGA-submission: MDGLs7tvvTd7BKGXP6TYAai9RNVbUU9xeHDbT1reEOCzq9fGgNqyZOK7BA3NTrYZZ0wKAhPg4SIJWAtiql9QcVEqxa6cxj0a0zsVx2fDfUpmN2uZYM6wfSEK7jSMJ0HxVagJaLNBVGYBLwsyjcmRGS1dFKbFgncBRLMjEUmvS8e1Tw== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:54 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DS4PnH0y94wIWUHIDxW3Xn0vsL7WdDCQDh4TCgJqtvK5E5FbpzzUu4e40172t+aY6m8hfEE/MtjJbhb+ju7xygrzajX5zxERs3Ve0ha82njzqV4GWUtxDtjnb63BsJM3JMZmYIGJY/y9c0AzawTBE4vjs64oPcXXiMt3Hl1YiZbi7kBCPa83wz9DUjvmBNuthLRHCnf09P7LnwnP71cn7FQLkxUdSHfXUjfNZbsoRh1Q6sPTXeU1202cEqhq0oXyIJd0BFt1E39ysr2SYszfjaFMnv/oBoeJMAIPC4SUepL94OssaJSEndaI6qu5lgiowEKdf8dJA5shS87jWVlxEA== 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=lokuilwH5N8vJsvnP4ToLvsgvaPjW/Dc0GK83AImbMY=; b=aOB/hhAMRAvgsfuFF/d+1bgMJ1MJH1AreRF5/m6ihEzr42HwaFpuB16FUqNbEj2o+rBitIDxU27QSOCJPqhlHXBikQdhz9+Lp/Mn0L2l9HFT5uKA1r0ENkqScPyutLDDMi8TxzKIbpoYKYBiuSWQ9VSVnlqswCgwSj2x3pvLdYkkbE4iVcyuI7GXUfy4IDIqYgTMk3NqgVLDJeZtgajoEWrfrf1EEV5jPtsb9QQ1UFw+ZzNeMswrDBY+foHm+91Qs2eMDmaJoz+/4bF2yUVI+LooJfkDpUGD4Tf4dUk+D6YLDF5Iu0pNDbpEGVTSwfb2Dev0u3z0wvQNHWYrWsvxcA== 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:52 +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:52 +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 20/22] pci: add a pci-level API for ATS Thread-Topic: [PATCH ats_vtd 20/22] pci: add a pci-level API for ATS Thread-Index: AQHaq4ByZz976K1p+kGzAFoHDNZtkQ== Date: Tue, 21 May 2024 13:11:52 +0000 Message-ID: <20240521130946.117849-21-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: 6ad381df-f401-4ee7-6619-08dc79979517 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?pRR9735CEO6VAfO9WFD7QnFXLiZgIWl?= =?utf-8?q?XLtBTsavfkgipKIvgq1s3aV9SM0lK7Y79L+6c3EviKafZQonrGBn0/1yz0ebeSK/H?= =?utf-8?q?/cyV5CSw+v4p9k6yN0RxByrvaxNOSXQYMbDVHCt8acJlIC5Qm9y4Y+d3Eq+qxSDbu?= =?utf-8?q?hr87BzT8Rj6FCTPQnn5bxhY/mBVNSwIU7Y6JiN+MGsnuwwmW76oDoOyauZZAZ+YFF?= =?utf-8?q?gmNC2y3uHMWr/W0vdjnuVlCdHJ3diH+oclRBvWs4fCApOesMdUvbgL0mUJxSpgeYS?= =?utf-8?q?K1jY9jNX9VQFG6XxxI5OhTcDauT+zDXqbFJFnsJ0rPC/gy4caacK7LtrbBnkhr5cB?= =?utf-8?q?GXam9ymLFIfU+tvSUxD9NI+BE0obWoMzwjzLLrLCrdGEvT9kBQBksviCzpdVgFocu?= =?utf-8?q?tHiFTqxfUNPng8lfm8rxHg/s4+E8L0yEuqM642gZ3vNpTE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D=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?bfZFTsGKfnzczZR3O7xGRu98W6LZ?= =?utf-8?q?3nvAFTIb3Cpt6hg38OcN5JdLrRhd6Quc47fGa9uDFCUcpuiOyiZId9GObXUcXVN6S?= =?utf-8?q?Uf1+OhcmTpf0X+jt/HiLw5PyJ2ghmOLj8KOc7M9SREZIrOgAvqIcaVop1XV1fDp7l?= =?utf-8?q?HTDZovTkHrD+Mk5r5JbYqGrjd9JsgRSBwEdVclaZ5uBJUhcUBsvEcYDnlKrwQHJpu?= =?utf-8?q?Z+cNXgpGLrkbEePUOJmzAFPVxHEgLIj5HPgdIJjg4VQalbH+caSFJG1rwEPHjx+z3?= =?utf-8?q?VS9uV0ugHZ6JyQYlJRXdgYwNQazBSoVa6zeLx/hVnmNYH5cOHY03R0I1Og5adkPi5?= =?utf-8?q?PJLOcsGc98TPqgKwQ6t71a0CMPmdlZSzRQjxjxEE3iKPpQzRXXQjr8n2n/Qoo2ZbW?= =?utf-8?q?20ochAEl8BnxhSFyfWgVCdyBHgLEOrVxFTiR3iJsgGcYSkx7eQRCfX7AyI7GIiKoD?= =?utf-8?q?1kF3WqLpkH1G0ZOrF6heRH+SkFPUOL1BEeaTLy0APofkx8pdUsNT29WBMPd6J9Gh3?= =?utf-8?q?MlY8ZdnDjvVF3podgGLkxYQR9ZaSqL8upkORH+JfHVi/SH3F47jscjQVVGEDY9cXk?= =?utf-8?q?Y671Vj7PQ72p4G7CrP6A39vUlQ+1Yeo+HKK838oTvUZfXCVJCcx6wVHtN56hkzn8H?= =?utf-8?q?UAO7a862WXAZ4xbq7Iob5/iPnAgeEx+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oTZNaQTqMFlTM=3D?= Content-ID: <8D2A294620C75A45B134EF95D29AABD2@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: 6ad381df-f401-4ee7-6619-08dc79979517 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:52.7918 (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: LOiCMTB7iiKb8kolVJhmaSOMTPYMqNI6SVlSuTNtjWFSvd23x/OnpMXzZXr9XB9E/ecg1dl3PqwOUscRTo0UbAM/AT6I8Y6JKlSUIJnm7B4ds7vOTOYJaNl0JonKVTyh X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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 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 | 44 +++++++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 0e14ef4ab2..10b0708130 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2833,6 +2833,50 @@ 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) +{ + assert(result_length); + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + 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 2147981423..8adba6af97 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -473,6 +473,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 * From patchwork Tue May 21 13:11:53 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: 13669433 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 81636C25B7E for ; Tue, 21 May 2024 13:12:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIH-0000ip-Rp; Tue, 21 May 2024 09:12:41 -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 1s9PHk-00080J-RX for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:09 -0400 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 1s9PHX-0001a9-Kt for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297115; x=1747833115; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=OYW6nDkzOmyJAYhlc9/fa1EDVXZlqVKe7EKbL9TNrZk=; b=DmXLKpuYbMHb5wNrlo7W+hIlfo6d4b4wEdDQMOHy1eqaaFaJ2QKCdvTJ b8UbawVlJsLAFQAbsbKqncQsGInfklkvsGrmUSRj05nK4AW04p7TLFfX5 vQki8ZZKmdDBmUQewBN+8pz/oySYb+RbXPR8v35hRA+KyqSGdreUbY4dC AEx0OsA3yxBjR7MZH5CwxrHMxw88maIOHI0OCbvrYITO5FNLLkV4huEeR fKEc9X0JO9HY8vQxLJPCT9aPx5u+Z2z9eDRlVvoxQJTX3jjQyCFr3ASWC Oq5f+09yF7TTfhh0+fOhDEVcy+A2ao/3BeDqZ3iE4EWKvtiA5RNSP1nRg w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13011538" X-MGA-submission: MDFXN0FrgkUGvL6RFU9+0ZjBjEznCVzp8ehWHn5K4xQlObfTmn5H4npf1weu0fAp2s2+yZ+R7PVbG2aeYCRVsmUZV7Rrk/Z0AzBRwctD+VdwGq+yVixnLy5OxSPYB4nKpyXwUojyQSNFRAujevSzGmGPfsppAn1uQW2fzLEFQ3haUA== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:54 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KRwQuYaF/hXovTJ5LZ9Nkv9wWtjdndcBcNrbHEKapDH/LMczQOlOx2QQTrBCyLUpT9iuh5Soz0086/hjYbzl0eL08/zmErVIJyD7KxDtKk5NKoC16Yzwvn9lfjfBJ/0D8Q1ZL9Uxx+gZkuuvolCrE9MksclnMr49WntGCF6PsQUdBiTYyYEFUxRyRHcYmceFonUWYv8uVwtIXEyAtW2tZ+zdOrAkQ4TUrTeq/zlmmuLltG2j8r6Bnb3TVDTfQv0ZZkMdUK9DJajAVzBfDllJpXb+stCX/GVbYqzPTcx1h3EMVW+1wB78FR7T1PB1rP245GcF0NZpUUXR9+G1O6wu9w== 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=OYW6nDkzOmyJAYhlc9/fa1EDVXZlqVKe7EKbL9TNrZk=; b=gSVQhUKHsBPtQ/PPVXD1Cfraaq37QY19QWYykYuHzqvU/g25xQM6rT2cgq1ddoI4kaO3W9juillbjtKS/IqJzwDBW4Hb7fsZyF44nhNJ0gebelYX8Bex7hI2UrRKgi5BWl9TKXKdatR99rcsfr0BDhptHBpJkvoSE/Zo0aWpOxbwNVEX2ypxNNR/USteiQm2s56q804HmC1EMPTaiMo9dxMKf48UzvPYy10KdIEedwGl3ulXCepOyWocXVi+4rwCrl+qmE/yGnPKtRlLqSkftcVcm0SS9jiNxlvubB8vnrN7vJxs0kiWLE7lhe1GazAXfOx6XlXh3erI/4+DazI6ag== 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:53 +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:53 +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 21/22] intel_iommu: set the address mask even when a translation fails Thread-Topic: [PATCH ats_vtd 21/22] intel_iommu: set the address mask even when a translation fails Thread-Index: AQHaq4Bz7Ru33W1vwk2nGsDl0E/tfg== Date: Tue, 21 May 2024 13:11:53 +0000 Message-ID: <20240521130946.117849-22-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: 86b9ede9-775f-49bc-6050-08dc79979593 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?n+qk+BazV6UskFbyU69mNHeXOppXpdC?= =?utf-8?q?7taeZYaAnZlmPuYLX/AzLKrP+4v74OaJQqSdflKg16aDWB7A1fXSMzANErISsfAwa?= =?utf-8?q?XS5ItzJiE6iqsG0q+YZVzhgZvPrggh/2Ik/zp+QcZVJZzUZ80JbDinLmipXa4HIzn?= =?utf-8?q?PXkf9cocE+jk1lzi5WvwOEi2Ncm5HQvcl2Dyxx/9G7BNw3QkdzKJceYB9yHX2RBPt?= =?utf-8?q?q9NA35kHmuhKzFogKTUSQxH6d4Mrshkha5d+4yN8Uux/v6SISTFUPAphOquH3RsOj?= =?utf-8?q?wwSmsQI9xaLEgeVcKR5M8ryQwYwYP+PzkMYbquEGFT4GL8ZMVtkuUPEF+HwjH9OA/?= =?utf-8?q?wocr634rpBNQobUvr8xOB7IWrWcHyoye0w7e81GG+yBENbSiTaW0QanadBFM4yYdq?= =?utf-8?q?1zXCep2aNSLyD2PG8TnudPzBBV7FCDaX3zetaUmyZIrUPmpzytSeD3ZpiF+Has+gR?= =?utf-8?q?QZTxvmhc660FHAnRuzE7pjl9bd3cpnJ6+CZDiipTFnQu2aoeoNlX2hka5NAjeHakI?= =?utf-8?q?29qj5GDNdoif4YJ+5NJ70WPQn4chR+mZOkxcy5cSSOla9170dBvcQqk2mFo00UOwA?= =?utf-8?q?RXvW/WS03nzYZCaFYPoY3tGVRJOxiw/CdHiLgMRV4gPzEI2do77I26J23BbBLZ1zv?= =?utf-8?q?idIZodFTJbUSe3cuvqrv5cbFZdO5iZtG94SQcTmwSzlgIZ2luoyhCjPiVMElsrIJY?= =?utf-8?q?1Suti1ufXCc8l/AkYIdyS87vH4lhBj6b3kal788q8WBPtEDoYqDcNDU8MtHnb5qD3?= =?utf-8?q?z6gfk6I2h2JAMLp6QIPs537HE5yskV6kY4hxYpyUCc3dEMh1NFqSj1+q3iexhZNv6?= =?utf-8?q?ydqFOCohFco9uGLO8J0Sviw/FNlvSUyOE7q6EklAtBdHMCxtXqO99wZNj6J1JLBXZ?= =?utf-8?q?vGNaSh8W1QnqRRmJtC6boyJYVo1MKr7kKP7s4C8Tf1rHl5Ydr4xXnOlp0mnmyE53v?= =?utf-8?q?PfocDxsjjcF4Vx8shw5UKYsahG3PpsfQ/DmkLNA7e/YHwXUrQYcPDZpqaLFsKIf74?= =?utf-8?q?bi+tYsRSUbHPMVwtcZOfCOyKGtS86YNzzbDaL20slJ6tIWi2hv6/XCzGhnrkfglYg?= =?utf-8?q?NTYlzTpt60QaSmT6y0nGUFmo7wKqUVwwnhOdlo72armsTkDArooeBHzWE2Xwbpx5l?= =?utf-8?q?0OTxWg65heTGYYeBzGbkebOQa4AY89ObsJzdSJ5yytiypb4H5ub1YwDIQNepROE8X?= =?utf-8?q?IKkK+KE5vpaI/FPxCtiNlvboHfv0Qq8f8oWD+wq4+kmftgPtOyR3EfxgkoOIYNNsz?= =?utf-8?q?si5ynUXt1dJf6v12nmCYNLhJNBUVF0ilygQ=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?1yXQw7dvXytriJ5Iyxtc/26fmMXu?= =?utf-8?q?1p7OgAL0Cvg2FZiisJKGQXBW38dYq8S/hTqGe5BmzzTGxn52C2LYFDaj6Cii4oIqc?= =?utf-8?q?gFNoICjzVnBOCkLiqW5NeiodoLwmc6UCrwyj3szsxitA5gMAsUb8AAztw4lTH/wRZ?= =?utf-8?q?kL1Qf2cBKNClZf1CoyJmD67wHDMLi5LAfieEN+Oww1mkzMTJ3Q5NfR5wle9WUWSzi?= =?utf-8?q?mLzQN+OKK91TPZKUsWOB/cMN1nSA39W2kR3X5qYYlIxR1m1sk8teawFPLfj3Ppew4?= =?utf-8?q?+t00/42POUijMYtP4IPBWUkg7Do2FgOtXe4pI8+rOM6CcB+urMwBdknfnWBKiCto7?= =?utf-8?q?ATdCDaEYCWT6mfzTdaSl5cICHbnJB66zJEVVIbGhAYVajcLUBZ5mHc0kmRW/Fke4d?= =?utf-8?q?+59KkzVi0V1hBaTmEOS128bN3YjYDVDoxayo44/i4QJMxg9N6eKgO/B82Gaf4fvoX?= =?utf-8?q?gBjqMU3ivwa9v2ZakAYK8cHAqVdAZHFOGJQjTiQgAZvBLJcDs/M+XQaZ3sEOOClIe?= =?utf-8?q?nMIARfYWEtA5iRL8HFTJiYRWS1od1/HhxKOpAQS4PS7UY+03aXpobNUAkc7nylGZM?= =?utf-8?q?lC106boQBmFzUVnuxxK8S7tuggGQoKgVjP8dkH0YWjDIrsm4niWgg4CNSlIv6LE3x?= =?utf-8?q?JY8HefPp6fxbcYTie4OaJB0T7AktJDfxYlw21Netc+vFxfsn9DpzjgdLk5O4Ose6j?= =?utf-8?q?5xbcft6PSMA4udJ/XIBljJAJy6P10zCza0pD3NaGLPn6AGcvrbd/z9zGpB2tTZqZz?= =?utf-8?q?/KUnK6OooEBiGjrrUvW6fXsOcPGohF4pXai1DTLTLrZ6Hne1LceNeB3UPz7Ja7EIF?= =?utf-8?q?BA01cok+KC3TLaMiSR5gPSd6BVZtFCGPEu+vbHKQFTwnFKv39Kxldm3AK6VL1+rD6?= =?utf-8?q?1q3Apgk62PUvUSix1nj31U4U6auWBtCPAIK9T43j1VuIxxoQWbiaGcTku9YG3RhlF?= =?utf-8?q?w4XapVyixBLCLOUY4Ja5c54WUyWST05BZDJCY1BLOLJeYnDgMrlM5gHHVAjLt0DCt?= =?utf-8?q?8baoBSI8226Tq0+4n0lOnOJTtF+cAGwHdWMDRZa00T0oLwK69uNH0dE4nq8bdTDcy?= =?utf-8?q?w9bqMq+gvzvyEVPP6+cV0MM6BFo0gTkc6UjLsKW4zIu7w4WzwF78JcyUC0mXObINK?= =?utf-8?q?N55fR07UStJqyjracQspew3qnPGBWKE6ttDHRstDWSrhsuA1hmKdpM6ePvIEVua5x?= =?utf-8?q?JU2MW/bxu6rhGXXdTh5TPbWDDSGNTRZHH4iaXU1XWt6QTKVIrRmDtPsHhCQ0532GW?= =?utf-8?q?B8cWRrnQHn81IweG10JCSTbjXrgAdubGyw4cmP55uXgajb2QKFOeniNScQFDM0DYN?= =?utf-8?q?jkLiKz2shZHPBgfqsFtwttrM/9MpFqZ4F+NboNy+cP90uKbUYtptcTc8/DjEPFgnl?= =?utf-8?q?JziaOB0P7XqQgqmn3aEFt8mItDXom0fKSe3JdT+pSWiQIZ5mA7zE/qsUrtOdiNnB4?= =?utf-8?q?q+mR3Odwp4hcOu+0N2SK2yT2EB9NcxEeFK6h2HWmpTHgvt9c/Y0kwmoR0Glw6mSZ0?= =?utf-8?q?OVyaYApKswTFatAVGDRnW1wHMqzDSaAEpScfYiDlIqntluKwjT7lPd8=3D?= Content-ID: <7A0A7C391FD5994FACA7E7235A4942D0@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: 86b9ede9-775f-49bc-6050-08dc79979593 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:53.6044 (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: vqI2dHeXg0p5H8vyyXC9OnxCiCe53T8uy4ROpK9Svni4IOi+IL70VlhMWTxpvN5S4Gl+rYo3b3/H32TDp7IxUEnQ684wivDR8asXYLoJ/MyD6LGveF0L6CSWWYMJPod9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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, 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 Implements the behavior defined in section 10.2.3.5 of PCIe spec rev 5. This is needed by devices that support ATS. Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index f08c3e8f00..496bed9447 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2169,7 +2169,8 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, uint8_t bus_num = pci_bus_num(bus); VTDContextCacheEntry *cc_entry; uint64_t pte, page_mask; - uint32_t level, pasid = vtd_as->pasid; + uint32_t level = UINT32_MAX; + uint32_t pasid = vtd_as->pasid; uint16_t source_id = PCI_BUILD_BDF(bus_num, devfn); int ret_fr; bool is_fpd_set = false; @@ -2314,7 +2315,12 @@ error: vtd_iommu_unlock(s); entry->iova = 0; entry->translated_addr = 0; - entry->addr_mask = 0; + /* + * Set the mask for ATS (the range must be present even when the + * translation fails : PCIe rev 5 10.2.3.5) + */ + entry->addr_mask = (level != UINT32_MAX) ? + (~vtd_slpt_level_page_mask(level)) : (~VTD_PAGE_MASK_4K); entry->perm = IOMMU_NONE; entry->pasid = PCI_NO_PASID; return false; From patchwork Tue May 21 13:11:54 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: 13669441 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 7A335C25B7A for ; Tue, 21 May 2024 13:13:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIC-0000MF-UQ; Tue, 21 May 2024 09:12:36 -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 1s9PHd-0007mg-2c for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:02 -0400 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 1s9PHa-0001co-6l for qemu-devel@nongnu.org; Tue, 21 May 2024 09:12:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297118; x=1747833118; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gOL1Z/9VTnohgeJlr7Aoab7lzDrd5FOG5MHKFkUZjKc=; b=pnx5gT3TGQ5rNEtDhJxQ3MveUljbp2owHSV17EuPNIoFZHCFieJ2/g9G QB2qgKV2pAeb8AsmRZY+PnsuZys1gXoik+bB+kw4Oc49yEgdhyRAO40OF kb0Q1uiRtiqg4b6jEexy8yKWjcHdKvFnUGSaWxe+EAKq0gq40UFgpr+vq z3vU1HnYugWsYNZVEfIoRHQVr75StqBZtyy8s8oGL6OTBbiQfyX0YrUCs aScS1qUyR0moSNX6zqAVtylxJgrOU6l7IkoUKHSsVnsj8seMhFjogx++5 tuPxRBQfHN1Gep5yJnZ9xKoFr8L/Iqmsdxlp4NJt9quOrHFOy/m4bF4fO Q==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13011546" X-MGA-submission: MDEsXXfpqCkV6Bs636Xm3BSa0iLQrFgKudtVVnUfKmt3yrCKOSuXqOL4fa4YSeILtk1b7H4Te6GDRHr9MxNTVFEkkjSJmcd4opj+R0FbzcikEeMXeE157qJe5H2KWk+pz+isu02a0OEMIFKsRYjsWq+CF67joztEkYYMtaH1pq1Znw== Received: from mail-dbaeur03lp2169.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.169]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:56 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QO0bfDfYq/kNQWZwbLqOdDWEyAls5gC+6c0fRJUOMo6aP6EgjCWABEebBWQ30UVTWEfhqIZS9MzaoT9RnDaUF3MbonH1iVDqjDuSC6Xyavn/i5rzWdKsutkSEnOZ0wHbZahtTiD2BUuo38jc4QxETaIMou5Ap3utbo8V288yhqPdggqaBa6+ZMu+PLTlpbA8LCZxXiHPTxVSkhLXWhxHJ7O79ouk4RPvmM2OT9x6up6VuU1aUzWbRwzJqq8KkATyXngfVFwS6DTfCexzn869wwumKt4wPknjyDbNsO5cxYR0s2BwbX1d9FFHqvu8+KU9XXbz/Ru79r1dZwVBplu5ow== 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=gOL1Z/9VTnohgeJlr7Aoab7lzDrd5FOG5MHKFkUZjKc=; b=lhufddWhhXhq/6q8OIDbXtH8NvLt2Y8un8fRmiYtLXMkfg6xpaeijGt3A0iQwyHvcMNjWGRgNqkPrKWDpjVSYEBCFNOzNhFE77SVSgLHISHjGkkS7N60UXroaYUUcPiPlOl9vPN72OIjV8AsrMHw8dQMVc9OhDTOV+ZhNeTtWbQAeQZbDXCYEvpSVN77k2tgRgxNRw9Xj5/kyld0yeGU3WdrAsCGKMZo3IYHcF86sojX4zuynvmOt8nFFxlCGOoPxPzeBcszfEGk6cyXS2O589YL5v9QP9ZGOuajXknHi0/KOzAPOK+Y7y0Z97g4BZNE2A3Ezs8QRc9FmYqeao+dKA== 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:54 +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:54 +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 22/22] intel_iommu: add support for ATS Thread-Topic: [PATCH ats_vtd 22/22] intel_iommu: add support for ATS Thread-Index: AQHaq4Bzxu50+1LF9ECmS9tKvgO8/A== Date: Tue, 21 May 2024 13:11:54 +0000 Message-ID: <20240521130946.117849-23-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: fa369c92-c842-41dd-5263-08dc7997960f 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?Y51DD2I1VvZhf3I7i1IHh4Ee3q9m1oC?= =?utf-8?q?rd8PgNmKE5pEfBVtqi+KfO/VrGMfao2d727o5Z7IzTwU8XuWoHegf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?= =?utf-8?q?SqHIkjQFRFuaBYOn+XMp1XShL9nqtmQbzxVZYKa1QX+VIZ5Kj1GVzSw0cE6FPKr5d?= =?utf-8?q?A4+1YuBmd4iKqGD5L6lsi9r/OalXtnt2kRJjXHUo5q4rEFFKJbJwSyWQaesE5kJrG?= =?utf-8?q?mOFa3FcllghyNlrTHWPy/Fboiztn9ev0jDqoKVbdh8RrJO1sf0qEGipm3P4bx/A73?= =?utf-8?q?sPnP6qkFa/UfbFbc4MU651nIKTvqATO6Y6OqjmwOTkOTIHJ0xwH54fD2Fe2mG/fNH?= =?utf-8?q?xlGk+mqCSqRTlIJn2glPZzJll5wo39+lz+K2X22Ysagf4EspNRISdAd1iGcYrlgCP?= =?utf-8?q?3QjtNSf+HK2qgmZ2il8Xr3XMQvEWK3phmiQ=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?mSfpwPRecDc1I6W76yAmft6Ype4m?= =?utf-8?q?Quh2+wwRtX6zlu+5twYzQkiT5dnEZw4mpiySZQ2VmScxE6rooFYzCE35M0JwEkPYy?= =?utf-8?q?sRZy292A++W/fyWtCcNSbXjKhRMBskt4BjF3cQx9rShrLVO8IfG6G8Hx8s09jD/3l?= =?utf-8?q?LO1vYmlBSm5x8JXOWbismc24zEjmqYC+6MAkH0khJPCtqqvd8uz3JnUYHFGZWWkJh?= =?utf-8?q?/4kL6v4IbI0eDUGBTc8pxOSd5E6AbLZ5VwnVQpphilqWtbQcSnPMVS7WgqSYgDEiA?= =?utf-8?q?cfIMLTnRPb7IPjfe430wo1v6l4pd4rgrcUd1d78xIvNTDn9mRQ+fvzwzwf2EZi8BK?= =?utf-8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OkAVhA4LpNDEarbZio3Iif7gXa2qArEB04FhrIdhYXcnYaE4cMo6k?= =?utf-8?q?o2y0Vs1x4n+WhG+ec1Oh0zy1P/7I/HHBzQLAk2wok0LUuUOTb2m2ED9cnkJbNqNf/?= =?utf-8?q?JI/YqZA/oQE68lfFhyeUcn3yyq/WTD3+a6hafh0GreWzhjIiN4dvHRk0/rJO4fbFU?= =?utf-8?q?R2nUjIS3hWhuDq5SxqVvImeuOZ2ha+NvIU6V78RJ0Gyaygo3uU+tF6pOvwS4sH020?= =?utf-8?q?fT5KHFvzIObdp0Rcjq9U93C+E+mS/VzM8dOQ6ONKoF8/cgRL0MNIUqOFcUq6t9B4D?= =?utf-8?q?zRSkaJQxRByhkP04eEDWQ/8E1WkgniBOtyYlwJuweBbA1jrCmtp8s2Y=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: fa369c92-c842-41dd-5263-08dc7997960f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:54.4017 (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: 92L/N0jEPxcPOEqzBWr9FusqqwsU2CuQPYdzjpwb6IRnJ6+XcXtoz2UxJe0u6EZg1U66nJldLqHXUjkanUxLbok/uwby85mMmJ9CGKoK1FwMzONAJwSiSjW0R/TH6zTa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 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, 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 | 75 ++++++++++++++++++++++++++++++++-- hw/i386/intel_iommu_internal.h | 1 + 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 496bed9447..2e78ebe6d2 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5381,12 +5381,10 @@ static void vtd_report_ir_illegal_access(VTDAddressSpace *vtd_as, bool is_fpd_set = false; VTDContextEntry ce; - assert(vtd_as->pasid != PCI_NO_PASID); - /* Try out best to fetch FPD, we can't do anything more */ if (vtd_dev_to_context_entry(s, bus_n, vtd_as->devfn, &ce) == 0) { is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD; - if (!is_fpd_set && s->root_scalable) { + if (!is_fpd_set && s->root_scalable && vtd_as->pasid != PCI_NO_PASID) { vtd_ce_get_pasid_fpd(s, &ce, &is_fpd_set, vtd_as->pasid); } } @@ -6004,6 +6002,75 @@ static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, return &vtd_as->iommu; } +static IOMMUTLBEntry vtd_iommu_ats_do_translate(IOMMUMemoryRegion *iommu, + hwaddr addr, + IOMMUAccessFlags flags, + int iommu_idx) +{ + IOMMUTLBEntry entry; + VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu); + + if (vtd_is_interrupt_addr(addr)) { + vtd_report_ir_illegal_access(vtd_as, addr, flags & IOMMU_WO); + entry.iova = 0; + entry.translated_addr = 0; + entry.addr_mask = ~VTD_PAGE_MASK_4K; + entry.perm = IOMMU_NONE; + entry.pasid = PCI_NO_PASID; + } else { + entry = vtd_iommu_translate(iommu, addr, flags, iommu_idx); + } + return entry; +} + +static ssize_t vtd_iommu_ats_request_translation(IOMMUMemoryRegion *iommu, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUAccessFlags flags = IOMMU_ACCESS_FLAG_FULL(true, !no_write, exec_req, + priv_req, false, false); + ssize_t res_index = 0; + hwaddr target_address = addr + length; + IOMMUTLBEntry entry; + + *err_count = 0; + + while ((addr < target_address) && (res_index < result_length)) { + entry = vtd_iommu_ats_do_translate(iommu, addr, flags, 0); + if (!IOMMU_TLB_ENTRY_TRANSLATION_ERROR(&entry)) { /* Translation done */ + if (no_write) { + /* The device should not use this entry for a write access */ + entry.perm &= ~IOMMU_WO; + } + /* + * 4.1.2 : Global Mapping (G) : Remapping hardware provides a value + * of 0 in this field + */ + entry.perm &= ~IOMMU_GLOBAL; + } else { + *err_count += 1; + } + result[res_index] = entry; + res_index += 1; + addr = (addr & (~entry.addr_mask)) + (entry.addr_mask + 1); + } + + /* Buffer too small */ + if (addr < target_address) { + return -ENOMEM; + } + return res_index; +} + +static uint64_t vtd_get_min_page_size(IOMMUMemoryRegion *iommu) +{ + return VTD_PAGE_SIZE; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, .get_address_space_pasid = vtd_host_dma_iommu_pasid, @@ -6210,6 +6277,8 @@ static void vtd_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = vtd_iommu_translate; imrc->notify_flag_changed = vtd_iommu_notify_flag_changed; imrc->replay = vtd_iommu_replay; + imrc->iommu_ats_request_translation = vtd_iommu_ats_request_translation; + imrc->get_min_page_size = vtd_get_min_page_size; } static const TypeInfo vtd_iommu_memory_region_info = { diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 1b0d8958ad..461158f588 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -194,6 +194,7 @@ #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_NEST (1ULL << 26) #define VTD_ECAP_SRS (1ULL << 31) +#define VTD_ECAP_NWFS (1ULL << 33) #define VTD_ECAP_PSS (19ULL << 35) #define VTD_ECAP_PASID (1ULL << 40) #define VTD_ECAP_SMTS (1ULL << 43)