From patchwork Fri Nov 29 07:43: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: 13888448 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 2B3A3D6EBE5 for ; Fri, 29 Nov 2024 07:45:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvff-000802-IH; Fri, 29 Nov 2024 02:44:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0007y7-6C for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfR-0002e4-St for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866238; x=1764402238; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=j7ZhHAc3M7mChDH3124zBWgd3jo5et1QNZwivcfTjKs=; b=mXMbeHenmze8uT3vbIUzR5vKe42a/5ZX5+Yks73kc0tMxN8t1UloStYn rtzeqHT71ZTHVQr6UmCoFjsyTWSYgKC87WmSxSImFe5jQs55yhWqDfhso Mo4Z5vW6cWb0+X9l7KAsaSpo82EChNyWnf38rc4SyasR9qtQM/Y5lNXWw Eg1ty1GYlEoSZHddMgStrL3ZDTodB+bFVNLRr8I8VcgmvIHZa86mJnPY4 bMN5k8KQFh0XriXnc0ZTi6qx9Fvzf8MElD6+MW0WH6Wvt3eFjbTLc/kKt Mn/Goef5lHxGIYnbgc+aG3cVLOrEwFonHSwBiUiRZG1L2DzGGqBuelv/J Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664396" X-MGA-submission: MDHfmMeb/1qzVUA+P//DOF0EIzToYCvs9+YJJq67RVZvclHk6lBbayvLv37sgQQd1u4tlMLa4sIxO2NCRNZR5O6Nb/jNpeS1z+R7+xzfXkZpdf9eCS9BtZ0TAWlmP4eAlokWp6lKYzD8z/s4zzbfVx5zdtyhVkHivnyHGsf9lCMX6g== Received: from mail-am6eur05lp2105.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.105]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:51 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x+VPZnsfwBsDjmDYsLhX2eh6bd4Tst0YMrueFwaqtHjktDyT5pc7dcf7tF+iAAoo4+Oqn50AvCnOO7WiVYwV5bDZ0t+MhyByLo4noqMRmrNVfyHYMxSOjp8c7vCBjC0ygUxJ5sJ67imHplfTvlTeoP0kwX4v+Ij+XUIGoDgEkuTSZs69AKzn8R34qFqdxi/Y09MUxBXXX0prubpqiIloxw5G/E5BLEhUP9quFIP9ZKMV9cgNoj0V2vMuEWbbMBnJr5qPlWQkkr77o5yyvXtGKoEiLzF9W6m8D9vsftVBa5B9fGdPQ/tBqRKIwizTuvwqLaKIdx/rmI7YCz0En2D38w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j7ZhHAc3M7mChDH3124zBWgd3jo5et1QNZwivcfTjKs=; b=KulmbskJyRGtyWNckqlTRvLgjhTUo1ofN9ejLK9NGe0xZniE5oeEQ7v19tGlihvg257xLfkVprBawZUs6pbIb0kAiiBxxX+73vLsCx66D5r7LidIBBg9QpnhbG7G0kuMIo6VA8hmk7ubOjgqgCyS9LxIVAjc9EwBVW2AGCAVFDHQ87sTx6NkzKkn8tcKzgzd/GKSe0QkgG1fCMZL9OTA0/RzYtEFNMuA+Axfpc/0jymsvOxF/uCe8j+Ig3LF5te8DeB3OBNvYD2paHUUfJ+XCUJwFiH5HcFi/7mVKISHncsQoJ2wD5DKXRBU099AqxCgZpoq5V0qaMePZ7ci41WIxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j7ZhHAc3M7mChDH3124zBWgd3jo5et1QNZwivcfTjKs=; b=LfLtD0K4gFBQIFAqdBT4HnOaYf69/GcgPOd3EV1RqpIPxWtdGhuTIVIcDKHS+8YHmnQTWMa0ds/U05EK2xIByniG0uR0uYB9C8kYmCRj1RCOaA4rPSDpMg426cBEFJShJfzfgqgf86O+dVaqMn1RXyf9VqplQmsFh9aA7xAckQL42nk2xac+HZxtVVH1ykjH7/sftUFI3+ogCjJrhq1kQ7yBRm9cLv5SUKWjYEfsSOuAYSky5nxD7Q2E+UCEBJGfWlz2t7vD5sGHPb6Hjrf1icbScMEoTDw5hhsqPcAbR8gOyVIJaRn2sz+qwNcOIUCyOvX7YxdwRgbHziqW3ESg6w== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43:49 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 01/19] memory: Add permissions in IOMMUAccessFlags Thread-Topic: [PATCH v1 01/19] memory: Add permissions in IOMMUAccessFlags Thread-Index: AQHbQjJt58lDGQrBW0y9U9llBbaxQA== Date: Fri, 29 Nov 2024 07:43:49 +0000 Message-ID: <20241129074332.87535-2-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: ae535b29-b2d1-4b48-29ca-08dd10499063 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?96zZKaa80y29OXH/7xVw/YRPZiEk3dU?= =?utf-8?q?6+BxxjloT4divaGBiC7UpS3MVRl0uGHBqp5O3n+ASKBRxp1JF+N+FQFbRcRMBTQY6?= =?utf-8?q?3jKFGaqi1+pMSVqbuFXeoxG3oxSxifHc+7zvvCfLK3k5i1qw108DfKVUdr9Bjoq7p?= =?utf-8?q?s9JwWFC12uO0E1z5ycnAvQvtz03SBSZEz9dq5PtPx+0rA5rcFbbrkpl85HLuXRYeZ?= =?utf-8?q?qpS6dZuwojryLsecT9lVIIs5RBzjdXza6+unI5q3kIC1nUDw57n6TEBnHBFDChtFn?= =?utf-8?q?2PHtTZXx8aCvab9i/mILnbi1dk4iDYqVivotGW5ThDxYgyqjVo1DlQVIaaO+Kq6P4?= =?utf-8?q?YRZ4Dd+hEt6DgzQgKIZoAlvpAu5NDjTou0EAoqxMvLFXIOoW+xSZZdTTn4nFrpIaC?= =?utf-8?q?PNDAL6HUOdEtN7mgppN6WnuW113pPJHtWml2p136z6rZz4zsDzSVHQM7EnPGVY07B?= =?utf-8?q?KRsaBgcB5Bn9mLuBPydrqf9iJxdzk2ldGS/+I1rGUDj4f3Akogxrxvm12188ZBWfR?= =?utf-8?q?y1jArwAWUwgsxYaiRFL2UK+Bq6xDQX6qwRh3KeP7pJfjNB/6ROFYUln4pTU3sDJjd?= =?utf-8?q?2mRWhhnrb5gsFxnInv7I8Wc+io3a1vClsdZwmCcbkWfLmdXovTceu1x31XeqCTZR/?= =?utf-8?q?sRBOQ+PoJHBoeGKDrscZFygBkzmEVIEstBq1aee2cVXcYSHu3E81vdU8zDamHYDr+?= =?utf-8?q?I6JIq1V5fnRSguVF0Z/NvOM3NUNgnEOGVY9Ypg0R2iNjta+4pAY5FBSYHMiEH2Bpt?= =?utf-8?q?cbmffMTgFt4ujpNO4F6TTZ0ydZkWstF1v5M88EbxuVPSDFcBD+6u8NdSSUfUEd8wb?= =?utf-8?q?DHwupv5uWdBk5rr5oMBJX4WmMF9ywDcR5VVGOUAM1JUqHjhQYZBrvr/RcsnEcJHw5?= =?utf-8?q?E/FgUe2OOn0oQaPHHY9xI+NXZtSsktL3K6E4F+Pf1kAVFsle7ZTXhEXpxjm0L6sZ2?= =?utf-8?q?rJ7X/dXy8XOVEj1FTb+N5PiRR7m/AQA3cXJc8MSplfP8cwJnuLR/aIwYjb+rELdH/?= =?utf-8?q?uLCVXmW+ni2YLuWO7PhWIKJspnPI45AY3VAZbUdIzM4VbWk6MYuiR/OZs1PI5IJ9q?= =?utf-8?q?m4XdPKlZntkFCvnuJWROYSrfk6YC+yXZe3V6F0ieqB/1FWKn/3GeLi+eBdZPBoa9h?= =?utf-8?q?q/mOy9PUM/Xw3AcossRmsc9ATaoeAPFQ+sxy/EFIDHry4EAbp7MhL2pyBPwGNxD4W?= =?utf-8?q?3vgejoEmvZfSb+4h0+bgU/aHcRKEXK/L3KBsquwM54EAPWeRqtKWNeqg6eEKu7xiC?= =?utf-8?q?to4h3nbE7SjLwkUJwZMEnfOCBe/6g93p4u02vuCmiR/S4m1ndaFkEsS6+sK+nY0UI?= =?utf-8?q?rJ4aRgjBjFTR7D3aSwUOT15HdPjWoIwD/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:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?RPTqQK9+iLIn1NQPXOWUze2d+g7C?= =?utf-8?q?Coxup8xAoNNZ7MbioYZ6zturrljsO69zqjLQs8XjcO2o3ihBRoZtf3f9DT3QPutdL?= =?utf-8?q?6MLgNyBIm+9cRgLQn/hm0WKcqzH1QrMHP+PYrWeVV1iOVPiR7fQogza8KcaG50tkq?= =?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Iv1DfqjTWbHFQcF/e7hwsYkGfohbzMWNeNndwVVl4uUHo+r+wdIvI2MmHH7fLdA?= =?utf-8?q?DcB59ZO4oZgK/ADy+yTNXdMK5hFR8eUGzysZM3Ba9gcrg9cr2lpmiGDVqi1kB5ZeZ?= =?utf-8?q?dBvwby7r9AjUryKLB5q8+uXDy+UVb3hwi2HT8A8YCkNQ7k418WczUFqmDLBpqsAPD?= =?utf-8?q?9W7cqrRThlWcc6s784CILBH6ed6pqOiRnfoeD2ae+Q2hIR5PTUWPSjzftWOIvIzlh?= =?utf-8?q?WZJoAIlrVssXO714K7leCqVOAWvtBwrCFrdBbvSIuARDYCYw7tJ2EzehSN6yS/ycg?= =?utf-8?q?PLlVIp7wVavW5I3tCQ6VzduCBCMy2U0vvdl3QHr+AZjonFFQ2yv31rDQdvLApKWGA?= =?utf-8?q?UilQgzfCLxkc8RwcW2J51yn56lZnj/dS+aDcCFwgIlipol2R5Z9QQXNg6t4rpHQfs?= =?utf-8?q?1PiipGbD7igeUAYjeVkzcTVxYA412RCEvQm85ntCAVUmETe790Q8FURfHW7YAIXnk?= =?utf-8?q?AKJ9bg7KnLGCwtlYkVohvr9RFnMFCP7a4k9hAYTeniXw7VLUVTz/JyA=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: ae535b29-b2d1-4b48-29ca-08dd10499063 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:49.7194 (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: N3xJXIPf8Vum8nyOxaX9+rs4CohzDFOradIvmQwckAQikSJea7o+G1WHDOVSdEn81SCwFbz5hrQX39PN4loO1xc87bF8oQRbmDtXXeZYzwMtrUm2VfSWu4xaGwaVnsg7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 9458e2801d..15fff69432 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 Fri Nov 29 07:43: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: 13888460 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 1B751D6EBE2 for ; Fri, 29 Nov 2024 07:48:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfT-0007xv-9z; Fri, 29 Nov 2024 02:43:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfR-0007wx-I9 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:57 -0500 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 1tGvfO-0002eL-JA for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866234; x=1764402234; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=QWd2tkeHQbBwbBNdDBZH/aGLavqAFkrtdTaIu/gE1UU=; b=UCAqjRcpkrj24LZ2UPK1XySl1aKa6ZgZeuHgBxfolBBI14XIarKIJMeN mt4S0I2o9r+bWj3Lo1H/G7lujoszpvHppyyWB1/kpdx7eDftFGDgGaPtU jJcV+KijzWFB8swV5TA1YU30IF+7OdHu5V/Z/pIKVfh5XoGa5jrD/AKnR zh9qUb5mrYcadBmiUSqSQq/HYD8wUBQPKyL+RJbHeRohI8iS1b97Y5tvC eUPbbZZp9OKA1oeVpjP4H7jvV/atKDBVIJTQhfgCwy0jSVcMnNQI0hez9 8ZdEBrPjdKZIGSofUkBkYT2DziMBGSqDY9rfT9RaVA/0pSWHT4tWRVgSn Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670793" X-MGA-submission: MDHrc9yHZwufgdxk5QNh0KWEmN8lJhM0ovdCA2j/+g2WGFdsIypo51rtvf+xoDXAI7uWKeJOpuhFHzl3CDwvGh/t12Ieg/Q+qQUg97XnZqZ9W4qbvO1jzup59VurkcXqUPQ/UkdH/o3qvIzi/QxpZ7WjHwqjnmOyonIRPGURUkj1cw== Received: from mail-am6eur05lp2105.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.105]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:51 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sFJ93EnwlS6GFrynhraqbxx/WbCL4yTODxzg2AKiuJOdQC4c9JnNwcwSQRSVYP/0MMeUxgXXO1n751CQe7lCtK1ZZmm7XBwMd6I1mf34u8vcv+pmGMkbXJTqR9b25xKENjbQwK09bd2N5AUXAm9Q6fEWrsRO+C7hhIfSMssiM3q33tsaab1Jbtq8TPfkFyVc3nHyCvNrikXd45+pTPdSafoOsGtpynzyMmpcuV0nEEwO1HTXSuyVGetJUjHhr3Xl1bknBzQZDcZA0gdmj++Oeecd6j+z9kAupZhRGC/GpLMiR71ADS3RdJHuFGvEGqZvSlZ9MmJEk8w/Xz1sC3flpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QWd2tkeHQbBwbBNdDBZH/aGLavqAFkrtdTaIu/gE1UU=; b=PwBrqrncBjHZn7rCgg4dFW6TgW0ySowcW6MWBw9JnPxe2mVh6hxwHpkaW7NWHVldS6B9urSnyaMVzcKJd7O69HHaN0bnKR+v4wTfHQ9KCa3cklTsCdeEefXDK0bDIrf3/Icl8QqMM2OW3DU+QcN4P1q/5fMwSBmXbEzJU1cpm2RwQeOFkHJXmBFvERm0MzlhdAVlnl5J7CW3/bZZ5YNhDOHeJeVCl4wmbKRcB98lkaG2DEaQLPAjuTg4POL0snUcVt+CacPv7GBMePtMlfX8sC5aSDFaJ8EpEBJH56PDffpOJQ1B8BPks9F9u5n4vbBPpp+JH+evk6ySyGBCQrBAOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QWd2tkeHQbBwbBNdDBZH/aGLavqAFkrtdTaIu/gE1UU=; b=FquTm4/vuVY0T5oJSItpe7fZnpVoYhbstkqnuEXmgUplEVC+JP6WsmQ2vB8crpvbaKpC1SuO0ADoyAoJvvzZ6+HiupcOFpV7PhERHRjG1sP6OSPzWcLmQm1wM5e2kD1rci3lsus42YilwTQsrSZaFr/B/rM0NOTzUYTU6yEj1Zwuw07HAYsBzV6yLVIf6yg77tUzZKHXbmf6kiZN2cxkiHJoZj+zby67aPLefVy5KVR4PsYbnG8wDkLGt1CRMvkkyoyxaoG4X2d0O7pfGFrVyqZiecQpuheLbqPiK9yfL+UNQG2ev8aw/SHDeBQr9Ot/AiZBKkzwEC/TEsjsACGZWw== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 02/19] intel_iommu: Declare supported PASID size Thread-Topic: [PATCH v1 02/19] intel_iommu: Declare supported PASID size Thread-Index: AQHbQjJuc09ui8+1N0yV5gvXicUETw== Date: Fri, 29 Nov 2024 07:43:50 +0000 Message-ID: <20241129074332.87535-3-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 482a81b7-2561-457d-c727-08dd104990d5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?kBOssBc4TnU0mz4Itzc8z8wKp+q63S8?= =?utf-8?q?TzvTYHuWae9kjPjdYlUQSWfINEuKoREDUUhBofMWJ1jicbg1Ph6DyY+96bD5PLLD/?= =?utf-8?q?L6ZLXQWyUXQRJeb7auA1A10TaQPiRFY7pULlpav4BVMUDyP2rlfZ18PhwCkVKBX1T?= =?utf-8?q?ImqIHF6ZMx5uNT3wB7fa0fNkgTYVA0616CKRp3wxU+PjsTBXAQwdrGSkSVyBTzEb6?= =?utf-8?q?W15XRF6Jye/H2WykiZ6l6h2eIHt6TaeMnXHzAEmLI9FozNGBCcsIlZoh262t3tAFE?= =?utf-8?q?AaDZ6SCGGp9bpA+7mM67OHTqmJLJrqVviSkvik4WkWnnhbzBk6N+rLZH01+KaA2uT?= =?utf-8?q?e3pUA0I69ge5tOJi0i1geDV0p6E8e+3rEBkmPVzsolGnAG4VWE3wtx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K5UbM?= =?utf-8?q?VcuwPZGzFXAFhamv1qHxGOcSVMwdTxFWOvxiKZbSimEEvwFNBhncdq9eMYA72RP11?= =?utf-8?q?CMeSR78avhhZCowNBZ5E+AhxsPzFBhXCuw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?YCcG5+mjhP1B8Hc9ths8thcb2y/W?= =?utf-8?q?9s8T+5uePS2FE2z0vlWzzjvjWrI8nvkCjS6Icde1P2LQMs95iZXLXXsVGRO+4baLR?= =?utf-8?q?0XMo/3ac6x7NAq6Pl0dcF6Ly2R4dIJ+2Xv7k/pTwQ/xh4/ylue5Yp1ktSlMJLDwnc?= =?utf-8?q?YqJGJNUypLUUMrVVJpS4eKD5oXLJl1XPcDcOQPHdUaHOxtUAuLeq/wdO3lWjVLmhS?= =?utf-8?q?/PCaav43V7XUUjQuQERduaIILTj+tOx3nVwcIWjCvGb1x9Udd2gdLUyKXr7dWd1aC?= =?utf-8?q?7HNlMj8XEf8JLXFAJfLD391jD67AQC2ogeTeuLKhB4HOnYg7O1ExqlKievq3Hj94C?= =?utf-8?q?x0NcwempxysK7Hp99Ht3etMzMHgvc5RW8iDrYDR1DypoAAO9kRCsGoFNVU8ZcsqYy?= =?utf-8?q?uSdU8eQCEdgK5Nix0guo4v0czpg55WSnTpLkb318tQjNon+nGnHY5KGUFbOisplG+?= =?utf-8?q?/2se/LJdsT5+7Q5pYYpbz+NhQVMn1I6udAGUYVmQwixMa3WUyaezjojX9DkMqGiLw?= =?utf-8?q?k46BjVyepj4prM3YpLRBfy1z4jlUlthXFG+iWIM+Ncx8Zv2EFq48+qM5uv3n9VGVR?= =?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?= =?utf-8?q?XNiSJ6nAFnKgF6A8wSsdDF7LNEBt70yMKsjH7e2YU/WUbSLf1em+q4lw6H91fWpUE?= =?utf-8?q?uMt8rk15bkVmrhRhHsZJrZqKGMa6l00YZF2hjCqsKAc4V7L0jjn330o=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: 482a81b7-2561-457d-c727-08dd104990d5 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:50.5046 (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: 4y1PUksNre6bx7Hvr4cRz07PVCzurKh9efFNKHBvmx+oGekAG3c7bNgeqX7XNq213VlYRpfCrTIl5idkmaicRlSRlEJ43skqoypJXFjwH2tn9WN2kxX//y2L0j03QppA X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif PSS field of the ecap register stores the supported PASID size minus 1. Thus, this commit adds support for 20bits PASIDs. 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 043426032c..aad132e367 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4575,7 +4575,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 e8b211e8b0..238f1f443f 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -192,6 +192,7 @@ #define VTD_ECAP_SC (1ULL << 7) #define VTD_ECAP_MHMV (15ULL << 20) #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 Fri Nov 29 07:43: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: 13888451 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 6194CD6EBE5 for ; Fri, 29 Nov 2024 07:46:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvff-0007zB-Ci; Fri, 29 Nov 2024 02:44:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfS-0007xC-8y for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:58 -0500 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 1tGvfP-0002fk-GM for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866235; x=1764402235; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=n8O98KShNuvgHQbN+mh2dS/8MP0Nk7wBFRcwtlVqYDg=; b=OcD8DvMoiwsczfgJ4TtCeF8d0c30s2Fvw9A9RKoRbG2L4B4KMoMsFReW DfQDiqQho2YeLZCksqjkPjtE6li3IpqYKfhLeYVjsz04UHDWVbUPzFqwz tbXJUkRP2vgd5Qv4CxoR254WehImpb8P4EIo+hhya0Jk+mze0mzKJvrkt B3ofqy0+Hwxi8WTMOToYqYNEe8t1tLW7Vid6vi91QxGogqNYHbsdsJivV hEC+IfD+Wq2PtCg3dxKpSJ9t9h9AYrxpwgtTlTsfAQcNOkQCUSYKtLbMM 1WgxbNV2ArogcLul7aKyY5PXcLHLmFcMtzXReuOktUflLDZZ1rBnp5vjM Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="26377115" X-MGA-submission: MDHlI7iHgExURIGa95c/M8LuI2hgkaWQG7n5dNMPtOuMxpsNkxXTeTAgqdVP0v5cx9KnFkl/cwg4JXqQ+A1LqXV3xh2omykEMAFLvPJ+OT+GBDrNYxn6GGJlXhgKoKadTHFZtqA2LrwKdD+wrYuN9ijsO/CGFcCyjkbYT79yLiEOKw== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:52 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VGUeaSzPDZ1gWrLYtEsgYL9aBcgoBHyVKt+rLly6RCx/e+yS9fZt6pFy+fhOhRSJ9gBStTd3wSpfKQxnVdoOcOq6K+ZibJsBGMJ8CfLL59BIqTeA1fcteGkwlGU8aeJX2T90iLXZ+7BBwwa2JUqqbnS4bBp4cTeC3wBLn7cLQdVQDQ4oaIJ2ob/NNr2RoZOkozCWUBF9KlQX9BfI0SEiMpvcAlFIMjkdmhSMrdM6BKh1ODuJUxai7YSTzF3ugOX0hWopyAKsjx+cppYFcaqy8vmkVF8zDfGBQm2H1wbR1ZDvDA1gvVXuyO6mrGb1eG3E2sEaeOe2sJgLo+m9+vU45A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n8O98KShNuvgHQbN+mh2dS/8MP0Nk7wBFRcwtlVqYDg=; b=RyniU3hIQo/FGQlJ+RCXdkikEJuheheB0PqhLK+n59YHlr2MM7J47Bl02MUlVcTzwFczEsFCcG5qWoLWRbtRaM3mr0vMssYEIrEtmkrpwMjHma/66h1RdsPOKTCjyCdm44WWiu0hcYg8nwGOoPDL9Pe2Wd1mibIuf3LOlHMr+P6f3jfhnaGX3JCIxjXDNsGq5BMcbzO35qI0/evdf1FYzA4RSesprL2Lr7hSgwR1YNq2PJ2ESYKMrpRnTnSYvmoISxvYQlsSQri7CtxF7BonE4AT953lMja7Yvpf99yfzcUDq/5zkx66CdB4+6R9mqoRSNGaX4qwr8ckkUXK9dDZqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n8O98KShNuvgHQbN+mh2dS/8MP0Nk7wBFRcwtlVqYDg=; b=q+jBtZ/UqNNAAc2iJhlN+ot6Kb93bK7COt/vWIO8T7syz4+tdj+cymO5A/C4o7a2FvbOoVOuFOhuSTfVmBMCJAZ94i8ysbjixUiN54zytmHoMlhRLo6+uHNGE2SrFpXJElB0UmBTir1ZSAO2GF3Q46Ab0wXQP1WoAvtfeiTzEmO5Mb/2tgcV+1pTwyZYdLUOBRTnWLjOhv5JLnVU/D2V0znma0R2qVpnzJj+KaXYgtzFxgnrjYUNoqRdCF78GAlp6P0DIKElq/KyDYexsyLoRsACh50KmfcMvNPI3rPjLn9Fc7IjR6YwhROHM1y7yy9nVOiHX0wtzF8JRUVBENif8A== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 03/19] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Topic: [PATCH v1 03/19] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Index: AQHbQjJuVhzKX0BtCk+R1aLGA9xAJA== Date: Fri, 29 Nov 2024 07:43:51 +0000 Message-ID: <20241129074332.87535-4-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: ebf6b0d0-9d22-4d73-b24a-08dd10499151 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?sWxQuDBBKMWSHqKMa5lsJg18p/ffIyT?= =?utf-8?q?4taLLf/ABuIQ0v0ImJVF8g7qnpx/EaLW+MPFu+dai5OAfkaGW8gX32/432SgwXmiY?= =?utf-8?q?Yv8s7omyIbZrtlgnviImukNsdui4StcI6UfyiHu5/RqNWQDmTTHGYwBXHVj711rAl?= =?utf-8?q?slL5QM86ZzKISiukHhFPf5tKzLJm7JR+yt4iABu675Met273s2GnPyiUHaXqw/uBw?= =?utf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VMmiyFxBqxQ/DTZqxz8jT35Cye8+YGqLPToE1JjfVCvFjwpujP7NNtrK?= =?utf-8?q?boHFNLyccWZ/u3qOTZFE8sd/D1UONmv/bJQmExqb6046QtHu/uOlxPOxw58y3gGEB?= =?utf-8?q?ySJeXEPu4tbEvRerOeU3Xc0w66Ci19YjrY/QJVj6lErTPjYWxH5cVw64ywkWEVZVJ?= =?utf-8?q?nHqE6n5p91D1uTs8GqEIVJr6MK9gXZBPunOpIdu3aB+KbzgeDWC6tHQdWfDkFj4d8?= =?utf-8?q?cV3DGSZS/byaxMNCD+KRXykKvc3KgLPQcQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?pB4qnu9lHDCFuM01HOHP2FmpLv98?= =?utf-8?q?G97nMlWw7Li45L9WCrF7gU30CqVfbIfcErjgrxjXaBwoz074DytPmij58tAwJsYeN?= =?utf-8?q?+fO41ZXNT+SRpBMjx3E6iUGcg18owrmDIcLzBTUCsbR9D4dbYYmomLNmH/7mKuYAH?= =?utf-8?q?y7WnSiMKenZJA+oI4h1Bro2EWJHqOJcRfiGtreX2wU3fVpaTCnBhp24Gh2WFytaPJ?= =?utf-8?q?/fQ6sgjaB1Fxh0DqSFUnGGeOsGULlpOmhPBdiU0OViAqnIxzc58uk1VtAl5+5eW18?= =?utf-8?q?BokHcyfRQJXtEMDNUiA0v3/nXI0n/BP+GmDJLepZwFfY9+VZvKzBtwIXrDR4OJ2g4?= =?utf-8?q?paU7sn9Q5BCinbjhlhsrbGkCt+GCRsszVBLuH7ZVqTdhauxTkEIy6lnPRZw14FqP7?= =?utf-8?q?zNvfxPIB0PgTpGMIJ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Z/jG0Hx5r78n7WZTl4rP5AtYnfJ36XyOcnCgjGAecU/TdD27n0Nk3?= =?utf-8?q?IdjzgBLDCNWhKSDAlMFgVPyijmnzhAtND2fNJ11UWG2omU7VYG+K3iQQcDNUBkYE3?= =?utf-8?q?rmixYJhZND8wiQG9GJVTtqOgQRhnDkFjP2060g+ULXgoskOGzaSGS/PJ/1020rqlp?= =?utf-8?q?LOmBQXMEXuVU0+1m2d6tSY9oDLbenvpRU5Vc401trEgIrsN216NFsQ3UnSojx9yBI?= =?utf-8?q?VOPGV2WY9/O8i2K/j0Q83Q4OPHTruAA6RzsqucckQr1wzBuhtOu6mOw=3D?= Content-ID: <70E67DE5C74D2747A5ACD2686E753665@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: ebf6b0d0-9d22-4d73-b24a-08dd10499151 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:51.2633 (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: UOleF5CtLnYf28y4ddTRoJ7uObK/d7t6d266DW5Mm446PdnvCb6GeyJy1TiAZpJYN92vz+S8Mp2HBexsRc4ThLs8cySuHKI4zpOm9gSJ/JdYHbVIKyCIR6TNVzLnQ8qY X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif This will be useful for devices that support ATS and need to store entries in an ATC (device IOTLB). 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 15fff69432..756dd2ea7f 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 Fri Nov 29 07:43: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: 13888457 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 70B64D6EBE5 for ; Fri, 29 Nov 2024 07:48:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfi-00081I-EX; Fri, 29 Nov 2024 02:44:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0007yG-Fc for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 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 1tGvfS-0002fk-JB for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866238; x=1764402238; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=rX+tJ+oComjbrky4DpyY1uHu/VCIFl2io6UCQg7jFHo=; b=O+vS8tGXThVPbi9+zg0thDpwzdF7jVZak0DYp3VbwsSk1oPW9AMnf3JS HZqyjb5x+s3fdjzgHPQXZ9F0OcXd6CT9GH9805vSwmUZ7dykbMrmA/gnB Bo+dfTfrBfX6mvEYwSzquC/gsuR4VseZ8kcDFmvKQ6Ib6s1Ql4IhetK12 LiGnF4i0OQnzR0YEmS11kGJ8Xfh168N7+uHFn5H+QfvgCivc49MZ0NPXf wvKk7JyCftnRV3mNsA3cfOOYHVJRGV8viyfZPqeKdWE8EGKGjrnAtX/2w g4sByiHdMVHWVJoJT8zvpZD7tKvHK5PQYWDkEmYHvFhNM7GBIOKF1nif6 w==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="26377116" X-MGA-submission: MDEdpAa2xxhhsoRkzAoa+W6H844oFiyu0JgeIuUmo161lkVPG8TP/DD82CariAphnXFokZhXMRaUgZoYtwH1IUREXbBi+SRXAlBepRSLaunSdlI8aoSalBaSO8DnV+CWnhHyqdqlhE63n467lOWjW90Rn5X1KCZtSYOLMDup8FgChQ== Received: from mail-am6eur05lp2107.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.107]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:53 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jelfD5q2cHxiM4rBs9BFbahB9LbMyoO43TBPtcvMKVxd930rzrdgel15M2+TCMeZVZk8FoRVu7mIN3XbVs80YTYhZPu2vdTCq4YCSCNp/+IclUSGbBPAay1cwq5pW97b7Y+BpeuS2LduqMtW3fXjeAUmx1ezHJJ8E8mleFCIt61AmO8zx+rLGtFh4ZJjl3Q/XJauIS/8DybKsLL6FavQ8BnKcY8zQ9vGBtt9WrzaCfktzomthckmU/AY4NQutspRFVYVQxE/c6727Wzb1CrL+M4mStzo6zJs2ySSqM4VmvTmksOteKqwHmIQHi3v/KvIqqiWQJluz4iQ4w627oLeNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rX+tJ+oComjbrky4DpyY1uHu/VCIFl2io6UCQg7jFHo=; b=Go/sOazKfF10geAhdduZMuYChCPHj0NJPCgKJQBs/StEXiiKUNjddVA7ml5cirQTBihwv3HxS/lB3L9ipXCKkYKZHZ7cGgW9HCagC1yk5dHX2XEdpzT7oOaNjhTY+7QGK2/61ScK3m1aTzyWm3dtRbDN9OHWPah+SgVnDbcnWEWtk1JS5fJc3HmlFM0Cyi6OLsJVOO4ApNsLmjVZHnutsDGkVh21WIAxZYwxcSCflKGyHbXcDiQNUnSIAxofn/6xdCYhdRzHLkEXQNTr+qscwRJAiTGi/Oh5L9Cv6pnw4k+QlBHJ66Ws5wYG7cZ7DRzGBWFOLVPAtWuk2fMyxvOFNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rX+tJ+oComjbrky4DpyY1uHu/VCIFl2io6UCQg7jFHo=; b=s0XLlyFo6Uw7DeVyRQZRSGgzC81Y7SE70MEXwE96cVgr6jCByvgO2JStKB5YuUyXTAN0mpCFz3MVCVB1ZsSSd5skDVLFI3UAObJTw1dzyaFnN7dqMY9OFY3ngSPUAljIOa4CM3bHcPV7wSzLe5/MIXNCy81ykOlS/EqJtIiiymiDOUjqRN0URuhaAE6e75cTvlfLx0qBC3OoKpe685b64POraozsfGIr6RAs+VGdq9DNJisp/44HVVsaZZqF4kJgG59pW5ipWhEy0/z3Gl3aPo1c6y+riFOB1z8yTx6wB/OcuITHrfQXzkbS4ED1laEd8O8LV1AdliyFV6Mr62rZ2w== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 04/19] intel_iommu: Fill the PASID field when creating an IOMMUTLBEntry Thread-Topic: [PATCH v1 04/19] intel_iommu: Fill the PASID field when creating an IOMMUTLBEntry Thread-Index: AQHbQjJvXDmiXC52f0OTAvckNfcVmQ== Date: Fri, 29 Nov 2024 07:43:51 +0000 Message-ID: <20241129074332.87535-5-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 4d8e5bf3-ef73-4967-7369-08dd104991b3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?dOpOAw34n26sx9PfgoSHRY7sfm3aaVI?= =?utf-8?q?CmgBhMgb9Ze4kv775zLvu8N+ayHE7VUMaNkhusoeJ0Vac+sMPKhEeqcGN12O35lyC?= =?utf-8?q?ZNMs6dtptvLmXV5RrHj4UxEBqhiVzTG9R0hNh2bLqtuu43fI+WaPHK4Xi6HU9pYRk?= =?utf-8?q?6rwC+3fj4f9qj7PbsHb+Gin693JH/p/P+VzRibNOGCCDIvFlYhTHgvQAl1E+J9UPA?= =?utf-8?q?ftoTqPt9S3mO7a3gKSi1DvIrSSDZmnDG2eNoCk27/W4/FQteUFsnI6946FwXcusra?= =?utf-8?q?dWO7b1uJM4fyO0A3mDoYTzUnTnONALEZFctkjA5y0t7mML4Bh+ECPfKq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fIpX?= =?utf-8?q?AwNZ5glDFOrtITVG2eT5FZVOvYsduBL47pGbUw5RuE9FBKNlF9qMRmHjrMi1cqiW6?= =?utf-8?q?gzwtQ3tmlyQCTUNditiFlTzPUyE8ppAEFUuqKKGLYhFA85LZEHvXLifvdvW90PlEq?= =?utf-8?q?9aEOeIn6zYXO1ZoWLBiPsSmAEYmmnuSzqQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?tEHO77FV7LEtL3HlKxrsHnZDWx5b?= =?utf-8?q?g/bFZAQH4AJGsetMM7S1yK5E9AWMG3wcgyabX8dbH+ejrsne6YI7xrBcS+jJMKpzc?= =?utf-8?q?mS2WT+zeLo3/1yP7h2YZf1S5AwqGxEzYjR87mrCJRlBBlLoF9nW8oHMfyWYm2DPYY?= =?utf-8?q?EZE+yYIdjo/UoScrjprVNYVVDjInB14EEYeb6TutVciLBC3dkbQ6GvfcOWlOMNa9H?= =?utf-8?q?7bZVQ1YavC91wDFPt8zJlZgP7vwbaZt64uOY90PlMq+DigYdV9QSf4pNzn7uylnm4?= =?utf-8?q?dd2p1BxhlMSNtaBdJguEYQwR9t2u4tNN5Fw6qK5ea6J/4jgwVm/2GJsEEsSFVsg5e?= =?utf-8?q?27FsxoZGuXRI3IrUcD5RcIKlGHaiE11dAVF0l36U2PKRIfFJZCYD5lQUxiaSXE47L?= =?utf-8?q?jtxLUyeTeId0SZWoGbyj5Vcbmqz1JID6WresgsHUgXoc1l1f1T4iKNn1UJ4D08Qqf?= =?utf-8?q?kVW9IBOmVW/cWt8X8qgh9ApBp1apZifvg/A0W+AQtUxoWHArGa9wYMkNhvj6xdhe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0cOqiiBnF//An1hCpS1QwokLU3A5IDAMCNojquf66hPj2GvXFGf5/ki8/aAp?= =?utf-8?q?u6lzyEB7J2ATQsiu7yTkk4HK4ut2kofwO0Tm3iq/LbY14pgmPUKARkZuIiSG/RLg/?= =?utf-8?q?xXxU998PAppZSoIgg/lKkFFTaJWlEc0H2CpKYooS0ki8k1VcMxedXf8=3D?= Content-ID: <34EB571D86DA77448E459DE72B3909D7@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: 4d8e5bf3-ef73-4967-7369-08dd104991b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:51.9380 (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: KvR+mpm145Ws1xMdjazB/e0wEFtZxj9x070V/6jbP54T/3wASZ8hi/r8qkcpZ5MjMX6wZoxdNBQPW76I1F68YdOj0dMDWfOTjwyRitEOkSZYHFaBLKhFPfO9EoDQ4x1w X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif PASID value must be used by devices as a key (or part of a key) when populating their ATC with the IOTLB entries returned by the IOMMU. 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 aad132e367..a92ef9fe74 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2119,6 +2119,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 from IOTLB, we don't need RID2PASID logic */ @@ -2260,6 +2263,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: @@ -2268,6 +2272,7 @@ error: entry->translated_addr = 0; entry->addr_mask = 0; entry->perm = IOMMU_NONE; + entry->pasid = PCI_NO_PASID; return false; } @@ -2511,6 +2516,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .translated_addr = 0, .addr_mask = size - 1, .perm = IOMMU_NONE, + .pasid = pasid, }, }; memory_region_notify_iommu(&vtd_as->iommu, 0, event); @@ -3098,6 +3104,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); } @@ -3680,6 +3687,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; @@ -3692,6 +3700,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 Fri Nov 29 07:43: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: 13888443 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 248A4D6EBE2 for ; Fri, 29 Nov 2024 07:44:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfU-0007y5-5l; Fri, 29 Nov 2024 02:44:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfT-0007xw-9G for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:59 -0500 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 1tGvfR-0002iu-Cy for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866237; x=1764402237; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=aM8mqPyN5ZNPJ+XgspxAHIbZoobBBfEugTRjl/ShzBE=; b=xZ4eha9qgMrlwmEQaoHV7vuHtNBfN8zvAS1CA0NOfSRcG3yhJZRePU0d 7yGtOYIdGAAqpYwb8OcYMw/6/Q8ihHL1Wv9QojH6/LDbQmVWfZe4FuU5X HJMTLgjSDUImNAht6FMemABnQqKO0IWhnzrDAmYfsL/hwQUTCNSmeir6A uRvRQz7AAcGZMcRdVJ+1n+eo9+aTpEWJuWdF6KutPqJLL5WI14D5A9QlQ FMACAZAv+d3pRKb2wx9sXt6xoHj3kvca+3VzFQ8sFXEI5EG5vC1gkpRcT gnSJ/0+Ez2wuEC70Spb2sGop3yQU7z878XoRbPAwFeeK956J3MYG0ZLxX Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25663421" X-MGA-submission: MDGWdL3aigG+Z8ODGlCVozlFb9cZvifuLNw9ifvzDvsDkaNXRt1qyHvJWr9CXsp+tlZoy7aJmSIFd4UiTveWA3drBxgZ3+XbsgEg60O9SL5CJUXYv7DpRx9EVZ+ujK3g43HOH6aVtNTU4AhcZrqgiqUXsIlfbjPz2DWC+IsCeReIJA== Received: from mail-am6eur05lp2107.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.107]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:54 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lxPxFmquwuGE1ExCGKJphSK0zu0oNz9MMeUKvch2psv6kYAzQQMsA3AUjnXiUnYCCvYTL0yI8I9wLzob0tGiZ6llFthr8dnMeumxm+fQUc1pWmP1MFoR6sonPrju4UbabRjALLl9PVqHyuWXsenDJ0EuulhNaclWpl38tP0PQCMH9z6NbLCrwkpAR2y0HupH44SzkawyzgKrdXELSjmy3/cNqdXTpGGTNV1oERq6u7vmGRmW3tWs0lhXXGtyxv//qXtTlpjn65tbxnbLjZEIzINhyo4sYzedkwbAbns2cmA9N6sJ1ffaVuCF7TzZzpKxUl7TYJ+9ih8tGQdSjm9enQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aM8mqPyN5ZNPJ+XgspxAHIbZoobBBfEugTRjl/ShzBE=; b=fJ/vqOkCS9Uz2AOMGgl8dURzBEdIN95Hjjxuu9gNHdnXQZAsPDdrlUtsRQLe8D+Jo+hfiECZQfbURc1GqqTUkcL9O7s4e/cJ+ZOofjFh7CQDj+IljqsppsIcGrmaToQeKYTqFLJGdtdcfIo74diqDvXagzVBYDCccqNuP2b1hXEseBYsfgzapwRHRQCF5ywJEHRJs9PLQeue+3tSfBr0Gjd7za8W8n8vNItOSFwH+XSPbRLYocOwCp1vUc8jXQJ6nOhm0Zblw1Dc5hl7McYOpuMW/aX+xJPg81QCQ3BXtX0BkJR86BFVswwJeB5285RmTxR6Mg+HTuYuoqNmTfsYsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aM8mqPyN5ZNPJ+XgspxAHIbZoobBBfEugTRjl/ShzBE=; b=MEMqfMEfqyLnfqg5Xasa4wTS/ssgcI3m/QZqX/pVoykM9DOj2mpp2hyQ7Jz0yLneJVY0pJscA6b7d6kfix0Dbr9uV9hqBl6qmWKxe5zp+sZggDSyPARrm2x6knuvXBEl+JWpFDo8Tj8pJ9tolFRHQymqxOLWp69kGqzaTUFXCaWe+R3H7/Mezt2Ftl5iH+rTgO/Fhhn5Najgv3Je2/rhIueT7hYYtCFttrOGqclcYS2y+h3wS0hLlL+4Zeknokmz3xOKZzI7PhgqMoNZ6FBTZUKew6yaWzqEdacQjOrXiUTG/Qt5pXTPSrE2nut7w/u2pdwkCVzJn0Cs/GolLvxDcQ== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 05/19] pcie: Add helper to declare PASID capability for a pcie device Thread-Topic: [PATCH v1 05/19] pcie: Add helper to declare PASID capability for a pcie device Thread-Index: AQHbQjJv/djmAPSDTkCKwQvJ1qVl7w== Date: Fri, 29 Nov 2024 07:43:52 +0000 Message-ID: <20241129074332.87535-6-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: afc98462-0cce-497a-d08a-08dd10499225 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?hCFrPdYE6MIrUD4OqaBZCRlTiUHaEel?= =?utf-8?q?6UaKnZcDNeqChjp3zrK73c78Dtm/WEMl1pRXViyd12zphlzH+fJZ+rwi/dOrRmzig?= =?utf-8?q?AGSvVb8qqyLqMCuxDa+8APeF0iWVwe2iO2UDIYJ0RNV93yocEoov2We7dgZe+j5jR?= =?utf-8?q?a34rYm6hrufEgw88I/6p7DQCVTL5BvdXlgqug7gt1spxyLq6zJtW9coDjcYnsLZ8g?= =?utf-8?q?/l6ATQM7QVxg4W48WIUoVpjA7Ig66+m6oEOq042ykhazUUicWjeAwCspW0mx9AAEf?= =?utf-8?q?bNPGzhXA/puH9TAG4vIBe8+3ZGn6+h5B65h4FzSYuR++RatLnHUbKSU9DehhVW4+r?= =?utf-8?q?uVIb2MP0yImuZucJ20tXDFzUShsndEaJd/3bfaAz1GuLxmOPCYA3yf1UjP4JC9ArG?= =?utf-8?q?o5rDssyiLA/kMGQElUL38Xc4PgFTfp7pAVxztW6cse/WWMe9WgDJSMD9qWvHuiVkM?= =?utf-8?q?AzD5Oyb2R7XtPLDbpcVmH856XBAEdYcUyfhS22CzKBu/21d3dpLg7LdjfZiVsiXu1?= =?utf-8?q?CTdLtC4ak39v87IWciediS3LHiUOLOec3Zc88K7tM0C8lzQNuwysNkvxullicmFFY?= =?utf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; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?x5U/k9MFuITl9hcVAzcMfRP/FXBr?= =?utf-8?q?X5WCOwolvxRd6hXJV8+UD0xFhbEEPF0Ykrbb4+4jDla3PnDLp6MPb/GGg9NKyOu7S?= =?utf-8?q?BM5CwksoTpVJp92P9FiCSDmhpv5DhG0pTiz2iXHImwvXxYW/waAvzpgLN4JtK1tho?= =?utf-8?q?QBjfmXkmX+LbhBj0V3KVUgrhnfYcR/MNOAYTTC2t+yRod7seaLtDIwrzyL8H0xFnb?= =?utf-8?q?uwwHURSlvs2nKp+KB1eJs/JKMSLWVKCNkVcAyjsXzchbElJIksXotnJTF/Qasy45Q?= =?utf-8?q?PSdU8Pvv4c38+ZsR6o+c0x9SCPnVBheXF7NdgECDdlBbnlI5SN8QqdYqJHK33n/G8?= =?utf-8?q?wTT2AuVqnxYNDqU0+/gM4+ujFJK4ZSpcaWnXPoei1SMG+Q4C5isJHskprtG6D/9WS?= =?utf-8?q?WN5yhxUyVJ5ip5ggW4RxDwbLqNrTJQ2fDoplGrIv6iLT1gVGrRUgJISXG674dx5U+?= =?utf-8?q?vXd6Yim3XD621P+4idV3RNAmQrFdLwRfinad6Hqdt5cnf0/jwc56j1HWx43tDnjxb?= =?utf-8?q?VQLVwN3jbbrvtof5ntITbZnZyBvgBJg5K1YJrGgnKAs3DGC2+UVsqhDeIO7gLF4n0?= =?utf-8?q?WFKJ2Wl6s517yDS/pqGIfiHHjl2PRnmiGcnnpkwikkgh2eG60i7rcLXiqqCr804/E?= =?utf-8?q?6ZnJTuW/Dqg8VhxoKZMSbgmFpOBzNrSR+7t3aEyk86xwH/RqgFfjnbLNNYOb1ZiZz?= =?utf-8?q?3Ife3fVAzG2OtHDWG0/AxEXIQiyNUcgxqo/2PPwDCIRkHrIZUT/5XnwAmn90UngtP?= =?utf-8?q?b3biVtInY3QTVpyPeeD+mbkZhySfCJ+A7WqCMKOTB8bsQlL4YK2CzVWOCH6+SpaVN?= =?utf-8?q?PjbHSrB+mTF32tnLgEP8AuwXTQUR8SPG4c2Y5jS0W/DsBdquz6HmminsLvvqjl362?= =?utf-8?q?SC+KMbagkJMs2x06Dlah3tJqFWtxPbukQNQsG8eujEedY+6yv1TscUILplKf3SAXy?= =?utf-8?q?G55bTMNm5yBd/E0u2YBWf9gUVcCLrL8UkRx5N05lmQP2GEweKWvpi7X7SHfZRbnyp?= =?utf-8?q?n99J2QMyijuEKToGpWVpGVCa8d2Sd3A3gdU3533GxDFoJvqCI3Fe3yA2LV6G2QpVF?= =?utf-8?q?bhQsJj/6wbGPK58j2nPQ9gukvf70GLURAfBVccBN0Cve8qgVpxkKvsfxAg7FapM3l?= =?utf-8?q?VwfcDIjVCAFNelHuk0F7Kh2QXMLWZL+LaxC1n8cufNDiTqAvNKbwTqNa+MEosMBew?= =?utf-8?q?651ln1nQE8HjUb5r9skykmnf7XOhY/cXxph4tm62WeMyLruHihMJeTNrHjm/pns2M?= =?utf-8?q?g69gGqq12tuGjng9QWzXz5WAvmwMfqbpzazAkrdvirwugXitkZSOoXchbsF0BIDXI?= =?utf-8?q?0pJlDTv5SPCng5u+6ZAuSpKoflbxPC1rfgwZYiSOt9vdnwRHTKLnG9YrQR9xdgDUl?= =?utf-8?q?cK+q8DyihUJ7yGKfpQ3aL4jfLAln0f7otSkqRaLkl4R/DUeJjq6LfvK+cr8BPjNBe?= =?utf-8?q?Wvm+JGODR5ZjP8J6pL0ipu5TSfhcYnnw3rm4HmzME/niHl1KUwMI6/glUSTrzdoGm?= =?utf-8?q?KcPlo0P4ShVBQH/W5ZOsFFfzOQTKVdKG7NsKOMbSoxVGnOJOKajpy5w=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: afc98462-0cce-497a-d08a-08dd10499225 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:52.6593 (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: rBWRT4Mwp6AXIYvOPrOoXoNYtvpVGyFFjNmM2kVK/urec8gQKwOEhnrK/urW2Xq3n+N7tzgDL+daHzThhSlTHAT7NSdw0rCMe4UeDX1GnsZ8MDKqSreH9n511g5HKCIL X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 24 ++++++++++++++++++++++++ include/hw/pci/pcie.h | 6 +++++- include/hw/pci/pcie_regs.h | 5 +++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 0b455c8654..5b896496ae 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1210,3 +1210,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 b8d59732bc..aa040c3e97 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; @@ -152,4 +153,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..4d9cf4a29c 100644 --- a/include/hw/pci/pcie_regs.h +++ b/include/hw/pci/pcie_regs.h @@ -86,6 +86,11 @@ 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 +#define PCI_PASID_CAP_WIDTH_SHIFT 8 + /* AER */ #define PCI_ERR_VER 2 #define PCI_ERR_SIZEOF 0x48 From patchwork Fri Nov 29 07:43: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: 13888452 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 0EB1DD6EBE2 for ; Fri, 29 Nov 2024 07:46:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfk-000827-0K; Fri, 29 Nov 2024 02:44:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfb-0007z9-FS for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:09 -0500 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 1tGvfT-0002iu-JD for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866239; x=1764402239; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=dSbec9u073dxNs0vgQ5NpjaCt5YwLh5q+Zos3VDB6P0=; b=MqBf2sbe5a50fkmMwswahGEaO8nGKhYqnuEwGnESK2b9e008b8mLCXos PSuuPTlJ3hkJf4kOuR/+PVi+2OPhbOcRnBdjcW14fc9+a2D1RSXuG04Uv vSPThX2Til5Ppf3KzMJIRABkXP3vFc4FOuIVBNCSLKDVDSWPvUI7IXlpV k+BwXDqC4KG3F3scLMfnN/WnZiY94bAykXpHo23BgHWO70REKcTewVXCa NgvQGax7XfdfPUTLhRsqcasS5Wk+EkPCsYD5GVegsnyJhWBX5qxrcenRC nMNGKJrgZ/wuh1Vckv53HVcqad3fmN7P2oZocHJC2UTljSavQrBsiZVHG g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25663422" X-MGA-submission: MDHdK7Kwv4sPI/A4mSEm5AOL3xkbWZby6lGG21BA0zYRys2IS5w7jmaFe1UP8LzbhDdTHPTaBr/Jh4ErKOnnczdO3B0tnBnYbZJ0mAH8/91067LeCsLr+FnABOVzCqEoN4EvYnpo6ckp9wU18z4UyNuk5WskkHlfx7nYhqCDFlH8Xg== Received: from mail-am6eur05lp2107.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.107]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:54 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wi/K6EKjfOPp+1LZwpKzLbo23IS74cb1Q3QYpjNsmrPMlJQU7HYp72TIMMYG87TmpKvOU16+sqEOUj5VnVe8DOyzoXLoPsCzmFGGwvAlc+nYtdflE/PpJAxj3OoQqwn+e1nPOXRgkHwcM0s4hXmfmk06VU1OheJmCW2gJeJBlWYJ30oSO4a03wXM4nbCgO6IezXzNvNeQQSLmG5Nwb2W3pFpOamtcfRKHXE82ZG+C6uKnnF3k9EmpAX7cJD+WU3NMhdiy0xcSrEXfgC3X5w+83VeWq7stn1bsNZ4YXRtcknecd/dmBWTUbXVpK+yMkR1XXJZUwyx7PAYtqCHCRqzCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dSbec9u073dxNs0vgQ5NpjaCt5YwLh5q+Zos3VDB6P0=; b=y1o5PlrvByXi9PxtMGVGF9xfXkzIz7kzo1xmIl5cLbP1qo0yV9B1zw7KAxMGqGnpB0qc7A80zpghMcNSdXtar2Z3B4qzN2aeVyrrkMeBnlRns+mYkk6rj9rsN9LmF9tPC6j4ZPGK69IAtSSa9nt8dApjH5WuJiev6VaAHPbcFgasYv1B9YeWpHb1qvto2LD1JLBjmfyJAMpHEM6futpA0eaee6doyAwhWCStFApsAkCsuUXkbVgZf0vc+PBy58zPCH63GzQPcaelo6QlKXJVisd38wcaz5VNPRYr8qzfmGsC7sWQYLB+8+xnI8spGKkgdgfGvVQx/QAkoLxnl54kVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dSbec9u073dxNs0vgQ5NpjaCt5YwLh5q+Zos3VDB6P0=; b=PDagTgmSS7us4b1h1/PBZ55h4i9/O+xNyCOs/Dk7fNSMaXRveXXdcmwsCiX+poE9uge+SHAVqdfPOSZxsk+GD9BOCjOg1SxWipiNnfVGQmlCrQ0z4jnCK5lGFU7q93C4Qtv2Bg1Z43mmTUZPuhQgVtWj3cbi52E5XR0UtZ/OWm/Ji7XHjZi8wVF7RpHVqKboz/V94YkSobchttpSPQGWHcEZ5349bdAeiEGosnQB+ow5Uu2PjvxVj8yR01PIIODkMHq23vVDLoW4LGBBgU4mW6jZbHRi6RL/yBSB7bcncWmmz09PadN4t9EEh0Fx9Vg15jDf1Wk4G6B88I5BUeUAUQ== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 06/19] pcie: Helper functions to check if PASID is enabled Thread-Topic: [PATCH v1 06/19] pcie: Helper functions to check if PASID is enabled Thread-Index: AQHbQjJwXoyduQYO3UOuG9p1h7xK9g== Date: Fri, 29 Nov 2024 07:43:53 +0000 Message-ID: <20241129074332.87535-7-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 34b96ed7-9690-4bfc-84aa-08dd10499293 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?Kt6MI1CovMLU//FO07hpRGqJyyYDZqk?= =?utf-8?q?Kcoq+NWPbRF++Q9Y7LKPv/HKVCrHAalyTGbrq7oQvirdoDqm2SaO36JyEmQENRodx?= =?utf-8?q?Z7Jc+0sHW4YnERbPFTu0TJTT9Os2SjH2Y0zf13PvcdA2dhh9i5c0UfUq5L6ftYwvy?= =?utf-8?q?OvsMCZ6V3gi5abwlXHZwU3WPJWqRH34HqRi42eyVGU1YSnUTM48iw0pH2ltMhEON+?= =?utf-8?q?A+mT3QUjhoN/gJaMO5C3GW4pCGA8qn3kaHmo7eKsxidBVYCnPbB86+fUyye7chZee?= =?utf-8?q?NJESymmKoRLE2bnpufR0WkhxD2ubpijuIBeqQTIDyqRqjMfRKNKHWeOenwmjnqMlv?= =?utf-8?q?/o2Xej94eXeVFwlcT0nUfYs+Vm7D15yZs6BHHBMLawQjP826sZK01ZP2ePv0RRAhK?= =?utf-8?q?s72lyUx/F1nAJZQgReVUTWDdMmyWYd2Me+/R1PRqY/mwtWRaUANt1VIzAaqadwIoM?= =?utf-8?q?f3ow4L9AIpLGSmAJOfz7vXddrgaloVB+G+XdT3rgmx+l/si8QpJL4gBBoHx/KFFhl?= =?utf-8?q?ZtANCFDn2WpVaa217dmFionMh7LnALxqCmotfR1vB8ZdCFBOZOwOUWSpHVZp66HaZ?= =?utf-8?q?t+fmpjRZFjiVwlhpwm/ljI/hyY5u7fXmw888SOMgRIcgOnTy/j9bHb1U+8fVKDzag?= =?utf-8?q?46YdfsHHwV6DyFCht95N6TFMyXcNo9mSWRmn5f7e1FMUWR4UyRACGwKub42z/R7ap?= =?utf-8?q?lc1UDmkZ6UNgmEuDL2iTiRz6ss0FWTib3CZasKLDnKKFHsmE9bwj0QNcfJEtA4Jz1?= =?utf-8?q?j/1Xaf7zqRpizNeVKsf9xLdT/cBBqxef2bDwU+6HRdjk5oS3zaN4LYa5qbhWOdHIy?= =?utf-8?q?vaQZ3IjHjq4grqW0FDRVoZgT6BwxCgT+Ej2vK7p9cY81foPpK5R3Z/pbe4DuxsXFr?= =?utf-8?q?wy3op+Il5N6bnRIhDv2HckgsVWse7filT1cAHnVYdFDa52sEAFSMndBPIXnA8XQes?= =?utf-8?q?MyZUwP5rGj6OsfUu2i4TN9yRHPW1oftfNF3ErFusvAkzsZWUO8GNOjt7GtxGzJB8c?= =?utf-8?q?tQczTxSqUOvXSjU0ylqfJh6vWJANbrc2y2YlXVcU+wR7UTKjO5fTuUMxkm92jSTSF?= =?utf-8?q?BD1xeTzg8dTA7pjidVGMlKRO5MvtgCEduhdSmI021xliviXqoZPy21rTiJsoqG1S5?= =?utf-8?q?VFYnBXD6Cn8QbT9QTOXiDx/NFl6VMiLchJYfnF5y2hFBg5uvU53tDVpY5TQ0f6tUa?= =?utf-8?q?GwWpAxgNMOg7pUetVLpbxlneF2jePVUXhMTJ6KCMRom3C5Mzx50Cds0APFRVHzdYP?= =?utf-8?q?Gj98c1+1XuI61W3f2eXzbhlBaOB52kgYvkCDRCbUylvrJbGqFO1CvBTZhL/LAeh8l?= =?utf-8?q?Wq+VSodMuM/3MRLl8lK8uQn/OdKwjTsNwQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?fUQzd6qbRSw5l+qDiQH7JnslNftZ?= =?utf-8?q?QXgoh4oqMdiHfQ7z36HzZAKQ/LVfEHn6lmfH4vmjacrOQQV+PaAkN/DFrDBwCCH+O?= =?utf-8?q?5YjWrenaQ1aeUn2LNxtz0vpRqkSeCGCmD38yfFqNYS/sv+kqdBim3GmDz8pHm0n+1?= =?utf-8?q?FQ+51GxiDdDJ4SmWizU1wL5Nmtcr1w6lWgs8NCeeTj7Tc5BcVbhUBBeSsGH9VG2wB?= =?utf-8?q?J57iQA3EtdWcuurWbJ4XxweI87tqqHskVvNARoY6o/Msl0QCPpn9SKBulpG6YvF5f?= =?utf-8?q?dosYMPzauvC+czguzL6JjV1KWPn8cpPGfwsgZpT+l5Pb9UpUq3KjE71A/VtOD3ZKM?= =?utf-8?q?Q5fu7XW9YUJ6SsLOIMQY7hxkZrJ3pE8KKy7KcwZzRTwruxllkfA+rxNZ53BUZdv/O?= =?utf-8?q?dBAI0U+Cdu2ivX7zw7zIH2U9q33Mj5mb62ecF0my49p33/63VrB5fAwITwuyZXm+c?= =?utf-8?q?NbPVwJPOGNja1GsEsZhE6B8MS48aApMbOG0MNpwsi7gr8PgBzYNqBnK6Ptbtdjnj9?= =?utf-8?q?bg2/TYKyEbrcyWgC+ty8VgP63imPqbqQ+rrc2eFI5kvpCiCWlkyaxiFzHzGBrQ+l8?= =?utf-8?q?PYuQ3cUea6pkHYI05SIauZOONbdOMRbdVEiXefrffySS283ewKpaFR1n3SPwOY88C?= =?utf-8?q?N5gf6f54NOLiLS1PTbJqqWZrDT8pNouW58RFUyIlG36fuUSd0/7BJMBkKbZEoDonC?= =?utf-8?q?SXZMDkWlz6Bxwtfi099IhaxJU8Rs6nWCxEOE/YHQ+wMwrFORr4m2+3vJUC31nAUK7?= =?utf-8?q?8Vi4MDHgAutfy+I+WoPcFykjU5tTNqysU2quqmME+6FYzegALECrLG+CXwNqLu/zt?= =?utf-8?q?KGCi0Dp0dEpVTi/ehyP3Qr4n0jxRgrveduzQtM61qSdr933VL+Y3yS0x0ZZawVY00?= =?utf-8?q?QWAlZ6quZtlOOnEaNmhydDNYu9qDF7Zm5EhW5inC6gUVUytrq25/ZFDfoKW6D8qkS?= =?utf-8?q?t/xO4r8aVdgkQoQ9y4WtIAi3cxTLZEwVEE3s2NxRTMMXmBV8Muy4RExf6VOcMY5+1?= =?utf-8?q?8h/I8I5tuEwUsXjFppxom0UKkrvHHCuXdDQzfRCI1ax6HyS3yMqB1vmbH7/p0xvd2?= =?utf-8?q?WfVkk57VFk4hzFCK+Ecqcbjywa7idZjS4zZO6pqhN3ypFVON1CT0FKnJrdlg7iCl7?= =?utf-8?q?8jJ1vAXj2owye7CCHG/xPasub1KzJMUaUOK1chQPzarrQYGn1nq6rObKaDNWqM9tl?= =?utf-8?q?eI7fQzOkklEDEUPtrY/Q48TW7nI+K47JhcTMwTtgrmLqsONou7vnK5HyinSHIx+cl?= =?utf-8?q?qNuNY3uDTUxR5HZb78m9V5CIsWAk2YhvgkhIZj88vPxfOQ7th0IMMugZZyFcc7zYi?= =?utf-8?q?6zcBBrejB2+SSHLy1YU4HhZApL7lUPNuIXiEJBN3Irq2i2eFRMUK5+SdpcUG3jmMw?= =?utf-8?q?Oa06OfAbJJe6x/AZ7UwRrYwBicIdHj2Tld/tvmGHjHE3MCaS6dOJvKfc+SAc21tPz?= =?utf-8?q?bWP8Ynop7wiBMO2ApcYFTIMvXfLoq/JDNdk1t1sEuzBYhVFzbZBdbHuC3OiEVFtf6?= =?utf-8?q?wNyPPGavmHGpi5tpmBy8NH+akINbpIQB8JQ8vit89tE9ZXG05i+ArAc=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: 34b96ed7-9690-4bfc-84aa-08dd10499293 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:53.3763 (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: 821KS86VsF6wrb+D+z6VIN79YkA33cBwZ9aDZnkD3ytqjiOq/G0sl4KQcJXMyV5h531n8JaodAxWqwsQUI6Pe6NeJtIAA6ZIgx8tMBPG3RBL9UEqV+1saYg2PeW5NWQ0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif pasid_enabled checks whether the capability is 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 | 9 +++++++++ include/hw/pci/pcie.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 5b896496ae..b6e84acc93 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1234,3 +1234,12 @@ 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; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index aa040c3e97..63604ccc6e 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -156,4 +156,6 @@ 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); #endif /* QEMU_PCIE_H */ From patchwork Fri Nov 29 07:43: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: 13888453 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 EAD6DD6EBE5 for ; Fri, 29 Nov 2024 07:46:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfh-00080s-Me; Fri, 29 Nov 2024 02:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0007y8-6W for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfS-0002l6-FD for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866239; x=1764402239; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=nLO7oFl1vVw/df1gXC30zEz+WpNpsTM0Fxzn4pMLcgjUGbjUBVhcbCwY r7wfARh/vpQo105yjpKXgDuEg3vwFr/eKGgUA9A93EIbDYp8rxHGOT7/t 8LPTlHG+QaQCYarhi51vK4qB9P1OY5Y6fOmavvhiJdKMFGzgCj7R6qUV0 2BueMoIk13IdJRzMjtOr1AQIuGDlvwJY/rff4HqlcoHnjkDfwA7KOJb9B 88g1fmkPilv7Cv9afC9Uic5Kam/eDRg/G5nRgyWrp6BYvWdKxKj7+Dtl3 7ZAbTVHaO52FFBxBnv7CeTRF+W0r6dhHF5FT3lSrSjY/zj1dVPacbtVoQ Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664403" X-MGA-submission: MDEZNtdPT7zhjxTYdsJrzrE+B6bVspPyFTlwnXiC3c0sDTOXXYyoguh6IRmIQlbOY9N2ou1BBqPSfMgmMD8SJV7ecvGH11DB3plEM01gkIeaQD+ZKoKEFLl1X445PcoEdK9GhsPdMQCxe9X/CrBGQrE8BTRBY5y1A4qhVmg8023mOQ== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:57 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M9CEcEtqqX9zHpWO6AKvaEpGFpbnghc7YUuMt+sZOkBDyUlb3cf+YVqkvxY4+iRiU1HjW9AbvwBR+tuP8XXSmTQ5PvUgTNYjMKYBMs/6Ty9fDTEJlZpAYyblHRyeDLnMuV4KQ6gSK5sRsMQ0/SFgfX4lpYU5MpbY7TR8LeBrMWtEFQK4IEMYqHqrB7AmbrP8L4/WNuROteNK7SycLmRf69ZAPtJHl4RDWM5jLC/rwhqoqfYqyrDKjRZ6KiDXNZFXJ1lSEV4YDTR9zD3PtnCMrEtV1Y7KrpV6ujMXAmN9k3QlNgyxlQ1jZPPgfJOLKdc+bj7PQJeVlEcBvMW45GbUWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=dxyUqNORLKCKo2zLcesLl33bujECXchdUOryzmB4Zm1xhlK/KgKp727tfi3kHUM9AzAGoAK4Lajk3DLruS1ygLDujjGM1kSST7daVyMDCCLvGpOMwUjfq87XClEAuoFGIDy0uQcZUQSjvkyic3k0kpCb9BypnytrSgbvg2nHLGFP5gV9oyH5+eRjeQnMvqgkMr+3pYFaOOMvIHjhj1RMrkCIYT6ghOY7/amUz2PXt0L8psXXDsRLvsEzzVS2SFC71OZ3TnVXcGy497kRlpdpH9ayRaOeDOvlyOnfPCVMN5MsU2U1+h9SH0yI/nIVYpGp+DHTYsAR9df3VBSUR5pMKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=iCo7xBMu0XGJ7O0uqilEkecBAg72+PyLYxFkQtxnCgYLckLaqTp361wDSYzH4fLvznT5x8UJFSEUTavmMQROoSNjQfgoJc2LmtE8tcRpYFjZ+d5iHURuV8m5BRXzmVw/fREhc/WzAIjYeKHbjs8AwYPPM1BDEOgc29VoBY5dbk2G1zKS8R4G9r0FpqrfmNm0tqS6DxF8hJkR5136auXSPDWHZkZ0+BKnmNqIwVO0Jl2B2JDoeiQDWsUOIqbjdn34GtArxByKQv2465g1HNkkUBXYvvr1Bv7AcUQn+DKQ1wei1T2HvFVONUWtAVaJoPYEqDAdrnNQEa5kk7vXNroohQ== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43: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.8207.014; Fri, 29 Nov 2024 07:43: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" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 07/19] pcie: Helper function to check if ATS is enabled Thread-Topic: [PATCH v1 07/19] pcie: Helper function to check if ATS is enabled Thread-Index: AQHbQjJw7Xoxk7N7VUCV2WyGQB2/QQ== Date: Fri, 29 Nov 2024 07:43:54 +0000 Message-ID: <20241129074332.87535-8-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: ea94c5a2-8bb6-4cb9-c5f9-08dd104992fe x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?rWhDn6HTtGisUOz5QSJc2/SZrZXJEN5?= =?utf-8?q?s20g3YuZvDU0kaIMnIMDwdVulmLhnw8uUw200OFSHA6I6pvSUusPzuz5HB8yOklWp?= =?utf-8?q?Hx6B02tqUcSDZuBhq8zL8jdTQpKwDeKwLdQeowYP1D8j/ynjTSya0i1tKc/oyObX1?= =?utf-8?q?azuZ15pePKykS/WZ1k9x1Mgp0fbfAfDtZKmPaWUBJEGxLmgYd5XP/QNF9OgRrj95N?= =?utf-8?q?Els59XT3po23RmL8F9OBQlPRM0gRFgY9E9kFvJ0tgUVYjiYtN6uk41PGmnTkK2V1g?= =?utf-8?q?TBkKoIgu2tuVzOx7RO6AQwfJOeod7Z3L6ZeRaPX8h/hoIPDFrprjuBonodjFEq6BO?= =?utf-8?q?fWM0zKgmxWggxaDet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TkBTbZ72W8l4gRkNQkHGohNiwhbbqQKpKITfSN5ZAveUGyGBmC?= =?utf-8?q?755og9lcyG2DnQTtBIIwZe9GrkY9WMAe8gjNdPWmL3KEmCQ6HKrB3+G5Gse+gccN/?= =?utf-8?q?P0BDYTintS9Dp2HB93WLD0fj3jAZ5Gt8Ng=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?LzhvxtmUpjFsSTSqMXGv1IUg4riK?= =?utf-8?q?S2p6dnKfL6oPpI1rjzQGrhBrzejbwB3KpYqZ9YxljfphO4jqYJL+1igy19e2VIBVd?= =?utf-8?q?MUDqpiq5Kbw4dbyVGQWbskJXVyW99McIXpFEEbLMzXscGTeRSqWQbbUTciMsyJyTZ?= =?utf-8?q?16damxUOkkErL3sbZgImBOlZs25Ivqf3IBSmXyYaPzhm8yrGQEDBA1ySJ3zl7AlHR?= =?utf-8?q?bC3a8FJn8Yfk/mygApBW6cl95LDOGjmN6bwH4FYffzQPB5vKMVJuJqRbYnyzTmdDg?= =?utf-8?q?7hh3sipUmO+kyKtJjBxBMSL8psqOiarSxMRyFh6nJKnrIdWD4slR4aVil4Z4BKczx?= =?utf-8?q?wbdeDEZo9c5tN+e1y8/02+dKwxG5dKYwhJMUnt9pW/VOfQ3FrfGUWlNjLmmrryOAz?= =?utf-8?q?/vP9BoVf4N2uK0PO0Qv6JVWZso3sdebTzplbP1fN7qP0ZPzJ4J3fdPV3TWZtJM7AD?= =?utf-8?q?u+WQ4KJpLZ+uJGllHm5PhEUlm/1n2lnZpy9EEu+1Y3uG7vsqddTuDjlFoYA0o1i7i?= =?utf-8?q?2wmvBUT8VzPJ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k/wWhOmAKOx0iR5qhvNn7M09NVUE2umNIfLBgGuPoxVtpOTq?= =?utf-8?q?LXArFsdHTsjPRb3ClwiZzFwXTmqqsVQe7EzMwiN9jEbURQFx4SuC6jkHQSEOADNMl?= =?utf-8?q?sVCTm0NbqNFglJ8cezRummqnEfaRirPAwVE3RxZ/KmKYK1LWu+8Bdx0=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: ea94c5a2-8bb6-4cb9-c5f9-08dd104992fe X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:54.1081 (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: BXszZwXww1PrisbXNPACx0KC9qFL13JYzX3fDsgMb2sS7n9M5hMuZ3bNi7MJCLaMCJjBYI3lF/bsily79k8wx4+Af90LzyMx0NHgkXpqYto/DMu9j1nmWW1ZEF4EVLvl X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif ats_enabled checks whether the capability is 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 | 9 +++++++++ include/hw/pci/pcie.h | 1 + 2 files changed, 10 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b6e84acc93..72bdf07834 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1243,3 +1243,12 @@ bool pcie_pasid_enabled(const PCIDevice *dev) 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 63604ccc6e..7e7b8baa6e 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,4 +158,5 @@ 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 Fri Nov 29 07:43: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: 13888462 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 8B5CCD6EBE2 for ; Fri, 29 Nov 2024 07:48:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfl-00083N-BO; Fri, 29 Nov 2024 02:44:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfb-0007zA-G3 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:09 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0002e4-9i for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866240; x=1764402240; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=SgZ/NdieoWyyUYJq31zTUmPy3l7qes7ujZUCB5UJYUw=; b=GGCQRfYD0NQLrQYMv87e3lfAgJRiwCpipyOZa7XfpGoCfYgk37r6VMiS oB7fD0/OGPG9O7IibWXVpsWW+5rt5CGKnY8sEOSu0+fz98keZm36qyqIq 6aHCQkOHJ5VMnNqd6QcmQhYKWdvSn+qkBVd8+iDxkKYBJUIRPyWfEH7KS pvzzCZmf7EXqsovii/Hvu6BwSvyA5ylihh5mw3dV7o0mNLmJ3vhmw3Xh6 POCqI0TK5r7E9iKdjaXg+z1hOT1xUxd70YUEzItEIHfmc9DdVA6TnGcL8 GILShHxl3MEJa6esNr1ACe6o3TLAMztQwwyfrsnZYnywoDRwE+nSftzub g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664404" X-MGA-submission: MDFIMZM8J5+PI8S/UsUuFt+ekDXmTEttc6dhj1SNFbhvBlzVIMe27S9Nu4cvZbml3hSPCYsVx8xxk8AtMYHdj3zoVUeFNkiDH9t+ymmhxWIF/BhqdnXaOQPLwUwimfU3G5jYrBDaHT0smczfawrjJ2+4nborwyIHgetaQvmZBqRmtg== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:57 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=otDriJfUgLl+whCAijuGnbDawrrmQ18YKQA+L5fK2YVtWjqFNsaaKf/bYU6mZMR2mJG8uyI0+8UFyyp34FsGZdqOvOJ1eTp20Iyt96RUvLMl9RT0RKdtqxdfeJLx2giFOoNpqxqWgpDgvCDnhRbFmgdj/Q137YEK1+YIJaO5QqZkuNSdARWPIlfNjbIRMqTzaPXYTtohGqCkw9DsfCJgUejZEzTxml5qgOWNg3RIMz+vmEA1mDnQlDXHT6RWFVpOYUBs6Nvt7QrwbmfcuM8F1pjvQgWDygDINwx2p3NXQ2moq6XFHOAIGav8+Wnq6cEyIYfzqMmAvFX5BKb5E98T5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SgZ/NdieoWyyUYJq31zTUmPy3l7qes7ujZUCB5UJYUw=; b=bYW4myQNDhHGjMG4nss1+P4mvlxxN31ys0riWilGtksER4Xii6gb9HHjUOnK/+ln7E3FHkAAoXgK5K/dnl49AkXS6crPimId7RPwDu7CJFhtOZT2OtauByg7g2tk2r5JyXc9LM3divMxIidLLW0hEzBCO2Ijr1J2XI++iJUDT6WHjwLYAOLdAi9vbXBK3NlcFnqhZLU7NfLoac2dPeldQU7kI7hsW1SrFfPzq8szbxwcwS4GYtGD9h6faC3tj4ZhC7zVHXPCcBnI5O6Q+GFnmXKwgxGBVSpbfODiq4SIzZT6XqWbAnAJRB7000so0WN1V80n1szO3Tetf1RoTP6Sdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SgZ/NdieoWyyUYJq31zTUmPy3l7qes7ujZUCB5UJYUw=; b=WQlNKHgyxmIN6TxyYsCCr7dNIqHgylBrFGLdSebouAH7nQDlx2G+lYRkO4UtyHQV0T1KUklc+G9ZrzM5m2Ru+MiD4JYTPBTIB0U5ebSGrC04CluUSgSpa3qT2tONvm5GxaejCrhIpj20c+XXKS8ARQLvxwcyVYE1v0VNebgOzVdLCCVynKgdjZKiUeHNcwUQlIWPj9C60g7ceTi45EXFZizNLeltyUAYWNm9IRDBb1+wx91xvFaQWRbcFCx0T0SfBM4At99honZ0ZK55cQJhRVfGc4h54hZoONExCiLYsWJYYW6Wc6O2lN47jN3rV/9aWiaGEdlQVLm4E5p37ybZ4A== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:56 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:56 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 08/19] pci: Cache the bus mastering status in the device Thread-Topic: [PATCH v1 08/19] pci: Cache the bus mastering status in the device Thread-Index: AQHbQjJwwtKQ1xqBiESCRkJz4hVdrg== Date: Fri, 29 Nov 2024 07:43:54 +0000 Message-ID: <20241129074332.87535-9-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: cd734155-2d13-4014-8e76-08dd10499427 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?FbCpl1X1P6eEWS/Sfbjhn6ZeUFPdmPy?= =?utf-8?q?pactVip5nl6sbAw2IAEsnGz1/VOibYkyk4ojUluKdO0FNJ4U44yr8aTDoNX658ddc?= =?utf-8?q?TOzOr4s88pGvKGZSWs0jiyVs99y6ob4DNwM60MIK3ynpR91Gv1KzN5oT1mmQtKKf5?= =?ut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?EAcxMs0Bws4WEfVjxmN7LxLGUe6mYsAxdg9GlXaleSOrYMO62UskuI84SNSXjicps?= =?utf-8?q?l+Hq9b3hikTElx6orlwGmCK0GAJt7m80xsPPDPOxggJdB7qbI6PCPwSlXC2mKWXCs?= =?utf-8?q?THQR5xgtLsyjM1a+t0/lE6/u8vpBlWrhe18n8tvjVvprqygVt5fEJG/kfboeRJmHu?= =?utf-8?q?9c7PYLOh4HYP9au+JdJSDt2LRTdsf/KNX91J73VYpc3fALkCQNbl9zI8D1lUjiM6z?= =?utf-8?q?I1z/AgLmsUgtTEWRan45cDdqJVIH5e0qkODVAjFy2o68EpmbcIPEaP/rbGAw1W31b?= =?utf-8?q?YaFUwuih1MGB89UOXvqvCWCTuIs7L8l/sw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?1hqEW6xD7JBXLZIlv4LsZIv5+bPT?= =?utf-8?q?wsRuX1grXY1zTm+c1eCNdE5tr7dF4HXSCcQZBFrRq+L76t4OkxsCwaNCJb9P8iBF0?= =?utf-8?q?h4liqd3bYIWU5gtmOKQwi0ZFMlzTcGolUdyWB80uyGx4XCoudYvg0zfkBh759Zf6p?= =?utf-8?q?yatbC/EhWR8cRGbQuyjHl3TagqbZaJGHKo/fxeHwP/UtqbUJijPvDTnme3oP+kil/?= =?utf-8?q?mm8Vrg3CSurG/7ouqD40+I3GsM8DqN6rryd5S4XGrjV0PN/mMJ+BD86kuYE7fVkMY?= =?utf-8?q?xMsYDRoBDQmzC5BBWY9IDdMacavqTITHXtpfJHg4HvCqB8Tk/X7/cUdQxCYLQLaZY?= =?utf-8?q?DL5EwYHGMjrCQ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wvB13ESH1DxF4dFJ1Xc8ISaR7OHm2RpzYwIvSwMteSCQmhxLX?= =?utf-8?q?+CzTGCmXWPJy+5qNuWB8KQn758WD/LxYnxdIhf/pRI+Hg+DMgiV0zg+IBlwvZc7G/?= =?utf-8?q?kFoc4f4drY6j1iSQ0/Agj/SWOzHrlp0b+bpf36zJPP+hq3z5xknpJsjNh3+O1FGm9?= =?utf-8?q?/kYHYGZr63gJvUWMhmJ24B5/AaSgCN4b1gJ7pe/1cnG0+tUZWr0L4Ry8ht0Y7ZpM0?= =?utf-8?q?OTxytmVVqZDk8Q/Nd4bqfrZTQOkJhrNWNNhOsI7XgIQssZu4MT/j42T+JbHf9Qosf?= =?utf-8?q?UesypIkSMcn+bK8WLBYq/gX8h0ZITyXVLaOgC/VQrcKCLPlg3wjwHhk=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: cd734155-2d13-4014-8e76-08dd10499427 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:54.8071 (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: Q+dUZ+XaSu9H2rCgHharpwAmSYdU+Mjr0dk/LzopfzfG8ebUaSbagrDe+5Phw1asvGowcgxgafLFzDivAmN7JqFmTDD3G268hXtQWdH+LpqfL8BgHgiHP6NmtpmsxEm2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif The cached is_master value is necessary to know if a device is allowed to issue ATS requests or not. This behavior is implemented in an upcoming patch. Signed-off-by: Clément Mathieu--Drif --- hw/pci/pci.c | 25 +++++++++++++++---------- include/hw/pci/pci_device.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1416ae202c..bd36c5227b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -134,6 +134,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); @@ -141,7 +147,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); } @@ -675,9 +681,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; @@ -1632,9 +1637,10 @@ 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); @@ -2917,9 +2923,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 8eaf0d58bb..de53a44ae9 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -88,6 +88,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 Fri Nov 29 07:43:55 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: 13888454 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 6E04CD6EBE5 for ; Fri, 29 Nov 2024 07:47:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfj-00081i-Cc; Fri, 29 Nov 2024 02:44:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfb-0007z7-F9 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:09 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0002l6-C2 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866240; x=1764402240; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=JYTIqof7QhuFRW4wADhZR8s7wPY2u4yiamG1OLfdCiQ=; b=IFrUYJx8YDNqFtGSAwbOr6c30DgVqJ4c1aqnIuFfxar7gFZSY/x7Q5sr /qOWOv0tNIxK30FpBAi2JcllUrz5ZsM+52w0nFwZTQ3FpYuWajV1rbVc6 np2XmQ/l1CMg6qZJfMExcLLphe65LqqSn1MRfI51bQmWWw8bP6HdBsV3r BAWtZFivQOiEh1uSPN4qjTIeQLlVVcPMhkGN//RB73wvxBaIuTw1sTGz0 W/Kfxm068U0Z1I+bJFKu23itRrKRx2eI8nGHnkt7DPYPB6MQ6pd4x+bn6 g1K7wSP83eo94r9TCY4WPpYHgr5NiI8fhWTlt+Gu81NSdpjhn6TWSlyIF A==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664405" X-MGA-submission: MDHYsGRhdcfUuLh3lc4jqcYd0pwONASn3+DS+ZJCBBXl5aUnpNfMcRnmMeXM5RBnrxo8t+rmXLWUQy2+em8CZ5ptQ7ya052eFCQAxtGHpOx2dtmn0+GzZoJUnZXnWJlo2IEoVdc7cX0Ir2gor602fMMtKDtO7sf77hpVjOOEpfNv4Q== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:58 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xxBKPxVbuBgtbSRQTMiErk6c/NRJfG6qjR533Lc8eFKmE1dKpixWIgveQgsvDPar6hhvOxjl05aTUPinXoF90Zl1HoOH+F3LZhpptkdh+/0Wl47wESI+0pM2k5g69bJcn9XkXAqcqgh8Vuzfgm8Hxck+42FGLDVNILeh8YIAg/6v5+wMKqe0V6ANCn994XeRfSmYZVGjH731qpBA959r7BNdDVO/kLFA487yw+Od7mVJuA6fAMnqtbw5SWjSqGFzB9N8cL3YmrX9tMvjssWGxxLJ52+xgb6JL8Sx4tF48gPaVSrgngf0Hp7ttFIc58i60yLuuKkTD3P8s4AotFXScg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JYTIqof7QhuFRW4wADhZR8s7wPY2u4yiamG1OLfdCiQ=; b=LxR/Ym1wRisIc17KZjjUlOh5nT2zwZq2DPlSSWFrBCFrtPAdvPBxuYVgU+qs6y9ZhI/ffUA8KrEn63dmcI4pcgYqlITBhjrAQeaNyszP5nxVLeacQ2ZKrw2qtRvAiIyEiNetFLXgx9uZHvf2/g1gtqtV9mbqFpZcUeOug42Zlml610emiPkkq6LKzCskoWZdWYxD7kOwOQr2iIU1oV424i8p7pNQIUuojn1StQ9v0YC4Sjts2LgJMkjPg8NmR7EgPtW7GTpCeO5J8pLD846QAluB0/QLAJtqlkX9zJB8YHCYcHQDMz6Ibx07Ud/tWqLa+L7uwyq+YxqA/QSxkqTfhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JYTIqof7QhuFRW4wADhZR8s7wPY2u4yiamG1OLfdCiQ=; b=oc9C2uzQ8x9mD3UOcFC4sTIyPKKTbk77Q5UhnV5s64m3CFu+9ayT2mP/IAres54B5GcNvgP/Y/Mo7d0Qq8akB1r0hgx8pbtNOLfALD6vTI5dgn7NUFS0+w98VbYqYz7XTow1rKfLSyIIcVzvhXClwr0Hm1KBayRJIyfb3awpytipi3icpBXSTlSP/sUAkVrap1s3f+PxQckOZ0ux85lZ2HRKUm6kRWrGXf7ZUfV5avn+ltdSUvDDAdd5EydVDka+0F/Ioli4LyIClX8dDxevvoeIoJJStNIfciqchdeCxq0pa5i/eFGuRKdzHIsCoW9w+hFP6NZqIS2pQZOJsFA0Tw== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:56 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:56 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 09/19] pci: Add IOMMU operations to get memory regions with PASID Thread-Topic: [PATCH v1 09/19] pci: Add IOMMU operations to get memory regions with PASID Thread-Index: AQHbQjJxlly1mLkXtUGLosCh8+EKPA== Date: Fri, 29 Nov 2024 07:43:55 +0000 Message-ID: <20241129074332.87535-10-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: b506727f-506c-4449-0fb9-08dd10499445 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?GLZrtfDIofL05sOh9aE9/DQey3Fsufq?= =?utf-8?q?Txto5F3sOGKynqeVzwH01X7P/hNhI7OSYzi1PHc1w5PQ/VtmJ0DRp1fU5oZQW28hq?= =?utf-8?q?36t8mhlmbf9sTs8fY/m8Qk0goTMksDYR/sBs2cQL5eUbio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q?euGQjaPthijkSM7lgxODOftJT+7dIFFf8KBhyQf0EEC+N+rXJFr2q2/XPmoCpQLgU?= =?utf-8?q?A8RaPZuv3thmeVM2FyZtAZ214qohy0GHS34BFA2ojw3v2a1E6wUk7W/5xo2HacOex?= =?utf-8?q?sFxTPHBsvJdbZre937opQIya+6kEqESLblihJPIzMYBCkWNzW5ITMUGi17LaR4JDT?= =?utf-8?q?G3Dcr1+/WS/StIMFzWEchhcsCJ5c516G4egle9WkTl3Yyxo68GMis/tUvmQ49tuE2?= =?utf-8?q?YWWZmKnrwhxmZ7twQHwwCBY3kWDIjxD7xnieWlyWZANh+7X6lxo3tjKl/UhVj85Lz?= =?utf-8?q?zboCZdBzkGkFN+x//YsC/MN/M7hQBTKpwQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?gs4Zb1BJbqN78hiqtYJN2dWkPkwu?= =?utf-8?q?CaAbquMI31/XJjA+ynWawN4gbS3XnE2A/4HoVV0oiInxK/r1/bzwFMQoLevW7HpZ6?= =?utf-8?q?iEFg8XDljxQj618xYfvrD/vrPbyy6XhENOzKU+s7f5+LHrADj7DjLW8+qAypOvxrH?= =?utf-8?q?nr+QlQCazzmzTvxoFyW+ELXO4ztysSgDqdLkRv4p1KVLQcAIfrVnIPiUzZmLnYEu5?= =?utf-8?q?t3FCyxctuq7ShKqX5uPA5ONu8LGt2kD/phcUdqSyw1slrpWxQd9tEZPC46CgBsiH+?= =?utf-8?q?etnGnNM7FKNvcHAPHbhzqx7tGrEmfv8wVJxWDvlHNpWLycAlngi5uKBh+45wCxrGe?= =?utf-8?q?pS3EKk4L81qlgsfJv0AR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X+b5B06+NqY8jyr10iJ+oTNW7ETdv37D2LdY5fvCpriOq?= =?utf-8?q?drn8Z8OSsf1l/3hw6XdL1Hba154L8ZMe4T+oDuYhbvXDmTXxiI0zUiOIVOGXtqv9i?= =?utf-8?q?pY3l1j2Zx1x4vTnpY0CjfZEyVyzwbWwxd8MUvInG6sE0vjm4i5GS2JpP49yA6+dms?= =?utf-8?q?CzFiMmaGXB/a2YrivnfzT15NZuWbz2u+P4Xo6xYWt+I2AC98rrQIdrqo0CpQUdbma?= =?utf-8?q?BGWEvs2T2WNrBn85ihytOvcw2KFCGm9hYT3wlEan9ORHQwL7Y9ymBL6GD6rT124wA?= =?utf-8?q?k3q1o+FF1cYLKVaqzGSBYDZTDPzGaWA0raRBN292Nsk2fK7dD1voo7I=3D?= Content-ID: <765DE4BFCF17E0459D9165253C140C9F@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: b506727f-506c-4449-0fb9-08dd10499445 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:55.6714 (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: Hu7EfzEH1Klw3ISuQZifV964yZ6q0p4H9KiqW4fyzaE+cApXtwI/NODeKQrUxkzdkiuo5zqbEH9N9CU99eXPZYWzlHooomi85tWbKkTT5SF1mjpfOeR3np/Yh814V++R X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif The region returned by this operation will be used as the input region for ATS. Signed-off-by: Clément Mathieu--Drif --- include/hw/pci/pci.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 135695c551..c34ec5ea81 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -388,6 +388,22 @@ typedef struct PCIIOMMUOps { * @devfn: device and function number */ AddressSpace * (*get_address_space)(PCIBus *bus, void *opaque, int devfn); + /** + * @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 * From patchwork Fri Nov 29 07:43:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13888446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62250D6EBE5 for ; Fri, 29 Nov 2024 07:45:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfo-00085M-QK; Fri, 29 Nov 2024 02:44:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfc-0007zE-9t for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfX-0002mK-Hn for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866244; x=1764402244; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=UI+wnTHf95zBFzL9yNBfBDGCIwnOJDA/ZvcEIJiXTnNGvjKGR1t9MHNL EAuvbaI0h/MnCXbLzAsgUuy5MDSOFd+EqFG2rAechfMqSiT1r6Z3UdPKF iGtWkYgnQCCe801SR3K0PP9kL2bJpTPsqisTwTeh+5idRV4fODMBAyvLK jLOZ4nxM1i5Vdjy6rPgYhV8Y9XfTSFFlLHygw8jLrMsQKv7mhVcsXy+ON JE/V7I0MFdlQyUNOLR4qvJDYTdSzGsHIbLsNhvBtC8p6/IxMlZPWKGe8v sbmNJ1iYA8P5rR1ZcH1cLoEaqI+1l7a+AlOTR49pv3dAK072a1NhX0QAk w==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664406" X-MGA-submission: MDGtBwjA5Nw44xfKT5Lzr3q5Gjp0txOBOCy2VwJVfBu0PmHA51M3AhPwk6TLf1pXG3OaQen/fdTz+h2GKc+BEJO+rivQ9qldY8ic6i2xq7wMvWGf8dp1McLg/AqJf3prsSzVv78F3vmuYvjuTwx43ygdvoCgwx2rQOBViEBABw/kIA== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:58 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dp8wDQWjJWNVAjcF2hxnVf5aU0EVNpJ24xhZdLM44b9sc23zeoU+ElWIxauo5GmBt+dJU8fmMtLLSeAE3BEmwI5YOka0ZFueJXr4akmMzi2AWYPN3C8v4AyeozHYQOEx4iq247aaV8QSmSM+a+Y+1SMRgNHH5TzFkjGSH4SH1pAU40IhTfkXYEgJRO2rkdO0cnvV3p/AuJt7PS0nAdX9ylww+daN06Ofdfe3DE/z7GGA1MyACKCaPuA9OPQ9kEgBRbnGuvmkR2dVkU4OgSxWnzuUyLfpKPABmGPFIQKHfzML+f0i9PJP5j5lvZvvcprN2p3anzMATOfcebjeEI2DjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=st+zP0ger25GRaE2ie2CtQIjQffkAZoo9zQTdIuJtuE6qT4urcMwETa/oANnGccJB0YyBi4W5cUNsbJodxYdD5pfe3L6TW/uhlfP+DldVw4QWbiwmn9gQdQyqlVhZEX9JuYIG24KCCD+jKtaZ+DD/Si6NO6hUbTokVzqiAG0Lm0fclNb+bAxHzzH+qqpGZ6f8805arVXRHG/2GZlg+p2eHKZHv49bEzM89wAo2BFpbJC5PxUFSc2FKFbC/nDefcPqI2GKOWcZ0hvRq8LnDwtQHXoMP7QqaIEMGVHFtIQaTBF1LWNm8I67Hz3pCO4/qinsM5GevpHwLQHvJ7OxkgapQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YBhE5BBedzp0ZGBHlCFslUbzcaTj+tWkn8qeTXWletU=; b=MGIF/FuoKTf/BR11JXoQ7gNkqaActgrp2+nuAQ5Un1ZcgYbVgfxdF7wCALfBNv0yo//bQAQtCtbxeYWQS8/oOi0YZezODUwNDRhi1NpfYgAGE800Tga513ATYq1wRw6UPUsRE7Rdu8R2Xth76u9fircGr1SKywDzTe1P8kKjOzeIGDdVF4zzHkBSPXMH5tgdXWU4HIPwQrWCgCt9vulwhE4H+HIOvxCaGzgdam37GKoT8tTuoaSJE43QmBTdZ6PLSN6t2HBiPamHyYHFvaqlSJBw5OD8br1Uzp1z2VFBa8wWEtwWQTnLcT3H2j46s17jNgFTov64hvv/cFfcUWwuXg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:56 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:56 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Topic: [PATCH v1 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Index: AQHbQjJx30tXT3ATwUiFDB81CRnjhg== Date: Fri, 29 Nov 2024 07:43:56 +0000 Message-ID: <20241129074332.87535-11-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 37c0f1c5-f8d3-4a30-8e3a-08dd1049946b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?qgyyVcYvShSfrO9TH8jBnVYwYihC/P2?= =?utf-8?q?FyESvox2lHWvxMaXj8ss242aQWTv4m9Tcw+a/foZhmbDLNtzlKpuyWNWa6G0Y3zWj?= =?utf-8?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SvStpHqM0lDhn5ZRtf3WR7kspHVhg3v9OC8HWajAWe6eTLqGXUkB0YRskZpPWQO?= =?utf-8?q?f1A1qAaSCntwvWX7/dwOj+Vr9XjXJ7E+C6gSiKv936vDv10pZ0NkkmcxLZY6xyj9C?= =?utf-8?q?tu8zveeGgIh8Kir8nbb9NE0TIOwLnMdU928ets5aau26ahFA94QRbkcViglEy3eob?= =?utf-8?q?rbZ4H5X1NBTNKxP+keC1Wgfv2HHp/VAt5eYx7dXAKCUZlsXKmzpyKbujv6b/RxFW6?= =?utf-8?q?XDxWkX5x59BqTXIYwP3rp5KD2VhTvm4cOqxyvt2s2lHYHncR9u3xHojfwRXQfEW0o?= =?utf-8?q?MjGOSfHolYkfqNqXvpScVMJ9inDPaprSVypsQxlh0JrS93bdygx23bjKC6htu+yii?= =?utf-8?q?jguW6p08Th/l/ihazekbqLwDn8x5ERfJXA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?nLc95tJ6/AniTb5KzKGakdwVIDTm?= =?utf-8?q?ULQi79N7561BOEYuTZHAMJnGJX+wgOyYSdlbFJJCgVKaByesXFl/0YBI3y1jNhRkS?= =?utf-8?q?G4MiY71avDYgE6Q0NhUyBrpGNNij3bfgHyETbWnKMYKWwDr96p4bXcW8EIRYcWfAb?= =?utf-8?q?Hl6szPbifrB+11urtzXd47c6fa5GtTfEzWL2pkKNYhBe4NikusPoJ5yZBFaukZWUp?= =?utf-8?q?mCRjyO5jH4p8eJfvRRBhgiIqVzPqxRft3vlfONjtZr+qYGwoNG/GsEapyzCEJCbzQ?= =?utf-8?q?PhBmLq71Ka09EP4GwaxPrwHKP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mAde8xcb8skKvbBWVo631TsAgMNv5VnwR4iV+?= =?utf-8?q?hH4MsuqP6e7FhIHDLDRWD/MxrMIkvnTrDjNuy89LUgG/dbO5sr1AxDQDWIqRG9O00?= =?utf-8?q?6kS1j+qVvJV7B8t3JyyQ8fR+z4Q3WFDaEkaak+CpDsnWvH+NsZy5yKBPp5GLI6Rjy?= =?utf-8?q?Pg401rV/I57OjjRg/ZBvx9IzWjCzQJO0bEr1vGinneYzuTms4sFSrPVR1ddgTtIWn?= =?utf-8?q?Gmow0rM4wU7DYOj2NO4f2WWv1wFonn9CdMEEcvrtdXtxr0qZb9GVbE0p4ocYaoK6s?= =?utf-8?q?gFGn8WaeHHG6hnfKRsCyBGuKZ+tRjv191r9yMC7MG+ye+4hWiqmZLLh2ffxaRbOaX?= =?utf-8?q?7AOpYWe1hKHGGy2E4yna4WQfSYgPME5HAqDvzLyXrGZ9Udm226dlbyQ=3D?= Content-ID: <66038F5E1B650D4D8F6EEFAFC7DDBCC0@eurprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: eviden.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37c0f1c5-f8d3-4a30-8e3a-08dd1049946b X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:56.5081 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7d1c7785-2d8a-437d-b842-1ed5d8fbe00a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: U73fHSWNQyej6D9CPYyZoKVeMHJLk15JJIVvpNttsHYo7VKVVJ9+72mu+KErnozkbRi3l5Jt6rnr1xtXQI3sfpJKcIB2cN2KPKYejpoPHqMGCw3otE1epbE7Yx+VGe6p X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 17 ++++++++++++++++- include/hw/i386/intel_iommu.h | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a92ef9fe74..7e8676efb0 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4209,7 +4209,7 @@ static const MemoryRegionOps vtd_mem_ir_fault_ops = { }; VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, - int devfn, unsigned int pasid) + int devfn, uint32_t pasid) { /* * We can't simply use sid here since the bus number might not be @@ -4726,8 +4726,23 @@ static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &vtd_as->as; } +static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid) +{ + IntelIOMMUState *s = opaque; + VTDAddressSpace *vtd_as; + + assert(0 <= devfn && devfn < PCI_DEVFN_MAX); + + vtd_as = vtd_find_add_as(s, bus, devfn, pasid); + return &vtd_as->iommu; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, + .get_memory_region_pasid = vtd_get_memory_region_pasid, .set_iommu_device = vtd_dev_set_iommu_device, .unset_iommu_device = vtd_dev_unset_iommu_device, }; diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 1a4a53053f..21f7f8a07b 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -324,6 +324,6 @@ struct IntelIOMMUState { * create a new one if none exists */ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, - int devfn, unsigned int pasid); + int devfn, uint32_t pasid); #endif From patchwork Fri Nov 29 07:43:57 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: 13888455 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 05E15D6EBE2 for ; Fri, 29 Nov 2024 07:47:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfi-00081T-Ro; Fri, 29 Nov 2024 02:44:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfb-0007z6-F3 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:09 -0500 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 1tGvfT-0002eL-7w for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866239; x=1764402239; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=m6yDis67dF1alZmmiGn0X8kfeXfpoNZ8C44721iYd5Y=; b=OhI/vO86mw1MfJnjsbCWXmc2C+GnhPxXNDfWZ8Jo03/0bnvq/dZPJz4+ TJSd4kHQ0s9R1+CQLLECU5bOJ2VL3jvGukVka8hGsW0XOcvWTrg9+GXoy nutQIdRX3fqlQXymCuCSQDA5q1wnftO3Msmb9NnUCN1TULYUZVRkdaGEK O99r7TSoTbS7JNioMpZJuYKEXBXbliza/Q6ZvSLLoofQyanztW0cT1sNS 9SfmWLfidEQv9hbHcD9A3YGwpwewdE5pirxDufT0VzOAK75iIJJxTFV5M WsQawUf7diKj3JgnbLsaLjrjiNrKnSCRe2Kvh503aAhLLkuu/WcNK+y+H g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670801" X-MGA-submission: MDGd+gu3E8dwwfAWmaJ4UUlpW8tOeM0lwfXLuX2SmGIK/IkiY+UceDBeBF/G9ZBCG+DUTcJxppFSkov3Uxtvw0N2oVCJktNy91fErWmi3kk00cTaUe7hp3gKZtwXz1T3eBHBR9Oeps/CF9u6sQj0CE8TEoYswuP/43hh/ejSuSxWng== 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; 29 Nov 2024 08:43:58 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XCVf87RXf2d1j8fo0xUvnn3+LzesxLGDnOth0RQ54ciQwEEFGUUZJfUmK8vXRoycOWBh1C7sA2v9DyK2v2ptlm647ox9tpA/9zpsqIlFYrBAG75IZtd8vqZJ+rs+pv+knMQe/WHQ3jdsS7RN62h1iCCyV4GrdT0KWN1lZ0xMFeWM8g5U2GNFfo7decl5pZDhu5FJj8rmJlRJZEOIPG/m/tSHnZCTiyVe7x3KZWXFXAVfbQTCuIlk3IdzrzST8DQTECcOGcaKpMR/LquhTr0/Zxaa1J02Bv5lIrIvpPrs53VAZ0H3dcLWC0WWSWv/XMIi7XEyE9jXCZVqtzEiAU7qxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m6yDis67dF1alZmmiGn0X8kfeXfpoNZ8C44721iYd5Y=; b=TWkzbS9CQbArM+8huw4ARd8k08f1LxmrQ6k6rTrQ4tOw3qycMfBt9OpneL/lllNa6HJGrePZ+jhbzMtYfo/l4zLp3oC9UH+N4yeZbWKbFkdLMUtib5NokFIXIeL6lK4KXiYxVxp47DVMaWkGH70fD3YILQ8ZTFw5bDTKx9NnHehga7+kDYDYMf6OdDvsD7B4AGBATFxFZD1bf5HLXJ40V09qPSiPGLSQTCaIrCw+j7FnE39PPba/J26C2hqPr47kCF/xIEUepdL2VSblz26s8y+NWGnNxSZSEpMnpIEJ+tAyB/hpeLks4T1ccrsZKwIw6lKUWy3hdvnDkC6KhGNM5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m6yDis67dF1alZmmiGn0X8kfeXfpoNZ8C44721iYd5Y=; b=bcpU7CCnPl1La1UkErRlyuqbRV5TnUzt62eGJb+ekEePWqUYs0uLFC20vDH92W44nQQILz72Zd198VMuQuIWdHcZvpvBaT8cH3nxpvG9lnL8rkovsSWjgwr2Xkrbzyh3SVTU7KopBfjNCL3z6wA87HZBYE/EC1bvOeS/Lryj9Dvyt+FDDhEhoRmxEYZ+G3+9I9jcjiinpbqLekrGuESHjZvLGZIIhAme/3Z3sHDjLYztQ3knPArN2CJQ6L7cC5pjO6xQg9Y0OkFMcehKe/dP2NjJMaVPPcH9CXUWhTAoIOGpHeBh5hcRUSXOWtwhAiC6hAbTUAcWOMmzGE4Dgz92iw== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:57 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:57 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 11/19] memory: Store user data pointer in the IOMMU notifiers Thread-Topic: [PATCH v1 11/19] memory: Store user data pointer in the IOMMU notifiers Thread-Index: AQHbQjJyHnrIgNnsXECB7r/kjdHmtg== Date: Fri, 29 Nov 2024 07:43:57 +0000 Message-ID: <20241129074332.87535-12-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: 803f1af2-d758-4f6b-5c63-08dd104994e0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?06YmZBpNHkoGtwWGz1owDHg+hAT8XXE?= =?utf-8?q?0m4CDi05gXbg4oIdNt6FALCG45PJbWqqYPAi6dez9XEyhYrqFD6xJCEMq9bCiYGJq?= =?utf-8?q?4NCKuUzkjXTWNVjjdZzyv9yn8bI0m3jvPQ1ovQTCtVDyCnfcajmKyaobACtXxLOmo?= =?utf-8?q?D3U4DJYPod0QrydEB4WX/nMUGONeZyYufGqXC4JjSuhGR3BbglDzcDSYHTKaaDOVe?= =?utf-8?q?TfsOEDR4/CM8yHvsoIu1ygi9W5CQk4ZgqBQUWa4bQUzjYn7fJD8X+az+GrHljJQP7?= =?utf-8?q?09PPJ0lCUY76a2X3yO5WKgoxZNlv7k338JZMNwAnRizzPH+O0Cnz5TTzjO/bjqmqA?= =?utf-8?q?u7ER3jhFwKlM7bKWiMwiBvEvei+om/fFbpEDUUHrVICPZoX3hfn9AW+Os/ZDwN3Ck?= =?utf-8?q?WwdV7pic3KxtItG/Mu05+K4t4v2+atbmLMpEzFaOZn6tjaIN/ANxq4Hh/riCJxTI7?= =?utf-8?q?oXcZDto6XeZX23wXJYbOArUvC0xttivEWVl0T4G2jT/uyrav7HsHEBYYoBb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ispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?Fk1tg91efbubpVPtPbTDyrgIBtEm?= =?utf-8?q?SmqgCieewb1WC6bKj5GIU77DxSM4uLQFmVuVvs1tsy5JxJ1mqjEd5oduXSXBZr3pW?= =?utf-8?q?8WUj7LhSNu2cPeoCUqwE1TGJMrBPdxN7bGkBZdj/UiLqVPLg2elxD0YnNCokAhEKd?= =?utf-8?q?pW4Fw8Ro9Mw5y711CBkvWYJjC8bLTZ4EyaNkaKO8DSVGYx0lZwzPcJdrPa9GW26OA?= =?utf-8?q?IhTXx0L1zHO4yMVHlqAnN3IwFlDxqDrHAFvy0wF9dpIT6XKzgMaOOOyzSR85wAc1K?= =?utf-8?q?nwbs6GTm2PHWJc4+cKfqSm4+kdHl7o8jN/uA8AjextLRK2Yf3LfQ4+prMN5tGWz2h?= =?utf-8?q?l1MrFhzpBn5BbCQLM8cTFjd+J5CggNufE29a2H4g0kVY/39JXQs7X/xWjFeBIGPUK?= =?utf-8?q?XqjEGPbQKG5DxadlEHnry4XMeTEx8FwbmuxnrWxv7ttYC4dKfJfl4Ey+z7TCfmvyS?= =?utf-8?q?j2nIMyvm+33NBtyJlnNyDF355LKK2lJQMMsIIoPymM+V4Ass306Jbau7tOVnpZ2Kk?= =?utf-8?q?T6cxD7EXfLPQUtox3OhpAAwNAAH65yk8wu3H78a6phyCfjGQxb+fe+EUefV42Fb7l?= =?utf-8?q?duMzizcimq5CFkVxdmix14S6ZqkjObHppakD8ZVH1lukdT8X4V1ecT775fTW7yJiG?= =?utf-8?q?7VYvU9MIp0MHCPGHbU5iGv8Opot+x6oJ2+isouXQmVLa31ky7V21GFa1D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o=3D?= Content-ID: <200A7DC6C30DFB4CBC2D1A7ACB295E26@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: 803f1af2-d758-4f6b-5c63-08dd104994e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:57.2456 (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: 2fK+jsmiZDyMhqO3x0Ouy1LU1Xq7nw82hw3jUhAAf2BNLg1D6lmwSfU27MdEkXUn6eVN1YEU+84waTrjjDX+9mxTb0o6YU/o8pTfNxQQJ8VmmNhhNYZrnIGoltm+WnNM X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 756dd2ea7f..c0d064dbd8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -204,6 +204,7 @@ struct IOMMUNotifier { hwaddr start; hwaddr end; int iommu_idx; + void *opaque; QLIST_ENTRY(IOMMUNotifier) node; }; typedef struct IOMMUNotifier IOMMUNotifier; From patchwork Fri Nov 29 07:43:58 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: 13888449 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 5495CD6EBE2 for ; Fri, 29 Nov 2024 07:45:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfo-00085S-Vz; Fri, 29 Nov 2024 02:44:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfc-0007zG-NZ for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -0500 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 1tGvfY-0002nD-Br for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866244; x=1764402244; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=NaZCpvqgA/bH2itIriVIa+Uv+Dy5+DrbRgkIjSU9Tfk=; b=iRX/iBPoIH3zLYdr6D5dNJtcXash2W/2KhNyPsv0kF4pi+JjH0xn/8mr muUTapVN1rAMcEY7qUJaFz7Ps55KJeMokO2UHf2S7KDjyXHtYht8PoKuv NGUviQOb/ROn7iKbm638KxfTsGVZkL4x5ohQTONhS7SedcsJDtZolNuDC YK5eLtsOxLeVDn91s5M9j42V0lnEFpH44gJ3+qcuri37MT9N26ebcl/Qe Lpi2VdumMpe2J7PlJAEkfbGz8V0ZljfW+v8pzL8T8MTn5qSjQv9TJSvyr c32rq/BIsrOXzIO8gHIivSAJlLFgY58maGu5nJrDY8fzi5QGxOMo0l7Ys A==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670810" X-MGA-submission: MDHhzpIxOaufYw7nCy3yoe3Y/z2Qcku/f4IKrvrXByE50bD13DljUALXbNy01fK77V9YNjRSFz0gUUKG0UiRXWFpw49v7dEA+ULluG5lwwKGN/psNEJp1NBoRS7yDczdm49HkjTmW8VPGLOF+qqMEuRN9fKQGLhCAwOtDYtbjRcDOQ== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:00 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HFuHAD7DFS5Con8bsYsUKwNhbHjUSPZqmbW/zg3WbnZOffn0EiY7h0e3IjJA/dLD1x+bSFXhOumRC1V7X93eVU+x3XD1AYT5InBACkCdkU8Pfu8TBjyApwzOq8H+djvgTNz40mCXglpGWAg89b6Jmfh5//B+ULN+NlaxPQwGv91bJJSOYbCYe6znW6ym5NekcynG08CcD9IggNySsxZwfBXcLhasa4gIyzFdVJv41O5KdNi+nAyqYoIN4jFXqU/g1OWmA9kFldB765Lndu5rz7D+fe7iZ5KIhkPtBoFemkLYdfvgz7eqqOTjShfNf7eWXy6sz9Qup+2lx4ZMvT2q3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NaZCpvqgA/bH2itIriVIa+Uv+Dy5+DrbRgkIjSU9Tfk=; b=n/Nbnj2rW1ewPGN+jxJXR/cEjPn6KnCdhxLcN9Gl1we5JqtlIpUCoTxnUuSoU8sTe+h6EaLmlgmLYnV/nnCNquInqWrg8HmQy7m5pRBF9NIysASxXRoQZKRTLK7RNwRWa2bDeMEMQ0dNY97oeFRg0OYMruLUxbJ5u7ojkNhV7uXAIf/6ir8J3bx4Z1tWdBfqXTc6F1dyI4hE7QTc9GilkLqDI9MdJOZPPNVUMYArhL6MFQRlobOUjC7rPb/7cyYk5UK8qCGfwyf12NEVGfXTubWGb/gwfWiTKsJqXTkjepjz25M86Gkgzj/HUadTPTXSAA2bfG7WR8H/xgoNWbuBeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NaZCpvqgA/bH2itIriVIa+Uv+Dy5+DrbRgkIjSU9Tfk=; b=atDvQhT3HJsJxocG9SOWw1otbflWngM639j6JNpJMCaTQNVmlDXAMD1KNFrxGJTKsHy0xyu+/x6+/0QhgFvKQqnmAKvqyHdtfc427aHljbhOW4AjiY22LejuL07jgkGaIykVA459KS42GW8qJ7f2sWiUfxy3Jq2O09J1mFPjMrptCELW5ImtdFsj0IFa11rTlvhX8CC5xVuBejwl2ijF1jHuo40fDXtOqgzdagggYrc1F5oBJJ8fS39AYZX0lY0wv94zqoaSU7qz8zKnlx+bO6xc3CPb1r/MZIJ5FR2JfI+CIwUjDWs0EGtojn9q6Rxi3lL4ZhMURwZmuOAvTJNO3Q== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:58 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:58 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 12/19] pci: Add a pci-level initialization function for iommu notifiers Thread-Topic: [PATCH v1 12/19] pci: Add a pci-level initialization function for iommu notifiers Thread-Index: AQHbQjJycOMVY49bv0uPDEfnaCo52w== Date: Fri, 29 Nov 2024 07:43:58 +0000 Message-ID: <20241129074332.87535-13-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 13ae6722-06db-41dd-5d11-08dd1049955c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?GgfzOrUKuOvmgEuZLqps90Lv9QKLYFs?= =?utf-8?q?zLTK4Ojxp9yT5HmikmkCq3Us5w0hiJ2zYc9E1Wq0N7O+K4dmbFPkPcsterkKeJGuB?= =?utf-8?q?CjabkZ2KkGzOdwlqdaDHm9hwvBTESJ9cAUBLBX5Y3hI59qa0d4tsIwLDi29tbBfH6?= =?utf-8?q?S5EUmGRIx8wbP04jBqaa7WuK/wJwAJEvIoFXDw/krZfAYZZCan55509cP5258iiVj?= =?utf-8?q?gEa3lOANInfYzX/PzunFckBZCEZxzdTbKv6KSnVdsg4B3hwb2Q4M4eH8z0PEtL54b?= =?utf-8?q?I1poLgmcif7SchsOpQR/ub/asQhO3UTeKldOglUMGCGDiSvK40zV8k8d5Zo8UmwoD?= =?utf-8?q?j4ofl8s8y1GGdGl16SWWrS3g2fIbW2Z+aBUV1pfxi63f3Uoc6FxV5WqST8fbag0Pr?= =?utf-8?q?fL5IF/g0LRHb1xza6hGkdKt2EiT9p9uf08NfwU+Thhf58n0SW2Z99gjGSKWXK0tEl?= =?utf-8?q?IHfBLaMo9XwiclbUj4lX4mR3kR4ZClg6aNq+TI+5rX7jBzTZTHiVuO3GzTlLbdd1n?= =?utf-8?q?OUJtxDOgx7u1jLNSewM39z+JC9/20J0YAn0b44aO7cD/nssMAAHnqQ5WwmlXhXOps?= =?utf-8?q?G5XWs68dgMv19a2nVEuksYmDa59+IuTj7Q+X69d8te98mUnjnNruG0CScD7RYzqCC?= =?utf-8?q?RYjllDnyS3EndjkO3nqCNTgRBpHwnTn3C4L62Sdrhd7Yipmq6foqBE1qQ0kfWvE3n?= =?utf-8?q?dBOfBd3ZePN58A+doQXu5pMJfGgJRIxqWXZ6azr9cY7eK4WmoXSIdGk1jaMYwWm1d?= =?utf-8?q?HxFYP3r1JH2Lg/kwCI+2KNG7dVDNNGQQ6YlInBvHfD1IBytbuJmIFoh7z0rDg9LTL?= =?utf-8?q?llc43SNI/H1PA5sqgqVwm6rt6GxyYv0ySdOjTstIDNdWZB4vR6rbhV99lRcMysac4?= =?utf-8?q?C55rH2Uz9Cxm/oW+Cbdk2//hBGarZNo/qyBR1IOG6XIrxSrzFse6CU6swe6C708mA?= =?utf-8?q?v6grv8P/yzs7KmGW1Yxnmn6Dsmv+nIZGHNtbiIDCA1+mnqkuyz9cmGF4jwOWewGKp?= =?utf-8?q?kwjj+R5tYz+LZJyAlhGt9dFkARL9iTMBPTTweAGGxN4sOPGM9dTsbWtxetnERvDLL?= =?utf-8?q?1777A8t3fY28NUszou770QkaatwajINahL2stEeoN3BS7rwoK1CrAF83tHb1mLRWE?= =?utf-8?q?UYc00Vrr3dIdgkp613/NJli1TwFsJPy/tFefLybtvqppt3+oZAdbdGqa5nnFniATz?= =?utf-8?q?S6zZBSxCKCVd/O2hhQk/8riWdDjZahD4goa8DBjV9rKG2DQoqwVCH5x3ohPczlP+O?= =?utf-8?q?aNL8jWBlqR3LYGmXm70Y1ItOYf7dcB3LANm5qp8PDpaHtGIqZUXBcNGw680qBXu1s?= =?utf-8?q?UQ1dPMkZ/jjF7GK9lrCgGWC9ppkI471bfg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?cUQXMwtFBg3b50wXAKMF3bPAT0Bt?= =?utf-8?q?9qf6B+DH4mExjOFcofgIPmDdiQMioQyLxecyObxQdyIekr87uI47iOBbKEAmtPmas?= =?utf-8?q?k5mjHDfcC9EOZsABRmWGD50DqWpRxh/qBW3WxaVKzNSk/D+9mZDpsYO/vV5v6ZqBo?= =?utf-8?q?z5nTU+5sUIIJDwcxtzJMVYwtF/3iLNS3he+ORaWYqLGs6R04FwpdPKkq87rLX4zSr?= =?utf-8?q?S+HnLjZANeHIg2+N18VuH9XWnwSJmpM86NWpdrSMFsUBOKgKrMDAYFemdQFygQ5Ir?= =?utf-8?q?Y0EPADjzOxcTQnXHpty0zOkH6RVzlxZrGDY9QsboMLY3/TJkfp2REbmMD3brK/mwp?= =?utf-8?q?NR70jZiurhlU7HyHIQ3erPLymlkh/p9y8SioSFMyUtUkAEMUn+LTP+YWG1p+RBWYy?= =?utf-8?q?aCC8DeCRoNVm/ESMk+Yw53irRhokh1slITD5CBTsrU0nYzypn+cCmIzYex3R52+1f?= =?utf-8?q?tjE3n0cZqfWoqUo0fFEua9tdeHdN53FQRCg9CkPRiVDkLeOLIV79y58BGUYoOLP8Q?= =?utf-8?q?25/Yj1ka430NeS673zfSEJMYK7eSBg6qBluC4q46jV+7oHahtT1btT5m8wWtXmzu9?= =?utf-8?q?fyyG68wAUfJ8AMDachfG4xQ096WXkkjDOGxIX4g9SnMO8ksQJMFks0uFFF/Zhg61u?= =?utf-8?q?rV3tb5H+u6MogW8aiLXpbJjFYGw/3zhBqm+mkJGo3AJtE0/5+W401jFFQhcBYfBaI?= =?utf-8?q?OcKtAiagPSlYKNJyLx5xsV/ZoqbindkjIPvmqBbCGmk0UyMdlTrbkTvaAOybwMour?= =?utf-8?q?CACWzSOgSu/Nlbo9iIr/3tnjBOhwLzi2IlT+BoKm/I2WQ0zuiHZSwZ6EEtjpmbL81?= =?utf-8?q?lu9z6WLt+5OE8WYL+xfIFWqSEYI3H3Xv1Qx00SSClE9h8Z6TQSqu9xkoIvCZUSngH?= =?utf-8?q?p/n0/ZZ1PZ5ttDu1pLXqC8ow3/W6Uvq4oR4DjfHqqlBY4r5B3a9vvnX8c6or73Ku9?= =?utf-8?q?G2CUfMOCEDmLvKonml3d+SojV5DvJnzuiRxU71vBZbPdz1Nd54RCmbtbw4evTJInw?= =?utf-8?q?81Pa+k3De3107CnV2MvJ2mLJzCF2F4xvWazfHCnBLppQtCBjk9AhwFNJWtSBSvKfH?= =?utf-8?q?biXluKVrWe1ET+ZU+TwiqKLuDy6F6tEqxUke6g4zijN661pKvqqd51bdvtok/MsF5?= =?utf-8?q?NbQwU8Hm8aiEETafPZK5uu9AOAiwo88gu2UiZrGh1Dy6GWpjEMJzvZo7pu+IFjt+n?= =?utf-8?q?wDmn2OQ6OIEqXGIx6HQ6OQ3PTnqNxsoRWxP+sLduJgChP2cnW7Ki9fHv1zQvhumXi?= =?utf-8?q?o5qViXlNl4oV2WIUynhyZNu8eZheb7jHFWqwDlUmRU+qT2fnMSwivOA6wDSIYGoTG?= =?utf-8?q?WdCrc4tkBMNRoRg5qIzvYMdH8i95r3dg9t6sh0i7rukQeI9jTeVjb//pcGR5d7GLT?= =?utf-8?q?3Ry1zxiRAdWfOMyfmyclApWf5cYo4OqBzPkNerxrpSquHFsrDNOljARWRS6FWlRrf?= =?utf-8?q?fu0A2Mem/Krm5SFAuLV36vXLBkvM6zaQhpQ0ieMnSIQyVvGN/n7503q5gWoqDg0+X?= =?utf-8?q?Bdy+yUiRoT9+LmGApTRgYBpShurSnG4f6Szsz5f8LV4WAn7eEsZ/lmc=3D?= Content-ID: <750E06CB7C5B7F43A4EDD02A20EA90F3@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: 13ae6722-06db-41dd-5d11-08dd1049955c X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:58.0740 (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: c5h0Om059H5steIy5pfb7YaE7h7CetVgN2gfALDheRYylhQFdk2P4iisAQ/bC2u9p0XJzyJh5YdLmDznXkMk5WN8E2EUZcr5Stv82wY+RwtHakH5CYzMJQRDVlyumRPG X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 bd36c5227b..435fcb6c78 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2773,6 +2773,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; +} + 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 c34ec5ea81..b21448bc2a 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -443,6 +443,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 Fri Nov 29 07:43:58 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: 13888456 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 67B1FD6EBE5 for ; Fri, 29 Nov 2024 07:48:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfm-00083j-4l; Fri, 29 Nov 2024 02:44:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfe-0007zT-7x for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -0500 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 1tGvfb-0002nM-0H for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866247; x=1764402247; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=lKFYdcossLRHzL2m6cO8jzSLlEUPo1FKRfk/C2cEJBY=; b=JCigumQ7ryzPAgOhNtxGccSP0NG4R5pI9u49yyB5l9VlsXClZf1Wkk3X 34mXIkqvOyWyr1if9Ngr3mJHc/vwitmcNMo/YabpufKSgmFV2gjTHUrbx Gbntag19siczOOsHwdWIzQwIbWTQjRe3Nj2fH8aGC7E81jjB618EaMvoT ITZRr0Fx4YPMN8jVpWzMGOpPvrUQj8Dm+t5W3nTPr4VnvtkCjlRRzj/Vz FYPkoX6NvepJsm2v5Z25sjc+NDASLGHcsDASt6j4o4zBSaUbC+6hPIdCJ P/qb9XY7+v8YwvLz7AfdSFr+CYVPJYmjzi52a/n5zRKWbIYpp9f/2JxyL g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670811" X-MGA-submission: MDGo7LgHrwqw3jDPn6WpDqwxKaBmucBmi77fnmNbIxiLI5obCk6RsYBsPbqLlxt29aAeM33YFAlR6DqVFKuqzkOFJIdFsuKpOUbby8dIED2cBTghyAeM6RsgpP5ppek+N4wjcqwzf4eRdi1EZfXQpGHWOgUuJRLbQ1aok60N38cmAw== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:01 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r4OAEbsHTQBwcuctCtA0HEY4P015KpHbwQYQMtMUU3a34g7TzcDaKLXHDU2oGBU9zffuWsx5ngRNRDWCJ2CV587k+ICZv2JWV4nTTvEmKvTakOKWTZG6V1N6pQ/wHB9oEz04z4OkWYGFYY+sU9j9TrWVCQkRnCctQCkqzpi1pw0NmzEOijZ1V4G6s59z1Yj6ZscNt8ZC5pGpaKp1SwpLNhiS7P05ILaweq6R8LghC+8Zgxzr5ttd/kuXYmyWhywFAiMU3M8baxjnBAeW85Lm1jdrC9/bOsz60/i+AKJp5hdyePnAutyd4eBVytKvWEdIQ49FbdGNY9YzhxJbhdxpKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lKFYdcossLRHzL2m6cO8jzSLlEUPo1FKRfk/C2cEJBY=; b=Wr+mKCsyhxUld+HBC6PCs84M9M9XxI68qWrM6oNzjxZ4BXaisSUL1efn612vxpPFyLat6wZSqYFfeodODXA54EftWNwZkmbzZFiE8rVXWvowuOMiylXTUrTHwVJAR60NeNSaK0GvdxTPgkhTd6tCnB5WphT7M5INP6lXgYA6HaqRMIujJNJRuHx9D/JkH4dGTTAOcQugVyE/xMBDGZfz/EDMvub2TDVbuyVpBVrLISZQywCTJhVGiOj+usg4qU9z0kAKnOnZ06iK6cLrY1ECVcxSKarIW6iJe47UsNjyU5ZNeivMK5pT9mNYGKpEEyu+8tE92iCT11D1ZIcvviN6SQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lKFYdcossLRHzL2m6cO8jzSLlEUPo1FKRfk/C2cEJBY=; b=IXZMD6gZ+vjtaS5HVrXC6rP9eesmWBjyCq241zSs85GPkh/4NHnVSx/3EuvzJgcMUkH45o1v48IUl+cAj2VLLI5nMQaGbPOlA9/wNaM5YRKaQzQz0n9lZybgbjUjufxAIohJSayvW/Q+CVt4cGl4nOZ1kbBOCudyHlKaOwr0oRDnn9EhlFR0lRWs6ttIG6fkb4b+/ojQyzcBWrHOvfsdAK4YbcgmH4a0y8N98G2zaF7BWFGOIbASjjPFSJLpZDltaWwOJOEwcSVzogy7OdalqROrGGp+tagREFvzWYmmi3qAAXb8RUqA+uqYtFsDS9zQxZdXEi78HdWZw/kvSk4SIg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:59 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:59 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 13/19] atc: Generic ATC that can be used by PCIe devices that support SVM Thread-Topic: [PATCH v1 13/19] atc: Generic ATC that can be used by PCIe devices that support SVM Thread-Index: AQHbQjJzOocc57+pXUCiOlRFpHu04w== Date: Fri, 29 Nov 2024 07:43:58 +0000 Message-ID: <20241129074332.87535-14-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 7a8d3666-3ab7-4b63-ddeb-08dd104995e1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?Za/ZHFMPH/rv1YsUatPXd4YP6UkRGHb?= =?utf-8?q?fYFYIRsX/dN6Jw3q+eumhTarMP6D4HdPGO8CgKk13bEeshvaqEGF1C+gTirSMJ/ow?= =?utf-8?q?9ufnl/siixQtRmezAeqsfW0c52NmRo4j7i3p+nBPx5a+xKhT5b1BQoAp1JrUcx0KN?= =?utf-8?q?9jJGQxNupbcLmQ8FNbRqQon5f6fqtJmBJB9wklS6UaCpeVs+7uQiEnxlqg9QKroLI?= =?utf-8?q?xfdcUvi58i6ZQZO78a51DjIMA6YGT4hi22QdWTGUdEV0HNfQX1BeBCixXI/r3cn2h?= =?utf-8?q?IRKGA403MJBFript9iYVrryrIpiSx03GAz5iqXyxs0koDCD5+vRcRRmH0uci1oNSQ?= =?utf-8?q?QSuX5jf/3khQnBwPigE/NAkD/Mx1M08Vo5GCmvtfMO3e+j2l2eG1eS+Eej3qhwV5I?= =?utf-8?q?9IjdzNccYkybQciP9N0dhVvg//rW/RWTSrLliQrCK4PKrE3BLdfI9ptkm4Eu3mbIQ?= =?utf-8?q?zKcJ3hqNNTgKGlceh2F/IqEnlbd4TEtaXSCSA5OFY5ba/dCML6QNKSrKkXooirSAG?= =?utf-8?q?DxYeyPwG0PzJ9dJMYxjnme2TnEHsydQvcGVVKebrV2CPiXs/JAIHgfEg3R0/oa3mi?= =?utf-8?q?cStSpYkxV6AwYAY39gvIfiE7+BjmNcJjG7eCU8biTxRWJNvEPb4gXJ+p7rMoA2sP0?= =?utf-8?q?go41eYzxd1O4MWUbE9VXxqhALNdKVwaht3fPyDBxmgJbLDGDc5M0cx+lB1nmvQsTf?= =?utf-8?q?2FBwA2VEsM8+5yp6BR9hQBMUNWKTVaynWrHZsJGSzZPbt4syotiyZLG6hCLT1GKoU?= =?utf-8?q?m2bp+ZOWYr8o9U2Q+4IuyjsG9DnbyMRrjCaAPE/KntXYcVjJevsaGTIDmjP4yw2O0?= =?utf-8?q?A9MJgkYZ1y+q6VFJN58GsQdZ7iTZf+hWECSn4+UYIDT6st9Z0PgZg6I2dSFQHn79L?= =?utf-8?q?yeG4pAyQEEVAjv0fQeaYYufi+LlzdHo/0x1F/eox7n0MNGyF1yxHqr6lwpbMHovzz?= =?utf-8?q?c8/n1JG9BdWSts0X7s7fmHR9Wh0LEcaEGxU621qRwvm70UgE/H5+5i4fJMRY6VIgN?= =?utf-8?q?gcVAAGovRnDoaPvQPwAxWVmABLSoCHOLjtrGf8ejUTUopv2/hQevVzEsi38GLbusT?= =?utf-8?q?FCop0ULbShnEXc52uoRET6SyC9e8OHxOmWggdjuLafB/SFSAuidouksBjqKeLp2Oa?= =?utf-8?q?ZGxxC/wRzlF0+6yoFaYLy/eJoU66HZpoEKF5E9w3rt4ujn2/lcWpCDwCaayvbwLeP?= =?utf-8?q?ni82SRBNZkuDiFO2ZSO0UNe7FWrTSt3K0NycC3cHgyjdL1fjFxX4ryeKsKiMYeAX+?= =?utf-8?q?MMftU7EhaZgJzh+XsbdK0eNd75gwRSg8QwImLqBrckZ0PvEwdbboLsMZm5BXMZWmH?= =?utf-8?q?jdfm6iLywa/xK+kvEHKD2gC/ZJn5TL4NJA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?c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5v7ZIjmkQ?= =?utf-8?q?HjNNbZW20e3U6sG18dW16WkUAAXo16sWi+iQ4QlZ85JNWlbEx2p7WvNZRNJijG2Pr?= =?utf-8?q?WwpWho85+DqaH2YiBbyr7Tch7MCPhk2kbBdTStx03AUykCZrfcTrLy6G/Nde6p0kd?= =?utf-8?q?8B1HdW91Xn+zEZaJSY1arO+OJGGLsvLqrgygK/rmlOLygX6xRraw6C0aMtAOBpohK?= =?utf-8?q?TyMxFfwPpbdEwRWUlbOVxtiRF54AHXWll/FS/i2roTbNoIkaV2cZ0XFDVByMANccc?= =?utf-8?q?MPaglRXtXS12C59BfAlFGZYqzOZzmXeNbPYkIF1kZfOCLS0r86NKjiDyd0KRtmhGE?= =?utf-8?q?Bxxirs9QqcpsQf5l2MrRg/+ZPHqpDKUaw+TsrWGqso1FEDhptAqn3ylfmbHhkToRm?= =?utf-8?q?igBUXowc6Bj3/x69h3diXl/NNP3lMAUtMT/7pPSw3WpUMSJlX5wwolcoCFq1y+9gY?= =?utf-8?q?99Bru6VPZXmpoYbYETTRSint/sbU2ZKVkVcnmTZKCAWaKJOAM3B6iS5vs9ov4e+Ne?= =?utf-8?q?M0LlFR2OxIcOuu/X2x1EJNLFOn6WnDtwVujrrnwPr3Vhqvg/F8eVOtX5tAeJq4ntv?= =?utf-8?q?5SY2/UVBSL9Mj5u/dVUQ8zmGWp4+71T94shBz4eVWcEAxwzVJDz0Tjydf3XrBe2HC?= =?utf-8?q?jF7XoJSddoI53SfS+0gyeAz/p8BXlZgnYpMSRK/XYZSTkCgEag1R1rk=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: 7a8d3666-3ab7-4b63-ddeb-08dd104995e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:58.9325 (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: DPPJyJUi2EnELMUvViUz5yJV+o0PSt93rPi/qUoIwbACMEELdNj3Ba7UgPibb/ZTzb5hZ4TkLF6VtCruIL7egWWgQxpTCq5i1FzH/K+EOTkbjkvviYDjl7a43UdDr09y X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 5d8bef9891..f2dec01300 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')) util_ss.add(files('nvdimm-utils.c')) util_ss.add(files('block-helpers.c')) From patchwork Fri Nov 29 07:43:59 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: 13888459 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 1F144D6EBE2 for ; Fri, 29 Nov 2024 07:48:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfj-00081b-14; Fri, 29 Nov 2024 02:44:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfe-0007zV-LY for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -0500 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 1tGvfb-0002eL-FL for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866247; x=1764402247; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=TOg2qey615bPbMGOVOFb9kk/xetbfF2n4Ge4E8toy68=; b=YQvDYPh7jeHxfLjCu2DxAdaseTbmvUcbL3RRvRurqnfyKsdiUHCFNga+ E+GpogPkd5NF2l4zlAThMmyVysPpg3TivwCufk5Mi3kGTP6hN8wwgWJQl sucajeaHSG5g+dV7t7aHOxFvwA/Sil06Bq3p+C7MxEe4F7073OdM1EYXQ 6HKTJrUEPsamPZ6Dp/vTTOvxMcoMYPFvEDRAxfxhmIdA791ll076TbuXy s4nQyIv/Xsl3JGOxDMkPZzuZJJ3N7x9/BjX0FL6LexwmtLh9szOtvJ0MR /f95oQf3AoHXi7LLx191LO/xAuyonmZ4DjI1E2pBBW5XnhhHgBMqHlBkT Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670812" X-MGA-submission: MDExnROP9tTJ5rFq9kr1F9FRbDUDQMrfIC4AyCPRs22iF6mo3P1LPYFAx8SjW99yhTlTi8FXyRROxh6Kg+Q1OJzit+F89jAmnFF3xpw7mrVqaiE0KU8ofWii/jh9YcQQ6CEEqpUIyXsW2mWDIJETrznGIcz675xd047Ij20GSwalwg== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:02 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YHz2Y1SwVgrJCpG9FF5n/3llGItcB7n0rcxSDiynq/4A36AxVqfnRe6I5pU6CNw9CJTBAuPP0FtDwT5oF/MRuahcKrtWQfssK2MUSmqA63io9wlw/SxvKzn6VRRw3L6GdSeWUkcq4UmnGeCkp+IMhdTA7ZenOPkTMF+E+ly8Q2FFq4UZvcoSwm+zq0g6DyCpKDPnkkLS65Wvm27SysRjtqCZ2bADx2I9JSz+Gtou1PJs6oAAhUtNU4IC98Oh8I8hFuWIL0wYz/mHanz6c0xFcNW+jI1+MmRWM5ZLHh5irZgFnRtKhdlHWQW0iSE5DAWnn0a6YLOtvBlagat6f2/cRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TOg2qey615bPbMGOVOFb9kk/xetbfF2n4Ge4E8toy68=; b=WdJeMWTAWRR9+ZT7fGBtFuwfoTX8vzXryK83AXyEVnlLNfEyArCywt7Qp4bINGQwVx4XUH9IKqFojrvgPc90ffHtCy+E32KyCvXj1WSAmeK5Mz6XINGXGRqnzkPt7MvPfwLKP7KZHop13FxuLvV8yicb43fzZaxgTY+HyygZX2oNKe9gIFot/ZaKmWYveC5nMwUFvisIJAfXCBdtETETd/zkuzNxdBjlyJLEJyzpUkv7xgihlQxR2gjVaTsIEYi1cd0a7TgQIRgKQsgtxxL0ga6L4rJyK4KJmLvOB5iLR8SWQiS9RT2ORwnVsM9x81Issj9o1g/1JHlwX345kzzEOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TOg2qey615bPbMGOVOFb9kk/xetbfF2n4Ge4E8toy68=; b=DjHWpGbJoWiZICqz0YwLFAcyt+K6SADibwvx4L/7eDMEhTw/vqUPNoUGVjlSCMZt8GcgPDp7mdexAWOdTHWdrUtUCi3M10MMGkyZJnQQfqypySvyZoe57C8g8KonEwo64bZZXHi4LJhShX4s6AUlG3TnHv6jAflF9aA7MXtwLY+8eMX9EM0Xjq0pdXC2V4l2TXIqird2bg/D/VQlJi33uyOqZGU5l1p5DyNZ37sj7t61wCquUewc5VOuy13Il0EZpains9HEi3Vl15B1CqC9KXcHqX0i6WKFflVdSlaZsIKCtHIUOSU2i7sSy8jGsUFkLDOMNvsjlIV89yfjPXxZjg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:59 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:59 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 14/19] atc: Add unit tests Thread-Topic: [PATCH v1 14/19] atc: Add unit tests Thread-Index: AQHbQjJzD3BJ3Z07D0etiK0rxw+UBg== Date: Fri, 29 Nov 2024 07:43:59 +0000 Message-ID: <20241129074332.87535-15-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: dab2f38a-f42c-4880-59a1-08dd10499654 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?eZ/5hWupdytedGWkqDGefERfAnRubXM?= =?utf-8?q?IDuNuE/TmokPIQRNAe/ZOUt5cSSw6OGUCjhDXTmoLbNE7wQqy4GCELZvycRtbEY7f?= =?utf-8?q?IEum3y/qm6TNX5fpSw41I3Bdi756KkKkIFUo3KzDJ6JdHfdXIlN4edz33onOAYd+B?= =?utf-8?q?IrGdquh44aTu1rpQKvStdiQ9YKfU3k81lbJpT/CNz+FhqOiORHL6FzfwHA/93F6N8?= =?utf-8?q?gyseOOun+2BnNtQGoYih58M1vJH+xh9XxEKdYK3JHHmG8Jfc0NNFAOmHrX6ZTsSp/?= =?utf-8?q?iBtHW0GhecylUYwvQDdN7bMA9z/2kAU1tSRLH5a5oqYjdtJqQJ7OPDaq0JoE+Hoan?= =?utf-8?q?KL/te88f+78836lU+CAVkZs/CgJ9OdAZcPzq2XcaVM4AqzScQ24n9B7GfQKshkd9l?= =?utf-8?q?FgocJX/4/cDy0GeG5IZINHLIHbuVsUjS50NeCxEotKf2T1VgxczImwGvGx7T+FDOm?= =?utf-8?q?cGMMCi8cTJ+lyumrwaikyBalNlBR30UEGkQsqJDKV6BXd8I+GTz1+YK5GKarAwtTK?= =?utf-8?q?M14Rr88/n+y9z9ykNO7BrVOh2D7anZBMqnooa7HP3HzO1YbuUrQzHB3UvqaoubBMt?= =?utf-8?q?1LqGFDGg27dW/PtXzpGfiCeAjNyvu3lJsQ1lueag/i7Vbv6EBpcy2ls9++Ld7NWTb?= =?utf-8?q?FkD8vbuP4MalW3XXc4912ja46kHJYwo4lP2uBfHj4811x9Yy3tsO/ymJdSlKwerqd?= =?utf-8?q?35sayK5I3MtdEYukoVnk/QbJncNRgc3bi6T23EKx/QNNC+ystuYMUjdR/UN6WpxGT?= =?utf-8?q?Tz2lQyvBv1sYmKVPzTeqv2Schij27xNnSXwZiIUs2VskqhbQ8Ju6v3r0jajQbCs3d?= =?utf-8?q?RmGOqDwyJCzlyufBF2p1y78/rs8MqljQ/DiZLHkZV2+t2Mvup5c0uw7sqiRtgZPEf?= =?utf-8?q?DhxZnIdMSXG5bLEXiERibvCPGf7beXudwIr14A44h36k9rHrDBZkT+1wqP0CYiRB1?= =?utf-8?q?Y6E31gjivRhBXl2GnkX621aVaJwMokqSau0EtUV5n5GFO0opNGCYlDaYi8g/gpnWm?= =?utf-8?q?4htIIhNCVBkWcNu1L/IuJzspEpJMXHZ1C6xNImooWiFEmYrS3sQ0/Q2pN6j6xRO7E?= =?utf-8?q?99D7n/JYUYkl1viUa4vCV7e0zLphtHru8e+h2968XioYD3Cdy6Ty0o8biltxxsOd4?= =?utf-8?q?j8pe8wRHd0q2m8N7hmiBNiW6CB1CG6v2ay4ruK6kVWa9P1D91mxcJ/A2kbMSx0rqC?= =?utf-8?q?ZgYuFPPkRWge8nPEHP8xLsVDLLWIfkoCibNO0lgUwpg6iquNn37ucDih22Wu9yvxW?= =?utf-8?q?Vkm6A8ZLMHn59pgG9ZE1tPGzksZC1m2EHYVuvno5Q2cB5ktAAMp3R9RB5+1Jy+Ojy?= =?utf-8?q?RcFHQ3Pm4H1oXU5eG/GHeGIAwBfJJvTl3g=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?a4lMgId9VRQmiEVAm/3Ppch1C12O?= =?utf-8?q?O1f6m705VSmvYWSOIQ+OJGT6l2ci0TInAPT4C7GIoFn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WquqnIlVL2AiQFxAtjB2zzZ?= =?utf-8?q?tynupFVCa7zJ+VkekZ2gIq0YqYvFJiyez7rolaX4sG0js8jbs0Q3D2tgfqPT+LCGf?= =?utf-8?q?qcGjdn4z+cqFAmT8bDFPhp9qhB/TQW/P8mPuIYYYV899GwLaT69ZljDtJ01suzqkk?= =?utf-8?q?/lUGQa2s0iCxQ/GfJLqtsIwSsxdACS8ertLr/coE/lE1s+ODwAV01g+WN2TtBAaqJ?= =?utf-8?q?eJRht5hcXwsVeuHSuLJh6yJsrvucahT8lVj0e12zRGUEoXIhb7osKfhTJPIS+kQZ5?= =?utf-8?q?LLLuQCCFjow8HbsJQVVbmDCSgwxPtTlk+BPuKiMVQQ5V74rKRsVQzvZ+mThHhex4B?= =?utf-8?q?xECzDWlOlb6tdOjf7Ptq3baTsV5v0rHbtua1Dot97Iwu+ojWCFJpedqea6y5mULyG?= =?utf-8?q?LvGIsg87y53txbKA9Ji/LCRy4Jmnu5JZJRQY9K7EewPYC34uy6g5JAhJ8vF4NVvd+?= =?utf-8?q?kiP11nXQxxHF+FBquqU/re086sLrGDGzkd9a3MhVzrQf67Vk5EH1+FrB1qEetbKbT?= =?utf-8?q?C+PjgzKyj3H9WaaiAb54cp8L6hoyFoP5C1VXaEQzTK8dVcayWovMHL2NhRxLD3npj?= =?utf-8?q?DBnPvFaeu0tPy9bXESyZoz9ZQFdYzlQbMHjT3tZwT1BXXDZysMmV2bA=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: dab2f38a-f42c-4880-59a1-08dd10499654 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:59.6909 (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: wEM83rl7+hmsDyvMaYmqKdNZPf7CFNLJpd/BY5PM9HxQOaLWUrGOoE1/L+uybhFXmRxACSC7L0phJ7hEszYBJD3v4uXFgZ5/eEaxR4aR+GBOneAiZwPmdjj4KxyviQRW X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif --- 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 d5248ae51d..810197d5e1 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -48,6 +48,7 @@ tests = { 'test-qapi-util': [], 'test-interval-tree': [], 'test-fifo': [], + '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..0d1c1b7ca7 --- /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) { + g_assert(atc->levels == levels); + g_assert(atc->level_offset == level_offset); + + 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 Fri Nov 29 07:44:00 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: 13888447 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 21963D6EBE5 for ; Fri, 29 Nov 2024 07:45:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfh-00080y-Tk; Fri, 29 Nov 2024 02:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfe-0007zW-Mh for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:11 -0500 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 1tGvfd-0002nD-0n for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866249; x=1764402249; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=E6spcd+vgURo5mrvsgn1W+za75oPRJn3obf1Yvr5WBA=; b=thavWXlzJuTQ/WMynyMUpuC3sh/sqStWRjDcfdUotjPdkCZ3xzk8Hpko PkWOsHdiW7roW54c43jeNjzn26ySUDwH9PhSo5eUEg/EXW/ca0NY6thz7 yk3f5DjLex47SgGc8ciSlwn2hWOD4jqb4wWL3etdKqV5R5nSJ0GLpE29A i5J5XhNrl8zc+hXVtnhMIKuZiLVV3PFD7mdZ36L7keiq3xkIsBoJ/C6cb SsmYUd6eIZNOEsmcGARcwUuamQ+OVtoW3asax6Lmni+S12WaiJ6Vne6O+ 1R/X6J9E+AUgIy8kr656SRb/ZgpLRzIo4aMr6R6iLWl6Iq2+fSPJ4Jor5 g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670815" X-MGA-submission: MDGfQXAr6yW+NrNSpnBFW0COyFjWbOwHAxxUiII5auO3aaaXIIx9v8gZpde3M3rHc8g5EtbHswtM3kDZJ8/v8qxjW4CDW+hV3lCa7hnmy3AV/a11jirMDLQjaHRYDUnAc7eKxxxdCi2n5gkhmpyMz9pGYZbdYYbK68EpUV30yu163Q== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:03 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Meji/nqoMiq6j8/s1TA2dtibPXoi8gY2Su6WbFX/uzoWd8TSEwAVKGMk2WhArMJkk1UckO1MUqTgSikR/TlLPbahOdvNCGCeLNdFbI9F7FuN94rCJx6LN8HAlenrzE7XOK0hjHPFZwdVoGGbsAP9FzKOzIFGFzRcJCpx6VcUAzj8FsMsFHYQQ2PsInZOraV43bu4hgCol7Kn8PHa2DLir1VDl0aoIml2geHP4DFA0SSH+7hfo10Tjf8KpO6eTGD4hX2GOWvHYAKLa2uZBFoLkfdjvNnoA1UX8RzE4GSCQeSQHA5Gu6dhCJ+7dDu86sCSJLyy3GytknMWbnlKhTbbXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E6spcd+vgURo5mrvsgn1W+za75oPRJn3obf1Yvr5WBA=; b=sdWHKJutLyUlJse/Iao6fBGRZpzV0bMuTTWHVa1nNYy3hM08GaN16kdqaQhRcaD1TV9FkaNEWs+ayIdudBsgthH7v8NdD5Z/39HZicato64n8UvA+g0rjNmYEYl4fQq7oN2VZ6TukGWmFAUvhp4Z0AQlH9GcrhoeJyMkYasR7cJGB5miPxFY8afHcqGff7mXcgxCkRhK5B5yv0ZJTPEx3ZusDFDiGLA3hVJ/pCTvnswrQsVNuoqu+P0JPs8wMNIUdwTl6uGHp6kNj5n/xcYurY+08qEdPtJCN19W6hG3JPgdnePfjRxqaGDc50keZ0QiN6nTxXm9JW8MSVhHfoxp8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E6spcd+vgURo5mrvsgn1W+za75oPRJn3obf1Yvr5WBA=; b=XPYqO/n1M0PD7T12y6NomIw4gtNCZXpFqkD8x1UTZ3MGJmOG356hdBQU8PZDORELB8cZr0K4XEJt+dDk0il7UgOjDFbpHSvH3X+Ht6TotRzXA0J2Dox+GQuT+iizKFUGeAP8/pL8d/Q87xPnwKcuNFvdl8SecOaiZr3uLohm9dA+OwpojW7yseVM/P1/ZpmPqY5thBUiRk9svHCU09q1DtsjLKHxUchzXss1oPfmQXC1rxOI3D/63mnE5KsWigI9NsgWI2SzTmLV0NW5K6t0jkEIDDclVEsbKvbEDeWnIpjRHperfs/DborvRsnrYo0B9f5JNRNjBO7DfQ4aHWn6dA== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:00 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:00 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 15/19] memory: Add an API for ATS support Thread-Topic: [PATCH v1 15/19] memory: Add an API for ATS support Thread-Index: AQHbQjJ0k0DlGQgy0Eihqb6cUgrbzw== Date: Fri, 29 Nov 2024 07:44:00 +0000 Message-ID: <20241129074332.87535-16-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: f20bae39-f0af-4179-1a2a-08dd104996d5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?jRIYgYWqR1qjkvtww2QsznqAq7T57J0?= =?utf-8?q?X8BM3Qr6Xt6WZ7UVGa3Xo0Jh78NuGcMne973d8a3DqucwlNnx151fTE4SD3dtmnjY?= =?utf-8?q?HLy58GnOWbn1LHez6dElNP0QpADMdWk5gc0SR75z/AfWb6it9WNVrxC8qWngVs0zy?= =?utf-8?q?VCIlcht+vBdD+Zgm6N5el2K9SmByK+zkX0IMMRUmjQTPh7PoNKrsFsjw7mOFDLw6S?= =?utf-8?q?Emo14xwrfvePCa3CJppxi/yIasWTlzkea5Ssgbft0GIaRaAhyNYiDb3ze+1syjriM?= =?utf-8?q?30p2+nAk5XiTdrHLIrs8qZwEcyzB2Mok59fCZZW7JJcbH+ixnr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FZFCQvMAFjzg?= =?utf-8?q?aFNmpUSYqiUniywPTkR0X33vZLLuL0VA3fvEECKMw3oFMj/j6QXEzRUpMkGF6FO3Y?= =?utf-8?q?iapm1/EPxKqlmU1L+/N1Kg8Gry7BGggio3aDPhRlZFU1urB1OUVBTSNixTz4hfT0m?= =?utf-8?q?shfa4MxlESqyqfoBCe6B3vNXPAndwBAbjw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?MSj//mtfuyGBcT8pnVUguLGJzGzR?= =?utf-8?q?GYHP460Iq1t+p4ARJps0aQ5lombRfbNk5L96mIK9qVkFwQcBvLSYtTyZunBSygceZ?= =?utf-8?q?6tqDj4M4Gn9PZX6UlMYLSup5ggbvzdkxg0EdUcUcIb3GONzCIlKzVCiE4Xda+W+sz?= =?utf-8?q?gEtP7Vk3Prudeobw8kyTP6OblnyvM/eeciGCzNGsJjn8mOdZIkFvcJRwUxt/dtg18?= =?utf-8?q?bwpiFTS71gtFvdPYe3j2lMGWYVUfmyBHMB566TLOwm+X9VoNrDPsi8ci+H3bRtSUG?= =?utf-8?q?mUopu9CSR9N2sU+3YJYJdnQAPvYhpb8154wexDNhdy6T9sF2dZIJc9rRhn4Pvtyt/?= =?utf-8?q?wtMzEtcaF9MKiAXp7TFFhsaZuuTgxaENaexX0y9cUC5QQyAzt644KWRqb5rKCcY9K?= =?utf-8?q?GUW526iR0ERB4xs1KhwgEWXJaJhECUouGbW/57G0T8PeEdwJxcOIv8su+d1JFyCQX?= =?utf-8?q?tK5/nRtFKhu95uHHYYCh2YukC80LVEG+EHLlA5uOlit5e6LQUEoZDbgaKo4ciWzEz?= =?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utf-8?q?pIEqaSeeF8rxeAn5CYmIV8DasEGtJlvTwj1In5lqLlRR2EUNNn4V4s3urQMHBej2R?= =?utf-8?q?0pN3K+21mOLpKw/9EMkz6Tlo5iBIUBIRCnO/8m/VHLj6r4YAvr21mDpi1II5xMhms?= =?utf-8?q?vlfyMcne1MfN++TvmPmxH3JjxecKH4zrr3y1riLUEWqweeIQ8a+yyIA=3D?= Content-ID: <778FE744520ED44CA741A72C8B1A86E6@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: f20bae39-f0af-4179-1a2a-08dd104996d5 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:00.5066 (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: qkVIpoKT0EY4qhPbT2F/6hlTN4jEToZYdbL8BiJL8/MlzXa/2rf0JksC9Z63bSOPi6psiHOIJ6NxJJaVQW9iVjmhGBDQ8w9lLSaI7rOEDly75GreMRo8wDisqxhW7PlO X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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. We decided not to use the existing translation operation for 2 reasons. First, ATS is designed to translate ranges and not isolated addresses. Second, we need ATS-specific parameters. 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 c0d064dbd8..14166e2874 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). @@ -525,6 +529,20 @@ struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + + /** + * @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; @@ -1883,6 +1901,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 85f6834cb3..7f6f3798e6 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2011,6 +2011,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, const IOMMUTLBEvent *event) { From patchwork Fri Nov 29 07:44:01 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: 13888450 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 2BE63D6EBE2 for ; Fri, 29 Nov 2024 07:46:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfj-00081m-Gb; Fri, 29 Nov 2024 02:44:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfg-00080X-Ac for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:13 -0500 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 1tGvfe-0002nM-Jw for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866250; x=1764402250; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=xJbU31GgV03COYoYanORSYPh8xOVZXFvCKse670MbwA1T3auf6ea3uR/ b/DcsDYFQ997B/qMzU0Kee3OpN/s6xzhXTXVxZSlC+w3QlIT+PYIo28zG 22itXrJdMjDOqp9BN7gP0oSOj6z3bBlwu0kCxn2HqoMtBhQwGOKxyO+pq 19Lbzfwt/CjcaomAEV1cvmNXp6Y6olNIFnOxg6QHGATXm++/75Ukdn31Z npaT1LbAkVQwFNHkGaJFGI4gSCyZ3i4CbRm2fLJQM0JgaoS++hFHFL59P fm/9oD5dNVctGB9lQrsKDbKGrDhx92vncOIzgz87t+xDBF5qGHC9CCzn5 g==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670816" X-MGA-submission: MDGDX/2qiBNAz8q3yiCuhFN6bRlJlS7XeZ2irm1R0QKfiyvycmwWdxaQuwSQFjuYxPzVabHSgQ5fOpSnvBVytxTB7RXEfxWFqkmZ8LmIMP1TX5GO1G1O6fYyoSDvl5M1RZoQ+YhKIl9Gag1eH8rQTneja1oPiUwKsnD1RjerehBTew== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:04 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MWOhvSugvkNgGBn9utqFZ4H+bsHoyiBW85jFA/sShUMFIFBFpDn1+R+bmITsFWPKZDpkoXufclPmDjRrcF9chW91g70mRi4oQvHAywTx37JWoKvxwzzGx+wcCN4M6CEN7hZl63KkgQkaH4wTbdOeGZvbdCSKTCgHw/w2X8jfW3YVemDn8PmLtvBZ6twoRakg29fTI6ucLV3purD7WTVvem3txHkudyfdHTr4E9KJUIvXpL8tWrr9WoX3XdYbncfb/ym5l5YBgmdcLU9nyvNK1M/6+z/wTYWZDyMvDlBhJlaoj8Wqfi9M1udIxKlAGQJJ3QP/dxTFT4qf0aPJXHWyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=LKwSBt/9/ZqB1oIpxHc+7OG21eUC+FOBmyJ3+kqL85k7CEZNfSMUiXgank3940vwfWeL4aPGR1IOE1As1hbLgHupLSg2l48WukNcwN51PFgOmIX4hGRfgEWvw+ULm65ZnJWe9ol7qwt9H48izg41Qi0Ph4O1pFDatU2/ICyvVWWmQQ3i6W5YXGNui9Ecz3uRZb9hDtVnV1+3RsQtgxxCv4h0qDx+hF422DsYXwwNze9GQ80e/NTOhe9u3kGt/kSoRxw99KaroSY57Eptc5liNbY3OXj0IWB5/fP2hzeU+oNnXPgvN+9ZLB/stt5uvZ0X/v/IEYfRWkJ2ebCrkXYPLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vYT7O3CmbHBot/TrWbgm+CGz6yYH2nqqj0xRWpdTDT0=; b=ZN95RiaF9h8jwHjlHQdQvBDWV6lByFg0fS9LCg4XU/NT+zyvPxNeEQs49h0u+LxL5U2Wg3dzBvQ8VoKcSyXDpl8Hxw6dtx3hLG5s6uk0Wmua/kRRwwq+MJm406XSLSshbKxB3zlDfeSTvoMlb1+drpv15qvyaUltW+CISFt/iRNJp3sb6jekglsQNXC00jD3crzBSnmM2UiplU9LF7lfVbfJPHQluy+tE5MalPZeal9J65z4/4dHpwrFiIflNH0xnMoAxlV2E6o+1Q3YtNzAoeghBeVmJsduGHxUUA/e+JOeA3dsDrlIN5VnkXc+S33y5rSh1mBn3JRvYPcc2zz59Q== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:01 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:01 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 16/19] pci: Add a pci-level API for ATS Thread-Topic: [PATCH v1 16/19] pci: Add a pci-level API for ATS Thread-Index: AQHbQjJ0APXgNcpLuE6g4EiGuYqvbg== Date: Fri, 29 Nov 2024 07:44:01 +0000 Message-ID: <20241129074332.87535-17-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 341eb73c-8094-41a2-0617-08dd10499751 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|4022899009|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?jKaeoSpIP5yjL9csX2a7HD42J8VjTWq?= =?utf-8?q?0zxMgUH7QJSg7R25agtpLn4GOC/3bjC+dyxvimfFtNAq49ecbEPprhXTfth0iEuqN?= =?utf-8?q?rCyyXOFdHzLrLnmnPiSZ3t8jfHR5j+Ja+qE82lv0H/fZD2iCQeJ0BYXwsrC/kFAPH?= =?utf-8?q?IZa5RD4b/PAXJKnET+WlJazHZvqQuykdTuxGIrwakK3hA9VhYmowyP2yoDQsxVPuB?= =?utf-8?q?546ixiOsa/H6m45ypzWpZ2bpSxUMPmCwwrwFhET2G+PdFsHcLGTTzyNub84V/bGN0?= =?utf-8?q?0ygQ7p8N+QvClDX1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iqCqsyEC4LS8aFx+EqJrvkMiSLviKQgeWYkLq5D?= =?utf-8?q?W+4M/xDbzGnt7AEEX6MpN7udFSpe4v1k+/g+gAT5jftKno6HJSsiCzdvDe0qx82G8?= =?utf-8?q?PYTVyvBT9R8hY1SDAM2EMifp925JCHdpQVR9QTAQoru8ZSWnVSVvbpviBInCsUEBr?= =?utf-8?q?jKtiU7Wvai9rmNx3YDurc/2nCabaqLgoow=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(4022899009)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?HF0Gllb2WPVfwC18DFIW+qfN3ws+?= =?utf-8?q?vvmEcEuW3tto/whQXPe2zsjyGzbE98vHE+2VKel/vep0Og/BRIrATOOqB+WQBtsB7?= =?utf-8?q?r4+wfhBy6rXoquln/O0BPslrr2XW846kulZsSDP8xMW1aVeGkjq/uKiZtovGdwZhQ?= =?utf-8?q?s9jqoxatECcfyZwpbKxx+6b3OYNmXb0Yq/iQ0ecsGgTYLfw2dPzpRoN+h3sHpmpM0?= =?utf-8?q?gUaqn2FXBgq0gKxSxNQu2uR6XG/ZvDHN+Qunl0b0Ac03zJAy58BxximCPIm491scf?= =?utf-8?q?zhZ7dz3O7/etgNA4vcKLExwIx5c21BlbMmevybRYwrVtTh5VdQ64lnwsXmT/34kSM?= =?utf-8?q?x43NMma0HgQLLlQMvY5s7ZWZ53EcsEGoV+zAwojDXcixzlyGeDIdSXrLIf/EmsGJJ?= =?utf-8?q?OiHMyWCTeKkxetx7Z238PAIQCbMCIzLSCHlG9lui/IvTWZMu01HD6niMj/qDXbSTH?= =?utf-8?q?narD55prjbYV77pRIUoH1UgLojJUYaO81vQaUZ45GJl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2f6FYHHwf0OLUQQ6JPjlVeQ?= =?utf-8?q?jI3WTNViLShm0njQ20VMT0AopddF/+iB6POtIyQJ/AyEbR752yhVECvOj1MoFncFV?= =?utf-8?q?TvWKCZJ+y2BS4AMn/J8B8F+UmmWQcNlKg4nll4DaRLMg1D6NcA5SAVmGRGIx3qL5D?= =?utf-8?q?HUu8+xZ7GirswkbkYvY6vgtjQmrjPF37VCXtjzHjbWEUxrbPPZyrKFw=3D?= Content-ID: <632A854F651E234F8932097EAEA280BD@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: 341eb73c-8094-41a2-0617-08dd10499751 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:01.3279 (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: /kz1UkzW2ysIpqRbr1DGctv/C39obcgdUasmVqkuewAa2uwtfXuP4iwHBKS4Ztlohv9RdrqIKwWB5VX+ynqjt4oiYmdeYf9JIelhxLxQBv/ir+OWMzC+zjhlmw8eZVsC X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 | 46 +++++++++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 435fcb6c78..7245089011 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2844,6 +2844,52 @@ 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) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + + assert(result_length); + + 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 b21448bc2a..f142e17a2e 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -458,6 +458,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 Fri Nov 29 07:44:02 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: 13888445 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 CEAEED6EBE5 for ; Fri, 29 Nov 2024 07:44:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfq-00085y-5B; Fri, 29 Nov 2024 02:44:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfg-00080Z-LG for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:13 -0500 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 1tGvfe-0002eL-W1 for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866251; x=1764402251; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=VTiec8G5rIHL0vyL3mg9SgoFhCVnChkHAUp8DJ/M3N8=; b=rdOAq1EJTn1QAbAfmRWlDvBOLNqPXl1iIOSWIh5EL6KHQpK1Z1UiYvey mWMmqSQktvnG3EMYpo69AHHa4sALDKzY5xlphxnaaj73XHfmqqMJZY5H9 c5Nc9O8PH7LFSFyRLdxF1DLfoavotE7YWI4ADMacahr0QUoaZy2ERJSXi 2oVs8OpOmii/57h5IStca2mpz/DrjRWCizIIXccUFrai69Ij495VA0clL S5un0hrqa8yzJfX3WxP6dqHfjjDgNjNXdOZeo0+tBapLfQomH6yM1bBs1 U7qNdpimRSVPXIXbOtBC5HpnxR21PLBqjLshUUamVlUaNoBKGXL8UQgrM A==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670818" X-MGA-submission: MDF9rLqqPdRhk/SkqYl4+2pU+GWhU4rzd8mgmeq9V/uhoN1hac8REYx4Dk4otXbs63DnL1ZvK8/5oeOdgqRp8KbeQuSPvUEOqWSNqjdg5HJT5jj+ANVs97aoJA22YCaiyzuGcDk2zOBCSVbt3FsQ+cSwNjoHoWqlfwGHCQ/xdGvOiA== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:05 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PhQH/BfjHmQISVcVvQ2C1s3xMaXLEBM+4iTpeLuc7mmHjEuuhvA7zQ6/MKLljZxnYxcWosxU73J/TL2Uf5embeYDZrh6JY4yFse9zBYYRqA/BsmOoFaB8haAfi5LKCo3sVWlc1CeENQnEJRnAIeDWXe+Ux6BETaAAJBcgaJt4ZBN81VPSY+lTmuIFmu5m3cnjJyFgg6ll2G7XmVBg0oi9SDZIGjqWmJVmNnkYzZGuerK5LGFVKzVBpIX76b3G5xWIdSh9ZMMs2N0LjgczvNONoggDywA7ldxu22Ryx/xYOhNN6gtK10vaQr7+7cSgQXYjIHpqj8aaAdboWLws34cqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VTiec8G5rIHL0vyL3mg9SgoFhCVnChkHAUp8DJ/M3N8=; b=L3TFMwUxYPShuIzB2OLXwI9stNxoGik0UgS5FE5jc4NSEv8cclyjvKd+gr0o2U+4cjuuRIfN06aygSzxqEPo/OwkTM61hCuWJJFb50YnG2phS3GuKdfVOdzmDPRODV/fLY1bRY9FokTgyMX9cgu+d4Z+eArijafd79yAKJodL6eWgmGtpeQNGrFF6MKmg2HmG6CsSQ6rGHQRwbYqv2a1cKgwOvg5FIp+tSXj4gwFLWPHSTd73kcoGZYpveY4yHp2mW8WkhmufZmAttlZo9+fIhvyF1tJC9hW2Lbslg98hh3wftUKI71xpnDab+GfvMsFP2cCdi98X1EHtr1DEyirMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VTiec8G5rIHL0vyL3mg9SgoFhCVnChkHAUp8DJ/M3N8=; b=YHaWhfKPDZ5zS7mY5eqkguQh/ptjqJs178S7W8AKJjxDbijueK8MU0UM1yHCafeEAB7m4vN8nREVNZQQIQPpH/dkkukPLNFNJ3q3ae/8NQuw6/yVrnYHCcve5ONnnR5zY3PB8bIb5ES4jRZdY3AbQi2VzpwyWG/roxFHkpkPjQ8/VK0+ALKhX7FAVb047y+lDr7vIs4ihSAJ20eY4Uuhc0mFQITU/Gxt3W5zfMOpkVNXKuY8wBSbR/qKxUKveQj+RxuUO7N11K3CgiiGFn4qhjxYJ4bR0bSfboY5O+oNwN/Oa9QtUEuTvkXXl4vTUdYnsfZDASyo+zGsS7B5un17Jg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:02 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:02 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Topic: [PATCH v1 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Index: AQHbQjJ1rB7nLH1SCUaPPBOjd8HJ8w== Date: Fri, 29 Nov 2024 07:44:02 +0000 Message-ID: <20241129074332.87535-18-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 6d5246a3-0740-4f2a-0687-08dd104997cd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?1e8gmDqjBeF5uNDUMizASwobCC0PCbe?= =?utf-8?q?5HbVMKx5GVx2M9QhaXBaeGbY3CriGgUkYMxpW642eGxoAK2Ok9IzDwlOFSkAqZdhS?= =?utf-8?q?dVlBgNRurP4ZNv36RLg7+8XP+G8IgDhnB7DxkdXf/b/ZDJcnJvc68DQBLVj8IiilS?= =?utf-8?q?knr2ARTlZI09oSDGHuYCYl0m3E4pldWZhMTcsyhnHWfVCtHfBkCydLaWiSepusmBG?= =?utf-8?q?03grbfnwRZObTB4Q43hgme9w+idZXYRigzlhAm4hudQIxhv5k2mEJEDjwkgreNkfH?= =?utf-8?q?0ccCOV6q0B3cU2MgeJ8T3G4leidvJ3Xg6hixQKmSOApRa1XWp96uBZAIS9DzbGpyE?= =?utf-8?q?fvZ7l8uFTgfrrQAfnjjlt3c1P9VUVYsfq0zfRZtYYkrlw+1tE/DqpHxKDqPmotJD+?= =?utf-8?q?c38MW4CBBjuCSXX65iM40QzXRfP20QjEBUCyJwuEHt8gs89Ay0kQxglAPmpKfrvcy?= =?utf-8?q?wYs27bMVLF33yt7e46GxjCQ6H00YlOEmJLxy+bQibvfTkG8BwXX9hNpumRuoNB1+3?= =?utf-8?q?C8z1G6hkeJCqKTweZtUPAUKsm0j5YJhR0K1u6b519EaaDzGeGPSSCeV2gwPV1/SnS?= =?utf-8?q?K+721UPXXRo8tDtskvOzy4vwteW08FacfqgF4YuX/F7n4bugxTg1GNB1Hyx5McOKI?= =?utf-8?q?tOWB6OP0R6GM7nfYObY118zP/n7YritUB0PU2g+n2vgNQL5ZB01BJYBQMHiYQR5vI?= =?utf-8?q?Y9whkFZYV+2rph6LCAfZQi1eY0FhopeThbSkgV3MG+IgGFxN4eA6uRXdmxPsIbQxs?= =?utf-8?q?DCDyoA5W2u9KQ0c9mS6XIdcLm1J8wGlScFmReDtDJuqAKBcPDPkN71KZEgEH32Yve?= =?utf-8?q?KDv6k3h//2yzbvJ75wSjMdJjDHsfA7VOtpgP4ptoVlGDkcAuwlEj2XbrZDgRAD8OI?= =?utf-8?q?HUXZyWIWRiqFwARH2e2r4AantdvAE1BpmtaijKkme4T9INUUXNrmAIcd/b1qY2meg?= =?utf-8?q?Jg/uu9vD96w4mKAQCKQj/uP+KTeeRArolfpOh2AKcXpKcDzrpugTrzaAnUfDJe9Ej?= =?utf-8?q?iW8gDmHVncL7g6YHFt70oaVpfmDj2wcPB0ZSk1FDpIWb58gVMHYYo5anZh4H+m5uW?= =?utf-8?q?XAxDNnGnggRb8yF0hWmngXNdpqe5j1c6KcdBaKH2UkyJPLve5rnszEkX6ZBaebD3g?= =?utf-8?q?igAnMJzmrN7qJ8Ur8omp9Mkeo/Kt80Z7qGMamj+5VM575U2hU319HItqx1L1eymhR?= =?utf-8?q?t7l/F09mvanIxKPhGct5Q2SGaNcJxVpUlmRyNknJ/wqHF2XvozgP+BG1c1CVJIUXb?= =?utf-8?q?LSvhoEHqLIKVYdUun0HzYUG46V95hDeIBhlqz7X9MMRgFYaSGsOjhF9UhhdbCEUS2?= =?utf-8?q?TIdQJ6F7Hhzf2czDxlrvpJmC4XO2BtPjeg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?D/OsmaNdJVXAEz8RbW3cPodhPhX2?= =?utf-8?q?BXo5rOeR8STv3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XBVP+EOMqJmw1byuJ90NQfjbG2Qf3B8zvXzKaFL/pPfb1rw+8?= =?utf-8?q?qc7FR6FS4ZcRz8usOKb361MHkGdkPrOIip5pnB6BqIZCzNUTU85Bu9DK8y893Q0pY?= =?utf-8?q?V/2vmcwjJPF0GifTMDQUPmXc9bC7TAH3Hay9HJa61UIJDIHHgIRA6/3SzcbILsdSs?= =?utf-8?q?3wOCQDTJASBm8lxtpMgP/CUbN93kqmYHPZShLCrSH5hCgSP3+w91OL+tR6cyPD3PQ?= =?utf-8?q?WXki4qDdpl788FPA8i+al/UWPC4ltUyMWEFGxdQ/OxFtrfoPTHb/VSyrv4AZ88LZU?= =?utf-8?q?pUaUGyaP59TtVB7V8nMIfLD4NK9Ub2KYc7ohYB2zH1L84U/Ml4HkrsylQ5Gt6g1DZ?= =?utf-8?q?stPqyuLrxZPLpm4pV/TKX5rLrawD2gOPU7lNgrQdMw/GOdj3uhAVipaAEeg5g2zVL?= =?utf-8?q?jtWHEm8IkJfeOz5YPIadFr0sTqN0Vlwb7CW6fTAn3vefi6v1F+bgxMFEIgwZvzNuD?= =?utf-8?q?3FgepMEQybySTCJSLl+1utMm3bA7TL8Fr7zXQNiiYrDyuH7ZRJ042e4bc6FmNebjV?= =?utf-8?q?7gkSwva9aULAtvCRCAEKjV5u6FUC52NXC+ZaEGVjAvVIUgYGuGQy9W+BHBv6qBcvE?= =?utf-8?q?HB02Du0EMxh7MVpnvtr+DgqXqAP7gOJFpxujQY/2UdJ46DUS/RJBkrw=3D?= Content-ID: <746DE87AFBF2F346A4B53915677E15F5@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: 6d5246a3-0740-4f2a-0687-08dd104997cd X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:02.1539 (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: Otnc7ndX4mrDB+SfB3Egxjdv6qBO4BWWIlFNvDAEZhsCqcA0AzpgtmVa96JTZjr13vHXGRYm6B7+Tyw60dAkedqRLM2cF7u+rA5I1Ow50814ML3EDYvhjHHCwbXQsVqi X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 7e8676efb0..0637437552 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2100,7 +2100,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; @@ -2262,7 +2263,7 @@ out: entry->iova = addr & page_mask; entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; - entry->perm = access_flags; + entry->perm = (is_write ? access_flags : (access_flags & (~IOMMU_WO))); /* pasid already set */ return true; @@ -2270,7 +2271,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_pt_level_page_mask(level)) : (~VTD_PAGE_MASK_4K); entry->perm = IOMMU_NONE; entry->pasid = PCI_NO_PASID; return false; From patchwork Fri Nov 29 07:44:04 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: 13888458 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 2D597D6EBE7 for ; Fri, 29 Nov 2024 07:48:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfl-00083J-6e; Fri, 29 Nov 2024 02:44:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfh-00080x-PU for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:13 -0500 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 1tGvff-0002nD-0p for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866251; x=1764402251; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=s5ra5nffzHwWucxF5rmuojk/qIU0y66Gpw4WdaZBVd0=; b=X/Uh2yzSLFN3G4pG4cWPzOl6nDUeTnd2gFq7R7lANGwS6AzfCQhZ5N0o LOozQf5DTq2mBRmxbX8v4Ed9z/9S8RZmzDLgdZZPm3bzS56A6loNeVX6e vVjh8lukKU5Vas69Pj2IYCqUnNz3PlLOu15Ye3D2Kv4JDaKzPyXD5+1fq fQ5lDqwR7/z7FF3jK0NyaPkhbmx28ZEHsNAla03+Zuu6yNlmxIhaO6MVY g/vbcnQqoTlpKlVgakQx8r0W7eoJ0O5CyZ9TVcrCHuq2CCV8QUnBL+VNA 0H3bdkNnFtx9OL1C9aBCm5X3dclXDD13nzEguK+hra0Sm+HkxJp2a39O0 w==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670819" X-MGA-submission: MDFBYtm2nTryqGVqbqEqJ+4E61ZhYjamntoaGs4GtZndf1fO+3g1tWDPSFycxJfeLKhYoMFOIiptmek6CMKlquTGhMV54gPKdaA8mKysGxcwz00bUt/3LK25fPI3vcY774INHmFBpLKD3F/oYJuzl/iww3YsB4QqJjpNFqGgxkcq1A== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:06 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hidjWI2pFU2D8aENcoH/HfQ8RX0gNhBjj/QPigMBOKzMl8/FbRYxPBZq7PT+mehEe0jIqE5xY08g79+4WJHVYw47ODd68lteBAgXkUMeZj/AdZl0siB71Wv5rWjZl78BR5SXbPEmrT6nhQJVC88xqJzDeWHmux00xHDzuSTA1aH7N8PcVnm1DgtpHTDfct8OgC4p+ib8YlO/dPYhQV3fCeB0aNU6ec8iuKd5DnHWv8XvLHrTWr2ALM9ymRwsELN+mgAiw0xIfEMWkroOo5FzhoOWZ3+gJ9d1YTl4oa/9mcg4JyyCeK/4ErLVmIJxBlJzAncVO0QjDMPS2p0TC8oNHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s5ra5nffzHwWucxF5rmuojk/qIU0y66Gpw4WdaZBVd0=; b=eszkPwTs3OUJ2av9kYv090608XM/Dw86AzrVu71aZbZBJoLfBtcBZtczwNq5mqnIz1KoYqdqedjrJV6aDahTPmFmOc2ecG3/babKFckOw28kbYSouPLPl5RFDjwajK522HQyk4MqGRc/XX3vR++962XvVJ8csQkyHfSUBmML1+H+gnLrR2IxQVoKnLkV4IqXWUl6YMs3i3Oi6RigUNTCFQsf+1SIEF4Sg8G8eNXDt+rEdUx5XmMCAfeJTy+/pcU0+OvipihTl1xSH/7r3rm+YokbADde04eVuqCXXwJdyxDz0E9xeYZrQUZvklA15TwVs5J4voJOXAFZ09P74/1yvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s5ra5nffzHwWucxF5rmuojk/qIU0y66Gpw4WdaZBVd0=; b=I5QiU/wGBIn3gIXhHjEYMgn3HSSikylXgceWqe0QbMP75ot949FVWMyMLmXH0WyJcBUnRqMO+kavRWddV3HR3E9iPU5+Ibpx/VeGkbtMEq4P7RRx9VHR5g4ildhoQtpETRbbfIqVySJl2AtW7qk9i5uEGx334ZREnalkWkR9BWmHTQwNrjvrE/hKOjJokUCktmuv56n/mOpsHA9pfzUjNPjxqj6OojbbAXI/Ou6pA66axl84fhgHjLHttYLhqK0EgtdD8dKQL/J+Jga1EtQ2MyYmUxyveiIsWe+0j+RIoL57K1Mc+VbFMxWREk8YNF103pWxPb1v8+je4KgG7jR6Ng== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:04 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:04 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Topic: [PATCH v1 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Index: AQHbQjJ2eyRaO/QBnEG/q4DtvF0FWQ== Date: Fri, 29 Nov 2024 07:44:04 +0000 Message-ID: <20241129074332.87535-19-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: d5e78ae4-1e45-484e-3194-08dd104998ee x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?kGeLUsDeGybjqgfslsvorVmVUo+SwyW?= =?utf-8?q?F5yaxWnKefGbbXUprQxlP5SwjAxCu7Fa9ePNoS0e5jAL3213EkKLK5Lh103SLt4Bv?= =?utf-8?q?u9BNWVWjZfIy7Yin8RA1v87XsxtMkhaE6kZXqv8V3IGsBbKs0d+By/T/bSUsEFZ0Z?= =?utf-8?q?OlDeCnmF3tzd0I0NyDaxgHfLE/PCne9nlGrRPdTO5NM4k+37SQ5T4WPOnlAS/vHjr?= =?utf-8?q?p7eZOd+EgyeXVMA2wX9JlSd+nYlrrwdwCPy/1ES01auMBtpRtlOfS0oNWrwWtsqae?= =?utf-8?q?wwDFKZtnwW28uluoDkP7IMPsmIeClshWiDW2FAdLqBvf05h0RchLOCVjcQBhZmw7Z?= =?utf-8?q?0JXmxd9Es/BxbOUYd5T+HW30G47IgRI6GcCfptE4dMzxDPmGomoTT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AB1?= =?utf-8?q?Jxtxypmf2jT99S+hOMoZL4B/3fqfm5wFhtnHHYYad449ahTX8uGinF/WByXKU8f+B?= =?utf-8?q?EUcPSQWjk3PC1VTyb9+p9f2rGooHqA3Idw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?kQhCtD2MLQto76+ej+Ai+4DErbj9?= =?utf-8?q?wpqhvWgdc0wRl+ghY2L8ddfutw7mex8GLVcYUJgvEQGlgXmGOVUgwDdhPnmLj7CkS?= =?utf-8?q?Gj6l1pX895BuZch7rW3H0qdyshtxzvQUHyd2Ao+0VnT50LaiU+VTmcnBFOBBNzAFL?= =?utf-8?q?qrO6aS9HMztzOumQOwFmsgu86m5oVX9a/mhXMLGcGUXZY1j2ARIkiKiMJrT8trinr?= =?utf-8?q?4QvCEhA2VoWecy2ZmLGqPbrC5D3JMONVBI5/MUmUx7rJ6wa8M+/TccAwrwYyLgDRg?= =?utf-8?q?K01oTbQOLeqGzxsy+iDkG0xVdbDtmCfprB7Q/Ma450JP1uVnwtNq13cBrQghiy+uB?= =?utf-8?q?PyasXMZzYhNgD/+aB98l9+hVTDlyy1f4lZPjXpCFS0GMraHIxsI3ab2CzxlFFys7T?= =?utf-8?q?dO8hMAFwyJ8Nc0Cl15xZUgbVqO3aMl+/th+XJV3SnsSf4hGxL8sA2Q/8TGAtjqytA?= =?utf-8?q?pidVwjOhX1AIN3zNz7VAU7CZQ7004fOMfeHlNrplZmgwu4pUPjaHHZ6XHNfEb/8BH?= =?utf-8?q?O6D7t3PJvlOax+peQAoj3msMjEQwVIMDGFylZdlmoAkhkcNPPcz1ewRlEXSfI1HEA?= =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=?utf-8?q?1J5yloAD22pOiTFAOo2Rtje0EAdUMWoKTieeGBv54spyyGQuWerVEbmZAkYrJMdvR?= =?utf-8?q?/mcgVXumkK8/B8F3RqWyYrNyusVOm4htqpaEsoL8p0f7z19Q0I5BzCY=3D?= Content-ID: <9237B26B234F9A468753FFD2D0F00C43@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: d5e78ae4-1e45-484e-3194-08dd104998ee X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:04.0518 (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: y1khjslCVar7Y3q2qTY+Y89L+XeMPUoNPgRh2JdXzH3MRK7wn4BBHAhAXZ1PDal2T+MkomVYHB+g3P2iya/4LxFwe8QUnG7KI7lFS0LZRCQS3a6plBAdFh67XjmOnfiB X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif 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 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 0637437552..a3e972af75 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1995,9 +1995,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, flag_ad = VTD_FL_A; + *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 "," @@ -2006,11 +2006,11 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, } while (true) { - offset = vtd_iova_level_offset(iova, level); + offset = vtd_iova_level_offset(iova, *flpte_level); flpte = vtd_get_pte(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 pasid-entry */ return -VTD_FR_PASID_ENTRY_FSPTPTR_INV; } else { @@ -2036,15 +2036,15 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, if (is_write && !(flpte & VTD_FL_RW)) { return -VTD_FR_SM_WRITE; } - if (vtd_flpte_nonzero_rsvd(flpte, level)) { + if (vtd_flpte_nonzero_rsvd(flpte, *flpte_level)) { error_report_once("%s: detected flpte reserved non-zero " "iova=0x%" PRIx64 ", level=0x%" PRIx32 "flpte=0x%" PRIx64 ", pasid=0x%" PRIX32 ")", - __func__, iova, level, flpte, pasid); + __func__, iova, *flpte_level, flpte, pasid); return -VTD_FR_FS_PAGING_ENTRY_RSVD; } - if (vtd_is_last_pte(flpte, level) && is_write) { + if (vtd_is_last_pte(flpte, *flpte_level) && is_write) { flag_ad |= VTD_FL_D; } @@ -2052,14 +2052,13 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, return -VTD_FR_FS_BIT_UPDATE_FAILED; } - if (vtd_is_last_pte(flpte, level)) { + if (vtd_is_last_pte(flpte, *flpte_level)) { *flptep = flpte; - *flpte_level = level; return 0; } addr = vtd_get_pte_addr(flpte, aw_bits); - level--; + (*flpte_level)--; } } From patchwork Fri Nov 29 07:44:05 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: 13888461 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 90B8FD6EBE5 for ; Fri, 29 Nov 2024 07:48:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfp-00085Z-Mp; Fri, 29 Nov 2024 02:44:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfi-00081U-Ji for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:14 -0500 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 1tGvfg-0002nM-MR for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866253; x=1764402253; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=r1cIMR2bydzS/r8/JNnPbdEFMy5ycwRYByzUFRA40/o=; b=Upp4fDke0KFj5Ng8a7k5ScWFxhCLYAtWa7Lq23wAgx5wg8+NUz0IoWH7 ZGzl80VaLlFxq3pLvvE9rdYPEo+JC1cCEgVMvhTXgniiD2vnO/jfuAF7U E5vKXVLMrDQXRXXCiURwqLuG7ap9N1fUn9Fsn84AoFZ97FGeO95b/gDYA 4Rt0t9Z2Ph1SAjI9RpmTwbjNdJ4qj1Ek7g0NdLBj0gTWQ8zOkXP69Nmd8 ZBtC8vg7auPDekfZ2m1yH0Di8SEn3mGsM+3jptxY53vbdKR8Oq6i2mjxL dhCwf080olNQniIqncnFZb2OkjA/Kn43+8BcCKJ29asUixwJlrTPU/aHw w==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25670820" X-MGA-submission: MDHwBCCxTrnBU+wELJSvXKCeujxKx9y/MTdV3vhMu9wh91zH4uF18ynTEZjP/wZIhsAgtt+1xjZX3sBiF44zZUOgd930LdoGgKFh8PGgihE9p7I89pIMma3VGZ3+vpNm2dxCV4Kx/RXzE16yCyJ8cNoEXwbOa57IiW8U40Jvdt8nrQ== Received: from mail-norwayeastazlp17013077.outbound.protection.outlook.com (HELO OSPPR02CU001.outbound.protection.outlook.com) ([40.93.81.77]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:44:07 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Im0+fdXMmMYpvO48Xpzdus41smX8ohQ0num5t2H/2bTRwkfKwy8DbuNxROriHEnTLtz+567O2i0ItMEL31EiFpvb3cTzDqJ2RZE2mGxLTDLUsUjS8TAMzESlEtSo7T6rgi5cBi5RzWddZ8fxIvlVXlhToyXleiOWcdPckGxHm0tv+pTpzIUtJRW2ud441hGi66sbiQHG2SeZvQqWClw+Tkeg+yp/ZT+cfh77JZMgYzWwQ+Yfr75KIldOnmPnevCM9XNKcbTXYiuseVospj1A+Mem7M/ssO4dXeBi8HPyxAp2tN0P6/jPRR9Pz6nyRDXPqb4xaPhmIpivjvkS6E53qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r1cIMR2bydzS/r8/JNnPbdEFMy5ycwRYByzUFRA40/o=; b=Xce/7jtyut1Enl37oStbC8WjWdpepdvfvgaRah7/6lJhx6a3x3oTyXOO4XlfdirmjhGQPzidYUuUmj9evePQ7r0r3rIexyQMUr9xXhVHkLh4O4WSzRr+e3rrqjFSQATLR4uXiiVmjpeFQnNJDxWwTy4O7E7TTcLB/eFpnZEpROzAQ9zsr1CpDF8/QI7BWdO/3sB45oKvDGAX6sXYjftVlCzw6FniRXkgQuRk9B/Wj6LOvEa0kIkwZT0wEYpm1ZZKRVUwYDHqGdqFzztJFksep14pxvFK+3k/cUTVcXQwhQ0FxOBn5pbcQQLuzL91ZGDnPfSmxGkzQV5nU4l4nAjNwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r1cIMR2bydzS/r8/JNnPbdEFMy5ycwRYByzUFRA40/o=; b=JM3+6h5n/3JVfta6gShLiNyPv8ZUOOCcZFaIfZ9PYlEkNNSLno5Su3dCF2wiNdbub+1lsxMBmULm/OMEYY09L8v34Q1zbmWyPZnI/ER1JsZ/6UH4hxPB53Pa6Q687iUnZ3U9boGmRSNCnLNllMSMPDpSNcNRA0Q8zsBPu6pPfPzo6AQjMEFz5zMaqViLQLcFGw59Q2m4z01MwZIBgBzuG6IH0m2ofull19ILQ30HMlv3rLy05dCXy7wx8poFCsZzmu1PRmSqycjtg0FQ+cGnxi78CS3gMOrcidzLMm8WiaF91Mes59J+RqZXZ1Z5gOMI2HENA05D6g93qjdk1bGnPw== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6414.eurprd07.prod.outlook.com (2603:10a6:800:139::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:44:05 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:44:05 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 19/19] intel_iommu: Add support for ATS Thread-Topic: [PATCH v1 19/19] intel_iommu: Add support for ATS Thread-Index: AQHbQjJ3Jcu7IEEYSky5Kq9PmWavTQ== Date: Fri, 29 Nov 2024 07:44:05 +0000 Message-ID: <20241129074332.87535-20-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|VI1PR07MB6414:EE_ x-ms-office365-filtering-correlation-id: 6f7abee3-0bb4-4a99-a328-08dd1049998f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?qwfg32hRraFCdqDkMahgd+BbL6/CR4E?= =?utf-8?q?7umLJvOfxgp4oL0/h77LK/PKHPiojuVaxRbwrgvseq5CWMmeq5rPyi+C01s6Pn1Zg?= =?utf-8?q?0iEHdI8sTGw4aK9L4cvd3uLto9wc4OanCvYEuMc6ZGdSn5gHnEEJvCgKYc2+4e3ye?= =?utf-8?q?j+gnMZXv/HAVytlyldVKV35Fh4DgKtudW/TwApMXoSJ2i/gIR1LnNShSrxUxPfXYM?= =?utf-8?q?zLxCCftJyzlDrg4JZOuFn1n9AlmBv86tblonvhW2zxeMbGfBJPvL272UKhUbom3Fa?= =?utf-8?q?cJ7Q5yYsNTKxlPgUnLckC1qGO/0Jj9XUgJrEMj9rH/EbfegpO2c6NDm98cyIKkaPy?= =?utf-8?q?gfWmZZ71k5dadma2CuXRydkVopf8++OkLophtqKF9tipt9Zg8APxR0PYHi++alk93?= =?utf-8?q?o7NT8LYywphgAzLbbRzUgIUwQhKq29oy6P/FuHoIr/mbgu+jLGadEU5zLq+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8?q?Mms1ArpnN/i6U74g8NCF5rOR/uZL56pucg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?SwQsyvBrEEQR1TnIf9YXyBz2c4Bu?= =?utf-8?q?ZY1cKDjDNgauHLj3nJh8B5XPk0fn6laPWnQs24zVfwXND2p1VaAP4b8PCGtBIrYd/?= =?utf-8?q?npzNqcCGmDxQ7jNYz4A55GLQsyNaWHa96hcnPTjEQFQ9FDh31Y45Fg4wDh9TVpG4f?= =?utf-8?q?VWzlsQimykR490R3TOKO3YQ1ACSxFefVJtJS0Hj4yHSU5mwJlhGdyXsY2t6f0On0A?= =?utf-8?q?Luej/YCPegzb+ZL2HW9NAtbXjhdUcaCNWg9tMmhLr8i2fXI0Cyg5f4BdsavBOFFLQ?= =?utf-8?q?MD5B9DmqrjE+facO4Uv4nEn26wKp5+gNP01v6umcfLNalaRBILoqEXY2QU5n2B5WU?= =?utf-8?q?CGtS65NSTUMQn/MW/iQi1wisdpWoA9bBuIN/PLiAKQZW6QtH+yMURonLzYLqz7DVY?= =?utf-8?q?VWIzUt0GZVW2vM7873NuTO4TFnEQy+UlGzAr8AGvI3j2jMW5gAg0y54ijr9uJO/sM?= =?utf-8?q?osPQKzwrCms8V/LCAFbb4swgVGcIy3C+yxmDEN0I6RFfiWb+/E1B/L0bnbcDV9E0K?= =?utf-8?q?oFjM/VH1n7BMojLxGz55oeDNsjuIGTKgEERD2niCQCFNy6xH/2KtUTsuQ4V0kDLmv?= =?utf-8?q?DBqlwflAVoWfceiM/CbUZpxFGtfsFYB2Vjj5BhWjc0xU6gntWXK7Jl2dNeR5Hus1M?= =?utf-8?q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d0taJsJg287e4TzPsZwMNvjntRqwLEPIvx2JAigHqjMM=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: 6f7abee3-0bb4-4a99-a328-08dd1049998f X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:44:05.1044 (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: TP/tzPD3nPveRRb0kJEavlOQ1vMnSMn/2VQB52H7/c3dXdsd68wtTHfn37cbcQM/XolfXsBUNuXP/StKA2sSuWTmpH6NB+MoQ6ukwgsV2WeiU1lg7spB4R7HA84pJH38 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6414 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 71 ++++++++++++++++++++++++++++++++-- hw/i386/intel_iommu_internal.h | 1 + 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a3e972af75..899c8506de 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4166,12 +4166,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); } } @@ -4745,6 +4743,71 @@ 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 */ + /* + * 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_memory_region_pasid = vtd_get_memory_region_pasid, @@ -4922,6 +4985,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 238f1f443f..7e2071cd4d 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -192,6 +192,7 @@ #define VTD_ECAP_SC (1ULL << 7) #define VTD_ECAP_MHMV (15ULL << 20) #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)