From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394969; cv=pass; d=zohomail.com; s=zohoarc; b=iqr4tQ+bUmeIK6yJD4YqEp62gDiBLsy5hejzh6kORjQNyx7K7avEEW8YkqKL1dTeYnJrkv408k60ksAw6Pn0orjeYJ4EHA7Q79LijvLF/OFMumUV9+x/mdSZri1ujzenuRNKVpSvSMRwIpaF9guXm83RjXwtPxOdtit0XG1ql4g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394969; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CpX0VUIYzldTTRNfMbFoHs+MfYXfgrsOMotxAkNQZ+w=; b=Ys1GPqm33zKvByO0nhQGMe8hJ42K5nhW/jq3ppqGDaHO4S0OIpjCmut8Xbdl+fGxvea7MSPgUlzGLCLhGP31G8Gl7cN/JZ1fL9TT0Mto+ogX4jxh4jw6oU5RXXFoTNzbrJOa1YxJZ9p3+NALeAoENRRpZ/2XXrIw7K/6BluXxV8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394969676688.5595976337751; Mon, 20 Jan 2025 09:42:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmZ-0004XW-T4; Mon, 20 Jan 2025 12:41:51 -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 1tZvmT-0004W9-SF for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:45 -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 1tZvmQ-0000YO-99 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:45 -0500 Received: from mail-db5eur02lp2111.outbound.protection.outlook.com (HELO EUR02-DB5-obe.outbound.protection.outlook.com) ([104.47.11.111]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:39 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by GVXPR07MB9869.eurprd07.prod.outlook.com (2603:10a6:150:121::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.20; Mon, 20 Jan 2025 17:41:37 +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.8356.020; Mon, 20 Jan 2025 17:41:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394902; x=1768930902; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=OxUnyvW9zBQ9FfogOiHdNv0//4oqMEtExS+PO4DE7tc=; b=Wa7ZcoGlxP/fZXMO54F1r/FNmd2YQdGPeBxHWm/L6xxg9RPk43tgI5gI PRKzSojT80ZYs0jeBgx/Y1DaL3tCPPm0Jwdk6Xrap0TJ6pS9Lxn+UoRQT gvgt8m/yo4/nRdiMYWoMXn+A0Q8Tgc0SqnKqA+7I1rupbksHiObHH1k/E wmbhTA7os4u5ckfpoOjIB08lmUfAr7+NFMuvjqFgkPXCZYX20YHDahS/i 8TIJvBpbFP1vGa/+yS55YB4Nl1xvIVQt21FEupYn+0AG+/J0RVGfaKJvp 2KmmE0MeY/6OEPg01OIXM5oyDqJ5VdkeXWz+/tSMlndPc+Oj9I8jGygf8 g==; X-CSE-ConnectionGUID: SMLwsgFFS3ewXGbJFeHmOw== X-CSE-MsgGUID: gweK18bBT62IFV9YhHmfyQ== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291716" X-MGA-submission: =?us-ascii?q?MDFDmnptiAhGjY5mq+shaQt69PUjRRYcC6pBDB?= =?us-ascii?q?MnrDi2jMNRa4pg9PU7LK88ndkBDtlgMFsazlcfacx3G9ZI2hcBL39D6F?= =?us-ascii?q?KLhbA4eYYbgFedlwvubXbIqRbH9aUwtGovpUOFxlKs/E3uz7WMNEDlcC?= =?us-ascii?q?jVpDtQIh/G901E4atgTnMNhw=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CsOSHTO+RV3YxHyM56NPltitaYoktj1YC0aClDDfQ5mKuEWjzCOln3282wyvj8x12/Y2x5YebTrAG6BmkCPK8pbl4N8fgBktG9LO0wuquNl5HlyZ2fwtbFpdqguNvsRkTH20KLy1JDP2LhIwr3KM2cYXLTdvIScj6A2NYp1OLIPznJrkBE2od0hl1tMsgMvFb1rsDHlqLw6F/Us7BtEz/8DvJC5rpeOgS+wjQAdI7pXGxcU1PLfcCFOKujOBIbrBjtQNpYydPvNNpyjCmf+2QN86y0GiIkos+gYareP99lapVjwZlvGjVD7G6pvzJyyzR23g4vK8WARoDYX13sF4OA== 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=CpX0VUIYzldTTRNfMbFoHs+MfYXfgrsOMotxAkNQZ+w=; b=Sfbtm55rk6RWw4w/KM1KEHH2hW7mSGvnYNaBxhq+BTCWE2XYmWaRkEZpeSuJ3/USXzqWkspiHYPqsdpv+C2lVxqIvQdxqMr2SpqSojKOE/PmVVikPZWKvfBaAL9ElLODYSecDOBR+xwFxDsrznc802cigYi8yqwf2SKBw45Ysqzz06+zhGmb4JNWpGkomEN86mBVF4pyA6vzGsiJXIbx6BcA1khGDC20hXAbGvdsqYWkhezFKexnW37/kW7IYb5aL8O2d3k+2rFR8tIreljvtLTz7efczY8YRLuPtFCRGz/8TCpSpW8JwBBKTWuzMCggyBtRa+TIKnE4rG11uXau9g== 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=CpX0VUIYzldTTRNfMbFoHs+MfYXfgrsOMotxAkNQZ+w=; b=tBSP3yBuLI5/qON0XvbgvEKZGBnhgQwHXhCWF6NWJNZ/2FTYhmzzQ1iG2ybHF5w33hnOstPvA50SFqvJazbLuG7mu0D/4op1X6WaEJKDbBflsEEuIwZjpzo5jIF2h1jl/uwjgKZIze29B2mUTSOp71cgabOi672aRbIVEkiGBgjoQGJ1Z1kqO6sD6R0HmHSQJS2YcCvJvDBCzavsBn2spn+LTU77BONF8QFK23zDpecOxBU3ExD9XdxysV7b+WJfXq65Od4crAR2ssf7WQKo5h3AhrlYykKlAQ2Lq4WIxR17VnGv6Vj3mvaFopsjxv3FIdAxlNPZLARbkAFQoBZ+rw== 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 v2 01/19] memory: Add permissions in IOMMUAccessFlags Thread-Topic: [PATCH v2 01/19] memory: Add permissions in IOMMUAccessFlags Thread-Index: AQHba2KOkVqnr+ry5kun121ROC5Drg== Date: Mon, 20 Jan 2025 17:41:37 +0000 Message-ID: <20250120174033.308518-2-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|GVXPR07MB9869:EE_ x-ms-office365-filtering-correlation-id: c7b13164-4008-45fd-1bb0-08dd3979b0c6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?SE5YF2Uu0mPgiw0xKayTEAGDOHjQwBJrZZ0HJFHvgQL7HhPNeWgG2FsrCT?= =?iso-8859-1?Q?I6nFPBWjRpBdwCJuLLmh/pNXo18VY0bJa2+jT10+y5hZTEPeNP1eE+f/Ih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lNOrna+C5cMWFV1v85Oz9r?= =?iso-8859-1?Q?DFVoKB3Q9zd4iwbWx2xT2HtCJIQUOzK6p1urm8GvWoWLJ+rL/6jITouWtQ?= =?iso-8859-1?Q?JwCYSQahR98vHrdaPYISdsq6H2hZwmWIvsnDZSdtrxp22rpKEg1BbZYQHo?= =?iso-8859-1?Q?C/xY7n+9fqBTGlN7zEiSIppnMv4HYOVH2Ib1/JjwzmCmRIbC65A0Wqi1uW?= =?iso-8859-1?Q?Yjcix3m4DZh2OlF3UAa8/CiKIIXq70GlXoD+F9BN6NCPM30l96peHhYetH?= =?iso-8859-1?Q?/8haDh7lWJK3A5YJCxXEMpbseD81vSYXEXOdaRdPyO4gb9wU0pACmBmZET?= =?iso-8859-1?Q?xqhJstGPYjriF9H0EqrVo3SUOGKTEJc/YBQaLUHdntFhQqGXxHQK1GkMTy?= =?iso-8859-1?Q?fxw11NDpsr3AYEo2AXbQztbUwKHsJjDqMOOIn0R6SU+v4OfmVlQ8UP/f3k?= =?iso-8859-1?Q?u82RHbe30pHTsofTucVMfo81wMIrTNvnHDLEfPQ4OS2t98ydgdKu8GjE9r?= =?iso-8859-1?Q?m0xJgUxZHmDiPEJsRyVCKR?= 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)(1800799024)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?fyIT4a2ORs+6lEgnPOUHIPYPa+hX6NlGZVaXSCsa+JDHEYwQdSDYXoRp9C?= =?iso-8859-1?Q?kI4rvNmpN9qF6A/InO1zOiruaqTFdxRkVicdof+v411cKcWUp64LTIefXv?= =?iso-8859-1?Q?mgzP5ez5zrqkCxrbv/QwHPiqbbM88fLtwnW7nGqhXgrWC6+io1faKbl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DSuUiiGLF6wK+uaiILg2bSL3RDphq?= =?iso-8859-1?Q?fORi/4wqig7D8XkZnS3IQgJ4GC5GDstqrFvDGVdyQSI3J0EYro/HAIpiH/?= =?iso-8859-1?Q?JxTv7I01O/DzqrkEYuA1rV+Vge/kfd3ad1/i4PPmHpjSc4cDOKDKEcQDK6?= =?iso-8859-1?Q?HdbW3KgVWnY7rF2GmQk1GA5RR3jrmu+orPT76NRvRRHn18+PXnGd3BTVsG?= =?iso-8859-1?Q?CymA2VLkWVLOpJ3rRuJX3HAPdUzMHIS2D+gEnLWS4eWKGty+H3wWfLR5Fn?= =?iso-8859-1?Q?T/Y32yBwk5h/DsJf/d1AeIlJ5PNe+K9S97ulnXT5WI0irIlsd/j/SB7BC5?= =?iso-8859-1?Q?B+isK1ATJCcl+B6T4pI2DGehDlb3nFEjla7HXopA9XRXZL3vHW5tfakDDH?= =?iso-8859-1?Q?D4gIkIZS1t8X/XCfLt+sqZVtDnh+kWjD2Y4pqyd7z9np9MhWytpcx8Ozhn?= =?iso-8859-1?Q?hzQB02wIIXG9k87JsEcaXjAv9Hm7TtmJEZm8ssEHnyqhXBTCZohms9rk7L?= =?iso-8859-1?Q?pvTGUR+yzp85hkNYsOpiIMfTai1HJEPKhIZpEHcWG/RPorJZAmcPyvweCk?= =?iso-8859-1?Q?b31CUIJslEjQhTwMDT+fsYA2pr7PAnJ5YesXStlmzuox+9zs15QQmn+duT?= =?iso-8859-1?Q?rtJ6ZKe6kzlQgJMNosI=3D?= Content-Transfer-Encoding: quoted-printable 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: c7b13164-4008-45fd-1bb0-08dd3979b0c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:37.6014 (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: snNOdc6ux6gGzjlyatD8H7Sp4wlgtJ8O1k62ZDZQqXwu8e47a4yUwNp6tU1YtBLJNuflZ+1rgtqpC/LMt4UKUYhZqAZ/gpV4QR7C7yVuvvyLJBEnQnJSemRjwN8wb7zx X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR07MB9869 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394971066019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 3ee1901b52..56c3a3515e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -110,15 +110,34 @@ struct MemoryRegionSection { =20 typedef struct IOMMUTLBEntry IOMMUTLBEntry; =20 -/* 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 =3D 0, IOMMU_RO =3D 1, IOMMU_WO =3D 2, IOMMU_RW =3D 3, + IOMMU_EXEC =3D 4, + IOMMU_PRIV =3D 8, + IOMMU_GLOBAL =3D 16, + IOMMU_UNTRANSLATED_ONLY =3D 32, } IOMMUAccessFlags; =20 -#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)) =20 struct IOMMUTLBEntry { AddressSpace *target_as; --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395039; cv=pass; d=zohomail.com; s=zohoarc; b=guUtsw/TbCDnRTBHyKZkckE44Vcoz4Lj2S+Zk3jEHo8YQFDfKEt5GC2m9Bgv/Rno8wK/pJzzswdbP6zE+uyXpLkZE5Xktw5xNRl6RXsdu5irSUvIjpY7fNyHQg3rFNQBqn0PAMMEM8Ym/scHdqRQi1Bz/E3ToC6bRjzsXNECoDU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395039; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MVkhoKa+zWw25OWncBd6cKrfwqHMKy/axZuf3JScfE8=; b=dZDgszVthTg7iqL3KTpzlXVzXoMOH19MfVScTWC31MqxVdB6vYwmVNFE2lsQMM4mCHx6N3xDLHxc2g1tL3gEEWQHI3AqZeIvCaaZV7IcEJPh/Vq2NOLRz7Ngf+65y78s+ks3pAgQkVlRhCWqVHoZ4uA8YVY0aT8evaWxPNU7fQs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395039942260.7439315769151; Mon, 20 Jan 2025 09:43:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmc-0004cj-9j; Mon, 20 Jan 2025 12:41:54 -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 1tZvmT-0004WA-Sl for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:45 -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 1tZvmR-0000Ya-G2 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:45 -0500 Received: from mail-db8eur05lp2111.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.111]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:41 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:40 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394903; x=1768930903; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6MckZQwCYjffMS2jXtjONQ/OHOr/zGtMmZperPRxHuY=; b=nqCzTsdlSXdKqdOoOVY1vwnFCCae9+fwwO2jWOIVtSLG62ht19GqgcIN 2jXM5PW6+//NhlOAeD1f7BRwwM4mvFQa5qpbApx6ujadYl/qlfl3xUwMJ 7AmfaKPWp+4qhYWymPxjU6OYDE+QjcRyLnVgG4DlbdzCRcnu2Z1OzcbOV Ju4t0pr1mw4Vo8kzdVRlO9XyyvkBURmRvE4QikxZrInKOmQTv3rCGIbA+ hCrViBO1jWz4k7cjJI6tBF0DaP3yUdQq23U6FZ77wH8rPW1Yd+qyKJQ9g FND3IuctKC3kZFY4tDhcWibCNy4hWUjY82xNl/J3o4IelTsr7ZIY17INU g==; X-CSE-ConnectionGUID: OUkLtZ1BSRaGyuj0IQ8qIg== X-CSE-MsgGUID: M+zK+41hRnGSrnJKa9jl1g== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291717" X-MGA-submission: =?us-ascii?q?MDGmXsEpqMchtTU4s8IrzGa/htVpLuB4mdB84w?= =?us-ascii?q?OjS9VMP+18vl/kxw9al2XtHJU7VztPhdES5deZePi0Q8Yi3PGqPOlpCB?= =?us-ascii?q?tblcV/A5HvC2gESVd3y4SRGzP3C/4eQfjkouY0NKCAf+xvWM/4fDGzCE?= =?us-ascii?q?MCRvNq1K8jzzD15Et+WfKnnA=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=va47eTGCG4AMKfiUyOoaTFtUuYMCh0e3P6pfQZmWSt4edoXojhTyllrUN41Vg43DRAbptaKtC2+Mzyb7EazSvbn5Up55ZFz7jTU+S1VMyBDLqw+iHc7dDADQf5oIO6/MWbv+YEn1x3pPhMHsDKQofXyt7+JD6AGiS56jU5aWqkBrb0TG+XEXgr8lkZd6s9prK1ck1Aqv2J+6XxzYf5GMAp63DF2jcsCVNlpLsUm/6oWEewtmsV3zGV1WvKAf5f1PxucVejaH7oIiRr4/0uCU41SXW2kD6j4mNGbzXSPXodDmXbRduCv3SoGH+YUKLC35A31ScrzRCfvdYcD88jJ4kQ== 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=MVkhoKa+zWw25OWncBd6cKrfwqHMKy/axZuf3JScfE8=; b=m93EJjYZq64YEEKGqUbWU326tThqctFXY5BAaXHGzL/pLMSBO1qd8Y7/W7JG6ibVQdD4CHHjBnz9dTpEZhvE5teIPvouEyFsXsnJrGWrOKMsaQArwpKoQWve0TNjXXNp3HjJ0/q6ro8fZupzLb93FNJOvSAW73nkkLGd4mWQI4sPZjB4Om1TPO11U7c5or0oY2bATJnkj4JucFAxF24Dod91Xyc8AaU34cmAJxaEcrsKT2pqV2LrQN7m7O9ZJMwNkQPd3O5+bVjRG2VEC327aeUBpdJuHVaymG3aLGdupfRitOWcv1+brRr/PwlHhWsCoFoFzOT3sgU9mJC/nOAbjw== 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=MVkhoKa+zWw25OWncBd6cKrfwqHMKy/axZuf3JScfE8=; b=UqKy0TWCkFg+NCdgFcbg17/3mhY5uVQbsTbo8L4XXZP02xcm83+dlDMM3id2a6Od8E9XZ/CiFGPlS/HZsNzEfAkNsdSw3f93Qp423+D8/s03FZFYInBNWiLWS5xOrXVIC02mFZ4jHI3iiSTmXu+V/P5TCIJXoUhucHM1tyCuS5Tp1LV0Ga+2cVz11WYoc9nSbR7G+S5+2l+jq7Lk0+SNnnhc6JaQl1OXDDsHw0xoZl13TCWAP2XKVkMSbaAoIAfXMkzgtGZ/o6D7hrqlsG9iXzN1ZeyOD7YUkmYQPK+j71A8bih15UIAx93gwwr7CQlv0Q+yAA0M/2I9TH+GqCx3HQ== 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 v2 02/19] intel_iommu: Declare supported PASID size Thread-Topic: [PATCH v2 02/19] intel_iommu: Declare supported PASID size Thread-Index: AQHba2KP0vNGn4J+iEKQX3X8t9NAGQ== Date: Mon, 20 Jan 2025 17:41:40 +0000 Message-ID: <20250120174033.308518-3-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 21a7d2dc-1d7e-454f-b55d-08dd3979b256 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?EW3I13h6KBwVYyMrQt3FOs4DilTQnio1K2ltyythBps4Gmg4oOsLdBqfVP?= =?iso-8859-1?Q?mvZsOv5+cJ/sDWssJNbJd8L6cUfOFj2PM2xe5OZQIMIP4u28/piR4ipe9U?= =?iso-8859-1?Q?69ryjwPqpbmWrNKq/VKfuv/fG9LxXIxkNYHm0mfTC8hKeLXeIDrdnxPe1Z?= =?iso-8859-1?Q?zoblZfmh2GyIdEst5rxSIUnFq7Tw9ppKu8CnnNXC6CFfSRyL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vZNUAFPS8tx/Hw7f6huTqsih2Zge9ByVO39tITpAHHI?= =?iso-8859-1?Q?LCPq9eqYapNhSdt199Jyw3jOuz4qAtZW2sosMEP2IakPpHIxwp+WSxSjPv?= =?iso-8859-1?Q?c+xVNWI9A3sFUuz2oQuunquvmlzQtW5vahH3O7Iz4b/ASNgtJrV54OrNMK?= =?iso-8859-1?Q?NB6oWuxr9fPs6dXOua023i2Zl2jO75EjBAgnDNOcCLGdz8IV5e0++gzN0/?= =?iso-8859-1?Q?gksuciCyjKe0/81RM1meyrSJg2JK0YiFaOUkdvP3ftboLBX/17PUj+HIvU?= =?iso-8859-1?Q?n43KDu6RbWbgRGUNwkQq2QxhUpD/pbr61leU90NEYbL0wiJjD96mq0nFaa?= =?iso-8859-1?Q?rXnydLorPA8MCW7zL4HPQSa5trgSqDOngZ/PcKcva/5TWvGsppcz5meUH0?= =?iso-8859-1?Q?N2zXlCEYBJjmtOpnB57VTk?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?EFZeSo4jskUct96z19TCQE80dEK4pRB2Kcb3ipUJYGRDgAYlYvBofebOb/?= =?iso-8859-1?Q?rxDvI0lGxqGj0Sc6vZRxDaSN1A1c73/2z4dWTmup1hNQj5e1Lu5zQ/qMvD?= =?iso-8859-1?Q?RkO7KoxQyW+x/AKhZnMWWho1lsRxytVrDUcq/gxHs7yTHutm3Q3VSTqmo4?= =?iso-8859-1?Q?fnAa/UMuTZPhzf37dUYtQtORutghO9zTmNmE15J2vJpb6EtJVQP91o9nRZ?= =?iso-8859-1?Q?4KBeGqavDr7zHWyBDZxrD1dgf99+UxGLd/ZG1jaYtv8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+d52c/pDyN0ks6y5AFoAIkRcb2BmWsw7AJDx66+nijCuEJTP5?= =?iso-8859-1?Q?Jieeye/wzYNArx47nftuDXG0TwatbWvqQlHuv1XjSrze0p2wMVt9D9Iiat?= =?iso-8859-1?Q?2WrtjtZdKM/gPc9mTonAhH1gHRNGUtPCHFRbhFxvI4VLUctWcudzzu6Vvb?= =?iso-8859-1?Q?ZqM2lf3VXFKxCo+eGSGm/aJWrKwYEoUOb83bvA1b9bxurCtzXakah6k+lV?= =?iso-8859-1?Q?UujrWc7J/ejOqNc5HHkU2QLpSrV6iLyIA/eez58nh5PwGIEozoFKNS2KHL?= =?iso-8859-1?Q?ojf2C+721k4MYlaAtHLBmTLxMX2z12J15sz1C04tbZtnHRYVvJoKHwRkcI?= =?iso-8859-1?Q?c3DRNxbpPS+teMB98sZwiunoOtTwEEj5HzXo2GuHjz0XRLFqIfdfKY1kPV?= =?iso-8859-1?Q?crU9G62LdQpf1T4GOCEc5ihvudg/YEfywZQsHF/a6pj4Kk+BEpEOHg9EqW?= =?iso-8859-1?Q?9EmfWW6n/5KR3xoJRtX9DE0EWU++piT0dAVb1I1gO85Md2q3qtdFTX7cil?= =?iso-8859-1?Q?yvfzJoyXwEBzD7JBT6g=3D?= Content-Transfer-Encoding: quoted-printable 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: 21a7d2dc-1d7e-454f-b55d-08dd3979b256 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:40.2156 (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: 5aciZ3rhAAGPCSiQEBjmcJIsg3iSddjlJLmv6wNM4SRviUd9hwLO+4A3QIsN13RQ/9zcCZ2AAUCNWsl2Nupc8HS7JfRdkXCXsokE+W2/nsjYHQUILuI1OCaP7S8WALL9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395041568019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 f366c223d0..1d5ff8f4f6 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4574,7 +4574,7 @@ static void vtd_cap_init(IntelIOMMUState *s) } =20 if (s->pasid) { - s->ecap |=3D VTD_ECAP_PASID; + s->ecap |=3D VTD_ECAP_PASID | VTD_ECAP_PSS; } } =20 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) --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395057; cv=pass; d=zohomail.com; s=zohoarc; b=YzYgyw38QfwgpHC6RNJMJOmWN3CenVuwFh2VoZm32RKYrBbe8ShIDuNS+a2sSBj3oG+t75EXNm2L9MQVmY8fnVCvSSNBRV45HPlpwZqm73wd5ul3anYKy9I0gE0Y82vtTAkBLzZ4+msllIZBOHMR9C8t66cjrAKteoS6WV8ufHs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395057; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wBCPTnyGGbWndBc2Xd/ytVLloQX3gIb+PHViU7P1S0w=; b=Li0kvF+Dy3UxtBf/VYu1ZuAUNqVKmottmAd/yRy62xa9YFYT/Z5DJpf11CghWDeLMNsdm8m5+6bb3eUEzFHfL7Y/QmM32T5vhkg4fYwNTxgn4QVmt48GieNJQEyYEjpdCSHoTLR9kPfWSlGRdj85Ls7Ke3mhM7KyxmGTqQxFJe8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17373950579211.532521071043675; Mon, 20 Jan 2025 09:44:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvme-0004fZ-Nb; Mon, 20 Jan 2025 12:41:56 -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 1tZvmX-0004Wt-KA for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:51 -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 1tZvmT-0000Yo-8l for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:46 -0500 Received: from mail-db8eur05lp2106.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.106]) by smarthost2.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:42 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:41 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394905; x=1768930905; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=1IHq78BYelvBVFqSgj8wg7Wu+RzQhCjG5QqwwNWlpJE=; b=JMilGOXjA9O0FZcGk9I+yFP2c9ssNezxOqRjOkD3hPwc8IS/f6BpnDNK g2DcgGpplpGiPEHEDQbAO9N4+sjwlOFGMbaSCyXtrI/4OLHyBjKX1Oh79 3LwzqymR5oTwAFsKdha8Rqql+0hCQc8r3ToTFF5MZ/EmDIR8GSb1nb7jC K/+mIVAvc5RBQKEC8KDwWe5rb26GRavZVhqxFt7r3kWCKONyVIipR/2Aq gZrZ+f9hkYNVNL0cVck651QygkqHvKpckI2/5fpPe8fvpOSYys9ND0e6d m4mtvDMwbMnCHvr8OVy64pj55ZNRgrxznouxFYPKKuySQnqbb8zoPbxIm w==; X-CSE-ConnectionGUID: pok4FplYQVKzdHomUs3pCg== X-CSE-MsgGUID: U58BKR2YRl+Wxv9EklmCXg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125306" X-MGA-submission: =?us-ascii?q?MDG2GIIuwTDLWn64efUFBUnYq5O6WeeW7k8zbZ?= =?us-ascii?q?noo5h1BUGzkRxksP5+TU9g5EIpFIQlJMNf+1o/DC0G94xStiMMJMUt4w?= =?us-ascii?q?cK4lhZxD8+BVNtFxB7XXlpv+LESJETnrtcEgsxRxTOKZ5BY8aJVWdAbx?= =?us-ascii?q?cjzoqKqgK4iFxC5Rhehb0s4A=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nkjhhY+2+07zRne3zWdwa+Gg+5F9GZK49k0jrFk9yakEca/VSP02+rJKaK9Ofgfz0imF/hBta54XziHAayD58FeeQpcXmLLeEkrSt0V27WAjg505czyH6Hz1rIYzdRxv3hCK33QY5xVBPe0E8MrnKTqcfJLp7cPRwdGWzaXy4isHa3goYpYxLMGEoufcL5Fi+3zYuANGrhZTuVAAiPlxUOr0h/JOF6JkynW4N9c0A9sDjI/U9R1WQ+uRrO9veyMARFq6rvlje2/3lSU0GFEfRw9X7ae9lzXLkViAjJW94tnyiQHv2pOqyvIaEq/VOxTm+Zd4k8DVth+DCscQ3cDzWg== 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=wBCPTnyGGbWndBc2Xd/ytVLloQX3gIb+PHViU7P1S0w=; b=gJP6Z/v/SQ4J2dl2fanbRvI3OZBOBpop+K1dutRXzvBsdAVB3MNXTTWUXLtyAx3WdNtekmu89tADkBIzfbarbluL5+IMbx9rRGlgtzx7S0lxpGA74sQyGjEcfZdFKIxHzR3g2liOeDPb1LFEJPsIxNAjbgFDW9uyjqj4E0ztxwNTjFpEpq13trKyDZC6vVb+/Zmuj5lnCZYD53Ez2eGXUXOb2qiUP/ifbSXmhQzp6SjMYoEAMJA3zUZB0lnk6DKWuwbv4hT+O4dHL6lHO61/Moia9Pq8xi/PFCYr8IAENwx3a09Iz1Sd7CIWiUgQvTclgyD/fQRRraK4t6dw2jxM3Q== 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=wBCPTnyGGbWndBc2Xd/ytVLloQX3gIb+PHViU7P1S0w=; b=TcnDB3KtF/Ciy8Ff5LHQn3tmv930Dr/9bv2ZM6JdCVUYvAdicn4ovDpIM+cAX9IHsfISKa74M3MwGkyOfrbUG58X1kfzsuMhZPH1KY7zOQt/BnF8jiwmIRj36Cc/m40fGJiOM2hyFVIGIW2Urgie1CUyt2cEcPkrCbDs1nDf1imuolsfLsyklctZuYidZ4Xx3eBQFLNZDzeF+XaxaEmIlRsUq0ASSHPvc/DXB0ZtX3wu5eEJLoQtW6lkCx9jsNFDwg+JPE3OxEgsNu7XYQuIJonDQ29uDPhVIJRxT8FSTZYYbDUNGZJi8tjy9zWKNiRu/25swKRwdt2pTdqG6HpiQw== 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 v2 03/19] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Topic: [PATCH v2 03/19] memory: Allow to store the PASID in IOMMUTLBEntry Thread-Index: AQHba2KQqGWs+S0pR0S0AsCg/ViXhQ== Date: Mon, 20 Jan 2025 17:41:41 +0000 Message-ID: <20250120174033.308518-4-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 859260f2-8915-4b60-5e94-08dd3979b315 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?xtx/5E6NbW+2CnukQbag9JFe8917vNBjyV6BZsvVuObZhmVfthIqX0g7mx?= =?iso-8859-1?Q?3Cl1cfYRn6Q25pUcLpLq1F+KHsaalkoTIFG0ImR5p8auYQSJwDHLIlSrX/?= =?iso-8859-1?Q?gWXOnCakYWR3r9mYMXMKREpA7tjKXDdq9E9EqnsfeBYbCs3qOFaa6aN0do?= =?iso-8859-1?Q?F+pF4gvahXpRu5ilfjj25Zz13FtZPDBkjT81n71Ocqdk/UTJfUtqrIrarj?= =?iso-8859-1?Q?Smd/d0WNgK28gc4PTLEzqWTgur7eBs/av2mNLY9juO06wE9jtdidCFFXUp?= =?iso-8859-1?Q?WAsloGJlPmFfjdLmQCyXKNzdy8aM4iDwl/vbgzqUagcSW7QVCyCvbgr7Fz?= =?iso-8859-1?Q?4jn670cobjCSUR4yd6TElaUMIFSpgenvR6nW4mnkBK+nuQRhtoURyFVoo2?= =?iso-8859-1?Q?wDw7/q1jrZB+hxhfF0PMVU/fbzG59xXJiGPf9HLQ9cCuV/HqI5wErKRd3d?= =?iso-8859-1?Q?VCP/Z3eNkfT2T8v1Jpqv7OOZBwcKsJ6E1WjH3EMh6yTShL+g6b5IJeoDmC?= =?iso-8859-1?Q?UDHKE086lsQKsdoKPwbildIi+u/S9Az6ZLCvPBCLJrxbBxe1VjTaYxJ3Yd?= =?iso-8859-1?Q?403UWBf7k0qyDUHde9T5gcGGONFIRBe2lPB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xbua/YM/WnyagwZdPCKy?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?81Jbk9arfr6BxLPTrKuyDEv4UVcpkABC8XIMUxe5ZgEBZ1zuRpTUM65NMH?= =?iso-8859-1?Q?BrbC1N1K3DYy8bCNtxi4D65dp615yf9Z2RxvkoTtfvJFjP5PlQsuOsucKN?= =?iso-8859-1?Q?6f/y8TeKeWD0YSW3D/GlwEZ/yD2QFphiYnR1jBRcxVFXtAcrPIa6T0dPcG?= =?iso-8859-1?Q?YHvPeY6rgXUeJdB3gHl3WPRs5+KBUrL08o7kpK2VncF/B0jg73VmLmigIy?= =?iso-8859-1?Q?tiFNeq8v/hk6J9NHs64R99TDFSndw/gfkgqURtymxhMaWOlsl8rOq6O9Nz?= =?iso-8859-1?Q?PsPZ+eHLJFe3BLqK6CM46NglxiJ7UbOrX8b0KNJrtb81gBBoLB6y9EdXeJ?= =?iso-8859-1?Q?OdZSHKqJqZOvC8gcYgLKlnFfhjYn5fNuyNmbY77J3H9NGIHqANc9jSdAYg?= =?iso-8859-1?Q?1Ug8CHvwjL3EIgU3ZhQ7szpaS8neTDFvPy3/OE6zpaOJjXsN4l797O6TTl?= =?iso-8859-1?Q?jDq8ow48fHYz1rELU1RP3O8ueHEqn4hVzpfF7eyx3G+VPh+Wqk5D9obHuY?= =?iso-8859-1?Q?xZZ4rYN4AD/2mKbeHABIa7f0D7nwYH+6QaLLmredeQdlt3SJOubb5mb1P2?= =?iso-8859-1?Q?OZkrAnsT2U72r6UPLqq+RjE04AFNPn1hquYh2fEZQQz5a/PYw826Ep4Eb3?= =?iso-8859-1?Q?FKHvH90rC4p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WTGpan+7+?= =?iso-8859-1?Q?FEkoNCfe8hGcUS8Sjtz4cu7iDJdE4tcr5xnxkc0Muih3Obu9l9kbyuTInp?= =?iso-8859-1?Q?FO4njY+gghKYNELCWMkjeIbAw1XjHkH+Nc05HfbQS0I8oFa2FOT3640Ywg?= =?iso-8859-1?Q?iV/o4dERv+R15krtdB0=3D?= Content-Transfer-Encoding: quoted-printable 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: 859260f2-8915-4b60-5e94-08dd3979b315 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:41.4423 (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: DjjAvXkCjdljKC6bRZO5Ngl3pIPb/5+YKzWXS341Z3ZwPGh3xyl4460Z4xoD/hA2WrkgqYzjVctIGEu+ED2XG3ynaCzxPWgmbw9OcIVnyCWVWqfKMLibSPuIfOxkSO9/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395064847019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif This will be useful for devices that support ATS and need to store entries in an ATC (device IOTLB). Signed-off-by: Clement 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 56c3a3515e..9889b97abb 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -145,6 +145,7 @@ struct IOMMUTLBEntry { hwaddr translated_addr; hwaddr addr_mask; /* 0xfff =3D 4k translation */ IOMMUAccessFlags perm; + uint32_t pasid; }; =20 /* --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395115; cv=pass; d=zohomail.com; s=zohoarc; b=Q/NADMWNNpp7elogvRnYdN9mXME2AzLHLWGSukwv07gmfF6ADL/vvSbVLH24V5K2Pz0kZRb9QsL5coRBRHs04T8npxHgumaAjzF++PzHr+yZMI1sEgqBeg3Oqvcur78C6PK9N8tkAA2znFHb2HLT6WCEdY364sYwjONt/qiUqlY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395115; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b63JwT/W3QFF2AdBMAfGy1CbHlCNQp2Hc5PSBtMwLlU=; b=DFUAhxuq2TTOCv7THjzp7ip0Ol70WM8bG3CGT1J/chQn/bx2EaQjtPcaU6zIOk5rmXEQPzVJmJMccuCpfrWN2G6eb9lyxNjl8106X+Q9T/Igfuj//Spjc3F7rbZcjhqEqV8tebwX7qIyhpomaTB2ePxPkPxJs85cg6+ZdLp/rgk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395115035389.5040911814946; Mon, 20 Jan 2025 09:45:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmd-0004eR-7P; Mon, 20 Jan 2025 12:41:55 -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 1tZvmX-0004Wu-Kd for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:51 -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 1tZvmT-0000Yv-Na for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:48 -0500 Received: from mail-db8eur05lp2109.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.109]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:44 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:42 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394906; x=1768930906; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QjevDev5eUjw/Y9whaZdJdOcVV49XsTnrI6bYczFujc=; b=uEEZVyJ8RD0tft1Wdw7tvVpCFKE5+u9Rxy7t3vPk3qMiSCFBt4XxyZcQ fdGJdh69HH5djQWWBN6mO9KiiAKhXgvD7MKDyCaAycuAZT9mQUqqKgfMs pmMYuY/OdskxXwHM2zlafI3fNncCYR5gmn+kwQ7nPcVtAxwSchJGF6OEj EKxSFHvKJO4k9/SzH8jQC85SQB8CdwvyaBpzQRs3xujodkRnp06LqTsv1 rrBOD+oAMczqbSMy/LzNTrsLa9OJkjfuKubDlS9H23pbQoShevzz4niZR 9gNRAi1rsBh+e9N+gVNhRHPr84KQ6+InKYL/dwf5tK47Mkv4YO3m4PYk1 A==; X-CSE-ConnectionGUID: 3WduwJNfSP+kKivNdEI9dw== X-CSE-MsgGUID: eXMk+PatRpGzdScCjX2iYg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291718" X-MGA-submission: =?us-ascii?q?MDG/6lSJ2nWNtSvvvMbTYkjUCjJuxxLnbWBUlu?= =?us-ascii?q?dkX/wQz4ZAsxYNfW6gGYVkpaELUBxiwEXuhqDsxqD97GjOq1YL9VC2BZ?= =?us-ascii?q?8dYy4CGBjfftpVVGPzamJooFvJfC0RyvemSrEGof45VE3g17XH+yN2rU?= =?us-ascii?q?KGmgC7YpOo7U04d4+qA+E2tg=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iuaN0LgXMsD4CS98xsJfFqP4h/QJxMiOJLa6ozhilUkJk+IMh3b6IxBGBE95hKu0Q41U2E4N5WuDSjUwux93EyRmh3jECPAk0UeNohwoK8foShSvMd73iBoojLpEy5UQhGA4NGzisTFSEWsmfrsyXY7PLhmWlRJjxy+D+zEopaIlERZu6jR1RP5xsqmxm66rKRXtAFmscL0ZBMJ8/ynUu8GRi0GCY+enlzroMqcPL0dAZNIwY2SBejffn+rp4FNlelr7V4XR2lKyolvDfNeRVKkOpUrnQkigi4IURflxA12wyJspR+mEqe4ePUC6seL7E9jBbPxWOW1PaH8c9LBI+g== 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=b63JwT/W3QFF2AdBMAfGy1CbHlCNQp2Hc5PSBtMwLlU=; b=KaUx2u4djsTL5rIu8IR72nXGE9tSw27J+nyPNNma3/8Jir8hGjab+1YdDV2jTM1DWP6fOj7OgpI4k7ij5a6VX/mRHElzKlri84pc8UuXS0cennjIskvdqPza1oZWFpRn0zwKiLXq4YjqqKS+HdjEKbkhIc8ekmVKPWMMczgXCSLRzk+a4jnpAse0rKtMC4EY3KHhZOiR/fhSD1SDis9e2wotSEl4UEWNnAL8ibzaMghVSwPCYgBS6c5h7zvvdfJDXFJHw/u8gitx6zm6Z6UsEyS6fmv1iBU8kqUaKXGCosfnwAY4dxBolrvhaly/vjmtm5lxls2sSHOwAXCWMRA1Sg== 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=b63JwT/W3QFF2AdBMAfGy1CbHlCNQp2Hc5PSBtMwLlU=; b=O5bWQ4dQ5yEdOaoqUf96t0hyhaBB9rWCADwe2pmGRrtliySdAdljJxerSoeq6GYdjGlsvwIJfutxtHX3qp/+7M9YNlYZ22Ubmx3uq7Go0WDSF6gRPgpLArckgOMGoiTXIITdHBM4OUOvQog7KPYJQFCqKM8a0idyw9fA1SCFUF3aK5wI2qhsO8enM3f2G92/29JP70BoRIW+dL0JJj6lsmd8Myy4DAXyOWE3kgBWJ+wSRGVDy8iCPd4UhPmW5sPNvw38BlaSyEH/RI3/5EIKyuJhUVq3iYcIni0G42Dg4ood4v42lX4aTRicavt6xkqtTBIwBeoLo3h5lbS/FpVUbQ== 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 v2 04/19] intel_iommu: Fill the PASID field when creating an IOMMUTLBEntry Thread-Topic: [PATCH v2 04/19] intel_iommu: Fill the PASID field when creating an IOMMUTLBEntry Thread-Index: AQHba2KRHmsbEDO7vkC0f7S4oxcf8w== Date: Mon, 20 Jan 2025 17:41:42 +0000 Message-ID: <20250120174033.308518-5-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: b4fecd6d-caa5-4fe5-0c90-08dd3979b3c1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?RrtJGn5CO09ADkbO06oTjsMkXpit4IrzYun07TDmr+BAlXGluiflnd0e/1?= =?iso-8859-1?Q?6vmYAHLD8BC/FyMQqlojsLK6glWS/aqWnkF43s6uT+PLkqfgbbLbo4nsLo?= =?iso-8859-1?Q?zaqWbQzk9WIPgr8QFoDW6WZ/yvikW5Bef9qVRGhPIuo1xsEM3rzCoOkQl9?= =?iso-8859-1?Q?K1pWdjp4LcgH4qnoROUC4rDHC49qXszD0+wXz1oz3+5nKLvxdweYKBjaYQ?= =?iso-8859-1?Q?9gIzqgUxC1fVyBN80MlYAFwsnRnoIyk0oxKTjbXC/FQk3pvD8AYlCfKe2e?= =?iso-8859-1?Q?F+BnaX6MkaL9UwQRYe9fOfGl2RzxE66PpfVLaAUBFkqL/VlviuanbzY4s+?= =?iso-8859-1?Q?GycBfhs6wNoEb4bQ08BDh1shmGJEbNWFwn4TEZ/Z8IUVklkmgZSn7AycEV?= =?iso-8859-1?Q?GdgsmGcbYbICGHE+Vi5u4+xsS28OwXKdCiEeb1wlHhnwrsWQAiQTndZRT2?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CYojBnUGjKcwnI6wpJAhu1V4Q5dDb+T1gR8J?= =?iso-8859-1?Q?sgMw29ITMaVQxEGz6imoq5fv51Kw+/HV7vvtQDAFlRniUq64hH4mjH6m+o?= =?iso-8859-1?Q?KB6ngCBohbbGZABzMGWjAfe5ybtnLTzmjgMsOcma1Pi5tWmBCwck7+zlOs?= =?iso-8859-1?Q?+2mPQeJry0DbUnvEQP1erH?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?T3bQvEspttPUiBx4yBQa+nf1CN2FX2zhTbffC3XEFIl0wmv30mxYg2rEJD?= =?iso-8859-1?Q?i6TVjkHHv0W/5Vg61vOaCeoGMpkVYUyyphDxUDuPXiE2Fkz8zp33qMNSiR?= =?iso-8859-1?Q?XGKzglHnOxVO+2t1M92wFgo+9YXkVMVhbEfIvnr9ccgj85rqMLA2wtx1F/?= =?iso-8859-1?Q?fF/23Z/gZ8bmYFH4FdDh/ltnHiWnAsXpHjAvaD5QWkPCD6WzrmHqbJx/a5?= =?iso-8859-1?Q?SrrrpICiOKHZO+NNNpXB912TQgMDXz5rfOXMfDSAt7Mq2llTl8r9tIGh6L?= =?iso-8859-1?Q?kasWCDBIEZqzZ90Z7mJ8dCFAhPLjXl6m1Kyv9xv/xjcu7URolRqX6z0PrK?= =?iso-8859-1?Q?PMbcTmpVD3F/XiVrQ6Xi3w0RSedQCpB1xz0Lgy/hUmGkTRdv+dSbRERE7r?= =?iso-8859-1?Q?kq0VgYd8JBQfqgqnozZAPfdsjeoEtYn0uJ0coK76+Trudhp3Iiezh6mpcO?= =?iso-8859-1?Q?ingVnDI1x3tTJfKQjpnW6bKrjaP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M15puL0pfuvjhMjqq6sf0DaInhF29SkQy5+gOB/hvQg+nJv?= =?iso-8859-1?Q?oz+HnEv+kvf9U+fHVt3eaesJKu86WKMJP8HY+yQ+GRuXLhWfluC/B1nmyI?= =?iso-8859-1?Q?Wcl0tPCGRkmp9Hn+cQPr6kSAADMMAv5rYuKoaU/nVlJbgrbET+tB92E1sf?= =?iso-8859-1?Q?exBV8GoVVvutWsIM2O8CNXefpMpzSNfjIVbZma1L8rG2+194yRo9n9LLhg?= =?iso-8859-1?Q?KG+aIKRPZbvrjU6f4KVFFkE99hEC8JkXlj50k+opqwM6aUAodsgZBM2jyB?= =?iso-8859-1?Q?0LdMCVrqKkN9rZQG8Ac=3D?= Content-Transfer-Encoding: quoted-printable 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: b4fecd6d-caa5-4fe5-0c90-08dd3979b3c1 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:42.5570 (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: T+L6aVUc4wM1aLI34lXfkC2LUAejSdjEwGi75xpStfKtZXjVL23ECCITOJuqdSbDbdPfmEsjDiMhSSQ+ouDjiQccJmD1ND04fFsFOOXrcsVw9D56T5zsXQLhXPPo/W3d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395116728019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement Mathieu--Drif --- hw/i386/intel_iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 1d5ff8f4f6..c58e18a56c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2511,6 +2511,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOM= MUState *s, .translated_addr =3D 0, .addr_mask =3D size - 1, .perm =3D IOMMU_NONE, + .pasid =3D vtd_as->pasid, }, }; memory_region_notify_iommu(&vtd_as->iommu, 0, event); @@ -3098,6 +3099,7 @@ static void do_invalidate_device_tlb(VTDAddressSpace = *vtd_dev_as, event.entry.iova =3D addr; event.entry.perm =3D IOMMU_NONE; event.entry.translated_addr =3D 0; + event.entry.pasid =3D vtd_dev_as->pasid; memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event); } =20 @@ -3680,6 +3682,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryR= egion *iommu, hwaddr addr, IOMMUTLBEntry iotlb =3D { /* We'll fill in the rest later. */ .target_as =3D &address_space_memory, + .pasid =3D vtd_as->pasid, }; bool success; =20 --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395034; cv=pass; d=zohomail.com; s=zohoarc; b=Fkl6c3/NP3RZoZwTvFNdSt2AzFmMEF+j7zk6gCuaYTFTleszXcKTUrmaDlEhnZksJmKUERHk9D33vLcnd59RedpE3SqulhY3Kwkwl6OVZR3MiMERbQRzVQZS1psWhG+x3ECvmKBbGx3JCxCPUQwhBtOHKDaPds3KR9ntvT8NC/I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395034; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UuG5OjThV8VBS1EM6QJlXXrLyzON/GBiTeb4xCqjQlk=; b=RrCL6Qh1AHULjh4+dXtxWWOUng8KlfjyiBOfd8EmtVlh/c9lWqkkDzAr6Pq/eAUyYf2Oj8WEipGAATlcxkef4jEV4s03lgXfexB0AvM8BWtDb7/v7+RO1/KFGQLtDUEKsBBHRYl+QaVqHYukrdAv5qH98KTq6QOpkaEZ8T0o7C4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395034878750.231878044986; Mon, 20 Jan 2025 09:43:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvme-0004f3-Ja; Mon, 20 Jan 2025 12:41:56 -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 1tZvmX-0004Wv-KH for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:51 -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 1tZvmT-0000YG-Nv for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:48 -0500 Received: from mail-db8eur05lp2112.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.112]) by smarthost3.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:44 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:43 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394905; x=1768930905; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=SCmChwFr652hQ1WXAdzdeZEqcWdhe6cyhklzf5ejZUg=; b=ouhZhzWxEdZl4KGhggeVTTB9PMglI0ske+GVm6PC9CAYZv48mbsr/tx8 SirDAPTL3TA+whnySB8qLekoMA4jD87sJOpc9Gck/FTnZn/g63afH2jkf DIzaFNcLliyOoBaAHJeXXxMdNlafFHVNes+YkKm5iwjnmHFdA2liLxNRz a4Mg/0J21Bd+2lukjoWhizP8O3cjqDINN+KdSbMol1ujCecmCtAK/5dKj jTXVXpf0J/uKa5QGgsfZLUlOSGcfVUvtyMDPdRP3ZEyV4gAnlP1/llpDs tQ4AMsMr4tAPGnvlTsBD6RIjsmQyM6+PbAsnuYdaho4TDKWVOqS1h0xcn g==; X-CSE-ConnectionGUID: 9pnGLJgsTV+PK67oV6bxCA== X-CSE-MsgGUID: uQWYnGzhSdGZDF6sMMEI3w== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125394" X-MGA-submission: =?us-ascii?q?MDFokaHJggJzYoAu1CA7H5E2Ip7Ta3KC/vNCO4?= =?us-ascii?q?/MzMCKXhA/QK60TRK9V/8Ufxv9+NgaUKniRWkSpCwK5bh4Z5E2gYH5+F?= =?us-ascii?q?95xJsCVQ8xAUUkkwL5WOI7Lt4JcUt9QIBudEu0k30CsHDe5an90Il3+L?= =?us-ascii?q?pJj/gjolzMoiBE5mCJ8kNz3w=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c0dg+zBdhANzNkhVOEJvxnuEEdi3pJi0SWUEKvveS3YN34N5H2Z9SHQn43E4nkP0eRINLPa99GWLsXoWq7lBO64GqrQfIZ60k+SUV0TrW9i7XfwrcuDsB7c9O/bJy+3fsC+vCFeC1L3ObDQJWwnHeT4K7VhTC6WWPefbfCxAahJK3ibrZtXxHlmxbYfZP77nltqH7AIPkgDkLrFJPE/KJr/DKu2N3fFLtiTkqY741+hcF+258waLrxEP9KZ4BF3xgmIn+6QeMJnOZ+XbmAZz/SgQvj45NilFT96ieuC2ti04po2OOQNSrX/pbvO9peZBSv9DSR/qgqxvW7Kh0S2iow== 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=UuG5OjThV8VBS1EM6QJlXXrLyzON/GBiTeb4xCqjQlk=; b=AgUwgoAttcr56oMjrWuAGrr3Kc/pJx2ogYbO/pHMpuq6WSIPUy9woBotro2ATfK/DZn8zc9ZfOObdeeeicWk4s21TKG4Q6OLCeU5SN8VDFT8wB4R8v1Mg+xqiqA7LvKwa2Nlvbqm0t21KteI9qgI0tPU8Rx9UZqeO6epjP1PntAxOyzfwoSWPDqRBqYw7l2kaNbGsbkIaDt0QQ7t0lR9YUmtLlO5kLPib4atINJQetWdS9I+8sVrFNjtXP8J9iAlVF6NPJAHXuulklgCrjSGMF6E8wCy5oif9xhHyqvNiutD2hKITcV4GQUchrBw/sBBwU8uJjRcfRV8UaKCSuRa+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none 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=UuG5OjThV8VBS1EM6QJlXXrLyzON/GBiTeb4xCqjQlk=; b=pH5U9nniRnPOLTwBTo3FQfyk9JFhAKL4hqmdugskAeyrJGpirM3Y9ajvMY1jfDQIljnoVQDRnjJ5by6hc+YThaAVJFx0YrG1gVaveiWO8B9oQAtFXkvi9BpoUSjVGzeUpryJ/ZTV+x6AckSCUepoH3I5EkTatzf+RadyiAHL57d9MR/kvFetXG4RBqTVK6lM94Qsc8QXUSYZyrVG8zpMFN+XIErM8NpTheEFvylFYFUSlovSVSEycRwU/sUrXQwxcUPt+z0yB0bO/F51uamQuugX6lbqpZflpFV3pPGIP28DC3uq/BY9nhDk3ifdG3yuZTDWIgbu36zfZdLlc76OWg== 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 v2 05/19] pcie: Add helper to declare PASID capability for a pcie device Thread-Topic: [PATCH v2 05/19] pcie: Add helper to declare PASID capability for a pcie device Thread-Index: AQHba2KRuVRpVIdPc0iwYyvwuc4RKQ== Date: Mon, 20 Jan 2025 17:41:43 +0000 Message-ID: <20250120174033.308518-6-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: e977585a-bb12-478a-3a03-08dd3979b463 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso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p2jKcTnAyAuNrVpRVhc++U8FTBDJD5?= =?iso-8859-1?Q?8RLgjdvAO3ljhLy5DriMKBO/VMEDiv7FBo3g2jguDdbHzJzA6/xy0+FUVR?= =?iso-8859-1?Q?H2SqYQMoh2V24yNTSlWbxJn4LBHIPWnBXCIKlt0vgo3Tb3jO6kXukEN1H/?= =?iso-8859-1?Q?YN5xpUK1portTZFEJqQaYBVwz3L0Uzw/pH13UoNO1mcnSw2y2bPEO65UX4?= =?iso-8859-1?Q?AC14DkJPjrmccY4fW2dmrPjMjtEc3/qT/Dn2SYem/O0X0vZ7y88/ggNWyL?= =?iso-8859-1?Q?79OP9rZfXIT2ocGlifw2jlEKL7ZUqObgeg7bMfcEVs1IjVuzgXgnmR7a4I?= =?iso-8859-1?Q?CObSsGUXFGWXUYsshF7FM61VlaLMiznlLqdkvaNb2j0+pWwVkRCxtCMmRE?= =?iso-8859-1?Q?BofKJSqCer1LkbplGkfKUVPBreJcRj5ATsbofqCioSL83my84++BxFkwtb?= =?iso-8859-1?Q?NOUAWRm0SGo7lykxmk8CHQg4KMlORZdRBcxHpDvLz/7NlruVy3HAvxSr2c?= =?iso-8859-1?Q?mXd2KWqulTf/C1GiMDor3AOpLmYu4c5N2i9wKeGyQJsOWqvQbgCoG3ASFL?= =?iso-8859-1?Q?uDLVAwfzE3jCRmRiV7dH17ECUFatJCzJaQyhzkSM6b2SvwKrCWF+7+8h8D?= =?iso-8859-1?Q?ijwDqW4g8Dx33cm7zjmmdS?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?reMbc6pHt5V3Hl2XyFnEfXpuSv3iO0CMiBd2Eli7jAhG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IGvWnMfZsdtqqJWW5XwVqe7PvsN/ZusgT?= =?iso-8859-1?Q?xRdbfwpoVpEccv/RzGS7+1xvLYlDbj12IqctmyufLk3GIz3U4G6DTiQDXk?= =?iso-8859-1?Q?jSTKhWR7chk8POveN5/40q1CKepMCDRjwgfkjqPlYTaXcRws2C+uhE2INL?= =?iso-8859-1?Q?r9+tAPv2kZWZ/v6ffdfMTmndVY9UAmFT7c9YQy3qIJqe4cl6IYdu4MwLfr?= =?iso-8859-1?Q?MDrTXNbP3a0tXBzYrrxuNGv5qN7sI0lYoB5p6/FNEwqADIyU5PEEUAadOs?= =?iso-8859-1?Q?x74jyZ5X0Mg2AqSoT3UgYiS2GRE1ZDgeu28z6un1xojgMtJ/xwo+7YX9ey?= =?iso-8859-1?Q?7V3AVtuIGqRFg3ZFqxQB3nHGvSZkfRWBZ2NP9H3zN8SkRgJT1njx7Tr5oa?= =?iso-8859-1?Q?4l5PT0KuaA3ex8gUhoXPV4Ua5zb4PqJUHDJBXzkXSKEqIhUOm2fhqkoi6J?= =?iso-8859-1?Q?UCpXAc+ozRWN83XPNiTwePGG8wY6w44zO5O7Km2EyGLOwc+GC7GjX5aqXv?= =?iso-8859-1?Q?EXYpP7oqm09KjDY2Ur8B2oarGcr9kmN0CN0rBPVPa5nGQo9Bhc50oyPNWT?= =?iso-8859-1?Q?piTMDZPxfZlRP0ejoQJOWrkohauyguzgZcWVrG6nOWJq46RLBqlGnbW3PJ?= =?iso-8859-1?Q?yJmtnWzzLwDRdiW3Nr+o46zCoAsrTDueR0hC/KFrqYMQCPzWKrxSBeZVbD?= =?iso-8859-1?Q?FYybqr/+qtmCrLuvSpGTV1tvmi/1rXhkRiDMEV20pz2p4cDCX2JxoQc3Im?= =?iso-8859-1?Q?pJPMXrJzkoVjwmKAkgs=3D?= Content-Transfer-Encoding: quoted-printable 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: e977585a-bb12-478a-3a03-08dd3979b463 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:43.6195 (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: 6IohCsCXJ7wWiS0QWpwk48F/mbYj59j7kBc/Tmin+EZVZ72ZD/Jh8X+thNCHX9Gwkta+iL5ac4PctPBUl5yXEYneYYr2qZ55CqRm41FUkinTeKlVxSbOppUBcqZ/D3OZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395035715019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif Signed-off-by: Clement 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 1b12db6fa2..f42a256f15 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1214,3 +1214,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 <=3D PCI_EXT_CAP_PASID_MAX_WIDTH); + static const uint16_t control_reg_rw_mask =3D 0x07; + uint16_t capability_reg =3D pasid_width; + + pcie_add_capability(dev, PCI_EXT_CAP_ID_PASID, PCI_PASID_VER, offset, + PCI_EXT_CAP_PASID_SIZEOF); + + capability_reg <<=3D PCI_PASID_CAP_WIDTH_SHIFT; + capability_reg |=3D exec_perm ? PCI_PASID_CAP_EXEC : 0; + capability_reg |=3D 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 =3D 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; =20 - /* Offset of ATS capability in config space */ + /* Offset of ATS and PASID capabilities in config space */ uint16_t ats_cap; + uint16_t pasid_cap; =20 /* ACS */ uint16_t acs_cap; @@ -152,4 +153,7 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_de= v, 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 =20 +/* 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 --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395024; cv=pass; d=zohomail.com; s=zohoarc; b=XJYOJQoSl3Jk86h8ArY3/nPMQIebgZj1xj0zTD013brBO8ZgQQGD+5RAbzuKQno1kbsn73eGxfHG2zeBy2JDJj6Hr2TVBTmoBUf+g6tj+tXnXxRkZ++F3N1SJlL0LQey7J5gfMII9AMWHh9qK3ZhcBWw2v4Xp3MKNUnyyms5okI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395024; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iflbwMKRHPu/81SZW+ngwd/GXI6yY0hn/LYJYOaw8bI=; b=QAzgY73ktQp4hzz50vzB0/7bNolcqXaquo69LwYwFccm/q/+pY24wZthbB3AlrENpJVNOok4vxA7iPPycGz10nlFR1enf99VxA+k8lqFKLr3WRiQoRGqKmIVOiCUsmFOXnai0XfoPnN0+KnP4ip1MVBMznNwVF1/uNYsE0lzl+c= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395024863154.35606060928887; Mon, 20 Jan 2025 09:43:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmd-0004eK-6H; Mon, 20 Jan 2025 12:41:55 -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 1tZvmc-0004c2-3f for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -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 1tZvmX-0000ZN-O0 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:53 -0500 Received: from mail-db8eur05lp2104.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.104]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:45 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:44 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394909; x=1768930909; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kX2S2fq6b8D1k6opTFdMUw64SYd+sruvzT3Q+IJnIUc=; b=ImoQRL6ArGGNg9oBVcfI/8rusnlpyHrup3pP9zxEYiyNHeXXw3cuMGvm GAKIPRXEdzxyPOUsFYrNoUXhclKXHqOryQ+7gBhv2iOIQ8ShJxsruxFVo pb9luDshSmJAJVaonK/jFvdGsYm+RmFV+pnbTOVF5eyuBjlQOP8uCBM8T kEo2EyR87Z9j/MQEhe2YWjSemTcYtXn44wTqrKYCJrOv5+rJAdHJHHFWO 2xMN2RVx75VmExQhGKSEwzGVezieiBbHAG34ftdR01zxp+8sBVwoXcDwn +EdlPWYZBU9P0ED/KVr+9y1MWfy2NmRBatIS/IncnvujdIA8nPplrEtXn A==; X-CSE-ConnectionGUID: L/KexgJvQNyo7sgych1f7g== X-CSE-MsgGUID: I4Jr+GR9QYGKqou3y8PdSA== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133395" X-MGA-submission: =?us-ascii?q?MDFpzbeiaUZhiNazcwuLI3kO2akcxy7lRnst2o?= =?us-ascii?q?85N3lAhz64BtBl4rvRz8Nwv+iwJRFxzx8a5D2RsH9i9d6lszY2pDxwz/?= =?us-ascii?q?pFxt/fZ813swOD6KTvJE0FqladSvm7xEuTB8luUVx1/W0egNGrLsFnhi?= =?us-ascii?q?5C620eVMaWP/hYxNx4R5379w=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NQo9+Xt+BSfjOXP66x7xNQYInX6dHTMctrbild9vsMCMoYRXeD7JH0v0qCdTqERjNLBmh+YkZj8BU1oJkPSyutXdKXKwOx1YUlOPBpVyVsNlDGl9n6WV8XGVYOg2+E01kP68g17rv3Cp2PBAFYXrtYxzzuAFs0SfO9xhzip3tPcd33rdj4RsOm83WpU/eiIm5lwLSlU5RxuG2jcgC0nQBbwRPdo0zm/BaxIP1msSC20hv0kIlmW7uP+WPBIrIhhQBEHy++L8KhIYRJyoZ2ypiLAAJgC/JDYE0eqeFiEjOF2gIpsIoMHYxNakpDtZmjK6pdt/NLkrOXhUitHS14ijjg== 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=iflbwMKRHPu/81SZW+ngwd/GXI6yY0hn/LYJYOaw8bI=; b=FPoewcIsKYLgxBllCZ0acXxIxM/tMs82EvDNAFBj+qBe7XQOscEtgxrklk2I/sIZMhhC3rx8H4hucL9+SexAbQJC0kfZ2dKMjrZuQ0kKnTYTWW+2kV6PiDbm4oayI1LDeJqWr5bEARe9Ny37OTathm+0qJitP3IgrCeO5eAmDkU9OPN9JSzj7FNUV2d5u1KhB2CCUXYokobhkod1D5wEZslfJazk9feupaIpi3wlPX+QpTSpKs2rKvUJmI7Ql6hFM1RzHfpy07upBfdbJx4RW4z5pPZnBJofywhFUqyieJpEb4baJpSMa8eF75L8AeGHektVp7pZQtZ6WJaEAS+mkQ== 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=iflbwMKRHPu/81SZW+ngwd/GXI6yY0hn/LYJYOaw8bI=; b=sk8a+oeoBFAamxRmMCgZitambQNTvVEO1lB+bqYc0kvsJ+nnFKWNzAfw1TbeuZutAjGptYKdEpub3mk+szgs7qyz5LmYaNXxP1nPDIoIgjDFu6tC9g8B7Cw4C9Zdx6FfyWlOfO8WxuGJmlFGi3H/ko7Lhuka6Fpe6aF6XM2pjiXKdB7IpFP4PJxl2soQZLqQqdAin05g9Z/bh5yy5s958bz3n9dkWgGDdf/L9cbPCo+Caq5VcvDc0boSdLidUEYN41fS2kTqK6T/gV9bdbaCOUK1WYF76V5vc2tIQ+loVSokV0UbrJQmJFdozlTvJS75P2gLIQkRMHTDNfpbwhwP0w== 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 v2 06/19] pcie: Helper functions to check if PASID is enabled Thread-Topic: [PATCH v2 06/19] pcie: Helper functions to check if PASID is enabled Thread-Index: AQHba2KSYJRjLgZTYkGGJ4ezUhqhcA== Date: Mon, 20 Jan 2025 17:41:44 +0000 Message-ID: <20250120174033.308518-7-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: c8589477-c3f2-4c7e-c212-08dd3979b4e8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?ciJLkcap7W4WB9tsxT+OwsRU8lmmotqSXFQjo6h4m0lLwaJ1Ha3/Efp/g+?= =?iso-8859-1?Q?iS9cyKe6fT4WxABbOP7RIVHcvk3TGl2bLo6IEAqfLvBUuXm7Apd69xCYmM?= =?iso-8859-1?Q?UOsyhdQNrd8EBAYa6kf4c/ecN9Ez4hxd7ofSCRUy2xJqA2am/rQkWip41w?= =?iso-8859-1?Q?owJV64giNFsNX/1LYLQnDKKgFaTw9W+tUOU4QtqJNrw14cKNYS7gcEDzV+?= =?iso-8859-1?Q?oMC2nXo2oP95BP6YdXwsiKecjcwpkdiza4hHF80d8fnJBL5lK3Sdq+G8eu?= =?iso-8859-1?Q?ZKJUxQ4J+NkcBIL63Mvt9nAexEIbE65eyb2SrXLeiFhE7pqSt8ddcbnufa?= =?iso-8859-1?Q?Nh5JBgaO0u9MD4Tr/QGVnWVue5C/d9dPTDpCVacGniqxmeZ1mPXh2WDcma?= =?iso-8859-1?Q?zv6xb7OjElhkj7pyxnAxJa1X7IF8p4Mg7Ml7qtcmstSefGHe+arkJ4XhXS?= =?iso-8859-1?Q?oOM+5zcV0EQpCd7+Whh3+Gw1kTTztdkNXrhoTfT8k0YP/K8g1p788X+n30?= =?iso-8859-1?Q?G7/wivXl+iNtvS5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5+FjiyR?= =?iso-8859-1?Q?7CmjYZ1n5XOb8LUrTNYZ3zAhuu0hVo2h1qMCW6ttVzXapVxyiR2oXDBJpS?= =?iso-8859-1?Q?/sEYr5LUuSAqsc+ZKmrl92?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?xTGv2G+mzmekMvvQ+F4HG+C/I5/bRIp7XcdcTygvRYVdyVEL+8OTWUTafb?= =?iso-8859-1?Q?Bm+KH/BpsZ/7KrtJ/iVNujz0uPm7Hm4pIH7OGAZYRw9G8gtpy1mXtyqHlI?= =?iso-8859-1?Q?QZGsB4GEBKI/a4GENc8Tt3/RS0jp5Pfqs8bSIi2frM2y1l9gsMnXKUk5E0?= =?iso-8859-1?Q?syn+J/4c+OS36FuFywUCXTEaPA9kV3bzc7XBAbfomv9c0K/BmHElhg0xp4?= =?iso-8859-1?Q?3yDttwb5keALWPOlGQeKSGFkn3HZwNuZ9T4bwk5qtAZXVn2dwdNCYJzuVP?= =?iso-8859-1?Q?RaiOGEQz+OdPIDDcZUazFfT/FXDhnPXRYTIjFxqlaOVoSvNwzpAvrTtRnD?= =?iso-8859-1?Q?n8kSAoup1ppawFiz+7KoJU3zdX6DIIaYcddm7AQuMYIISiiR0I4ldjU4Oe?= =?iso-8859-1?Q?6C42VsCS9R6owImFd4hJChTUlndGkvS2OaU1BlL8Bi7DUtWtuRxs+S6m0h?= =?iso-8859-1?Q?SDFiBWm9uQK2wJgRzkxLu67fHouItfNfhFqgayV3ZYqSvLxEDN78KGlSjb?= =?iso-8859-1?Q?w3No3IVv0rBMF4Ltk/IORxqVXiB+wBw/sLD42v7KycfOSgUMltibTgw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5Mw6dVBrJ1kU6sHXo9CwkYv9WsmM+Qm3PjD?= =?iso-8859-1?Q?9B9QuIagnZSQRBmYnwXVZ5fwfwQINKxj25Z/dyjRyFbVj35R8TU/FSu97W?= =?iso-8859-1?Q?hjft82m39iJcq/TmQ7K/GmmX/KSWXE/fwBmuLIOWXUftlX0v7QpAQTC3HQ?= =?iso-8859-1?Q?BvZ/cGKQLTPerM/scwbES9rqdyN4EPZOME1yZzKfn3cAqvK13OJNEiGvO7?= =?iso-8859-1?Q?Mgjd+n1qvt8FmEvbYk8=3D?= Content-Transfer-Encoding: quoted-printable 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: c8589477-c3f2-4c7e-c212-08dd3979b4e8 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:44.5235 (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: 82rOd/sXJMYWmz3c3tYeiXc1dM9mZk0AIySSbdiL1uKQIpGtLxS5R3iGG4ZD7UZjgVr4BwO7YnP6Rk6Y1Q2U93/tfy/iw0kVVYwRBYdSH+uyhwl8SW16+TaYOuU/T6gd X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395025605019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 f42a256f15..8186d64234 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1238,3 +1238,12 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset= , uint8_t pasid_width, =20 dev->exp.pasid_cap =3D 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) !=3D 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 *ho= tplug_dev, =20 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 */ --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394948; cv=pass; d=zohomail.com; s=zohoarc; b=RtE7KNy7sgwEsasp01RvcCODY9v5GKCYDnefgVZtY5LEKsMQgk07vA/Uo1eaM/cNDdMbICwrRxCpO/FhPI8wi916b8GpNZDIiIygL1L9v5dZPNv/360SmSBvP9GyqJ1inrTBF9HBs/pjHGNj9OWWtCUAvqFC32y5FsrhA/s/FR8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394948; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mxMhYZFYSn3X2ZShgsvqQ85rnjzav49VlNt0u4XhQeU=; b=Xt6svjSruCFxzpWwm+uOF4m2zkv8RixP+D+yRgsWcLsgwBWxrzFOm60Y018lAYfLz7eion226QaK7A+riCYGsQXf5Ax/whXVmQaizD3Xc6XfuIeU45HO1i773K1l0LjAF5r8yT5HgP9qGOkIZaxj+IOPK+223nO0D3+JI7VQmos= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394948742584.0719204134025; Mon, 20 Jan 2025 09:42:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmg-0004iu-Cl; Mon, 20 Jan 2025 12:41:58 -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 1tZvmb-0004bw-Rg for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -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 1tZvmX-0000ZQ-Gh for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:53 -0500 Received: from mail-db8eur05lp2107.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.107]) by smarthost3.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:46 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:45 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394909; x=1768930909; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nm91vlwGe5D+P6Uq5nJl+1ahvziKN3ReGpZa9nFH6IE=; b=d+jViTI9/Syj1djzaDYHZkDjt105W0O0GP5aDz1EjqRSDKOLNYfkb8hj H/HE5VUNFoG/MrBqQuPeFC8UHyiVqp3aIHhVn9B6Dh9q7dMbGxroohJFD LTGzoy45KRXUOEr2J33UWDW4fWtfFK5GMrCjDog3blXFJRUO0QMTrIN3w 5yWCADg/0XIAHdKXENTHn7A2Qb3wI8FhabvK2UevsPp1iJSfLU8hmYh18 s8T9wIXmOBA0gv14i4yCskC+AG7tnDykHs7GJqNcTgBT5QLjsmokSou/s OkaKr+umt0zLWobx2Dvqhonqb6gl2qa0BSbuPUJ8dTDwX/OKog2vgB6HZ w==; X-CSE-ConnectionGUID: WhFqQ3IXR06tq/EP9KJy+A== X-CSE-MsgGUID: NOXLJ1yPSh+YYt2Gvilofg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125395" X-MGA-submission: =?us-ascii?q?MDGCNDPG0jb0gvufw9cl56ciFo57gjLkKQxnxp?= =?us-ascii?q?pgeESJObntp6ePeZkBODaLibps6zj0SgksxOnyouP9006HcLcjHJldMh?= =?us-ascii?q?/8aBpZDiZZ+AYnDK4rCf3MD5f3zt2aLX/tZLwVdWvpstp/aD4Fmv2cgA?= =?us-ascii?q?I4xTc7ngmd3QbrQixQndxPwA=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HHAkGSpQhmFaiTJ7coWpyj10s+lz6cSH6E1UvUM8PUh9lCFFZhCJaKMf6cgiK5RQfsELDj+J4aFMlfXa2eiHJPEoZhIH2Vixh00xvoAwWM4KGwWurfqRmQuTIzImGSrSe2YktmwcNImxO4qtb7hx/d7knALfes7S1L+dHtnbopp/BzbWUBnDba0yiCJnqt3gJIAZKxvb0ME5CNKbJBD2981IAtIarroRE6sYDqdUtokWqsVd8ktSAkaIgi0za8lOQRf6ruEmz9QfcMJqeIO5TwP+F86Gx8pul5f4eJ+MDZY+QdCheq2In8CdbPzx6vVpKMMpxXonzBfeAJTfucG6kw== 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=mxMhYZFYSn3X2ZShgsvqQ85rnjzav49VlNt0u4XhQeU=; b=Yspy+3GzYEawiS4rahghcijSoMTCClDxRt4WW1ZSxy1pmJj+hRlyrUjNxAOOgQwV8vDa1R7zJjw/LBOw7nme9FYCvP7OeJFMBse4NsJx+++LlcPhBee9yuIk7vNe9+KIO9Bq/OYhRdCCSBOhWWeTJKfgsm6d9WTBjR72hF2y9Hwa3FC/xNZQJ6njBrDEgViGbo7rZ/bi3TLeC089RqcH+B4twYUsY2txb1Gyw6Trhw6anrSAZx8ahaaca1XgLH5fKJCfYC/MRyo1585ktcZkmcwcvArVsXEWdVqPs7kUgmVGb4H8OvChsdxkFdBiYeX8k/p8bAHW3Ia2J9vnZZXdqg== 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=mxMhYZFYSn3X2ZShgsvqQ85rnjzav49VlNt0u4XhQeU=; b=e96Mp88oGbuYL31lRMInraFds+Ffd5xSDkHiTZmaqNiQGJ5Ivgv01AfmyMs9yt1c/W4ta0+bxVnF1zm6VsUXgG5A30H7Oz3Hd6VsFXab3LVn2/04ARvpr//5uiQlKrsb/mEskuHTNLWJMyYOFSsypoJYJ5j4UZlPaO9WV+OqaF4NwcZss1nF+Mqwz3jzi7QwOmiuVd/NNiWDDGstItmtid8GaTll/cdf78xWTTOW6VMWAQVbvIZ6O2bk4Q+uNHsZ8oS/eD2qtpVaMP+Wt/5Pv035unpkfgi83JLTZcQZNK80pqtdb7dl2UDnjalku7ipEDxR5sZkU6nfZ32pt3yAbg== 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 v2 07/19] pcie: Helper function to check if ATS is enabled Thread-Topic: [PATCH v2 07/19] pcie: Helper function to check if ATS is enabled Thread-Index: AQHba2KScjmpYxRe6UitchMA/gFjVA== Date: Mon, 20 Jan 2025 17:41:45 +0000 Message-ID: <20250120174033.308518-8-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 7f362ab4-7987-48d6-42ee-08dd3979b56e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?wZL2E1p6PW/toeyns141XkWb6pu3HGrcokwC2mWhiWuV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PI0XZnyDZQt2P+bXffY9WSl6ePKaiUoNt5a3rhz1hR9?= =?iso-8859-1?Q?iBUgs73XvmE5is6pj3dqWv1Bd8jOM/QsxJqcRLzrv8Ye8VGyi/PXpMLrZg?= =?iso-8859-1?Q?jDmj0pemX40M6RPOotxMXAhh/18hXArWomfwcOriAMIRKrDhytMjsTbCDN?= =?iso-8859-1?Q?X//BaBK/v4pW/pnIRB9BITSaw08XI1J88Ouj+ZkAL4SQOguPRAOGGPARtR?= =?iso-8859-1?Q?trIPCShXbnD3lWqfVkaTs3FyaeESbeof6hIcceeao2a7dTZVN/6dpf55RY?= =?iso-8859-1?Q?lDW9iXtvH7fiMkVzlkjfDUHx56QprJJW6WZd6FdCErWQ1lzO8RQEuAuHmt?= =?iso-8859-1?Q?1haY0JwYqQCFiLfr45+U+crfBnO/LvPBFu7qqou2UYPvKxbWftz8Aroq3d?= =?iso-8859-1?Q?cybW4Drg3gnaRCC+voMs4DWbTaGX7DrJUOZu4DNapKzo2DG5RQWl54+LWt?= =?iso-8859-1?Q?qEXV+eQgXIjm15xlWWxG4BEeduhOgAH6zcvUjMx5J9pvug0cQtY6b6SipY?= =?iso-8859-1?Q?YozPEqnULOnX7710JKC3TQzmRY2GyPUTck0Rm8qRTJtTHOulsb63olgVEX?= =?iso-8859-1?Q?VvHK99OpWKuzxMt0s5eOmH?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?BIkAFxVpv9EjB9+k28B0Io9peKTJiH8JuVEoJLzjk/HmSgRV/MfBXifTXv?= =?iso-8859-1?Q?wIvVmoP2svzZntCDCeb9ijuWQ5ep+lsEhY+vjFxq1s55rU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QgHrlBQR8ZxaxN5eKQvlYcReIE+1zehzly3NlFw33t?= =?iso-8859-1?Q?QnhhcjnmuoFK2Y5oubfBwBk3Pu9YvRjWk4uTecHe3TGTcL+Ye3jn5vXa/+?= =?iso-8859-1?Q?X7+2m8AelwpwLsltLr7FKBIHfe/vmkbeIU2IIqo1tF9ifv98XxpoAZR9E4?= =?iso-8859-1?Q?PxXSI6ArS1zj4Kocf1VfbCZfuK5doo/+O05iCt8J9S5i+RH3ye+tC4981X?= =?iso-8859-1?Q?OVKdz2VZ4OKyVWEND4OGhgKeCun4O7HVMYeN8XM6zpw3yF4VogdLrirNY+?= =?iso-8859-1?Q?pZKOcgROajgZEFq1zIYuYC2KbevqQLgsEAwCvwpXJ2v92uhpunLliFrTdM?= =?iso-8859-1?Q?j9ncY1dXLyXDhA2ahLNKo/khTvXHWIUCJgUxWAP7qNGoCLv+8c+zgRYefj?= =?iso-8859-1?Q?e2au3gUGvKFDWTti7fVUjv4sw80T+Ba+H5IX2ZSBd+WMs7HrQ1MDq1oiaP?= =?iso-8859-1?Q?hJkOpXLxWUsdq1CFXvYmYMdN0f4IwYcrX04uZJ7LGBxqX9OgdKAdT0UpQg?= =?iso-8859-1?Q?usNsN2lx/dl4UvHvyM96S5t2FlbYq2AB1ahltsTxi7KbvG915tVktQzk1R?= =?iso-8859-1?Q?kaNCBepX6R/3rxtYuJoUAxQnymB24Gfw0f2I4aHIvnqGbY22baITeVx1Mm?= =?iso-8859-1?Q?TODfR0JqRJ+wp2iG3UgYcLNpe5mHzpP8K+bAdk1ppV2WBlvOb8kHkNytLZ?= =?iso-8859-1?Q?w6rN8+2As4WQkgS88AE=3D?= Content-Transfer-Encoding: quoted-printable 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: 7f362ab4-7987-48d6-42ee-08dd3979b56e X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:45.3872 (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: 1cOlyrk9CRxFuMZe8svV552c45S/x363IcvywTVsZESa9WA6DbfipQuPoAfOW8NiIX+KK0dVMjRafPbtt4FT41wQR19S5r9YdMg4JC3dFJlFNx5YA8cRx/oGCO1/5pB/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394950998019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 8186d64234..3b8fd6f33c 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1247,3 +1247,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) !=3D 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) !=3D 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, u= int8_t pasid_width, bool exec_perm, bool priv_mod); =20 bool pcie_pasid_enabled(const PCIDevice *dev); +bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */ --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395060; cv=pass; d=zohomail.com; s=zohoarc; b=MSeYODadGf9guKTZn9rVZwBENNOwwY2/jU4plYNfsnwqUiBGnb5ekHcv3+iag3gPD/xNTA1JLNDgTDuJ2fhI7hsU2JLqUF2gnsLLHQmXk/J4DKO0nJIkH4qzyYCA5nlNfIlZcFSRJM8ueAW8Edci1Rj6/nrH5BFUnSXh8YJAXpI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395060; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yKQbMkjT4VGlff0Vr6hWS1E7CHdK47iwGetnD3ykSVs=; b=b2b+cYpy3P88U9/J+YMY8MakD9LtEuKecnKdvWeDm5NstgBkFcFDZp392bTwSsCeyUy7oXrj5F2QKBHQIGiYH1pYFhn8eLYZ3eTs3wpDgfY5+U8tCNqv1/3mGfz9smXDYDXtNY9CsQQvh+/yvl/9epnTey3iVJOxaJjwOZqIgOk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17373950603861006.0989396074491; Mon, 20 Jan 2025 09:44:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmg-0004j5-Mz; Mon, 20 Jan 2025 12:41:58 -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 1tZvmc-0004c5-3k for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -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 1tZvmY-0000Ze-GQ for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:53 -0500 Received: from mail-db8eur05lp2110.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.110]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:47 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:46 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394911; x=1768930911; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=v2duwbg7QR28N2W4UNpyDMAV4hcBkv6EViHQREdJvHQ=; b=oJJM7MI4A7XlmQ8xk1LDsLcZ4NTbQcbRUiYdyQtJbb/voA8G/1611qyA swJLPzl64IOewcW27Nd9BBVey+shVqoAN/C9yowB8sCY2dZJSY4RBV/qI XoPqUYI60A7gCYmyltUfy5/U4aABgJ4ROmN4+UQKMD009T4Uyl1oZ2irs xh6PP4zS9o9rKCTDSSdKn0QFoBuAhLUWvzyF7G0oWPmKIAUsPCm3D9qPg oN3OSX+fdxxzwafw+NvVSGcepujPhzTWVXI8nxVqPLzNKv2HslUCSh6bo 4U/l1Rc95219OwzU85eI4vZ0teyNmub9rkMr73v0fdn+IjmSizNNkgKqk A==; X-CSE-ConnectionGUID: R2Sscq6dTPukvu9xIr7/Cg== X-CSE-MsgGUID: vcfcOemLR9CIxhTTUvHRDg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291720" X-MGA-submission: =?us-ascii?q?MDH/PuE3+IHgGnkr/orbSoNEJwueGtca4u5Khm?= =?us-ascii?q?RlVZtzg9z+EcdAiw7xYTC1EqR7IaE7W37oFP3y6ycpMSQ7YYIB4pVe4j?= =?us-ascii?q?qFOYx0Hh4Y0mtsccZPA2Ux7z8z8M3ESxe/1/a4hUfKo5ercm87DH2YIC?= =?us-ascii?q?VhG65rzzChP7SzqApHEFAn9g=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XYmyIqhJx9aysfVcikT+kkjd2M9qrOQ1UXMUVMe+e762t9DqqHIUFxCrjzsSRt6uxXlz6fN72QpIU17x+RA5cT4GgnWHxQZZuMsHV1qqbwgollao37Ex7cJKvjBbl8JH2OWsJcIJQQAiWlr14mD3+sTWr7/4dklDhsm0E21zFhciGXXTiu25RmyYAnzQ6YuJul+Hk3sN/RqI9U4TA3VhU7vqDyLz0iSKNS7luQHuoFVnO6ex1Z0K64JKBiDyu+2mxO1nTrltaSsqRb+Uyh71EYryxYRbK1XViHfK/j60jb4hqFCgngYgL2RBsjCkINqbpoRSQPP1JMwyALWDlUohjQ== 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=yKQbMkjT4VGlff0Vr6hWS1E7CHdK47iwGetnD3ykSVs=; b=PzvoMfFkG6sLUJREDyYfqdgQSPvWGqe3q7b4zdIzX9pD/tQQv56TqXM7jxxQ4XC5hQg790IDYDrGqx7betF308y0tZRcLXdH21QkiicJGXZeY1YmrTEDsVK5vaeiwoylX3Be7PvCNXjygpAtOHF4e4zBqzMq2dJT1W6gE75enqWVEoHrQVYDQOA8fvgp7U5qbma9ZDmqsMR16Do/qlGSgFBc7grYUXzDPysFkLeW+XFh7FeXngKV+4OxTAPJsqG16E0nXtWJAn48/r018klM2EDX8SZnDs4W5jT9Jm3B8aiOK9Kqz+cJJjRx0Zog0O4Pu5yrXIY/ILcYQcnuc+Ddsw== 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=yKQbMkjT4VGlff0Vr6hWS1E7CHdK47iwGetnD3ykSVs=; b=dBsm7JIXfFn7g6xSCy8sALntW+m7TyuOWGVRXHZN4/72IWJlKfKbToqf7h9vfFOIJFbaULFzpj0++QQB+D36v1p4R/wXsmXiyO+SWfaCzOzAqQob0O3dj9/bwxcwhrCjHoy8Q6e6478f4dm4gCIQi5QdbeXGGvLJ3Zov/6m+1E6ywaZJM3kfOLVgk8xClIZ5NYc9VHriGf6sknqDEYQXUoBgvUUE/WScksgiBsH8LMNpeBj2QztQcTu0xTFSQCOGv+vAyo4A7dQAck3VBdy+HhQB8YnxTg4BUNp2s5zuVxlAVzlTcLdNvkz51TNbIgw1dGDfYyCssnEJ7af4sK3vLQ== 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 v2 08/19] pci: Cache the bus mastering status in the device Thread-Topic: [PATCH v2 08/19] pci: Cache the bus mastering status in the device Thread-Index: AQHba2KTcxDTuKZ/OEGVhSISWwoG/Q== Date: Mon, 20 Jan 2025 17:41:46 +0000 Message-ID: <20250120174033.308518-9-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 5f0f9445-41c6-4c63-d886-08dd3979b5f3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?K039ILat+ZTw9aoUctqZj9cHwEX1jzXoImGCfbUL4otz4j8jehXk1RsdwF?= =?iso-8859-1?Q?jOwdiK1aXFxr8h1x/EDGXAqzGeoefFJ4bJr59qkXTjB3NWOlOVkaPrQO97?= =?iso-8859-1?Q?+t/Gdx533ReGoiykgnAFdfhNY14IldViu+YRSf+vDsuMMY+oENwtfh6k5H?= =?iso-8859-1?Q?9bzqWi07ggyejA/Ce8+dO7unBOZYOjWc6FjVOv6YQE77ousyyqzUvQxmxY?= =?iso-8859-1?Q?XQcLonTfR3IdpxbkQRHH2S/HZ/6UEHZclsEtKlkq1pDzEACfAj3JurLAM6?= =?iso-8859-1?Q?NhMfLoy3Eg9A3NIjA5/CU9r7VQFPRO6txrAKgH41bG0/w9vMZ8BEDNOGv3?= =?iso-8859-1?Q?PMt4UighgG3K0unJPgKWXd0Vt2BmbLEkgfmxISDLVdf/fI/Te7MqWqMU1S?= =?iso-8859-1?Q?atIJ7z3q4rBmUy3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3u?= =?iso-8859-1?Q?jjIsnHfr8QhfmY6i6CFF01tz+wgtA1RG5M47jN2+YGD61TSB5fTAZNL9IS?= =?iso-8859-1?Q?5cUo+e4qq/tAhzUhbLK8kKYj76bGsOiKrAZqw7t5c/o0JKEznuhiu22Gil?= =?iso-8859-1?Q?JmHj2IpoqdAUYSTZeQOC+A9C/Edp/kKZmza+syNnVLVSnIzgWXFNnD090d?= =?iso-8859-1?Q?Oev4hHX0/xG+z4L5ktVzjT?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?domHKLbMdylHvTYUYym0qxOX5gBbcI6lMV64n6QyelmbpdQdEM762TOaNr?= =?iso-8859-1?Q?0vOyVV2OpgvcMTqwvE7AdSjCQANxWJwTCNC3u/ooJCBctSzicVqbgeBfJA?= =?iso-8859-1?Q?iTbSOR+9LjBomzPaZVknxD5Q/irHOUgU6jQLog68kqE7rpU0xR/5WCmUTU?= =?iso-8859-1?Q?6a/Mqz0igrAZQBpp9j0l3UK8Lm4XI1Pe1jgOcOhftT2mdhy0jW5zFgugsm?= =?iso-8859-1?Q?wRigQL8iWXmOg30stu4G/UYAVO3z841iZ87/grdJXQNxgkqdi4JBssQCym?= =?iso-8859-1?Q?yN2RxXrHNjWkMXki+LnVy5rXxkR79r112Zan/U3L/ujGKcOpy/wpzldQsr?= =?iso-8859-1?Q?NcY+c+dAjjMkB/J+KEKrL+umlwzE/Pmr50OBGCt/+r2wSpW7bOnPewrFuB?= =?iso-8859-1?Q?cecHNk9Cziv6TGycHxkCSfxvNm+QNfQkBv2pncbru5nO4JdPjwWGjJDXuA?= =?iso-8859-1?Q?/BIjLbfi6p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YUFfG?= =?iso-8859-1?Q?TJV9pqFVKzfmjNym1FAxKbtRHNrcovrV9/GTt3BTjabrFWNBoNPFyKOV3v?= =?iso-8859-1?Q?IxTNWkpYo1JgYypSxsNFP0p2nUlAEXsmIvuE99f2TALCHxj9JugDoVqMAZ?= =?iso-8859-1?Q?+IvxVWym0gwxI2xy4CrMabfjfk6q2xOmjnMYSKL9OOlAWDjYikoZj2Y0W3?= =?iso-8859-1?Q?4K90313BbX+xQaqR9ZgwnVOLNm2499g01Fu1H+hdAR28YQ9v+XhpVrsyZ6?= =?iso-8859-1?Q?O0bRAGOT78fs9oRLG88Ry4vKKTmCzKLU9z/JMko9nFta0cHiToZVwHjdwF?= =?iso-8859-1?Q?Frb1wZFRdN/iwl2vZs0=3D?= Content-Transfer-Encoding: quoted-printable 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: 5f0f9445-41c6-4c63-d886-08dd3979b5f3 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:46.2467 (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: iAJHuvmc9kw3cdW/Nl8VBa2Ef3y6K8N93fWfWspXhgJzAriQceZAnM/iEMGihYuZTOgkPmRRW2Y2yFRqeGDQNhfWhhuB1vXxHHz3iW3jcwwtfvLgxR6705ksToxSx5LP X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395065091019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 2afa423925..164bb22e05 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; } =20 +static void pci_set_master(PCIDevice *d, bool enable) +{ + memory_region_set_enabled(&d->bus_master_enable_region, enable); + d->is_master =3D enable; /* cache the status */ +} + static void pci_init_bus_master(PCIDevice *pci_dev) { AddressSpace *dma_as =3D 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->r= oot)); - 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); } @@ -727,9 +733,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, pci_bridge_update_mappings(PCI_BRIDGE(s)); } =20 - 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); =20 g_free(config); return 0; @@ -1684,9 +1689,10 @@ void pci_default_write_config(PCIDevice *d, uint32_t= addr, uint32_t val_in, int =20 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->enabled); + pci_set_master(d, + (pci_get_word(d->config + PCI_COMMAND) & + PCI_COMMAND_MASTER) && + d->enabled); } =20 msi_write_config(d, addr, val_in, l); @@ -2974,9 +2980,8 @@ void pci_set_enabled(PCIDevice *d, bool state) =20 d->enabled =3D 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->enabled); + pci_set_master(d, (pci_get_word(d->config + PCI_COMMAND) + & PCI_COMMAND_MASTER) && d->enabled); if (!d->enabled) { pci_device_reset(d); } diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index add208edfa..40606baa5d 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; =20 --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395062; cv=pass; d=zohomail.com; s=zohoarc; b=dHoi8yS0pGa427cp+LF6AZLMkxk5EpOhmMwvO9Zus6bA6S3oLnFN5LzfWUZ+bhXx8b7MRUWaCmYsaSDlyzpG2/RIPxpDASIYdJWJAzyZqrzrZTpDjp9QrK61ujQIWFxdsvx2PNZWTJgeVw+tA4lU4k8wMgCdbqYHvkYRTM89Mik= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395062; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qIAdhx2JHVjQ7wp//+y78pr/QiWJCBXfQSzY33lVXdM=; b=ZcI7BPXprgR/MG0UP3dgNHn+04YyNHRZgh2XwAVridP4Y92Pff9GVlEkk7FEVEMRZ79Kp1L6CtoUd4appofYvljygXuLqFox0GzzKCanWsLPT07/zSzZJ84OyFJ2tgfKlTlrjDWg4vKUMzD88di1DVjwGqUD/hKSBxkxY9HMD6o= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395062908459.8144042920162; Mon, 20 Jan 2025 09:44:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmi-0004mj-FM; Mon, 20 Jan 2025 12:42: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 1tZvmd-0004e5-1K for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:55 -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 1tZvmZ-0000YG-CE for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -0500 Received: from mail-db8eur05lp2104.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.104]) by smarthost3.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:48 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:47 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 17:41:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394911; x=1768930911; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=rPkEds8qIZp9TtuHjcRhlqEFYcVgIFkbOepMRSmEI7s=; b=b+2jMOhjEgjokUzn9/ysLQv1yapM9QMUQg3yfxyI0yovwnTd842FcPGP V0TqXo3KEIRLt6dcPnzuWwCUbSdBnGD7bJ4q7EkHsIa7sbsVP5utBiPLj nzysO7Oz+C58JIdjDa3rhUt5uBj8XkFQwFXtCflXl9KR5nB/UWQI6jWWB 1bsK0gRK5zj5bZjW3co64/Ud3DPr8NPCKMZqoeOj9lNw+Lhn2H2jGl1Ya Q5nYm9trNBL73MW54gRmI7DkOVrcEgise+/hhTbtNSyNF1BB4Docl/NhZ Gx6zCnGmUjE5BXRQXvQuk23awm3GoILnWHrYyrt8J9GEzP5fh4CmOl/qN Q==; X-CSE-ConnectionGUID: BM7uEzDQRXenTiS/GdwBsw== X-CSE-MsgGUID: /B8S6bAcRmeVlC2t8tA5Kw== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125397" X-MGA-submission: =?us-ascii?q?MDHnk0s8qWZbw1BrlGt9IYR+THA0M0DDyYTKj6?= =?us-ascii?q?JAIDD9IzEzk7y+FLx0C/PVz4+uLhDhpmlykOEeub8R7rU0ur1KINHMVM?= =?us-ascii?q?0TRDX/CJxud/K+gy3eW3cxa0B1YaT/LDx0XgxLOMP4g8jQ495Jzd0eLj?= =?us-ascii?q?giBNBiMzBeW8WHZlKOiw2BCg=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FTQT2KdyyOKNHsOCJz4VLnkEAlIIlO9VuKSYiuCiqQZa/oWFxYifVh/MtwePVNuAUOV+VKoyrlsLwdE8elW+wxo1vO5k6qIV3if6youtMEWScng7arseJo6EsZqjBsZeIJCEAm+xaUEO7PBw7c/1M6EshDs5Y80es5TWVefsz8l0KYO2W0QUcstI5aV3MFg97B8XQseliD8dxt6e0grKDMPv6RH8ikd0qevjmW7LK6udvUhCI5fn7yV8AwLYm+s1KaXfgeO+5PmK/mUwrcrNqN02/hzaicqZtrhxSFhBJd/3QPk24S2xL5PSzooPiPXy1vlc8OxzJJjXZdNIzUEkKQ== 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=qIAdhx2JHVjQ7wp//+y78pr/QiWJCBXfQSzY33lVXdM=; b=Egt5hAduivSlEP9es6MEyC5zM9Dpdl32xRhDq8Y6QUGKjDVjHpd/4NPB5OF4M0kAZTJnBH8tQzVjVk0w5li1/Pz+ruP16IkOnQfIcpHlbBVlyGP6BpVq5bUezUTirtrFZj37F9rcuarRmpuHe20i57GMU2V6eHNCMdHsYC2WGrMLIpVDQ05LXTlSCixyG6zeEduMIYkljG2Kgew5cxbmayXerWx4KBNFPLOay+PdDwCrLQ2wo6B4r9038rAEJu7QuKr8IbA4xPNZ4Mp8t1Z91ZcvHYN1FwtqcmN5MtGZ0DBJFy2vJB9HmhrPCzuR4+7WJ0d0fLvVPW487qNykCdBzA== 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=qIAdhx2JHVjQ7wp//+y78pr/QiWJCBXfQSzY33lVXdM=; b=po8H3mMk0tnfUhiQ0U4ghctTa/SXWbu5H0GQ8cjYT0TxQBGpnyTPs0qU38eIqwlT0pvP24RqTpzb7mhedSGWuJfbZaSywIYDryzCyKk/VxA8BT79SmYUIGRkqVyc8ldOe6sLCOyhACvGfdvaz+ZkiVDGHAfU6awi6oSpU2GvJmI38bWPsL6e4JatdmWcGyY34lvHqqwrNSGPmlYlf+Uta884oTVdjWqMBxVhxf77oWbi8ogE81B3SFg0TpE1B8+FpEgoWVQWIKfzlQXrZ2UmLjAaYOPPuF6YSM6doF5vEkuIEHS67NdxpXgJKs84AN2IZRpFhbHTfB8Fdp8xnFss+w== 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 v2 09/19] pci: Add IOMMU operations to get memory regions with PASID Thread-Topic: [PATCH v2 09/19] pci: Add IOMMU operations to get memory regions with PASID Thread-Index: AQHba2KUJdA6wV4bfU+cysc549ov3g== Date: Mon, 20 Jan 2025 17:41:47 +0000 Message-ID: <20250120174033.308518-10-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: e7fcad6b-09f8-4d07-b5de-08dd3979b6d8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?3ecSMNxJk1wR1RnNawbgqeovNrHml1mCDSj9mNgjcvmjWgRgm+lfATSydm?= =?iso-8859-1?Q?WeYKQprlty57cSVPAFftg9o50aD3d4IetT5g6qBBzerBuLoSfIaVBh0V/A?= =?iso-8859-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O1rw+wf0R?= =?iso-8859-1?Q?fkMcotUO8pk+n3EZ9Anx69Lbxqr3L7mrUgmSXWou8rjKcxWtwzQNVlSaXq?= =?iso-8859-1?Q?UqNqBMQgTU9taJ2cDBVq/VOhzbnaoXeLuMSFzpt5B/UUqqB5qIowIPSO0G?= =?iso-8859-1?Q?rDAXCvRLQwiKdho32TnE0TGaiuL2kLClEs8lZVCSM0MrdCCM3VF4wYHNA1?= =?iso-8859-1?Q?mrxeZnhuNPytx4Ae3bOUa4nkrgxuQgGsrhHZ0Xq9J1T+N+Dm0e65dtmU7s?= =?iso-8859-1?Q?Fx/1yN4tmCXWQ5gXIQIfklDfDSsoLzRjBGhCnS4XwydEe2tVvvIA4np3gd?= =?iso-8859-1?Q?Lc5ZZ8QfGsjZJU/o+Zh87d9SKN8erYK9gFy3YiphXbaiiZECOJRsjkpQgD?= =?iso-8859-1?Q?RPGmJ0wm75QijvhtrvVyj+/2GnLz93fcT0KYVwq9YqhKnX6HZ6TVej1idP?= =?iso-8859-1?Q?PILZgX0CHM/FawN5nwPI1hb4J/+mxd2OpWG70+UTK0Qm7lIsqaXwHuis6R?= =?iso-8859-1?Q?8J1l2E32Pj7frAYoIonFp5?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?UQe5nPZwPmP1UJR/97Ok4yaOaBHGg5bZO5z19Eg5vakmmG8p8+qGMKNWSI?= =?iso-8859-1?Q?h7S8dYkhs2Zkau4qxpef6Wp4sC5OdN3F8zeXcc3/tUZ1fetTNXSB/BLlG/?= =?iso-8859-1?Q?Fk2ns4F3Z1yW8O08f3hLPoSdEOeAwbarhKT8Z8eXq2Kd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BPPcG5lRfqgKs0z+TKqQM9fqcm4WE+hI/dERpQYO?= =?iso-8859-1?Q?LSXGPzmNCmMPTKC+qH1Z9N6OZis1h77fBqqU0ysbhCWeFzU7t31f09B2Vk?= =?iso-8859-1?Q?V/6EhYmNmLhEgv7ec1G9SqIEyZ7kn7pOoWM+3UfiBCnNfScIEnyl4a1Hg6?= =?iso-8859-1?Q?Mzn4xXVXtCIUk4e0rg3UkfPkHbMR0E/ruK/5j3vU2bGHJZXtVIbE63XnxS?= =?iso-8859-1?Q?bDXrz8Q6TceDmzBz01HItM7ka7USpKqJav/0cnDI/FdgQqJXXHQ66ROhuM?= =?iso-8859-1?Q?XQRfspyGOGF0D+ZqqSiQCNeB7kAsrwuEEGZPihkhef0mdoXec5WLypfcNA?= =?iso-8859-1?Q?+jAAyi7d/vlwXvIB4gZIpjvsrUtxoCZ2+97aCFmQV7/fdMzbDL+lI6/EKl?= =?iso-8859-1?Q?lO+Yhh/kamKjOaBo/HtXeVfJCz9UgzPFmFw7EQvLbhbSBg5wHJRB8WMx8j?= =?iso-8859-1?Q?bBUw4gDa0etLThH+6XgU3eVtbU4I5rdwIUUgzRuVxFSXmso/WOsYGQlDj0?= =?iso-8859-1?Q?WNnQka/4mBwgOITUwdCnf99DEWy10m1P7/VRdTkc3U+/DDdi8AluEEWokZ?= =?iso-8859-1?Q?1TTKN1X1SGtD/7o2VemD6/XbkhWsk2AtQxkhAB5WvM1lbI+3p/fP/Ykr/L?= =?iso-8859-1?Q?70S2WEsAhUN3g+H/ON0=3D?= Content-Transfer-Encoding: quoted-printable 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: e7fcad6b-09f8-4d07-b5de-08dd3979b6d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:47.7939 (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: Loib89T37uEn7S8mZIJy5H2BtT0w+tMlZ4xLrjBVW4yA6nD74RVmHEXypyVcc25I2fcMvVmvDKZkjU50EuV2JSt4gvtkp0eMeKVlJHqvmfn5/RQBtwBr+iylrzOnsvWR X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395065184019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif The region returned by this operation will be used as the input region for ATS. Signed-off-by: Clement 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 4002bbeebd..644551550b 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -391,6 +391,22 @@ typedef struct PCIIOMMUOps { * @devfn: device and function number */ AddressSpace * (*get_address_space)(PCIBus *bus, void *opaque, int dev= fn); + /** + * @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 * --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394942; cv=pass; d=zohomail.com; s=zohoarc; b=nCMgISbv9gdyDpXO74VW3MAQCUFKhIiojshoGwafNYtZjzxk+OECZ4zeKVY23H/EOpifwBjKvNbgnMzuHP8mwry2ayC40NpSjP0SkF3/klPjIFDojfO7+juEREstr02SxnFGpNPkKuJkCSEAtBTeiJ+A0wFsNIWcaWpYIOIhsyU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394942; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yUpzAwgWrTnHfWavIWbZfjsz9cTvu8hVyOJRd8nEh7k=; b=c+mWdksf/C0lFb+QylNraRGWTb9ZkB7s93onE5TyJGAjhhxasGiN7KGwNt1bVUBgqHKfL2oqJ/Mg2LiC9gxlfeVwujZSzQ1e4AWWRMz9pEpD/aCZv38B/ly/YDgehuWCONLxgdM90ncKkpzpohhXxOYBAhTHRcRRLZrSTHsLy4g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394942295364.79887004178784; Mon, 20 Jan 2025 09:42:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmh-0004jI-11; Mon, 20 Jan 2025 12:41: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 1tZvmc-0004ds-L3 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -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 1tZvmZ-0000Yv-Ce for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -0500 Received: from mail-db8eur05lp2104.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.104]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:50 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394911; x=1768930911; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=YMoWfnZMWfI82l93VsVdxFOZSPZMyQ5sjcppm9XKXHI=; b=qqEkZhNEqlWR17nCaaHZL0t4N8IOVRbsfvt1H3GvKVjPsUV/8bydGOBO D38IMy2OouN4Lezm0982B63xjxF6RSPauvVIKlW40HVMWCylF/JbbTYGI p2B2q4LaEt0l6iQKUuiGg660QjbOpGv6z5NeaE0dyOrxwBR2eZOyH+dB5 0G3kCn5C2U/4jpAJcrxgUW/1NAsNd86In9Kka2v/OuMGSci8FRkm8Gv8R /zOumjdM+bQAP9QVv8P76dA6E9eoE07yhI83ukPn/z/3bHErH7QpTnpiH /iBKwkfI5z/nqtFSiwVcXdGi+va4oxiUEb4ShMigVOsjzV31SS3eHBpM0 Q==; X-CSE-ConnectionGUID: wOR4GZ0QR8+JydJWYz+Z+Q== X-CSE-MsgGUID: PwXdLVw+RGuhYf8Rc/o/bA== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291722" X-MGA-submission: =?us-ascii?q?MDFwS7EzwZ0/GqQfpjUE5NU3KzO3kblVwk0PDM?= =?us-ascii?q?rLWunapABapFPWvISHUXuFF/DdEYiVYrgfsUIa41I2Ck02Y75yNl5iDj?= =?us-ascii?q?PZuB/sGkZcB67jbpyrNryRHhL6uTr50NIwWQdd5I3SXVKJT57hAc0DpW?= =?us-ascii?q?pm1leT/GhJoMR2XrBkM13QEQ=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=offBvemCE5qCuiiGDF9DQajQReTw+mKhaonFEGlkoeUrzUYI0DaXtGPPKJfP5LxuEe5InenPJZypAFxS+Xi0TxPCL0PAEd4VfdpBc8ASTMzguw11HyU7DJhh3pNHF+njboimDR9C+LJeeoOM+lSrQXM0K7E2axThQkl95DZDZ5ggTuaJfYaOwyUUi3I2e8yhssgRlGexsJ2q++lN985lEfFAG/jj97nhMOC1F7/gL/KFsAEspPkFjOXICx14KjGlAWZWUWQBVjcPWLHHnhSD4ahlKCBJfHTEeSRD+GiYrU5to1zj2wEvlLqGDwbW8XxyxwQza1ZZSwwg5r+e8nlv+w== 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=yUpzAwgWrTnHfWavIWbZfjsz9cTvu8hVyOJRd8nEh7k=; b=KPIt731ygVddahYP4fFgkshjOaNgUBtEZ7oCTdPD0Smp6ZJ4p35bxv18/iVUdN+nV28uqVTxmqjesK+T4Dllov8bYWoccXY+I5Z+MEBt0dSoChQTpdFPc/eLvWCrZKEw5nA346bdrKlDYjGtP7SNqjuk58MUIEnyxOAMs1jIycIQsYiX8VdyL6qQHv6tzOnUOKsCXt10/FMvDdkcHrWR937gHQdracX7IOSUPO9oIXA68L5HLiEoA/ETyAAJEFOgumABMKAUaE052CksZU0iqkD7K89fQClslS7/BBawKM38BpRrF+VSKVRyrO6cALO5hrlW2f4sxAemLd0TbE862w== 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=yUpzAwgWrTnHfWavIWbZfjsz9cTvu8hVyOJRd8nEh7k=; b=I29CktFgNjBdIC1w86BVkmovrTzwj7CHsO+qa4+37lJPlHHQSRwMqOpoIYVqAqIlt6i0T8Dh32SZX0wuQoZ28tS8w1OSwKxJI0GC7peirm/4usRFwjmmefC513H7obaFmpF4+DRT+torqgWYPx/yJkTInoWEywZ5FoFZUz9SQZ0L3bLbtajllIQ9Kx64sPLhJe3Drn29ADV+70vQiH7dQp3XAMPTNIICZEGhm2NgHUIOzppFZBSaNzt3KDikiDBq+CHQmjCPjxgaEoMjsn8lw0gO8LeL1V2/nnyuD9Pn4fyTqQgmVYeIrDBVLSUa/Bg1DsJvc68xj2Ib4KsGi1pkaA== 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 v2 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Topic: [PATCH v2 10/19] intel_iommu: Implement the get_memory_region_pasid iommu operation Thread-Index: AQHba2KV0OH+x6FBOUW1Iip7kCrRdA== Date: Mon, 20 Jan 2025 17:41:49 +0000 Message-ID: <20250120174033.308518-11-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: b6e90198-b308-4c74-04ac-08dd3979b7a1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?c4f0R5yEHUoiR48HhiysjwlstpIWF1GxP4tCo7ea9QsQ8GgSK/kTMRpNKo?= =?iso-8859-1?Q?KwKRRTQ4txC2qNjfuBVmpH7h8mr7XPnoRLavhJWhSc1k7eWc2H5HEsuHn6?= =?iso-8859-1?Q?2bmitafb3ujG+8ggGpDJII+Ka8/6a9iFDi4gJvrPT8n7HsDXWBUtdtp/Ab?= =?iso-8859-1?Q?+uymGUj/l9ZYrYjsAM2dexuGWkVSWuINbQ0Nza0AYK9fxwpyO37P3ft7GE?= =?iso-8859-1?Q?bstEejvCx0C2NN04G+vUL2Jta15PHSXtfrvHUtq1nSl0hcNt/J+kHc3pGf?= =?iso-8859-1?Q?9//amMP8orCUkNXeGM5rDB6W4tXoGdmoJwzlOVLHqaHvr28HB3PjR8hx6U?= =?iso-8859-1?Q?wYKJzAvJV3L6WuJ0lqzcaXkOlZJmznA29p6t7mOS0octSOxNizTru+BCb3?= =?iso-8859-1?Q?0qKyP0cRQ79OOHxGT5ynd8zgkxCPx80UQULubV8pcJdYNCgf3BTTKBujQG?= =?iso-8859-1?Q?y/lwT40aVfhSYhcUMcDKe2cszCEpllorlnUu75hn2RyuwQXIKkWwOJGrci?= =?iso-8859-1?Q?fz5s9Fi/4cAkHM27YaaTvNZU8S8DNQYQRDHNpy+Yt5/YuaClmv/OC2iV7G?= =?iso-8859-1?Q?YYrC0kKcBAIKfmZcO/03Vpbx9fMVJ0+aE04XcVed8cUtK/rOhqZ/Owkm2e?= =?iso-8859-1?Q?7hpg7JHD+wbafXBJN/bGsqjK38K0IZofgGICMGv7S4EgvkX4yYxKXc4tu/?= =?iso-8859-1?Q?6ltHlnIf9Q6Nv9TU4O9YQ/ZwOwL2ye7ThYTkSpF0bC5/1/bIj8TslSRcYg?= =?iso-8859-1?Q?F95HW3l2ZZPa3te9wiBazmplY7leOoIVuVwrMAXCMkl8HzCu8757J0/1X/?= =?iso-8859-1?Q?dSxuse+D9NRgGtrEWuSfE/gHChOeZJPqGXsyxtcdnWNdQW1cSzFJPcNfTp?= =?iso-8859-1?Q?wxqRJjmq7EdoEA70Ax1dq27PTu/Mw5JbiShRWU+dLCqd3GNBSBlwnNXL7c?= =?iso-8859-1?Q?D0Flljx5MVSIjaD/MyLrF/9b2aVH8JbO5dbq29H0od5pA6qZpBqwcFJPLu?= =?iso-8859-1?Q?91BUGJ0eiRNir4SdMu5vcTQb+kUKBp4NdxuuEDXolI6wTU0LjrJ2eg41CL?= =?iso-8859-1?Q?B5td4eqrGgRuLHisO7BfwwbGRvASM86EjHlZq7To+EQs5M8wr2qbLtA2w2?= =?iso-8859-1?Q?VdEa6Yo29+JhaYtRARnmG6Y5wcSe7UI/SmNJS3UaYo7wPTvBOFAuqZ3mk8?= =?iso-8859-1?Q?5uu8WfWw79Dff8zg92nksM/gE7AAP2qrkrql6JBSkUE8EUR49rZRgFJI/D?= =?iso-8859-1?Q?G3bzDoOwvtm3Slno3S0kT3oL6uOp+je2EM6AZxUYyKHhFbiRcs5xmweO71?= =?iso-8859-1?Q?azS4ajUtpVjVaNYbybsTJ+cp+DUdeKS809n9u7OlExmIMetYWbLOuPGjWH?= =?iso-8859-1?Q?bDLMBofEPH2LYUtFDCtOJragxRq2b0LU1cMrv7odwu9ig44lcAJ7b0Pk3T?= =?iso-8859-1?Q?BQPOEX7iJPlEmV9no+5dp9unpGKlubPpOUReNSnBbshSM8rGuQfArjPonw?= =?iso-8859-1?Q?4pq0uvzKrtYmE09gCn/jKw?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ihu3iL0/l6mK+QJpTzRQQ1nv/VGb5O0Dx6jXSkZrP84wHmZ30xUq2YIEWy?= =?iso-8859-1?Q?dRSO2RdZHYnpl5MY6PyEkziqsvQje5IbSqBu8YTNPlifgE4w0MJVqTRFt5?= =?iso-8859-1?Q?RcZwbeCtMsydqFt4ViljNR6owWAANjKDTUVM3svEx3d2P9eDU5htFSODZT?= =?iso-8859-1?Q?bqHdzRReZ+uXBZ3KVU7073ySzjKrNtd485J5x09JkSkxMa1KhzeFgk7f9J?= =?iso-8859-1?Q?cq8Aphr5pnoirmW5twfyZ4vzFbzWfCU09U8n/+rxOtdbWiwcxgBFQCI4n2?= =?iso-8859-1?Q?QhDnMdc+5ilKMp8Iw6Qg+jIe5xAl7/qNmwUHR2NsGQTTrOD/TIePJjM7gC?= =?iso-8859-1?Q?ncrqraEN4jtuOD1wf1zspAamNBse28AZZv1RKRhmzaZenJ8QtK49umdj2P?= =?iso-8859-1?Q?efXlRewjvUxyyujD4IBB2bTBH04hDv3G/E7i1qVBeNdtnEfn2whm+KX/uU?= =?iso-8859-1?Q?MwaFrv5H/kJRLhOz/LeTt1VmewrMqlVAri+RefHkt2WcYpcn2LTVaeEB7Q?= =?iso-8859-1?Q?xh1GNo4sZL4RI0j4ubgTLdrNslrW1ZKOik+Brs57Kf0cmZ8BCSsf8Mn1yd?= =?iso-8859-1?Q?m48nOM+/l3F7Zx6FaVro3R3CVjHVBEtubMd/xaI8HkasOihQ6aThYqOenz?= =?iso-8859-1?Q?mjQBBWWHFUeK1AtvNAPKDVq4gzStsk1Oss+XtDil0YHPbBwU2r9OUiWmJJ?= =?iso-8859-1?Q?NnclezY+2l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GoH?= =?iso-8859-1?Q?5v495ohOYWa5Ox3Qe2T+QgdbPRJ1uewiQNfyXKnK2yJ22wIWbQAjmRQOHL?= =?iso-8859-1?Q?yRjFPwI3Y4GMUp5ZR/s=3D?= Content-Transfer-Encoding: quoted-printable 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: b6e90198-b308-4c74-04ac-08dd3979b7a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:49.0584 (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: JBaG520gDRAlKnUssHh0k6LSuyASSc3gSCPtM0A/WyXuNA/HW1kcG+cEasnIqSCgnIjSLCW+XBQig66IUJz4tKFZbR1xgvEs022FdROkjsMyEDYS2dqVO5rhCw7Bq8Hz X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394943130019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif Signed-off-by: Clement 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 c58e18a56c..021834c41f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4202,7 +4202,7 @@ static const MemoryRegionOps vtd_mem_ir_fault_ops =3D= { }; =20 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 @@ -4719,8 +4719,23 @@ static AddressSpace *vtd_host_dma_iommu(PCIBus *bus,= void *opaque, int devfn) return &vtd_as->as; } =20 +static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid) +{ + IntelIOMMUState *s =3D opaque; + VTDAddressSpace *vtd_as; + + assert(0 <=3D devfn && devfn < PCI_DEVFN_MAX); + + vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); + return &vtd_as->iommu; +} + static PCIIOMMUOps vtd_iommu_ops =3D { .get_address_space =3D vtd_host_dma_iommu, + .get_memory_region_pasid =3D vtd_get_memory_region_pasid, .set_iommu_device =3D vtd_dev_set_iommu_device, .unset_iommu_device =3D vtd_dev_unset_iommu_device, }; diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index e95477e855..08f71c262e 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); =20 #endif --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395114; cv=pass; d=zohomail.com; s=zohoarc; b=fmde3PDRDrXWBqv2nS9vaZ0PRGtfZIzPn4Vw05O5q7EexM/4/kJ3+XhfukTPP5Bp2q6uOsl/if5wgSGVsL5t/J/vtL+pztAWE42wo+sNl1XpZr3DCLasTKutelwRaIiZBHRPdWF7qKdsWFgvgM3GZ8AUpswuIAw9obl/pfvaLD8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395114; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DRkmyg8DSSLCXELD3gKcIdGkG14Pzetncm4+Qq9hxLE=; b=VN1U6naSJGrv2nWL9SG8NOFwf8HsxiJ74kk2nLei3JtuLB9726tXBCsOFn472wBEd1zylg8V92bIEiCM/ZdkPrgoPlM1qyrFY90bafO4fAIz1dJyn9Rn0uMNxeCJeA3FyRKgxBcEQ/AuyPONAHSgC5WbaM455+bIdJLkdS3hlDs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395114761420.5685215630235; Mon, 20 Jan 2025 09:45:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmi-0004ly-3J; Mon, 20 Jan 2025 12:42: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 1tZvmd-0004eS-6b for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:55 -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 1tZvma-0000Zj-Jk for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:54 -0500 Received: from mail-db8eur05lp2109.outbound.protection.outlook.com (HELO EUR05-DB8-obe.outbound.protection.outlook.com) ([104.47.17.109]) by smarthost3.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:51 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394912; x=1768930912; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hQh6FTIQrfprwK9v9FBxCrr3B0CdVveiPcxr0eYnTMo=; b=J0HAyxI+OCGQF5bAxFyi+UICBIJlZZ1XV0ofHtSDDQrgrPphTZKciMes 8Rbi4qMpMKKciq6xGNtm+1XttkmSNd+2gWeVi+nltrtdl9ig727B8IkiA HTPQ3V1meI/ni9yS8m/jJivSgU+hzHkYaOZiy/jg16vf701tYbwuETvyC 8DTeQN+6P13ujxld/mDyizyp+KnzY/6VRjTILgC2uECl1Nm5Z5fhiFwo/ TeL9lpeO6AvSmRQ1NxbIUZC76UmyyHLA2DKqFxrF9yo0XRroaBxeJOLpH AD+2Bk+mfbNO+7fwWAdYHH5XuvTcSv6ZXtMi+65rpMwrk7uYd3lB2dMmJ Q==; X-CSE-ConnectionGUID: +e/PN2NpT3WdgcW6o0A1nQ== X-CSE-MsgGUID: jdSn6SkAQ2aFZgmMGJkqrw== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125398" X-MGA-submission: =?us-ascii?q?MDHETIQ0OR06QgH1OdvMEK/9PDR6gHrflINlhF?= =?us-ascii?q?iiLlI8ZeLcVB6VFVJplMy6xMITbgWIqJHCPRJy8EK7mdIkxgSfdr1TAM?= =?us-ascii?q?/5pGVif0uau9fdtO9TE8fNfS/1zz3uvk0/+HrPsK696Pl2Y/q3IMAMPc?= =?us-ascii?q?rQ4m/rV3cBqoZkRWQHz1uOOQ=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZeJfSZeQOxGRIHA2got6yPUET/YL2mdQGUkzjqLelPi5PJljV2fS0pkRysUwFBDo3athzbNHdl/W+kgUYWkP9K73WdqPhxkfZoDKvmKsQlT3UkJ8DesW5/+RAT6uHv5uzw5EA+0vZ9RqcPjjsMksU5gkSPByWimiCPPAQyM5+XLsJ0/mcs0VQ1g5wLmWAbtKdWFd7h9Rt7mezSZx+ZbcPdlw7Z1f5nKCL7seTZxotX601+1+zDKTezVi6i+lkwQeSal6Urw775rOAHMSM7cosOr+koAADsInRHGuMYO0Erb+Nv9vJg3juU4RmcAX0Z9zJnELC7BnsT0KYM41n6MqIA== 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=DRkmyg8DSSLCXELD3gKcIdGkG14Pzetncm4+Qq9hxLE=; b=xE3bYw2w364jxlWfu8qzwx5OK4bdWUQ8/cuwSaMDHPhIurMvMPvN0+EwTcHNG9X5GeYruMtTgu7twnjNREX5BIAPLt2qvCJ8lGc7Bdq2gFTEg5/p9MSbmnHVYFdRZgyCL7bOFJSwaK0pDzSTvWy3u0f8gUFYHVtYvqcax38NEkLRkAQQX3AoiK2m30ldX4obnpwhnt9VyUpT4s9kZZ19D8nzPCnhksn9okUTIwAbgM6Rvw+rpJm0BzuIvfjqH0KuPbrlfkNsivSgQVqw+vdTKQu+3UpUBvLRR8w1GxbvF7fpUnV7etqkWpqbvrRzk5mdWEyPQWqNBybHwUEr2mz5cw== 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=DRkmyg8DSSLCXELD3gKcIdGkG14Pzetncm4+Qq9hxLE=; b=SJ75eVdktmFSFUlrE0P9KNo2HfTfCEVFzwVTFQCXYV7m+DWCK8Is1AHUKQVszXb4PW1vGMegYGqtuiADKKLDsXM+wk47JcOIZIjgEnCLIEn9Ny9TE1OTY2J6eKgcjwXlPr9QmXRUeu5Z243hR0rQ0e95iRily7QGKXEKrbfq77ytY5zgKg9bxTz+zoaPg8GnC3rhPdWPS4XUJPpMsQSAx3NUOnrpJXQPPotdK1PSEuoWX1+GL2Za94/3q9hCHxFjt5mKBYDkCDOZV9lHE4P1ilwrifPf0UI0TNBvD0N1Gdu9ISer/0o+hUkXcmLkMogbykOSZli7z1vW+Gf5U0qOLg== 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 v2 11/19] memory: Store user data pointer in the IOMMU notifiers Thread-Topic: [PATCH v2 11/19] memory: Store user data pointer in the IOMMU notifiers Thread-Index: AQHba2KVqTIM+q5C8EuMszYWE7oOGw== Date: Mon, 20 Jan 2025 17:41:50 +0000 Message-ID: <20250120174033.308518-12-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 62a08ffa-e805-4657-9bfb-08dd3979b839 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?1+pDqtT8ocVl7dJqW5xgkqsncqLnWqpo6oketGveOyioepbcGiZmO0RW3W?= =?iso-8859-1?Q?iOZEDyAR3K0eJhOFzDGQm0GcBR7mWHdKhD92E0mkKqlRpfNDJ5dcAUq9e7?= =?iso-8859-1?Q?bKUym7OtdiRy+FREkK06E9UC+KwmUdNM0gfUHIyRrrezUrgG9hDjpeCvK+?= =?iso-8859-1?Q?ndRxwC1FRYVabTibFqoK22xJSH7Kjma/PxO3DB7wMKpTb3VwumvbucWqEJ?= =?iso-8859-1?Q?4UfjNkm2+rSQ97P8ZgR24CQ9KuGA/gdwX5UsIlCGVEQ8xq7WrIhscEZ2CX?= =?iso-8859-1?Q?7C3WnwtyEBrqPGBqVbvBBVxDH3Lzp/lzGdVm0VPjdRwaQ4O0OmJUvXFU/9?= =?iso-8859-1?Q?vb6JCu954CJidAV0YdiAFPdHt6vNFYnyq+aAYzzAvVncH4XnZf1YHLeCOp?= =?iso-8859-1?Q?dR84FKJcU6/2Un+pZEy6v+DEaHtUowGrefXoUvALuMZudUlseXdo7LsUOE?= =?iso-8859-1?Q?G1VeGywUL2U/Qh+mo0bmBZtzP1Wqu++hPotlsE6HATz/7hZfs6p7ESGRjJ?= =?iso-8859-1?Q?g1F0cjaQ8qyzREXCvIbj3E8DFvjw7QmoSx30RJWEj729wHdycomLQHtirN?= =?iso-8859-1?Q?3kpJcwGA2WZ3EvMLExovl9MTjeSr2ESrEDo8o1SWyCR3O8KNypkwrtVsTC?= =?iso-8859-1?Q?VtRNsZKnakh3dp9chHoQfV8jeUJHHrYYPHPZ9CUcZxqgzeoKqWfuCdtpUc?= =?iso-8859-1?Q?N78fjJ4CFyE9YDUFu2PwAKWTk4NsqCvnhz5H6VX5jDEEfaroFIS76K1zu3?= =?iso-8859-1?Q?FxSXnQVYDLq88Ix/j6OqSLpFzyhS6Tqz/6HeLEqbteoFkTwGsKg2hbMKte?= =?iso-8859-1?Q?ZSQgUKQv7tC13XydnpL+N5jo1ooTiTer2XBPxiaDbLgKwGhLEBnzUgK5/P?= =?iso-8859-1?Q?/lnMQGw9edCBnPfKVt1boRmis9jeUCOd7s95/xG03npz8edxkdHLoLZ0tx?= =?iso-8859-1?Q?bcZRBIOXcw9c+jax7rLjgCqYClPth3E2m3Mv8bE+Y0NxheCfY2rP7Clx9e?= =?iso-8859-1?Q?QIm1ig8vJWh8nrBOBgg70cjMO4wVq5eNPwTGB9woJAuEsAsfVBCwDy92z1?= =?iso-8859-1?Q?Upy9RVri8x5RRDbYXjs7oQemIWhX1ngXXV5vqD5Pk7vnY6KOLeTK3UKzA4?= =?iso-8859-1?Q?C0gyk7HsWgjEZZJgRUyqL929tajcA8gR9YEff4t7GAhZy9YukGG5LxjXFG?= =?iso-8859-1?Q?Ytir3d0tOYfDYmlNGFmzzTFd9uGaQCjh9A8eqWeAi2Oho30MWNlt7AyYC8?= =?iso-8859-1?Q?se6kIoPAyyqSHwmluKEYNnptefqO4uEMU7iBjXbz2HbCldKn83eqr/XrsQ?= =?iso-8859-1?Q?68D1ftFW8tjOcdtaK46HLnICrg/pUuTJDhrFJB+YPV7ASvW6NPdEJYXjc5?= =?iso-8859-1?Q?E20qoAXuDbhEdDYZ/ISF5yEZ8f1/a9GGsIMYGinfj0ceZwssDv+OUMsrF6?= =?iso-8859-1?Q?Y2WSHtJNNgY6eMj3eF0Jbk2Lol/xFjT1obc0HDvMG2+Sx1PORcOwWPLkSb?= =?iso-8859-1?Q?xzNzbQ0rDs4C8FdfIbbzsm?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?uLKfCXTZ3Udm8s9EaPm1JQUVqdiJM47UtngT2dke8XB0Vxjwap5s0O05oq?= =?iso-8859-1?Q?q4C4VgO4F7k1WGDOcWAGKZ0CHKm/230pT4GmagKxY+LNlHhkGVD8oZJchK?= =?iso-8859-1?Q?IYHaMikxkstlOyzb5TDn+ruG8VTOAppqC92zDmtWUPbksxf4uD5XWKTP9W?= =?iso-8859-1?Q?AwiyyYpxtEKXqHef8XBC8x59ypplEaKbAotZO2/QXmOlmfz1ayyQxLfT0m?= =?iso-8859-1?Q?21hkVzlCukFUn6xqhVWetBvlAt23AB5Smh/D8kCltiumPJRx6pYgxpvKV8?= =?iso-8859-1?Q?bM6ctuhB+BjOxr+XAxJxRbSVewcQYgAZlyrYGSWQ4AUdE3nX0qQRbhib6s?= =?iso-8859-1?Q?kDwev+ciRNnNhA0ZSIXUIK0tPhgytmiB5AVrKIX82nv+uP68S+puW/tGdb?= =?iso-8859-1?Q?xvE7bqizLyDaH0hvB/6dU619lmL390TATq2lv6oxpaUtFK6f8Y5eQ+n/tu?= =?iso-8859-1?Q?UpgijOC3EsW8ITlhkstvepUupsCN21ou1S+sHQZXG9GQU4LAWKDweQVpFd?= =?iso-8859-1?Q?AgG36Lgcyp2LOaVym7VJpEaODQBHfojFnazB/pUdvMcBRbxFoaaoTLChMh?= =?iso-8859-1?Q?gkLvbLboZXCbGCUIh3NB86XjmimpcFRbDxQkyjWbTMra972QjkFlpzmL9v?= =?iso-8859-1?Q?rPOJrOJO0gOaY3rsKsJvqWFLPt0+I9MvgQUTbe2CyKL7nHPaK/gBt8fskl?= =?iso-8859-1?Q?FHm33ateJzAGSzy93PCGfY2bsvlbL1uzROK5GbGnGdn5jrv/+LnMI3qE7y?= =?iso-8859-1?Q?Qc5ZRVXCgtwIGd3TVYepv5cX4TzvBdD3bAp8erIoLsn9ub1p6MFpkCr8rE?= =?iso-8859-1?Q?knOa1FgW2gXquMEPlxzDvRK0RSl7ae1Acqe6mGj2HvUvJtLrBCIj4wdG45?= =?iso-8859-1?Q?CgzgV3Uve1X8UQc4u1UnyKZOjS60+Yy4cA4aX2CDqX9wn67rJ8TnH08f+q?= =?iso-8859-1?Q?ri+5WTeWd/2smFyksEy8K71BlPgLrjPadAIIAFo6P2KopEd118VCnWnmO4?= =?iso-8859-1?Q?/GeKZwariDOHMb6INxn/B52wVNokVmQGSh73qlWsnE/T2Dxvf7bImChoxa?= =?iso-8859-1?Q?G1zX3yApx6ynCrPoZ0DpVvkrS2B7I2wQ51BitXugN9YSlpYTtCnuQLiYLi?= =?iso-8859-1?Q?MJK05Gg3B41e77XuNzyuFuSCSHqRjn5TzKpMhl8IqJURqYEub1ScyCNDNK?= =?iso-8859-1?Q?k0WLvggKfnHQrSSSoTV9opoOUjw8dxOcM3vqqa9Rxok8XA7BVRzuLPUJLV?= =?iso-8859-1?Q?pKLcyIeq28ye0my5fiB8gzvVO4twPW2k1fgr17obnLpzgcWGaT+LafG9fV?= =?iso-8859-1?Q?3HA8gJCoe4esuVLgkve38ODbS1+QdfkiGINUrPzZ3ZjzY5J4F+ExAZQGu2?= =?iso-8859-1?Q?Jua0g3J+szPMkgQAqC6Pn3YaKSkEB6RgwKkrS4GiK5nDeFnzTnskMfqenP?= =?iso-8859-1?Q?1bm2WGpt8C9tL1qP6St48cUWPP+mMB/yivMQLEd5YhYV00QovY4pKrm8jJ?= =?iso-8859-1?Q?8g1bxv7INVQB54UZaEOApw3y51giDCGq0QNG/FANsOPc5aX+Db1Kxuo4AO?= =?iso-8859-1?Q?+yIbKXihGXO8sBifG/3wiyEV/xA8SprcxEKfSjZj2Ta2K83nPBlgMjt39n?= =?iso-8859-1?Q?qegFEIWNqB95rlj1GupzYheluEeaRz1AVQnI/Pv275VdD0gPhZR6DH0q0a?= =?iso-8859-1?Q?pWtXjxDo7btKivbFSIQ=3D?= Content-Transfer-Encoding: quoted-printable 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: 62a08ffa-e805-4657-9bfb-08dd3979b839 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:50.0695 (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: geo03uJhatMbehW1UZhchI2heV3y9qJVv1+YTkTffbUdlol3kN2hCO3+F3K6XADkCHmqAvAfFHiGJ8qnaKAYiIdA3xeBQzrKXJ3jLxgdNG5Q3QU14q06kOx+1fFAy1ft X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395116729019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif This will help developers of svm devices to track a state Signed-off-by: Clement 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 9889b97abb..468b003bf1 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; --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394968; cv=pass; d=zohomail.com; s=zohoarc; b=XkpEXdEH04f+w5EtkaArj1/kQvV7gI7piq3BKv1amjTOTzDpBoWRuPk5bUluLgQY9zMBZIkglnXepUmFdNlJHVB4GOJE0TFyz+XApD/o5w4K7WYpA36/Uhn7iL0CA14cs5UDVemRR+HU/yYiDc+wYRNvhq2cRVmceKXvrQMoYbI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394968; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l8VdlQWnhpXy0HtPJRFkjFTGAckun8aBFJlSx79Q7CI=; b=HbQlNn5Y6+A5OGLDBg+S/RuH9ejMhFV35JOlSpDKSN0OS1Mn5HX7OI69bIxlNEmLhWws9lZQbEkYum4p3JjmkXUbTNuL4ykQ8el9OYAljz4mZXC9zAwE1VnnJS7M8SJEBPwdKsKwQvgx3k3rZRMGaZVSfvD1wLPFsL9VjJjOcmw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394968211741.2460767205089; Mon, 20 Jan 2025 09:42:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmj-0004s0-Qa; Mon, 20 Jan 2025 12:42:02 -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 1tZvmd-0004eY-BW for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:55 -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 1tZvmb-0000Yo-H2 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:55 -0500 Received: from mail-am6eur05lp2112.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.112]) by smarthost2.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:53 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394914; x=1768930914; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ZIOT9iQhluPDbIqbho90pINJD7KjmJBOhC3aAEtEqFI=; b=u83ksaAdHKGSO8j+rL58NNq0p5YGZFMaYxY/tWGcxEwdJNqwANJcWpPi vEcREfkX9EQZv5ySv+fH/o2vHfZfuVsCq2b4JmvPfdWj+geEW9XIiF8qv 8HCU6fUcaGu2s6u/IZD5reTZAp5DyIWmzhB45F4KhQdwN2UCUDyusI1sN GVCzr1l8aqwlFbu5cukis4W48aYzVDG3awnPyK/kb0QDyLfj2fXLEiIl7 9u4xCy9N5W/l56XSiqaRjI4ddwtaikQxl7SkZKMFAUdJd99IbHlCvPswC 0TNnskv6qtD5JyQ90NuSfLAaFCSduYIGky5U8yf7i2RBQ5K3u5cmwNLEp w==; X-CSE-ConnectionGUID: K3jlmBP/S2CO6pBWs3j6Fg== X-CSE-MsgGUID: GQmBHHyxSRWai9LvsQC1Ug== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29125317" X-MGA-submission: =?us-ascii?q?MDG3E9SiOOAubCfPZA3XNhr4iuV/tOU12pFzDF?= =?us-ascii?q?1aYJswel0i5nTynKiLeOPyPiiUbokWfycUnXacXMQ975zg+pArpZUCHH?= =?us-ascii?q?yA7tRzGwdSlkmBYM8c4gBi8HYNMPfQ12Ev49gUcp5q376+A4Nyn6Bb8x?= =?us-ascii?q?AC9s4rG6Uxt5Rs3FEcZQpkwg=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lA1zfjxAZZIT/RxW/kibn0+lUznTYSG20XewMNMAWvmmug6zwhY2r8SKw0JqqsLZ2eAZphU35vY8eUug6jni9oTeCQOFxtb2CY+kH5l7IIz+FKRYS7WmgslUzT2qanADsLrxNmDzK+a9YYmGOogbyGNTTx3wITPiHdudZVNk2at+avhLjcQnWoEpgkrzAmxXkWGvULVrakQk2/HYZNAG1JfCkl1l9J+r5gKSc1ymYmisXiPekHTTRk0GaJs6Nxk7RCUOFa0/+YPEdmaimZyLLB4mXth8QNRxeXTQkY3OXtoh9G3bkPbSWxPu11KMiUxZnVU26kqTzFGdB66IpNburw== 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=l8VdlQWnhpXy0HtPJRFkjFTGAckun8aBFJlSx79Q7CI=; b=V8yqhQPY+1+bCfePytQVdBlKiumN6hg2Np+jBXW8vBIo9R/B3bO38q/7tXOz7MOP6OvzWM/NFvaT8mFWsrQuZp/K9GJ0Xf32Uq+ypdL9dNQXNWr4po+/KGco4g3j72V8Jl4qS3sngZ/VL20uMLK9krZWZEDQZmpm8eBsgQDtxwN5KIPuJffcDrHMVsKWkz5YlrATjwBlJ6bfXwoi/jIRUYx+OyWM2nSmQYpfNBSq1gILo9/A1xgMvBMzJ6mbwLbFXeLk8oGSkOHWkJLyQzsXavv9xRwVfF6DPM9s8tHEifgEJOmmx+vEyQQJkhgQ181ZZdfFNTe1fgkSbsoQ2akBgQ== 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=l8VdlQWnhpXy0HtPJRFkjFTGAckun8aBFJlSx79Q7CI=; b=aeHW6zNk8lyxSIOqEwqzhOqkYV1tSpa+Qn1sJUv0Ti7YdLmDnY+LQ3bARzi4HOFX7XBYmq4Bs8QOafdyNvao+lizJrJJVxOoxUZmKK96EQnclaQI8WZCU6KaR1bxS1+UwOhKpgwQrOo94Vw9MMY/YmnF29dgtDOyWUo1sdHipwk5VazhewgP8YxqEYshfgQoQ86BQezIRYO0f6Y7kP1BjCtDNK0NDhJGI6J88LjPsM7KRAea2KXPbYJVT58e+3ZBo7CFhH0ER0sAqqj2QVQUbZm//AQI/xPTWaPWfmyxixd3Xc2Pv25ByrnSoefhLGPVr6oIBBCjjf74p2/IrSs86w== 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 v2 12/19] pci: Add a pci-level initialization function for iommu notifiers Thread-Topic: [PATCH v2 12/19] pci: Add a pci-level initialization function for iommu notifiers Thread-Index: AQHba2KWf94PTyJm8UuanHrURjYpuA== Date: Mon, 20 Jan 2025 17:41:51 +0000 Message-ID: <20250120174033.308518-13-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 793d97d7-4f0d-4787-1d12-08dd3979b8de x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?C50UJbo7WRU7MzUuWUvNFF/fmg3KNph+j4z0OZO1ZQQ2P+qewrxYiIC6qp?= =?iso-8859-1?Q?444WdN4gGupdWkt4oFWljEa6IdepzGC0um8otgoz+PZ5m96EgLCf9IicDE?= =?iso-8859-1?Q?dupIKnj4updGeyKUA40oDsQx7j71i0AlLMAfM2Fhdosn6+encuUNGFaIfW?= =?iso-8859-1?Q?Fg05JdJPocOMTCFkCsTefks3pZwbosntNaih+sATO31Q7PPBUsVl1uxDq8?= =?iso-8859-1?Q?CHyfxuocs9NUViTa2bEGdccIpDMTfwQOWPTYAEvQ9sbv3RpXq+NeSrnGXl?= =?iso-8859-1?Q?nKGA7t7uoARXnqIy/E3J1JbfbLTy0H4lhL4prMJfUENsguP/CmiEV3FaNG?= =?iso-8859-1?Q?tfoAKj+8hnZteMpqOkkYI/KZSeQeiSLwo5FFScYSgcxUu/YBH+jycQE1Uw?= =?iso-8859-1?Q?mWbc0iMT5ZGKoLXO/lJNmFRCiJXQfqnwQCHWmQigMDdEdhk/enmiH6nF0v?= =?iso-8859-1?Q?OG8Iag/faY7lD0xtGVaKG7+SL8/KGbR2ijFNUUbBevTzy3Spo67sGJ5i18?= =?iso-8859-1?Q?jBLN0xNSEt5FH1mu0/Ru7d/To+cjI5Rj82HxRx/B9h8y2X1ZDAZPzpN13v?= =?iso-8859-1?Q?wIO91izxKrdjDiyBZr1zOn2o5VUAL0EBTfQVAxeCdgUFQ5STkYuR44iT5Q?= =?iso-8859-1?Q?Lr4scmXARIpHrguwBtgmrD5JkZf6VqmaJeTP7QkW8r94TFJThQUaY5K6Nx?= =?iso-8859-1?Q?0/m4tv6VeJ0Dln7+90Zrmxr5WNtLzhwK3nItiQjBpapWPRmenGQPmeJkEE?= =?iso-8859-1?Q?slPIemWfsQp4/n3QKPG1dpfI/voNybWVa4fSvBuP2nncul1UzW9E0NgKRJ?= =?iso-8859-1?Q?/s2Ha0sn/yMPb+IE89RWT+FBOkMy9mZRqUeb7dMECpkjJbEMNJd/R5EQ7/?= =?iso-8859-1?Q?V/J8PUsz5FN0csD+MwHe5I/vUDvCWL/YH+au9fvwFMn7AEKa2HCMZFtIKa?= =?iso-8859-1?Q?TA9s7pXJBmLl3n/6MTMD8DXlIDLRxZps4+3MlcryUKIcLY0OVp+akN+Ep7?= =?iso-8859-1?Q?O53cTm6q77Dia1o5rRCx9y4eD8rcsE3lr9vv3IDDzv/JQ7rN6VQ6Lx4a6D?= =?iso-8859-1?Q?i990ywEWHzJwu8/bfGBnmHaVl7+K9eL2aZMgG/2djkY+IvNuUn9wm4Oqte?= =?iso-8859-1?Q?//sBcL0iDgl5Cp5eLmko5r2W9tQemJomuMD2Nynh0LLhFuwwjRKi/MCp3d?= =?iso-8859-1?Q?DKOlkk9kzTOfV5s3CyYicrMr+K76DXlzA6DmMkM+HRAuthURuoccGUw2q8?= =?iso-8859-1?Q?1bKj0baxk3hNqi89VLvThkEKBTbNgxpL7rgLJjdy9UYLwSAZ3/JyFe9yrK?= =?iso-8859-1?Q?QwqvtuitN3Z0ooVqoZrBhBu7jwyznPFwDQDLbRjmNgow9cGBU84MNEIeMO?= =?iso-8859-1?Q?lDvmXUctkRHWk2yMTEiN2DbnonpSFrXfKkRnRqFnur4EtMs9gslx38pz+d?= =?iso-8859-1?Q?eX0UmRbwOH9/5wO2Wol1UTIXgvPsKDvJY6UNcVuUUtbQmP3/V6UcAHo0Y5?= =?iso-8859-1?Q?HfkqaV6M3LjOWyVgDfVeMi?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?WaUaBSDpSjB4pchA9MYLV2sVVE2r1eIAFbStgYUTLP+sJ5DbT8UXn1P8En?= =?iso-8859-1?Q?qmh6UxbtRAEchIdcGuAHf7pl/hY1/gtL6V5q/IJv+8Ifzyn3bfk3sdouit?= =?iso-8859-1?Q?wJD/14iBIJEC/cnVlDy1CdtMlNT5Y4lPs09/GWzvub40K3dQyt1wdE3l8S?= =?iso-8859-1?Q?i/3iwt7P0TqB8WtDVGUFBfyce+gIYjUTQUUJjjk4udqPngH3BEZXK0cUfC?= =?iso-8859-1?Q?R+c8PK99A0015xKToc3k+MrBMf/f04mQg7AIQA58S1ueq7VJCUxU44ff6S?= =?iso-8859-1?Q?3V++cmRiuKmgIhZumQ7tHL4pPATPikPBoGSnv15DQ/43wUp7RonJiSTaOP?= =?iso-8859-1?Q?deROZvcwOgE2xS9z27LJUbcnXmbqDcTny28NOIhnTIXzG9N+43O31oz28H?= =?iso-8859-1?Q?QShHRjVWPe8IOtsc+gtubgS5iw79YX+KXlECSENODPcRiwwSimAeTtS3h/?= =?iso-8859-1?Q?wUTxA7JIP2FekQbTHl7JZaCIfknh0aWSWvXwZFsKe3f4rZYUQ9JGjHYU6k?= =?iso-8859-1?Q?U/LjEseXxSQ94BjGU0fxl98H/mGLlaR13ZtD73dpS/dOR0RcmvjMHd9g4k?= =?iso-8859-1?Q?XbkmAJfE1F72A89L1RhT8npEYBKPmEWqqcuM3jzFtR98njZOl5JL3/Rk3U?= =?iso-8859-1?Q?466k1c/p54ztuw3+f7Ymzd1wcpbHKY/NQYJxtk9RDhKgDmtO+Lo2vNdCHn?= =?iso-8859-1?Q?9/bRHd69K+ttQGpRmSG6bn5ze1VlkunoG+cmec3ggf/HUojXIzj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6uzSPro2xmWsRji2UiLG08knzav?= =?iso-8859-1?Q?6qCokP5ZodiLA4RmP6c=3D?= Content-Transfer-Encoding: quoted-printable 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: 793d97d7-4f0d-4787-1d12-08dd3979b8de X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:51.1525 (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: ERO4NnITtWXkli3U4IvTwdqg2A8nYHu1J+mP2SMI7snsRWpJH6xdRaRuuaPIj2CQ+HhK/wtvn3P7CiXQW5E0bc8KpNhC4nS/zbGL0yr0SNHRg+m3vPZP0mO6eqeO9tmC X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394969306019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 164bb22e05..be29c0375f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2825,6 +2825,46 @@ AddressSpace *pci_device_iommu_address_space(PCIDevi= ce *dev) return &address_space_memory; } =20 +static IOMMUMemoryRegion *pci_device_iommu_memory_region_pasid(PCIDevice *= dev, + uint32_t pa= sid) +{ + 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 !=3D 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 =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + if (!iommu_mr) { + return false; + } + iommu_notifier_init(n, fn, IOMMU_NOTIFIER_DEVIOTLB_EVENTS, 0, HWADDR_M= AX, + memory_region_iommu_attrs_to_index(iommu_mr, + MEMTXATTRS_UNSPECIF= IED)); + n->opaque =3D 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 644551550b..a11366e08d 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -446,6 +446,21 @@ bool pci_device_set_iommu_device(PCIDevice *dev, HostI= OMMUDevice *hiod, Error **errp); void pci_device_unset_iommu_device(PCIDevice *dev); =20 +/** + * 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 * --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394939; cv=pass; d=zohomail.com; s=zohoarc; b=ja2i4GRR4/RBYP0nLT4bK8l5Mjrii8aMIYv3DbSnxWf4h24YkJYR3IrkF36iNKEaJ58beASuFr7GQEF5GFyJQyo8fVAPihp1kWjLUSzaODzKV5Bg3EszntkTbpRRq41g9nAXx476NohgCTI9q8VX9otrdTeIY7nbFD3abAsig3k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394939; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lkpzHx7jPGLa8EZn0sfsAfpjrZGuiQXVmGadzefMMB4=; b=NaaaOTxXHJsynZODe85dkW4s33shRugTzEpojhB1HX5fx+mTBIfBj1daTb8IvEj0BAKKA01kFWOroyG1FCpDTArVqGI5wXJLfkm5eJwDDiqq4MsUNvtfrgLT+Wq1rQSFjME8VsW1BJC/qPVjYhYpQGXmnMmSMtQto3bic7ii7KA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394939745672.242394095846; Mon, 20 Jan 2025 09:42:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmj-0004rx-Qg; Mon, 20 Jan 2025 12:42:02 -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 1tZvmf-0004hI-25 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:57 -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 1tZvmc-0000ZN-E6 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:56 -0500 Received: from mail-am6eur05lp2112.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.112]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:53 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394914; x=1768930914; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=iLlXujx6dEU2/AOLGEZhZjJQizzoRYB0ZTIDZP91pKE=; b=jtnbkVT9TnuuG7Ynd4xkFg1hchPxbNaD6PCNqvJ4A8rmtOhZmMwHJDbM yzHgfrtcvCar1pR9qNxkpssLZN3l6AD6kpojrmCdCoGwneB4MVxQ/XBsW F0UTdhwOFq7XSCp4UfcYWqKBUfKgL6ImFqJ4tJxt7sleA1Cb++b8f/Ziz jhNkhg2aaSfme56/al9lkOuFB4gXswnOUT20hrXmmoav1KLs/G3OPi80b XX0B+UkJ1vqwDi7W/VX9OfQJmyB3VwblsYveyl7Rvrei8a7zN5/E7L3pI cJIRBxLvE8ymmdrGuj/tZ4XIdh0aaVu+Ok9Cc3XzmqtPnKPwDecWIF7qa w==; X-CSE-ConnectionGUID: G/6jYN5STwSyS2lJUDvbQQ== X-CSE-MsgGUID: Afik9JLdSW+ORjQCjEsTKg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133402" X-MGA-submission: =?us-ascii?q?MDFpWsZcjXj9M2pdSgdHocGPS2TxOwRToOK/nm?= =?us-ascii?q?13cI6Mk4EzgmgNHaH+ePhsBt0Cv/zddz4mya2chrckG0bQMEN3unwRzL?= =?us-ascii?q?C8ZAovyFWy0LvcvBdE3kcHzzuGSc0CFesmAm9X+ULqFlRTvtukCLarLs?= =?us-ascii?q?TSy3X4VEv1y0HuNDTlSRrJbA=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bAqRe7eTbQWg2P62Iig5AAqr3qS0jRNUO66YygjGFh0Wl6OyfTF7zvN7iKwUKZE3LUzOr6AGJBHNExD0yu13sJcArzuN9wks2pHI/JnjQPLj2avg6cJgb4YZxKWt5cj5HKU9pUc3H8lUyCL93bYOd1IORZAaQg1J3YJuEa400XHbWNPXwNusnhcdzKFyUp6WN/iqVQ1yBRV+UR3+PnSXvZfaZ+DRd4Kc0ylBZpbUGPvVGQOBU5mWGNcG8DOikbrxAMk3lcMNGbwkxbdBByhCeFqKANn1pyzI/gxTiEAlRiP91IqCkLtFLjVi0ExBu8FbnmG/MkYdjBuTGaAnsUAxVw== 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=lkpzHx7jPGLa8EZn0sfsAfpjrZGuiQXVmGadzefMMB4=; b=wG/sYJQn0sHFrSe0MGmsilUDfhglZIrLaGwNJiw0xbIH9H/grUeI9894K/84N5YrGWxFU7xZ0Duyu3IDyZ9slR7IWOdtl7Au/A1nCIqOkboZJ2f/oOsYcJB0HOPVxr4K1Jz+Ttmw4wGyFo9vZU2qQ4b8X61t+WABKOejqKi4jpKc0KEQ4G0CcWpksm9TuWIMm9dtllGJDq/iHV4AvMoAJyfUGMQZG9of+lFvnC1mtlu/DMUVPt73eZeCHeX3HALdGYWfan1owEKeCfz6W5jQwXu4aOZlLG6s2b8v/+U2spiBQ+ZYiRQSCy4m1gj0SKu/kbjzcQDzx+7EKVm/rGnz1Q== 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=lkpzHx7jPGLa8EZn0sfsAfpjrZGuiQXVmGadzefMMB4=; b=VRoPSmVO3PLrUCbnAiYgk0HA7TQQ8TzcdW45NBmkRkqxIdjJ4QMN47Ciq/aBaTNLLJhB55Vx/e0ruWfXZ4NCUcKAA8ZkYAdJydKkHe+mQR+AprX9du6ogSCXV0pyZEImFFGMNVDVHI74LzqNHT6Hbr9Cu1snhSv82vW2V2dnpoiHldDf3EYEk1XU8rbfuB3IQpwUDhGd1rjIGkeANGevj9vVYStVlps9bAJTlUOsMqR64IY6GDcXpANzeVbrs4Q4OrHXtqFvJAwSJ+gh9Pl5BI77Eze7mnJ82Btui5e84JNg1UVJ+2T+ZmbhrtmWSD8AST0l8BKuIiz6zA/0LC0dVA== 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 v2 13/19] atc: Generic ATC that can be used by PCIe devices that support SVM Thread-Topic: [PATCH v2 13/19] atc: Generic ATC that can be used by PCIe devices that support SVM Thread-Index: AQHba2KWd1rFzxwaZUqmUmxBzA/gEw== Date: Mon, 20 Jan 2025 17:41:52 +0000 Message-ID: <20250120174033.308518-14-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: a2a09b4e-2131-4a37-1214-08dd3979b972 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|13003099007|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?g+T2wJU3KUQJL4Zr3zFH5TlAmOO5+vAKxlyvOU29aYrirHRgFiUtJV7CkH?= =?iso-8859-1?Q?b2BUUQKXNUal0K5TQRzr0oYEbphmPsMc+FsOe3xdspJTIAS/D4+esH+pGo?= =?iso-8859-1?Q?VWu02vt0two6kiBBxhm5RlPAOUZryLRB47KnsMK6U7Viz5nhPINXCnVVKv?= =?iso-8859-1?Q?OFJgDxm8nlbvJ+FpkSxK/b7QpVkNOblXoj4IzkyaBlZjhkIl+d1zWxKymS?= =?iso-8859-1?Q?x1qKrR+v1fQlsBFwypRCmbnVwBgwF5usTiulaMRv/SfiYcf/f8fLP1RLW3?= =?iso-8859-1?Q?sfMni7miBw6rFfNLPvzJbSPs/S/ZrXTNUzTwc5LaSpfpiAc2+q99/10ZjL?= =?iso-8859-1?Q?E3k/M/R4rjOsIwpW/qTiJA3CsglceMyslEAKs6J9FybAlSY5MJil4G617D?= =?iso-8859-1?Q?+gGRZM2IZPdQKemH9Fba+K37LUHRdgDk6JB757BPyI9KuTmteB6f0CjpHZ?= =?iso-8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ivDD2MKslDYfqw8I72bmgSNnamp+yGqbt?= =?iso-8859-1?Q?G77gnt27uTFyRitwG/N1rQQriaNqxtHZxPY3fkBunt2ez1cSKAEA/7toNj?= =?iso-8859-1?Q?usEefpnGWnBch9j3GENGcNuqmDgIIUTVEZsP7A=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)(1800799024)(366016)(7416014)(376014)(13003099007)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?E+GzxzzfyDSLFBf+SHcewOWd6AWmVOs8t5kqeXYnkWKJ2eO3u/e6L9sYb8?= =?iso-8859-1?Q?RCLKZC+5tHQGnnqcmwWu1BM9kB06h5c1PUGOIiVfMhi5k2c2p17ho3CAcd?= =?iso-8859-1?Q?GqUjeePUL2zgqpsO6ah3o+Y4a5MAKnf0WkV5QP93TqpMxXP+mpilNS+CaD?= =?iso-8859-1?Q?XLb1CjfJDgauilzNtc6C8X5COOCcGnSKOXd7W5A6u2jlRWDySMkGDjei1u?= =?iso-8859-1?Q?/O9MZIDKmW3E4P3QQIYmOGd0dN7OhHuVlqctmwESa92tKau592P9GEAMqt?= =?iso-8859-1?Q?gzV8oZlACQCoc8vtFBLpJn5ym+VKJrE/hYEvlrs45OocBPpcFkZqIUakgP?= =?iso-8859-1?Q?88Z+iwunN3AY9uC66mqygnV2OqjNIVvPCLbwge31iUKFlN5Gy3F9vJ2r8R?= =?iso-8859-1?Q?voyRpOTc00nbh9Jp3ljqQBEpL/pR+wNoB0bALZGfZ+skVqYvvXyqrGGFBY?= =?iso-8859-1?Q?0Lrre+v8MTQPxHdZ45+iNFnVBtqF++9E0xXcOU2/2/TysJ+9UgJkZ0ioah?= =?iso-8859-1?Q?XXIuAsLX2RC1NOdku4MS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TWyV?= =?iso-8859-1?Q?CnSmMBMmhp8CrqPeM23s1GZQGoiJ50KAI3rHKWN3MIPmUSE3uZAwzZmqP2?= =?iso-8859-1?Q?A4Bcue7luKKrkw02kfp3twTXnIeoeyRl3ZGuU7I6H3FnVTWjiV72/PzFPi?= =?iso-8859-1?Q?594ldsi1vbXm3weebQxdzka5a84hwmKPAQUYG93S66apv9L9/EDKgEUEme?= =?iso-8859-1?Q?xAqr7px+0zItQG5NlVbrvhQFO+0YDgFQddnixcZCzijlGFcXbfx6UCimfp?= =?iso-8859-1?Q?n7+OqMXXQGAkIzGrQaw=3D?= Content-Transfer-Encoding: quoted-printable 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: a2a09b4e-2131-4a37-1214-08dd3979b972 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:52.1033 (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: hEZZzQ5tbEx0RTEohH2IjlMmiP3HuvJ64M1WNUgan/v1Nj11iw+QWK4AkSW20lkVhUi+Jlqy21TOjokvOq9GEU7org9qyVr9h6wgXHB2GtLRqKASHaRpMKbHalcy0/2e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394941461019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 =3D=3D v2; +} + +/* Hash function for IOTLB entries */ +static guint atc_addr_key_hash(gconstpointer v) +{ + hwaddr addr =3D (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 =3D=3D (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 =3D 0; + while (val !=3D 1) { + if (val & 1) { + return UINT8_MAX; + } + + val >>=3D 1; + result +=3D 1; + } + return result; +} + +ATC *atc_new(uint64_t page_size, uint8_t address_width) +{ + ATC *atc; + uint8_t log_page_size =3D ilog2(page_size); + /* number of bits each used to store all the intermediate indexes */ + uint64_t addr_lookup_indexes_size; + + if (log_page_size =3D=3D UINT8_MAX) { + return NULL; + } + /* + * We only support page table entries of 8 (PAGE_TABLE_ENTRY_SIZE) byt= es + * log2(page_size / 8) =3D log2(page_size) - 3 + * is the level offset + */ + if (log_page_size <=3D 3) { + return NULL; + } + + atc =3D g_new0(ATC, 1); + atc->address_spaces =3D g_hash_table_new_full(atc_pasid_key_hash, + atc_pasid_key_equal, + NULL, atc_address_space_fr= ee); + atc->level_offset =3D log_page_size - 3; + /* at this point, we know that page_size is a power of 2 */ + atc->min_addr_mask =3D page_size - 1; + addr_lookup_indexes_size =3D address_width - log_page_size; + if ((addr_lookup_indexes_size % atc->level_offset) !=3D 0) { + goto error; + } + atc->levels =3D addr_lookup_indexes_size / atc->level_offset; + atc->page_size =3D page_size; + return atc; + +error: + g_free(atc); + return NULL; +} + +static inline GHashTable *atc_get_address_space_cache(ATC *atc, uint32_t p= asid) +{ + 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 =3D atc_get_address_space_cache(atc, pasid); + if (!as_cache) { + as_cache =3D 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 =3D atc_get_address_space_cache(atc, entry->pasid= ); + if (!as_cache) { + return -ENODEV; + } + value =3D 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 =3D atc->min_addr_mask; + hwaddr key =3D addr & (~mask); + GHashTable *as_cache =3D 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 =3D 0; level < atc->levels; ++level) { + entry =3D g_hash_table_lookup(as_cache, (gconstpointer)key); + if (entry && (mask =3D=3D entry->addr_mask)) { + return entry; + } + mask =3D (mask << atc->level_offset) | ((1 << atc->level_offset) -= 1); + key =3D addr & (~mask); + } + + return NULL; +} + +static gboolean atc_invalidate_entry_predicate(gpointer key, gpointer valu= e, + gpointer user_data) +{ + IOMMUTLBEntry *entry =3D (IOMMUTLBEntry *)value; + IOMMUTLBEntry *target =3D (IOMMUTLBEntry *)user_data; + hwaddr target_mask =3D ~target->addr_mask; + hwaddr entry_mask =3D ~entry->addr_mask; + return ((target->iova & target_mask) =3D=3D (entry->iova & target_mask= )) || + ((target->iova & entry_mask) =3D=3D (entry->iova & entry_mask)); +} + +void atc_invalidate(ATC *atc, IOMMUTLBEntry *entry) +{ + GHashTable *as_cache =3D 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 =3D ~(atc->min_addr_mask); + size_t result =3D (length / atc->page_size); + if ((((addr & page_mask) + length - 1) & page_mask) !=3D + ((addr + length - 1) & page_mask)) { + result +=3D 1; + } + return result + (length % atc->page_size !=3D 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 bi= ts) + */ +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')) --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395102; cv=pass; d=zohomail.com; s=zohoarc; b=lSfdV1mRHk4KSlATG/GVFR3cITabpfJ2nAnelll1ZFSpnn/PFSlyGIfZAyUzj3fXad4W7MT1T5V5iIHy3ZLb4vTSG+bRTDO5Ze1EZIY2xGX7dss98EPGX3/ujp3UMnUvJUmlVt/zQ46rAVjHELiCkRBc5N3k0dmNVAlSAqbRdC4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395102; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fRYAqsK3djNecieuq9gZMJbKslo9CcsSie6ejP5sSps=; b=h0EIth3yUT/RUEsuL7hjiQ6+/+1VcQHiOIFw216cEjBQ2iVnZp9VNGvK1cFQlG1ny/4khHXbqpMXcPItfZCeTew+ixx7oaRpg2tJOdOONmNg3/n2wyVlkYreyV7iAvbZNgUDrR61xuphmiXNarBK4x2mEwFn1Twd/IiDDDmL3f8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173739510282771.90376472419405; Mon, 20 Jan 2025 09:45:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmi-0004mC-3d; Mon, 20 Jan 2025 12:42: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 1tZvmg-0004it-98 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:58 -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 1tZvmd-0000aZ-E2 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:58 -0500 Received: from mail-am6eur05lp2113.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.113]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:54 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394915; x=1768930915; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=cfjC/wqFYSpLXoJOJ3oLFuGzwUlEFdalwLBOR1vc6bY=; b=tEqX6gUs21zeSZNcF+6vnFRVeXnBmr/xDbnz305JWH1FynQGV48R1g9i sKjWVR58RIDm9pLhxqgC+R1zX14tY8Erc7/YKjWPguDX2Mf6vZljX3zuS YEkjquNj8JZdlj18pyfmd8IW46PJEHUDD3ZBhAQRdzi8msrQyCEOmqbai uL6mXbVy9gMw6CsFpbMsfG6vi3BtPPS3+6quOGUuIz5dQD4me6WtTW3GA oqWuheydcojjcdESFy/MUfuabXL44NikyuxRhozYNgcRygTs+2RR7uDLq hzVAsmf/qV7sQVi8EMkuhcc6jsLvGGkgUfE9rjoOgJlElUxzhPvpVIqTU w==; X-CSE-ConnectionGUID: 5nRQC8sYRDSaF0bIaATAmw== X-CSE-MsgGUID: /C4lwRNYT8CuTWkNdgJIsA== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133403" X-MGA-submission: =?us-ascii?q?MDH6TmX8E4XUuBXgITKzvDkz7UUUuG7OGXDYzi?= =?us-ascii?q?7xRXLIsUT7D+m7D7sPQucnOLkmqG3TzNbY/7+xTuXZx7r1x01NOl8JPc?= =?us-ascii?q?2wJqf7nCB+l+7dHsCUmhXJS5Q8eo/YrFwidHLoFCOAgdxCIjdusGFGb1?= =?us-ascii?q?B+hkxoMPeUrsxGh665EkYNcg=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aaIXhkgCKsswHvL/TQLRee7x7ZAN0RP8FyGB5INaHjksk7V2m8TafXGgqQJgc879zpeoHTW/4r98g9nTP8heY9I7muUK1wtZ+hkDdh4Djc0/z/Tsure7lW0m2QfmVKAEcMJVszl8/jtzzt10eXb5TsnenlipZvL/n7cI0U4fLoNj9HBOzEI25XyzvIh8vmli+oNKbB9KflK6tSYyaL9XyMAagqQ4vaPw7RTjeNl4pkdAxRFBL7xMO1w+E4bMCQRQL0FJWclNC+NsF3FAgyTYtuNW8gfEazGCaweBlFhZKBC0oRAdoYX45z2JHNwVIYH8doikNCEmoXVbPNxIMQBPGw== 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=fRYAqsK3djNecieuq9gZMJbKslo9CcsSie6ejP5sSps=; b=M1f6z6hx+CBqc6DtDOfv0zdP172tk+L5ugpWUBu4921DqAB4frInLEDMbgn4XmiwTNQBr98K30vqxqeG0Z7zAe4xwunj5J5H+ThCd5Ka+3iauuSPlHsx7CVCssbCCr3v5SzT7wa7XBd4JkKi98BsLzUDAGP/2c5+UFcCXjHYk6sZv3JMNI632ExteqPf3zycp/siadJK6n145ndXRu8hHL447y3c0HYIWpM1wnqnvlfySZ7+KdtbpdzfXQ+IpbTaNrQ92zZjmoFkQYG2oWBr/pZ/JRAW9w0es22fIejcPqEX2dFzdQmwVV7fM7KfJzblnxV1sX8e+C6u5O5WLS7iXw== 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=fRYAqsK3djNecieuq9gZMJbKslo9CcsSie6ejP5sSps=; b=QZnlB8XO471mpRzeujeuPV+9tSuSxMx92CUtGr7uff1MYYYCpHbDJSWNhpd73OAwd4uAw+lMwsYp9joTDxeoHiO7GGs5MIzwzhSz1xFX2Z4nTmwuFDmZZKBN+LuoXQJ0U6+PEm0WOeQwP5h0+J2GZiVmQrJbqy9imPw2blCzBC3Xlh97s5t9sJt+NkzQuzysTMC6sKvJfEXZucEubiCifYg0FL1OogLdM/p0GH9ZifGiZUWTFMdNe0VnKa9+PNFwwmcTYm06vKcjKBe2z4p9jHEtxoGPL0RTvWgA99i8g3DDpG6xvY+1RkJKbgK9531LF9BzfZkBumD/hFbO5/neew== 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 v2 14/19] atc: Add unit tests Thread-Topic: [PATCH v2 14/19] atc: Add unit tests Thread-Index: AQHba2KXke9thKhyt0qrO3dDNNVJOw== Date: Mon, 20 Jan 2025 17:41:53 +0000 Message-ID: <20250120174033.308518-15-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: ae6fac31-a220-4d1c-2d76-08dd3979ba08 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?JU/CI/WiorAYeRzEnpBm9xh/w9F21L1lTFwvs6/KZEca8hBlkokcY/tD4B?= =?iso-8859-1?Q?IVgIWWO56uEXQpmhOOFXSbP6DAKFi+H5tjHJdwqqC3LXKNLyu2Jn5cuejZ?= =?iso-8859-1?Q?42T9u7aSqt2usT40lL3wewvgzG7Q3b4PL37lycCkm/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fjHCqkBbNv53Y4rN8PyNvFTo/m71RJGDFhFXf5Npkz0ZXzO?= =?iso-8859-1?Q?S/wxfE84ef3NAn1uqhEufV6Dk0mlyxOBSkiiN4S7KDbS/P/WWQxC/9rns6?= =?iso-8859-1?Q?2MUBJA3dP6jxtrC/QvmdPBT/LAiGgfPQZUPvcaRxMB7TrTPb0skepuYoM9?= =?iso-8859-1?Q?rTKF8BbRNDtbypEUN/IrDxfRgqXPp58MXl+fB7RK4K90J8jOFM/gEF1uMn?= =?iso-8859-1?Q?765e7bhp07Sq/TQUFqsCjmEBBVzT9ZwJRFEiKMamvLROlLkTWsdMkRYxZq?= =?iso-8859-1?Q?/Ye/kLHMLM59Kr0piRqfLLCpEzfv/DrVIWHNF1m+PPcw3sZ7+lc1sV1Jc/?= =?iso-8859-1?Q?ajPiOob4ZCcKVU+oDVgLEC//ttBeu4rKc45wHPvtnyS6H7UTPQhDkikmoC?= =?iso-8859-1?Q?33MvS8E6l6269GgO1CQHYDfVsrVKgeTLfqf1SA=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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?LamExWdQz8VFP/n5v6tw/4km96bVd2tD5UVh0evAbT/GBDPpHs8xBtKfrq?= =?iso-8859-1?Q?grgxRz7DB7s+ceLtveXDjzHULJVcRfWdlO5uo9bCoJR1jhjENaDrq1hFXT?= =?iso-8859-1?Q?6uEjtqECyGOMUsIP5VrGvu71gO7FWrS9Ngir9muiiD5NVIxuzUS85ZZR0l?= =?iso-8859-1?Q?HHOzyAh/waV9sh41P0InqY3bR9ecidkG7uk08tk6bA9cmJRG0WPRBNcsQQ?= =?iso-8859-1?Q?I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0dKpqFzKvWjXYtjpCjRZ6X8HH/?= =?iso-8859-1?Q?lq9d1XiBP4mdC8Vnbb/b20OFIN8Sp3WI+s/WBBb0aLy7G95Z6se8D4bs6n?= =?iso-8859-1?Q?u7CNLDBeLDEylXrR796jIgzr1CG8lYdsDinfzGIPu/LSXAtiCxnVCLa+fK?= =?iso-8859-1?Q?XbW7oDulf2vdIgl7XPVP/BV+mkRPaG+9NFWT6PBMDcjyyWmfJXJuKqalhN?= =?iso-8859-1?Q?I/LUZi8im3Nh+w4itaBhW7Ih8mu1gXYQ4dlhoQmVP6f1uTZ8mfEx9o5RrE?= =?iso-8859-1?Q?JEykIS5ote1OH5nSnm6bhgErPa8ziMa5/7SjTETyZ43L0NC11nE/4V0gIk?= =?iso-8859-1?Q?EVqKnnaf/z/c4b5RESFkwE99BWTUQRDhfpipKumzZMTQRRZ3wUaDt84iQS?= =?iso-8859-1?Q?1nAnqJi4Zm2p+RJ4TN9Y81UmYq25kFS21l5eZ6ZUSXD7eLu25jPkvq8Jml?= =?iso-8859-1?Q?Bx09o8HTiiwYkewxby5bqjFphhZQ90Ir16OMP39qqMM6OAO+SkdN8EVJWJ?= =?iso-8859-1?Q?um3tCTillW4usGy6aQydaVWs1Jw/bWD9ngHlyS7awcqRaxRxt3sjiQy3Ff?= =?iso-8859-1?Q?0tC2P2NwgSCzuiXYmsk=3D?= Content-Transfer-Encoding: quoted-printable 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: ae6fac31-a220-4d1c-2d76-08dd3979ba08 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:53.1283 (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: 6Swpn8dlzyWwHC1V0Wa7Ikcl2Xw4NOPWk8V0tCP7Atb+TI1WBjTFhgSBgKlnjyxA/mUBizDSkDdQg7pzpkCjQJGLIz8pK9bIhr6s+/kQGJu0N5Iq9IRVJTNV2XGiiS1y X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395105061019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif Signed-off-by: Clement 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 =3D { 'test-qapi-util': [], 'test-interval-tree': [], 'test-fifo': [], + 'test-atc': [], } =20 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 =3D=3D e2->iova && + e1->addr_mask =3D=3D e2->addr_mask && + e1->pasid =3D=3D e2->pasid && + e1->perm =3D=3D e2->perm && + e1->target_as =3D=3D e2->target_as && + e1->translated_addr =3D=3D e2->translated_addr; +} + +static void assert_lookup_equals(ATC *atc, IOMMUTLBEntry *target, + uint32_t pasid, hwaddr iova) +{ + IOMMUTLBEntry *result; + result =3D 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 =3D atc_new(page_size, address_width); + if (atc) { + g_assert(atc->levels =3D=3D levels); + g_assert(atc->level_offset =3D=3D 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 =3D { + .iova =3D 0x123456789000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 5, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xdeadbeefULL, + }; + + ATC *atc =3D 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) =3D=3D 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 =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0xabcdef200000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eedULL, + }; + + ATC *atc =3D 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 =3D 5; + static const hwaddr page_size =3D 4096; + + /* 2 consecutive entries */ + IOMMUTLBEntry e1 =3D { + .iova =3D 0x123456789000ULL, + .addr_mask =3D page_size - 1, + .pasid =3D pasid, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D e1.iova + page_size, + .addr_mask =3D page_size - 1, + .pasid =3D pasid, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x900df00dULL, + }; + + ATC *atc =3D 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) =3D=3D 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 =3D 5; + static const hwaddr page_size =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0x123456600000ULL, + .addr_mask =3D 0x1fffffULL, + .pasid =3D pasid, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xdeadbeefULL, + }; + hwaddr addr; + + ATC *atc =3D atc_new(page_size, 48); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + for (addr =3D e1.iova; addr <=3D e1.iova + e1.addr_mask; addr +=3D pag= e_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 =3D 0xaaaaaaaaa000ULL; + IOMMUTLBEntry e1 =3D { + .iova =3D addr, + .addr_mask =3D 0xfffULL, + .pasid =3D 8, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D addr, + .addr_mask =3D 0xfffULL, + .pasid =3D 2, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xb001ULL, + }; + uint16_t i; + + ATC *atc =3D 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 =3D 0; i <=3D MAX(e1.pasid, e2.pasid) + 1; ++i) { + if (i =3D=3D e1.pasid || i =3D=3D 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 =3D { + .iova =3D 0xaaaaaaaaa000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 8, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D 0x1f00baaaaabf000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D e1.pasid, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xdeadbeefULL, + }; + + ATC *atc =3D 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 =3D { + .iova =3D 0xaabbccdde000ULL, + .addr_mask =3D 0x1fffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + hwaddr i; + + ATC *atc =3D atc_new(8192, 43); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + i =3D e1.iova & (~e1.addr_mask); + assert_lookup_equals(atc, NULL, e1.pasid, i - 1); + while (i <=3D 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 =3D { + .iova =3D 0xaabbccfff000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + + ATC *atc =3D atc_new(4096, 48); + g_assert(atc_update(atc, &e1) !=3D 0); + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + atc_destroy(atc); +} + +static void test_invalidation(void) +{ + static uint64_t page_size =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0xaabbccddf000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D 0xffe00000ULL, + .addr_mask =3D 0x1fffffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xb000001ULL, + }; + IOMMUTLBEntry e3; + + ATC *atc =3D 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 =3D e2.iova; addr <=3D (e2.iova + e2.addr_mask); + addr +=3D page_size) { + atc_update(atc, &e2); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + e3 =3D (IOMMUTLBEntry){ + .iova =3D addr, + .addr_mask =3D page_size - 1, + .pasid =3D e2.pasid, + .perm =3D IOMMU_RW, + .translated_addr =3D 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 =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0xaabbccddf000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D e1.iova, + .addr_mask =3D 0xfffULL, + .pasid =3D 2, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eeeeeedULL, + }; + + ATC *atc =3D 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 =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0x1000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eedULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D 0xfffffffff000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xbeefULL, + }; + IOMMUTLBEntry e3 =3D { + .iova =3D 0, + .addr_mask =3D 0xffffffffffffffffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0, + }; + + ATC *atc =3D 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 =3D 4096; + IOMMUTLBEntry e1 =3D { + .iova =3D 0x1000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 1, + .perm =3D IOMMU_RW, + .translated_addr =3D 0x5eedULL, + }; + IOMMUTLBEntry e2 =3D { + .iova =3D 0xfffffffff000ULL, + .addr_mask =3D 0xfffULL, + .pasid =3D 2, + .perm =3D IOMMU_RW, + .translated_addr =3D 0xbeefULL, + }; + + ATC *atc =3D 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 =3D 4096; + hwaddr base =3D 0xc0fee000; /* aligned */ + ATC *atc =3D atc_new(page_size , 48); + g_assert(atc_get_max_number_of_pages(atc, base, page_size / 2) =3D=3D = 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size) =3D=3D 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size + 1) =3D=3D = 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, 1) =3D=3D 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size - 10) = =3D=3D 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 1) =3D=3D 2); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 2) =3D=3D 2); + + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 1) =3D= =3D 1); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 2) =3D= =3D 2); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 3) =3D= =3D 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size * 20) = =3D=3D 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + (page_size - 1= 0)) + =3D=3D 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + + (page_size - 10 + 1)) =3D=3D 22); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_func("/atc/test_creation_parameters", test_creation_paramet= ers); + 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(); +} --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395104; cv=pass; d=zohomail.com; s=zohoarc; b=MvudFqwGv6GDuvuKrKGl2v1wnlrMyymVONAC4YpDwwdxT1+h3suL3D3Z6oxMqS6GQcgZbjPaetYpgh52YzNkx8GF6KDqNPRp45UL3WZpkJvjJri4RuCnwIipK1L0Eg4PWQ3MRN4iTYcv4QN70E8p1Ff/sqZWAZH5kajpz6wHte8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395104; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VOf2f5rIkqvUHqqQnX73Mt6rzDe2WT3VgsfOVe4zjtA=; b=ellz47HVwcsNx8D7GonqBVV35RGpz2hVFpmbIjBcKr10nI11BInC7qbbwLD3KTt08qScAMs/p7SCT/driXEwWkg8fu/FJ+ToGc52v0UDhqwoU4X05b4wiXF5f0PP8sqUTxSD+/BZSX5kbOakfZpQlZMgZVs7xuRMZr/3r9rfPGo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395104584524.1129633495024; Mon, 20 Jan 2025 09:45:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvml-0004vY-5c; Mon, 20 Jan 2025 12:42:03 -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 1tZvmg-0004jF-PP for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:58 -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 1tZvme-0000bO-NE for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:58 -0500 Received: from mail-am6eur05lp2113.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.113]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:54 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394916; x=1768930916; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hS+ubrQMFsIzNpAi8WQb/IPQKIWvAB02nNA7fqJhrm8=; b=u+JCSzJJjlNSHViL9atfL33bXCglLZyGXV66k1SukLtIjcPtENkpqc8s Q6F60/l5ry5b+5U+cmqunrRddU6Tv9TA2Iun0ZU1Q/dfbA14XAwRnzPxo US3gYL99Uj9vc85uALSsbFyaCgC7hz0wrhzO5yHdTtICRL4PYLpUawfw/ xZydDzAoT3+Ci704v6/wfJF16zF54o2PJx13g8aYbcMVsL0RykWohO4BY VixDGzZtjyD7vtC6ZXuP/sOmpYuF25IaPIYaRiP53x8NHwrya6rbBmoDk UVuMaQKT0luFYp1oxlGkv1Pjq8DTeFRx7pFBYJZ6DCTiSeRiYf0UQ/3CW w==; X-CSE-ConnectionGUID: TUUnE5xnSkCQwBYtOhr/fw== X-CSE-MsgGUID: I+QRl/JoTGO/N+VPov5Bwg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133404" X-MGA-submission: =?us-ascii?q?MDEf8bepAENXnAdZCGtLsxUOXsrupHjthICIND?= =?us-ascii?q?hJ6f4/YzxG4W5vrhaAm4mG384pd0rf5p82MsrUdPii0AQs4mX4GNKC5r?= =?us-ascii?q?+WxKWv7heq25R8QFgyZ+Wfm82Xqnf8MGR68ItsbSMiOuj1gbb67H6W3z?= =?us-ascii?q?VBt5HjN+VcY4T73Pe2Axz8iw=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BW1KUV/nxFleGQsXGECz59AzBFSUN1ZY+tqj4xNnOEej52xyqZybv0cW1EHHxLPgnt7PqxWKB9F6itWZQcvRcDib0//qxcA8Ty46DwlKg+nnXwp1jLNpCgpplLqbKSgMHgmaJ5WMPDVGTQYD/SGQJBmNzBViOfUq2PLHCygJvftw6iYJAkNrU9w0qa4VhMMvoviG2lFSp27Q5m+kIYmrWvJHJv/yGtSZHQwnlaVtY38LcirSdtTb2Z8dvAcMT3y4B3dXJRv9ClYH+A1HW8j4OmegfRoFiW9afAXr5Kk0JmZxeI+dDjCCgfZRO2XXErLEJgl8T73tQyXhp9ndroPE/w== 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=VOf2f5rIkqvUHqqQnX73Mt6rzDe2WT3VgsfOVe4zjtA=; b=C6zhInCcKvD0hHY+nkzfLRwSn+4q8ZE1y59zW27KW8AielqZe/CuPC+7X4WIk/gTXZOch5sifVgyyEkWmywOpvPvhKeDmgYKWqmuxI1//0FHFgXsR5142JudwbHhm8oQ5+Z5C4F/wMh/czYEEHXylKRLPYfHC03zKtY9fdZPgdu5f53/iB67lBcLBNGDoCaWISXhk95GyUXgXoo0VQDMshleEJQzWvEPGPijw5QV4gJbcjISADDPcgFFkFmmje53aLMMiGXgj7Pyq20IcCVfGzTqZLHC0GehpZiSBowIXWjJD2OHqa24kqutdWE0hnXqTbYXqbx2O7giYjNqhQgpJA== 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=VOf2f5rIkqvUHqqQnX73Mt6rzDe2WT3VgsfOVe4zjtA=; b=L/GfRFjvNWwF+smwD/UIhCCmbgFdydQBywmn7lXSf3W75sre0JdCBp7+RGYyfoS0mkw8yqoRnCuTgkWzqCLjC/Hk4NmwSQmvEPx9y5HwVhSGKXCOIR+PsxS+gx6/CL6+iQeVcS6+KHkRiZrbYP4ZOb2472dLuU84xQs8q7jEBQgljiDPdottlOxONoOjQdRDLHoOlc7p0hAP+oHujqSI6xyrBpHisCPENr5uDAwdrS+mvVMCiq0Fvqy9PHXkNMLsWjU3JU6SUvNnmGBPoRx+8Q++uZ8KMOIUIXI2KIxr+JeaGO5rz3jZ6hFkS+G1sOx3zlEQl12LtHLgstDbTGIEOg== 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 v2 15/19] memory: Add an API for ATS support Thread-Topic: [PATCH v2 15/19] memory: Add an API for ATS support Thread-Index: AQHba2KYusTOf31TZkq7lrpG5ZaiWA== Date: Mon, 20 Jan 2025 17:41:53 +0000 Message-ID: <20250120174033.308518-16-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: da147a44-d56b-49a6-d08d-08dd3979ba8d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?BtJrSx9h+6TFlEx+9MWXlF/bzHE+CAfEVxL/yRB8vKoJdiLv8JR+Nh0lh4?= =?iso-8859-1?Q?v6Q7Zga8JIV2qazRzshonDp0W6DyKVPOZ+h4/iIZVu82pnwe5eXkugpBaP?= =?iso-8859-1?Q?q6ElDUiBaEzam47LkkRa7hhZ5tdoFwr+nxoRQLMRL2cYGlLlEs2n3O4y5H?= =?iso-8859-1?Q?VdK69g88SRQDjjd0q9xW1Xx+VaSTWr2TXaoAeo3AysSPQXPNJ1wQc6I3mb?= =?iso-8859-1?Q?R0R+6lwz6YoILcTw1b+3MG9adJ+/NtLmn2gmNJhVYRu7Z8nifL4rifJQ8D?= =?iso-8859-1?Q?mTZooSOPJ1EhljKUq7ZTnFOI1FCIb+3rMyQeAn5KWBqvFUq/sDGUpGGppW?= =?iso-8859-1?Q?8MMBUUuXuzAU+pUM1Q4bDLtOUeHc1C9ZlwzGu0+y4OOq8UuyWmLCyE4GQU?= =?iso-8859-1?Q?sySJNd99kFXd9Xo52KcWC5rTZJQPEPPhAfFLOMqRaGdsv+SGOCa734IV1J?= =?iso-8859-1?Q?joWZUAhG1bIe1EQ1zegVPnkN4+sIqTmL/5PuSBsVjpbwLSPyeY3n4EmLzB?= =?iso-8859-1?Q?YbbUbRaHs1BYFtaG4QL1hi91Xv+JfALBwUwXGdnn7SQAaJzsK9cMq3B2EV?= =?iso-8859-1?Q?24C9FNStsOC17tCVKgKhRM3sC0Vzx4Kqsqf+gsLnAlyjNbX9DPgpJMLSyz?= =?iso-8859-1?Q?tYimyCAlhvDci7G6ZOgTNMuiT6O1HaPO60BOdn7ohgSd8cWcyXbFf4UdV/?= =?iso-8859-1?Q?lKnHSFoy2ZuU9fFB1vDHhNMbgv+tjHaGPSl8ZJiKhIxKi+MDpOdmdgUCDY?= =?iso-8859-1?Q?J7VwGM+mBAuqXwt4YzxXIWkuyYjB+DNMObZ8WyBjB7++21G0mSCj1H9nT5?= =?iso-8859-1?Q?tD0U90BzMS2O6nDv4g024j+2i93PMiZoqgfHIFt5qYovxenWdp182nDGpF?= =?iso-8859-1?Q?edV/dD5WEg0xf7Ga26shId4OuPdsbrPLVMT686H1+3GeE2mQxzRzvT2GYb?= =?iso-8859-1?Q?RdJjkiqd/JJdFI9PqQdKTdig79PYDyKKyE6uR/xZSV1cdXkhkG0qD1oCiB?= =?iso-8859-1?Q?CbGfYukpit8Tl0BXfNM6vUcqIR2YYYqNcvkfbkNRO34TSme40vX4o1QBZa?= =?iso-8859-1?Q?qQ9RopwGnVPzoM6HHrGc8k80V/B7Z7ONNmSTNpoLrExzsruusREE+UKKZt?= =?iso-8859-1?Q?fxZ2UoQ+dt7/+RshORiVQz+mL2jHzSXbzDra3oHLYNpHxM4wpdxo4hb7Fm?= =?iso-8859-1?Q?cGvoA9qP5uR4B8wG6mva+cT7BMWon+jgl92iRlux0HRDY4UjRKcHJ7Z9pp?= =?iso-8859-1?Q?4N8bY8RTLm4iCGN0Y8Qg/KJkG8y6B/Ht7dG5RnlYkw/YZyOPRMkm67A3Ox?= =?iso-8859-1?Q?ZcXqLF3+FKk4XSF0s2uM4APetYJJXZEAQukh20EpUpp8OKEvOyMoguPEHE?= =?iso-8859-1?Q?LFFMWltQHpW+NMwExUmsjGpCVfv/w9TtxPTqZM0PTxfLfQF/GXn9FyMyJU?= =?iso-8859-1?Q?vON9D8qx+4RavBW5jwDydSY6Ja08kp7FcrOsTA9GfHqmbpiR7O32goM1+q?= =?iso-8859-1?Q?DUyxIL+PSkw+YTitzrQJv5?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?VvFJLeHCpl3hkzgaMqoskqsXMJjUWJvGofX4+WwyWK+uqt0Ebxy8+wPzVW?= =?iso-8859-1?Q?+zhryNMFrA+oQFvFuj7P4L3PMktpLe9G9nGtoo5+Y5TbPZu3XuvkIlK1xg?= =?iso-8859-1?Q?S/MX14sKccTiDNu9eHlqW48QHqzUEq19mC8RqiNSjIirZLIKv/e+cqqzad?= =?iso-8859-1?Q?AE4+eAmlO74LCuUPG/Xs7H6OKgwcUQF2Mn2jEERceaVN0E9DSO33L5fdAd?= =?iso-8859-1?Q?guW4I+ZNXN/WCbTgPsFmVyiu2MrmU4k/ebMr4kIAihVy0cDbmcL5FHQRAx?= =?iso-8859-1?Q?mMwnNHh9FzSOpmKViTwY20RLuahR0KL+v7FAgS3rwZfJQle7cFWdG4t34j?= =?iso-8859-1?Q?Nx9rz2tkshro/PwW9Ytljz0IpMy1ZApbhWy69GF7GzcTPBGuSxuozTpJrV?= =?iso-8859-1?Q?tDmlQ9NLuf655tPThEjcwuLzLjef9PH6tooomoYyd+rDRfC7v+bmRjNxeW?= =?iso-8859-1?Q?VSeWC/CkahzcW8fKszZZrjbSnNOFOsEFGgqEubksP+WFyKYct54V38XpVq?= =?iso-8859-1?Q?0MIx+fZ3jvSwZRIbWRHMNj7G9NStc+XzI6GpFkqdLvXbw9i8iWGenHVzo5?= =?iso-8859-1?Q?uRieIKi0eoHy4DxK9GJ3SXgxcE6e7wpR4LlpolxE0djOTXfjX4brLQjqjI?= =?iso-8859-1?Q?Ju5aa9PDABIpglGt9CZdrYVH9VO3idk1ZjkYTiSiJfwsaJCDGf3rbmoD29?= =?iso-8859-1?Q?GqtK00Vw4jGmenhb018R17PxTUXAbF+jA3ewPJ79Fb1TkgOOB0d5YwrxlB?= =?iso-8859-1?Q?UsIbCSgH3RLqGk/ZBv1SDcKDAcBFULi1R6qylNIzPh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bqpjQ6j5kk=3D?= Content-Transfer-Encoding: quoted-printable 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: da147a44-d56b-49a6-d08d-08dd3979ba8d X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:53.9779 (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: jrVysPfP8wFrd1S1JT/uHNItUPDQeSnCZYiFnSJcPVRnTqM30Oq7wkMJ+3+AlRmnjkjfq6Zgp86ClYAJOGgx7bxxOXEmZAlrfeaVivNWCFuF2RSazBwIxSwN/BPLBlQF X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395106601019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement Mathieu--Drif --- include/exec/memory.h | 26 ++++++++++++++++++++++++++ system/memory.c | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 468b003bf1..042d4ea5be 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -148,6 +148,10 @@ struct IOMMUTLBEntry { uint32_t pasid; }; =20 +/* Check if an IOMMU TLB entry indicates a translation error */ +#define IOMMU_TLB_ENTRY_TRANSLATION_ERROR(entry) ((((entry)->perm) & IOMMU= _RW) \ + =3D=3D 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); }; =20 typedef struct RamDiscardListener RamDiscardListener; @@ -1882,6 +1900,14 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *i= ommu_mr, IOMMUNotifier *n); void memory_region_unregister_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n); =20 +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iom= mu_mr, + bool priv_req, bool exec_r= eq, + 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 b17b5538ff..0a379a72bb 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2011,6 +2011,27 @@ void memory_region_unregister_iommu_notifier(MemoryR= egion *mr, memory_region_update_iommu_notify_flags(iommu_mr, NULL); } =20 +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iom= mu_mr, + bool priv_req, + bool exec_req, + hwaddr addr, size_t le= ngth, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegionClass *imrc =3D + 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_re= q, + addr, length, no_write, res= ult, + result_length, err_count); +} + void memory_region_notify_iommu_one(IOMMUNotifier *notifier, const IOMMUTLBEvent *event) { --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395123; cv=pass; d=zohomail.com; s=zohoarc; b=U23MsBhfNrJ+0aTa2bnLmOnVKtSp4ZE/S50+Vc12pS47KvxGsxJrLLXbObkPQy3DwtKNRUP3myd66z0rMf/ga2aCuWWdiTCTiP6yGY0SmK8n81op7SnAr6RCVx+XvD6JTynWeZGU1hBU/+cpJ6WJ61W8cG28rwfPhMqseHs2zHo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395123; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4EcxnBTXM+1uBGS5IiYSPs5giNM7LLxywy9NilbCkXw=; b=bvlpgtJJl2Aqicd0fKXkBWHJkbHZd/9XNUHukmpwJTmdW/jzYzj1xgE9ZuASNJVFmyRmfBDLAwp0HV5V2nVBkOqoSf/J36dKZ2gDtkbIcFGhNIoAOyPfxfY5wUHy7VIbviiUm/0Xk9cQ3CidiIRWN2cArhv993RzIVAVz0mjMEY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395123800308.00166544590627; Mon, 20 Jan 2025 09:45:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmn-0004xr-3Y; Mon, 20 Jan 2025 12:42:05 -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 1tZvmh-0004lo-Kr for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42: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 1tZvmf-0000ZN-Lw for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:41:59 -0500 Received: from mail-am6eur05lp2106.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.106]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:56 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:55 +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.8356.020; Mon, 20 Jan 2025 17:41:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394917; x=1768930917; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=VkUj+54NCtH5EiY7JotF/jxihud84WCF7QG782cfgdo=; b=HyfUA3CEpB7VQu0JOGNS1/xIYiaanu+DDx7I1NVzjI/t19UvWzgB9PB8 Fi3GeO+GQwllQ2ZXXr0SefZ50om5iW6fgwwPMjVWzD1vXaYmJL5P1sfVf L4Gs/0R/oSPPBt0mWr5OKDJU6jdNgv1VNqnvExsaaLRWq5qpYdPKHvK5r cc4mDy43KpQBJHU6XihDgQEzBx8J1h1vJQexBeiEFor6SDIypF0d65GrO g7CKAuWg6Ab/mZKpje9HHoAWqHVqA00rYT/V+e52diQ2HvQ+QlR3fxntg AprVEFGGkyd1t1ldjC4I5FnTp4hPymlSCovPcixe3LT2QV9iiEpmaGuKk Q==; X-CSE-ConnectionGUID: rIhI/FHjR6aOsH01S5wdmw== X-CSE-MsgGUID: ex30K8CyS5WpqYfYgjANfg== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133405" X-MGA-submission: =?us-ascii?q?MDGq8vuSmi7KJJX7wW65eeqoURloQ9jl4fbRL9?= =?us-ascii?q?CsNVOx5VTkBGHGXVwKKb+PdDNfcN+UXv+wTcZuhJNnBQ6CFbUylX46q5?= =?us-ascii?q?zKHNV4CLMwor9w7vwPROg3ogXtmXGiRxT6xZ9hXSrvieveNWfghZ4MCy?= =?us-ascii?q?TS+vcXBWY4JylEGP+3wdpUtA=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HKc/QEoEICjENmypBuAt92szpqHj4O3zUdLmhIcILAQXyE1s9jl3Ro4g4bs4vn0ycwXxN1ilNYAeHFQuRQlKMbOcT7FV+uXVc/PFQh2BLWvALsXmL2ncsJnJAuzoq04CCyBV4vT++4UaKzH1Q6/xVDD9AD5lzhrYwojgZEpVdtRa2bbJDEPoM4w5JrfQ42VQgADudF/RDaVPz5PQyI1bY5+yxW/PM/XobuC7840TNwxdMGHROQme+2Jvodxpa7fcVY7EzKJB6sLv0wJtBuxzBiztD01tgVTLX6Ho21HMYexAf8xY8fJzI6ZBPWehNqqbeEKZs7aOuLPM6CenEUQkOg== 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=4EcxnBTXM+1uBGS5IiYSPs5giNM7LLxywy9NilbCkXw=; b=A07019xee6maZbH6/hDbVMnmoALtMd537Zr5GK2kh0/oZHMG3fVYy2PVey5o19fp/+/MhVCcj6CGXuGS914w1BWvoNj5GhNTmb7LddTYaleKy4yrLkcdkBHj3B1/LZXcgP43FimSEyISsqNN7V8NZDR/PY5cUUelsBi9kBLcYJiPO35GiUZRi97Dn4V6ozlMlPT9aktMuOkAFcaNIdgXYuSwww1AbLKXNPvg60eOkR60JpBEjSnlQr7k4iPvY3ppaBqPdZjPaq/P9LgXKoDu38xmYw/GG/kHxBChcXtQmZVptGol+c0EpjZPJ45QtepXYb/ZsBmYi2H9h7fRc+DPOw== 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=4EcxnBTXM+1uBGS5IiYSPs5giNM7LLxywy9NilbCkXw=; b=aJpwMjzSQOIMWIgjtjvbBDde8aNl92GezXbzYXMbnXH/pt1HkWs4tQXf8PDH0Hqvmo9APpULmrDvJN+fWu2zsSjmzx97MpA1x3Y93ZRJ/fbpKjzLdEffgdYU8Jdho3Rt5IgkwQ+v5Qyvxr4zynYYRLvcmVt8/8eUI64jWLQMdadT+INhSkzKTjoGr5fQNotMOi7Rp8RAImxQ74YbxoiQI1r+WmlnP584zQD66BNHcMmswTYGq97XFkrvGqAi/bSWqS9zVkaxjM69qZbXsuSQtOD0ZMV7DnYtKQKCg1OumT0ZXCJCT7DcUnkXaoO6zRc8s1Dx2GNVv/cZ46sJebTwbA== 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 v2 16/19] pci: Add a pci-level API for ATS Thread-Topic: [PATCH v2 16/19] pci: Add a pci-level API for ATS Thread-Index: AQHba2KYPBDhY4wr0ECnIp+z7u6fAQ== Date: Mon, 20 Jan 2025 17:41:54 +0000 Message-ID: <20250120174033.308518-17-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 82870b5d-a64e-42d8-4f0d-08dd3979bb26 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|4022899009|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?3izouj+kcvlpG9O7o4oHDo9063nM4TirdwysTJfss122GPHYmX9dkL3BFT?= =?iso-8859-1?Q?ynb/BlnW/r4nWdcLrsW2AEhJFBTWMcYY0uIOrEHPvqlvvuTUp7yHzoCL6H?= =?iso-8859-1?Q?Q9wCi21Ztk9Shp6V/HZP55DMB4JBBnju98sCsR6OFB/uNJ/S9jLk1tOEbb?= =?iso-8859-1?Q?mKWO4PevyWZEl4WMX0w/nFdctAPf5GS+ohbNubya/Q1OpGro9hIBjcLwVH?= =?iso-8859-1?Q?kA1LimLMI+UvmUF3b45QbFl2ZdWADBC8gn39ZPkcNAmjRrGgDf3YSg/zgH?= =?iso-8859-1?Q?UTMg0pRgX0E40yYNab2H0OJIWTV+NuOarxqCwX38v8be7ixmf29bU+NDVS?= =?iso-8859-1?Q?uYHbjGRxJ3LwphMJB30JycD5JpEHPjLyhMu8NNpz9YYMKlVEpBVphfmHNs?= =?iso-8859-1?Q?TPMuhpH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kGQx?= =?iso-8859-1?Q?fT/0W9carOdOSYp+1V3KZvwnjXSB+u37rfhcSjXWyHMrlBwAD8Z/aCSCja?= =?iso-8859-1?Q?9CtDNMUSuc7mPwm1l28vTB93GC+MhERmOthOeXV+QqG0rTKpe5TK1Y3J2Z?= =?iso-8859-1?Q?uHPRfxoWeKMb3j8e8S0+oOfrfYhFER1c9UtjYd+GDiTdjr3MLYE/4twmfr?= =?iso-8859-1?Q?AyvgKp99rZCD07gH2vmENg?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Clb8Msjfb9jJfKGzczeZh5R2XPUqqqrSCK6C3CpVnTsIJ2NYJBoFrTk908?= =?iso-8859-1?Q?RiAkXTXU+AG12CXDUrilGW5qFzi5IgplMOwLfPX42gezEuPvNdYHFiBYdZ?= =?iso-8859-1?Q?biLc+aXZeDB4LTEEGl/fKthJ6I+SU9a2qSvB89JkmlMHb8wztPO8NOYa0V?= =?iso-8859-1?Q?dzyK+Ml7CptlNG3sh2WGFiwgKEdFYtUhrRPz/5VkA/9kxczimYy9IA0VcE?= =?iso-8859-1?Q?+rDldIZP8+PU/6R4Se8UCZCzAiIApyGsmuXDSGXKo06k8YZjT1plML4793?= =?iso-8859-1?Q?MI68LNNopQfsi8kOrK3JeHFJVWlJAjWt4Zb8hXPC/LOoso3dgFkLSnfgOv?= =?iso-8859-1?Q?4wixy+9OviWi6xi7U1nBbE5e7iIEvFgW/0xcD57ZvziaMLDpvf0WwuhiFE?= =?iso-8859-1?Q?ONjF/yx7SaoXVD8gWdETuvevJaycbXCLXfTPFSYAjUzqec70qQJ8U5I8ur?= =?iso-8859-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I1dYR2Vi/PkppCb7sdiuEa9s?= =?iso-8859-1?Q?yisoMwm2FC5+1BjJl6mDwTsh6IhmRNeGwCxQPWiwM0gaxO68BswAGLmsb8?= =?iso-8859-1?Q?1LNYzDQ7tq616AKu9xF2N2WK1i3TIWKSNUBcIgzujKnkphH4bsXvBup4mJ?= =?iso-8859-1?Q?iWHpkK8/rvfPqwDCxpHbiGRf4AiYyaCBlCkMyM4k0YQO53Ru7zGgV4vo7n?= =?iso-8859-1?Q?KrvduCZIwOFDJ2VZvLtjaZXIgnx0IF1vZnTTvaNUKP+sg8EGvbWoDKzWnw?= =?iso-8859-1?Q?9fTAMK9VzCrWCwQzbQCaw418mwcX9QiZfBfaanCfw7ZvpgDPEWMxjvRNcb?= =?iso-8859-1?Q?Jyq4FdNhqrb09LdMn0k=3D?= Content-Transfer-Encoding: quoted-printable 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: 82870b5d-a64e-42d8-4f0d-08dd3979bb26 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:54.9728 (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: Sd4a6kcKL88CeG5/Rr6UokqVBBaZLQ5RT0CW2aDsluMnHhmi+V4fM5UaG9XSTuf+vEWx7E/TG2S2TgJ4vUDZRftCA+kJxmiht6WVtXHjdhsst9+Rr4n1K0PkkkC4iu9R X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395125074019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 be29c0375f..0ccd0656b7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2896,6 +2896,52 @@ void pci_device_unset_iommu_device(PCIDevice *dev) } } =20 +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 *re= sult, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegion *iommu_mr =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + + 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, len= gth, + no_write, result, + result_length, + err_count); +} + +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + 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 =3D pci_device_iommu_memory_region_pasid(d= ev, + pa= sid); + 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 a11366e08d..592e72aee9 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -461,6 +461,58 @@ bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uin= t32_t pasid, IOMMUNotifier *n, IOMMUNotify fn, void *opaque); =20 +/** + * 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 *re= sult, + 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 * --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394957; cv=pass; d=zohomail.com; s=zohoarc; b=HSbw40LpFXx0h+GphWPY4wVRrw0udCtCMLHB3QxHd4GSPCMuDio+rr6wdQValUtBA8qy+sb7Yc0c6qlYhcniIE1CejjVdPETidwU1RV1h6GJoG8TSDQ6noagwASp5LsdwNYUPF0mt/PTi/kakPkxotZISrip5xa686vlZb7HP7w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394957; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XEm+kcr1XmCknek/aj1wwABq0rrHY6adgLyODzgqi/k=; b=TZSwyiiCFfl/eFT5036XKlzp9SjPFgusFMxpTcPtYvWhsvfCbIRMqQH7xUrMlQiDJVMx6qNazFdEfR/fRmOR/wODUm5oV60Vsq5m6qOC4/8VkX0DqhdHED2Bmx+HOr6cysHyOl00YSKl54zdOEPIj4lVb0KYSAf0lObZprejKZc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737394957776456.4388705102217; Mon, 20 Jan 2025 09:42:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvn7-0005P1-Nj; Mon, 20 Jan 2025 12:42:25 -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 1tZvmi-0004n6-BE for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42: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 1tZvmg-0000aZ-L4 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:00 -0500 Received: from mail-am6eur05lp2106.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.106]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:57 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394918; x=1768930918; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=5x886T3s2t0SJOfZjFtnvyt81lof+n12kWsM8oHoRLo=; b=Mf1xky4WVrFEQZ4KhDiXlmFS/YlNk88ohNrMBdTJkM66iffSgrb1gBhq 0DRCQwX+beUwXkg/ekDL2EtiVpcRZNHYt6N77EZmzQHcbe7ZjNlLKj5k6 wRIkP8+MQFHUoX5qBtNq2PPAItCRBclJ4H4p8UixUlDSqE0J+lhL2eG6J 2QFVSjdgr9Hi9KwoPHlUFewE801edu5mTnV9Z8txyynYRGYTIzjGz85A0 pes1er/ERC7/A6KvvZrEQl5b/Hfq1SkT+v3PPDExhMb4ZR6nEP1v74XFJ Jur11+zLZmLeItIo9kBZZf57MgA73AmoQjcPZmH/xfpRIEzLaY4vktOBQ A==; X-CSE-ConnectionGUID: 5V8nMTQVTDeiRYny7q9QNg== X-CSE-MsgGUID: bq+3+fYsRCml9xsIiC5Fqw== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133406" X-MGA-submission: =?us-ascii?q?MDGKnAO0RElry2rBfSfDCDFDmDHYrk+dO1AEFa?= =?us-ascii?q?FtvMC6rcKPS94LRtu4Us075ROGM8LjOASbibjE4HrKDoYaU/kMTk1ANn?= =?us-ascii?q?vg/v47B1GNyWUWUoyMEemQvMaHS4dk9L8ebF5cyWMnuZe3ILmgySq/Mb?= =?us-ascii?q?41IXlrQSsAj4r2RMVxQOqyfw=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TixZPlByYgaEkRRtw2y5iHNdqcGuRSP3EFvOQwgOQaT0OxIXlrknYxLJjPnoJvwr2FWLZtVr+YkIv0CuC6A6S/CkKg3rjnT74VY/bsCG7vTfpWUmEbJuVTC8p0pzAi8qUNKOPM3CnPRGejrG4fvwmyfBgwn1TmN30lEewHwazoZDnqp3XV+oR5fKOIGHG5lwlEd3jJRy6+q3DMBMSYVx4FTCeqgkBo513q233bai4byTp9xYdF5kM7c3XqRTPhvAfNCbPnSGFiSRT5IUQh7aEdQrar3T6ReZLoOyQaza722Ux63QvmCTC2KOpWVSpjRx2h6+TiMWiELKL28j7Sxg6Q== 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=XEm+kcr1XmCknek/aj1wwABq0rrHY6adgLyODzgqi/k=; b=d9NbuQ1nWKr52n+nXREwORPwfaonybJzYOE+uboIoAaQ1WCB/NoXE4oVagxx4W91LsI62H4XQPxwnqLtffp//0Q1ZxHwhPjn/NuJ7D45VI8d4xKs6Nw9ZRPWTUrGAEiBXAFgCLDctyVDB5uNBW/irg+/XHQxHY7OfEmNg+H3z177ae8tSA390/QxH9JJHM/nnswue2p/lATFSvAdKLrQXcB8/5JdtRzRr7t18EmTqGPuwzQ7/+w1aIsabaOClSyZr6z9O952jtAAdCN3W8siNpSwwHJQi+ByvXQiYAkj+ugzPYUZt7niojxxgIzktZnA7J2daktFw8ZhkRAOfq5dUg== 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=XEm+kcr1XmCknek/aj1wwABq0rrHY6adgLyODzgqi/k=; b=s3e5J3WbB54wo7ivFZsrBhJ6EwEiwa4B3JCw9Jt/l1BPY8EjGLL54nxe3IgIoBecDbVTGF+IRiapjRMu/vlGpAbH7uNI8INwlnSDbGOMa/d24alyHfh2M0u2/UF8uKUO4MNoVxNE9zrsHqhgHWX8nu7l2hk27tR/9wySiq9UaHcAXf3p8WsXMTZAV6c8lv619W7mfRjTT4bDvxlcU70esVlfEMX2JZs3pZE4YC7DLLxuF0qAmrfmYmt/h09+0o0yqKcjeHlRuWc3UEldY1jGIRQRjmGp2hv/hn9Vq5X8WRlE4FYtwkEsN7jExtoYpL4yrKKSDxzp807AztcHMhqLpg== 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 v2 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Topic: [PATCH v2 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Index: AQHba2KZ83QXp1EEake+3IoV4qOa7A== Date: Mon, 20 Jan 2025 17:41:56 +0000 Message-ID: <20250120174033.308518-18-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: f4b0278e-48c8-4d9e-0db5-08dd3979bbe5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?HCZ5BuUGlUvcA/9b7lUUZs3U35WnTn8TeEMwfwM0Mh4heXGfKVAbfHVAI/?= =?iso-8859-1?Q?p+I/zObTGN0L9kHP8xoEso9XsWrR5s2CiTrKjfbMtBa0g47CBvEhQx933v?= =?iso-8859-1?Q?b+9OQ+lr36FnZLOwWjhsyzlQsWxRjWq/dMEbdq1sXaQw1apqDKVfGiDE67?= =?iso-8859-1?Q?uD2rMd+PFzfJvDqN3aTXS5azu691iyqSxzf7tysak+G9FJULBV1VGpOxQ5?= =?iso-8859-1?Q?LMpDCAdp3QWTy320jQXEFCWl4BnQshZyGGX1Q1+CbQ4bZod+3cc3xl7yba?= =?iso-8859-1?Q?l822u1GY1JsBfeKjVDwLZgXUDm39SffoYsyeZrZo08tvwPAmBONEBOUqKb?= =?iso-8859-1?Q?kd/LUA2FWNI4x1QuRpItIz/TLdZWWMzrZNsbE89RtXOVniWp9h0gucYNe/?= =?iso-8859-1?Q?vM29j8UAu+/fR95V5qkJC8j8GYbee7POIhfPllYOLVo40iC6Ts5/Oa4Pfs?= =?iso-8859-1?Q?i1ZM3wRRzzfF7L/5BH01FOPOAkfJ1h1Gk4Zr7/WpdbBdU3xSu8ZjDeSbX7?= =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1TOvlxAhis5vm9ztgKYMz9N?= =?iso-8859-1?Q?Aajn9olKlJqMt4PcHqoriqzEaO8qxQtMwxAzskMFptIAJKWczQZwlNoTtM?= =?iso-8859-1?Q?VimShSjF+o0uK3h7YGHmCZ?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?pJP+cjzXYwTbKTj2eif5uDRhpXvrSApGlG8MfcXPG617m5lcDUmpu7ctOt?= =?iso-8859-1?Q?H1nrFqwglDAST4qD6qNAo+FDLRz4+GzdtbVTxYywcfmgIFS0lhVddgjmiN?= =?iso-8859-1?Q?RvfWFLewcpd7mie1xxSu9kZPkI6NJ1b7LezoFauhpECYfNTYTMl+xCYXEe?= =?iso-8859-1?Q?82BzhtaIxvq/0xsAmnveMA78NVH1CFcJDPKfz6EChX+mZVyyR0O7tYnUT8?= =?iso-8859-1?Q?FFffo4PN4RiLeCscYf4rceMHk8x9faRw/DP1piLiEIwUWshAfSHRWUzsiE?= =?iso-8859-1?Q?u4RFtA5CrRifrZ5pvGvrP5/WywGc+sAHC5v0x/rlJeJoigQYh3FqRowehE?= =?iso-8859-1?Q?oVv4nwmHH3gpQIpm6wyup7vAKiuaNatuuLuAnoEKQe9LnL6ZLJiPPkZ6+0?= =?iso-8859-1?Q?jSTCd7NMRjDpbMOkiQQ8ZJA1FMOEjIh52Uqt5CGJi7QvU2u0nMCkC5QSug?= =?iso-8859-1?Q?zDAsQYQZg/hV8gDY+XbaL7EDThXqmLIIogUg3xOQRZEkovSJKtLLFU5LOn?= =?iso-8859-1?Q?13bUl5g+R4GC+/n6D+KqipnqVhpGzBUqP4nuk39hh6hq1fdtjB/2MXv/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ro9kK/xZqoBZmIjn+R5WPIka34wuBsXN6NZZX?= =?iso-8859-1?Q?KVN2lQjO+NGWhmK/ZZ5Hor+Il4+vXGMYSfZW2RFrinD3u2l3D1yMxdRu/m?= =?iso-8859-1?Q?rA3jUo0coLy5Sqg4wvPZa2C8O/0b/BI3U3AjQX9YAG8BxCTRWzrS4b0wJQ?= =?iso-8859-1?Q?2k3SzaT4GHAitQ677oO0RAVUhuBhOx1kWwlVvuuaQXbP31CSpnxZB/DIYC?= =?iso-8859-1?Q?4StOQ0DSP8rzUOopww4=3D?= Content-Transfer-Encoding: quoted-printable 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: f4b0278e-48c8-4d9e-0db5-08dd3979bbe5 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:56.2209 (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: tCGtV56eV0QeGxZSGWA0VMJ4iBHD/ztWCMEU7AikzqaAJLMofjIOw2nnVdH4P7muCb7MUxu9SKCpxv7ER+rxYN/cLCxDryydbK4+aKxFpXw95s7fff0cFEJDzHLzG02D X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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_MSPIKE_H2=-0.036, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394959370019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 021834c41f..530b75a9a3 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2100,7 +2100,8 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *v= td_as, PCIBus *bus, uint8_t bus_num =3D pci_bus_num(bus); VTDContextCacheEntry *cc_entry; uint64_t pte, page_mask; - uint32_t level, pasid =3D vtd_as->pasid; + uint32_t level =3D UINT32_MAX; + uint32_t pasid =3D vtd_as->pasid; uint16_t source_id =3D PCI_BUILD_BDF(bus_num, devfn); int ret_fr; bool is_fpd_set =3D false; @@ -2259,14 +2260,19 @@ out: entry->iova =3D addr & page_mask; entry->translated_addr =3D vtd_get_pte_addr(pte, s->aw_bits) & page_ma= sk; entry->addr_mask =3D ~page_mask; - entry->perm =3D access_flags; + entry->perm =3D (is_write ? access_flags : (access_flags & (~IOMMU_WO)= )); return true; =20 error: vtd_iommu_unlock(s); entry->iova =3D 0; entry->translated_addr =3D 0; - entry->addr_mask =3D 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 =3D (level !=3D UINT32_MAX) ? + (~vtd_pt_level_page_mask(level)) : (~VTD_PAGE_MASK_= 4K); entry->perm =3D IOMMU_NONE; return false; } --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737395037; cv=pass; d=zohomail.com; s=zohoarc; b=fg6S7FcK9wgvmVGrI4qfPG3NQI7Xt+aNVfWqfathxXc3tkljJjOk7t1u3iZcvOXFkeyP3bUat3jUOCUlR1oQxfOw0CYFYfwP0hQQF60W2vlY/U3jpijFHgINdCExITp9+24HdSyJyzTvrDyTlX9jCfZJmb6vkhka8vTtZObSmWI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737395037; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x3aoXB9xnRHA18HBbamlCYkaq59Z3CUVOBuKGlxl1II=; b=NMYrOMGpiILIhqvad5p25jUxgi8T4WFIa0Ew586X+mEqVLlxKaIL0HwKMqX6D5S/4hhkTfGe/kQ9oMO3IrVPsFxtYSpImd5ileFS/XEmu7/FY5XLOoCWFubECjJd11HVWXOO42LsRSYkZ2aP+q/MXk6TWrtXR+adszmRCiqA5+M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737395037923569.34175342659; Mon, 20 Jan 2025 09:43:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmp-0004zr-8n; Mon, 20 Jan 2025 12:42:07 -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 1tZvmj-0004rI-G6 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:01 -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 1tZvmh-0000c8-OY for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:01 -0500 Received: from mail-am6eur05lp2108.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.108]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:58 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394920; x=1768930920; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=UgB59vyp3H3Jn7V5ztZldIZgHg8c5PO3izwVPJX5VW0=; b=aCwWwJPCkL09quRP5mCnZ0r8d6kClwvahYLAW0qROKfBFO456RG5RkZw WL5d+QHHfLoQcDltud83MJvhlwPDwmwjIiny4f56IjfCpjayAjGKB/9Jy j5+PXyTRSc+m8w75H2TKFtvEqma8NPwRG5q6u63LQCnEGLwiRwHAvDCz4 DcNSjdxZkbTbBV6wnGd6JMJXNdeR0BunWdHxFAmiaf8EFxZ7WUPs203sx q86xSQnMbWfkL9o9XleXTY9tCsiy+9Q5Y1delSKN9iBSw6WYG4K+4Z2X5 3YRIS6s7g7uKwOQu0OjxX5HKsx3PSvqP/Qq63iIIyMVCtTRGd6QtAkU7g Q==; X-CSE-ConnectionGUID: 0JOv/0Y4TPyWPCZfQCs9TA== X-CSE-MsgGUID: UtrTgLj6Qca4SueB8bJU/A== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291723" X-MGA-submission: =?us-ascii?q?MDEJ4Wc6wyL4sE8+RShbBIHvVrnE8P6itHe7K0?= =?us-ascii?q?W2Ut+8/SnwWC9GURbfTBLJA8jbAQVjDRDh3Owu/BTPtM47zox2SH3mDh?= =?us-ascii?q?DYWPGj4E5HHiuEUixT47IxsOKvV+TBAgLRbQexVTk9YNbx/HM9oBbnMu?= =?us-ascii?q?TuY5Owr8GYV+Myr2Uaz0mu+A=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WwEOEpatIMFx6ztVt14EXGNEPCzcjb79EhlWgua2OtBqIr4ABIZrcNNMOinV/LIjlhuoHeHvUBMZfvYpIXactZWwofNuxS2Nfub01Xemof45VSPwPEu/OsgKyRG9ibE/wDhzNiw5bRBPll4gFIpGVNTWK6XY3rWhNu/uVR+mqzbk3EQsMtlGChtnAyGhlSRrb9xeLpz2QbMW+fBgMDZDrVK33PbWAQQ6OYVQCe/onJiJhQJJYXjjO7GUkL8Aj8CPtrn+w6HMvBlxjE5hqFpEeT3Yx0ID9sQzxfjVY1AptWdV7iqar7QQSmxgCV/YVqiw53/bKYDEsZMFncWG33vhGA== 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=x3aoXB9xnRHA18HBbamlCYkaq59Z3CUVOBuKGlxl1II=; b=nAEteMkza4pNzM4IuD1A0iU+zNcGmDQOe7ICmL52REEBiOAGD8cqmmNFYziz5OOwhJ7F08lFWSVIitoTR5JgPddmYjdHfMO3KHQ8NCdpfrHQcVOzsVqOdPEKNGTsFKbKnTo7x/9IMmGGHah4FZBD3hjFNBZZiEtk5pHXkjKq6+TGH2ubJNj7WxeHp/yi2EmWGgipCIB0mlBwHVfGz0UEE6WcZsgjc6xM31Oc5NRbPW1Vfr5smUyPo0pBRFPnQQOtrmh2lu/hKU5Ec1QVTPnj4aQs4KOyEi45hAjIdiSkWDGs82aid7qSWfunsqsUtO2/DtOknnGHh25HNCALm0l7uw== 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=x3aoXB9xnRHA18HBbamlCYkaq59Z3CUVOBuKGlxl1II=; b=sG2a4mi73Vb0Ek3TouQ1JIf+wX1gamZMXE+KGkSqBGET6K7PQpgL/YuhvsJvQ4ZdwD2burRaW8XwyYwruesBFe/YdEaB7Hr7n/WoJTyVA7f1rGdLdCn0fOkVs6AIunmqFA51Ivf/kAZhGiMNWBFKU8moU4IFBlpJfTCjK5V6y3vAqj0/pRKpNCblwF7f5W2W4UdZZH4Y8BGcWfCNi9uONOh6j2oW+P9OkumVHjmGqaujLY3s7wmzsigO6MIyDYYgG90SQtZUuReqUFbPlsyI74AMCatdpwHIDQcHVhZMrWCxDQh4OBuUpHHpqImYOMwQ0axuJ/OyOg6NY8MWMqtvnQ== 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 v2 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Topic: [PATCH v2 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Index: AQHba2KZIdJ9XQWqrU+jq7FbQLTqYw== Date: Mon, 20 Jan 2025 17:41:57 +0000 Message-ID: <20250120174033.308518-19-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 6c90f56a-4787-4deb-fbca-08dd3979bc6c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?ntWV250InIe9rqfHqVgKei+mhf7kFn5iLLecRN8otN9wnphpphYJTFtuKB?= =?iso-8859-1?Q?XIjpo/Q3DhXWH4Zr5MdJ1YK00lLbvn8EzHWKu7Mbf9GNl3QH+BgcYj+uMB?= =?iso-8859-1?Q?rccGKOLbQsVEwMldNsWyvGzvXxtMGAEZq5eZYtCDo/93csUp5uon4pfvNF?= =?iso-8859-1?Q?VHSfZiMQ/lsJm7ja+eaAPuZA3DvlXM6Esf0FiVA0UzqN8F5aUgyJY4MfsS?= =?iso-8859-1?Q?tZeF/cmABVr0SXGBwIR6mT2jmLg1zKCXuXRlLSecJ2HeY8h/J87wsqkuTO?= =?iso-8859-1?Q?2ByuVvbF+53bjqKiOF+hmk2jpg2W2br0XBIdTDL0BAQmCjWjg8FhJBpIla?= =?iso-8859-1?Q?c7oa7kZEyiYVZB4xr3F402ItvyQZzkSNmm9gQmWP40Xrs1bl87o6s1nLgC?= =?iso-8859-1?Q?hjaOhVcyV73NHmGOkUPH8EiUnYSW9552BrlIryfTGOzqo8qKvBvsb7vSRL?= =?iso-8859-1?Q?FrNr5GqX5n+Gljj7TgVPRoV8LnxnjP3H+CJiOi/OxNSpR5k6AjUjYqlK8D?= =?iso-8859-1?Q?HK1GfOu8cjBM/MCiZxB+UWdrZ3e4PQYXirw9mdQp4/c/cmOg7u+UvFsKxB?= =?iso-8859-1?Q?JiX1sYY/binOD2gDOEGzIf7Vaa/capyzJGggEFSP6Oz7Te7s3SNhDE/CAw?= =?iso-8859-1?Q?Ebz1anrhKnucBzIlIntz9B4kYFEYX4kjswqzuPg1x+EXs4idOe3mO1aL+W?= =?iso-8859-1?Q?DTdU2svZBuoFIcdXi7HOMqZ7R3jn0LNB8yCRZeawBTWcoTQZYO8ZYvCS23?= =?iso-8859-1?Q?U7zIQklv0EaWxM18Sol0ZJ8XAyXO5ogWeid9HmB9sDqkNX70Krk+cgQBtX?= =?iso-8859-1?Q?JQyohQkbtgEkrHdV/gZULwUclDO47f9bftQ2WjXoWR57YAkK08gqge2b2L?= =?iso-8859-1?Q?miuPOZxm/y0wfU+kCbxfL7ZVUkQwqAMv3CblWeWJblQ4K+zcujgklAVBGD?= =?iso-8859-1?Q?MldA5zJnOGvOZhU9y7E7ovFS2CgF94+7x0//G8HFX4KWQCcckv1jfR5SMT?= =?iso-8859-1?Q?Yu2RMqBCqpgyqZqike3CFGGC5FvRu3RJDYTEWDy/HBHmDj5C2FLrJkBqS0?= =?iso-8859-1?Q?4mwffqj6MVtu1BsNBJhVmFTRQyv2PlKQ/K3OMPa3ylv8SnF1o4eGEFTi9j?= =?iso-8859-1?Q?oEIj8Sm21Cw18Unx5gX4xXXeZvJqomZRb/QRuQtheRZM3T62s0Aq1INfnJ?= =?iso-8859-1?Q?0u5W75eRdfBBb2C1lg7r1s3pEgN+VvG3zg6irzRU/IEgJbeteNTD3pCmvA?= =?iso-8859-1?Q?ZOmecQIbjUYQvv5KYvsXJsBTMciMLWAfhRk6hXHgnzQ6YEUYTH0Uc1HeWK?= =?iso-8859-1?Q?35QELDeHtPRSRB4yzkzjH0nynEbOj2HeQ3vTtdyiHk6oq/kH42wkOOSAfx?= =?iso-8859-1?Q?GBcXVJKCo/LvGHlmyHHqlTi1a7yE29pNGs3Yfz6Lwpxb3NUdLcnp5xXVey?= =?iso-8859-1?Q?XQOjlXwHZMIKcyuFOs6edPY4mZtIoFYEjfrx1oi1M/egStwqcjTzgbv/bo?= =?iso-8859-1?Q?QXddonzEKm0hEXKzvenPpH?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?nJ2mPoDiv+daiZkJOiYiqfSp/XPInGfVl//2FEsuU+/6qdDrLx4o8/bWht?= =?iso-8859-1?Q?L8SOf038J7IVvgnJiXyes54QLVNkIwrbyWXwyzmgdub/7Lrj5E6via3nIY?= =?iso-8859-1?Q?JDcsi1PkBREufDii29GgZezpg2854fgMftQFFIIZG3Qa7f0CsPFSOKpsZG?= =?iso-8859-1?Q?h5sSOWjosRz8wyRCeqhNaO6KvqwWw1S/92dHvkXu3fI1xNO/1qYECiUt7A?= =?iso-8859-1?Q?MRJEV3ljfQvp5MXZjOACRC1Q92s8pgWttFFJQFzvKuCYmy+rbnS30wwWPG?= =?iso-8859-1?Q?/g7mmsvjAKFGscMzP0Ls69etYVNnvTVHC3/V0iw6z06lA0pNMwh9S2xBiu?= =?iso-8859-1?Q?8LJ3RJ8SU3/vXRjnxGNMw0n8wJWbyZQ77JcRzR5PthVwqd6Y/+7kECGN3t?= =?iso-8859-1?Q?2K/UbqetolZZwUrn5Pya9N1n9OEUBN+xNYFHkStJ7NOCP63j+HHe2oef3N?= =?iso-8859-1?Q?NmKJfzcw8kDOJtPNeszb6GQb2KWXE9OXw9Ve0rbdBf5lg8oToCk1aePZ27?= =?iso-8859-1?Q?Ytd0kRH/iorLzSmlIpuAw/FJXbCmRgMvqlno6Zgf1ANXOveVrh1TUETt5M?= =?iso-8859-1?Q?EJf5y1uORf+0Sn59bIyVYlwrzYSN4p4LlUB38dnp7tz6S5eozHV0mWxmZF?= =?iso-8859-1?Q?kqPsmbtT3OLZ+SKTC+cqqNqj+xa+KwKrrdSTxBl+cSau9aqhAqp0oJvobN?= =?iso-8859-1?Q?+Ckq72uJpsqsrelQlVHNoXDEhpiygaF4RnoBRFpGl/D9Uab2MtfQ11xKdn?= =?iso-8859-1?Q?EEQi5xWNbxvulwABEF6ImXhLTAdXF91kuCKSmoRQTz91nAYchu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sRlqvVVcENM=3D?= Content-Transfer-Encoding: quoted-printable 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: 6c90f56a-4787-4deb-fbca-08dd3979bc6c X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:57.1050 (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: 5ErH0fGvVuliYHbgOHiUic24Bp9OL1zuieSbGFnu9KKpCm7kt9HLuCR89dqDmK3g3mfGjz4Dm8RQ29f4zuvtIT6tGXUSVyci628to5uQmDdOjL/AJMhJb5ysxAjjtYpd X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737395039573019000 Content-Type: text/plain; charset="utf-8" From: Clement 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: Clement 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 530b75a9a3..3c31dc1047 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, VTDC= ontextEntry *ce, uint32_t pasid) { dma_addr_t addr =3D vtd_get_iova_pgtbl_base(s, ce, pasid); - uint32_t level =3D vtd_get_iova_level(s, ce, pasid); uint32_t offset; uint64_t flpte, flag_ad =3D VTD_FL_A; + *flpte_level =3D vtd_get_iova_level(s, ce, pasid); =20 if (!vtd_iova_fl_check_canonical(s, iova, ce, pasid)) { error_report_once("%s: detected non canonical IOVA (iova=3D0x%" PR= Ix64 "," @@ -2006,11 +2006,11 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VT= DContextEntry *ce, } =20 while (true) { - offset =3D vtd_iova_level_offset(iova, level); + offset =3D vtd_iova_level_offset(iova, *flpte_level); flpte =3D vtd_get_pte(addr, offset); =20 if (flpte =3D=3D (uint64_t)-1) { - if (level =3D=3D vtd_get_iova_level(s, ce, pasid)) { + if (*flpte_level =3D=3D 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, VT= DContextEntry *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=3D0x%" PRIx64 ", level=3D0x%" PRIx32 "flpte=3D0x%" PRIx64 ", pasid=3D0x%" PRIX32 = ")", - __func__, iova, level, flpte, pasid); + __func__, iova, *flpte_level, flpte, pasid); return -VTD_FR_FS_PAGING_ENTRY_RSVD; } =20 - if (vtd_is_last_pte(flpte, level) && is_write) { + if (vtd_is_last_pte(flpte, *flpte_level) && is_write) { flag_ad |=3D VTD_FL_D; } =20 @@ -2052,14 +2052,13 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VT= DContextEntry *ce, return -VTD_FR_FS_BIT_UPDATE_FAILED; } =20 - if (vtd_is_last_pte(flpte, level)) { + if (vtd_is_last_pte(flpte, *flpte_level)) { *flptep =3D flpte; - *flpte_level =3D level; return 0; } =20 addr =3D vtd_get_pte_addr(flpte, aw_bits); - level--; + (*flpte_level)--; } } =20 --=20 2.47.1 From nobody Sat Apr 5 14:15:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass(p=reject dis=none) header.from=eviden.com ARC-Seal: i=2; a=rsa-sha256; t=1737394978; cv=pass; d=zohomail.com; s=zohoarc; b=bBDfNlygpympQa4bQ9nD0mi7LkqmuFdPN8ip+uDTQu8R0Ofu0vqIq5rr7DkGl0w5fp4PCLoNRZxCLvuLx1ukaK8XA19+w0mE4BQSfhB1Ym1G7Pif9Nwy9cwXDznRfym51NSXTchMf+HuTHbsDkXgC+i7T6fYnvM5mtDk/jxswo4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737394978; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ihlsVNHBhWzOiyKsk02pHbXIfjbbzjC7MTfT0JrY5gA=; b=FefYZBLgm4Ee1poLNYuVCDkSqwPZWGPH6HSh1fe0KvZWF3+3UaD4vdY6ETmFOWJcIRa4nscpB/vHG8uVoLLBvXwSFmaevXRMzqfVZo10uIoCSYM6XzQcBX6LLQB8OLeh7V5XaI0VJFe4fhMeCYea6EbNHYR46mIdRuRgYKFnmqc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=@eviden.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=eviden.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17373949787762.6139029674155836; Mon, 20 Jan 2025 09:42:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmo-0004zP-55; Mon, 20 Jan 2025 12:42:06 -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 1tZvmk-0004uV-SC for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:02 -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 1tZvmi-0000cP-Ol for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:02 -0500 Received: from mail-am6eur05lp2105.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.105]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:59 +0100 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41: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.8356.020; Mon, 20 Jan 2025 17:41:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394921; x=1768930921; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=utsA/EQVP03hwimpwCFqp0/zAZAKoMG7SGkkjc+HEe0=; b=BwJx7Uy+2LxpoAsHvu6514TeeWBTwPcsFy3EFcLqLNirc6WfOA7SNaTF Q+RNAIXdnujCpW3XPkGO9hRkvQImQTovb8nTvImq4A9lj60L7TI+qkbzZ 5PHoxp7LCt/0EnYjkM/xNE0CUa+y1NTgF1JiiXjMafrfDvr+Dq3KyFgPE XGATf437OyPkUWcVAP9Ivitxp520qhiwlm7Cagp1y94mGKiYJlfyGqydd vdhtlhMjfWcOjMOtemjYwXRtTovnrc86g9YKp6RSySur2ch+o/5vEFhLP BCz1sR/yyDIplqKM1T8mCRxLSpLv8uy84HriVzUUr9kZAjSYdoR3q2Mdm w==; X-CSE-ConnectionGUID: w6X+yHKRT4WtPDlE8ZVuzw== X-CSE-MsgGUID: eehT+nbbSZSWWkUJZiNW1w== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291725" X-MGA-submission: =?us-ascii?q?MDGmhSgbKL5sAAE0UseJojG6mRYDFo8OFpDe0b?= =?us-ascii?q?sAXrJG7YDsjLvyP1QeLDsNn43tUzmyP30qqz/WV+m8uQY5fA5Hu32zrD?= =?us-ascii?q?y74ha2fOQXhd2sBGYvDRseNEn1Qqwqdv8Q+mId7/Npi6xpt6MeV9HBu5?= =?us-ascii?q?UFMjYD+gtfQp/iNWB/UMvyCA=3D=3D?= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kHz9Dg4ft0lGIRaNU/0znUPkrhndbovlRG4FGhvHeOJ59Zl0oCbvzUKTdzM4LLYQsW2t8a80j3fN5Bi6WvZeO2b2c5ou6P5KumjBEAcv/GL4plKgiXEzgTRHDnW5qM3spjJEhXIrzizaMpYV/Y4tpYyB1MN7wN222IG1IwT7qmY6tl64etO/EyIKX4I0jSrZOLOMmNXoYOyI0qP+HrW4JHWkqz4x6ec8IMEszw+PdR+kuhgMkfkd5XgVfLEwcnn88u32jr0AYGaf1ZDTsAGYOhNuq6QjarafNuajqlwl6eguycDTyL0xw9/0A0+jgZt1TxkCV6yXVbEypewaN4tAPQ== 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=ihlsVNHBhWzOiyKsk02pHbXIfjbbzjC7MTfT0JrY5gA=; b=QGSuZO7ZBCnEzsUFhAl3DT04B3tyftyDzxJywFo105TOoMV0bZDMF5RxuJfHlr5tLZStjOy7On5/zFUKHhXbVXLDnqiSZHDKpgVfI74gBo2m11HUf/OhuMUfbRvaFZBfim5I7s/p7FBlAaZihy1nF28LGNTo7rNqf/fSxuFzarjbO/umYw8bKgUE5pGWrserCIo/EiavMSj4i60UPG2mrj/wyU1xzEHcPD6zMMpdBtraRzWx/+sLXYMouOy6OMC4BIKr7xt8iiVmRkGwCcTeDwYhGDx4ULEbNhWCAjRLrDZ7Txc3LdkNqm9wExXckuFUbWtGkKLfEUEo/Ehlzg6tSQ== 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=ihlsVNHBhWzOiyKsk02pHbXIfjbbzjC7MTfT0JrY5gA=; b=sJK+yA0GUJg//9XRTDRDxXVR9FvEN8ifTynXwM8djgyg/2mdV9n/YQY8bTV1aQjV7SZiBQoF2JrovY3f4zbbbAAai3okOEZGjXX3AHe0gOOZBe6RalZttTa9hKl9OLmJ0//n6e9RFPoWOncQHMCA8IZp3Sh7zxLHb1dOLSRAjjoidprQpTlUT1dRw+05KvcAA0X3rS4N+g5hE856i1o2+qFYkHhNx2UqEVnC5hewkljXskgwTJomJqyJnVRV1pDzzS3Snrd+Tx3P8fgfGQzOGa4GhzzgRDk2U1qgszLAavrtEpacEdzCBoO/nTPkShpd5ty9PNunnwjQSb46k/zDYw== 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 v2 19/19] intel_iommu: Add support for ATS Thread-Topic: [PATCH v2 19/19] intel_iommu: Add support for ATS Thread-Index: AQHba2Ka+y6joUjfBUuVcadc89bZlQ== Date: Mon, 20 Jan 2025 17:41:58 +0000 Message-ID: <20250120174033.308518-20-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: 6e0e3279-7344-45ee-8ec7-08dd3979bd05 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?I4g3E3Rn03D5DstDWfHv/wpB8vw4jlp4z4TC5gYyRRBRCuW+6TLMKN+E7p?= =?iso-8859-1?Q?Gl+2LUQ4VJaxY+EOSHvLJfkbJGra6jWi5zxxWZdrkI4EOGG9BLYEe0spnJ?= =?iso-8859-1?Q?iOofVq8fOY+A23wD/qxID64gg/A1HELSIplF09X4LPfXgkQUyGK55FcNbi?= =?iso-8859-1?Q?SOs1wRwqt+37ovTnQxWnWWodGTHLI0s+jWBY01wEisXPqiMrOaO3ezeZ4T?= =?iso-8859-1?Q?/AnFfTHaYCDY8UG67U8iYJ7N+82ePt9Ke2ixStxmnTrj10g70E2kNSk3Bw?= =?iso-8859-1?Q?wf6zM9W6zWDozyvHDU2YF2yKlZvapObSS7bEECrPp/d7RgKEIVe+ePHytr?= =?iso-8859-1?Q?rUvnkSiapPeZ6CdndfZxgtlj7gU+wLipLvwu8C7b15lEI45LjbVVNa+SgV?= =?iso-8859-1?Q?ChpMbNmZtTFDka5zu+T2257BvcVnq/ePMi1qvQNrfJojLVXBsR+ZdpNd84?= =?iso-8859-1?Q?qRSKMINAI9Z9maI10iLPN49eqFHPaSJmS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4WOgcL070xbAe1mtnlFaFqdDB4UUX9RlD8RbDzqFb5Kf9L0Ri0zchA/K/?= =?iso-8859-1?Q?3Hn7+Zy0gDkcG8WDVd1tSMPhkQPW8ukItRlZrcQkojjkjFS+ehi0TtmXg6?= =?iso-8859-1?Q?FTsHb+Oox1YFu+9puyj2eC?= 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)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?FrNv2lzVOxqSq/IoIH5OZwpKcyNsHKAdFzMLSW0hDlsUyrxGCLntzF6Oz0?= =?iso-8859-1?Q?esN3YbwX8+JVbCabLf0DcE64zVEaivKTdQY/1e6d+0lBpI5CodZkIvxtDh?= =?iso-8859-1?Q?+dDDHEaYERsoswaKH+YIV7LzYmm3aIfDH7VyxFb+JJQysP4xsPXz6MompB?= =?iso-8859-1?Q?Nth2uPq5i8gDFoaLBtHgCphGAwyqQC0dE+vesTj7IhbK1xpy/U1a08vxRZ?= =?iso-8859-1?Q?lAT+5ESYkSvSoXWQzI0J+m/eiutKVJOhfkDe3Ca/FHBXarc1xfZv8io8AT?= =?iso-8859-1?Q?LZ+3RKPziIK+kf2PjtMOyKgmq0jcIQLHO/gPE1xDuD3GDTAzNLixjMWI5c?= =?iso-8859-1?Q?XaH+1q7YkYLdfs84d5D6N2boRLS8HgQHKUifQcPJbN1G2EqRx0U8LnPCuz?= =?iso-8859-1?Q?H8lC4r+G6K4agZ39MwXc0wz5QsZXf7TaHAWizIE6i+3NJuO9TEgyPW+pb2?= =?iso-8859-1?Q?3ahy6gxjB/8+bFLmSBCbJRqQ9KngoZsDKN/DbPdK73nSY9GzDSbVVgvgt3?= =?iso-8859-1?Q?okxw/z5+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Poe?= =?iso-8859-1?Q?gQl4sIqbea5GbuY5pmvC3QdfAs2wIIY1M+GAMMMvD5F89yPIZVpwF4mmgU?= =?iso-8859-1?Q?Xp2KF/2G22PvOeo4IAc6i+ixrN+7nqfzvrdpM2NbC8zTRjSAFpVVzG4ePq?= =?iso-8859-1?Q?mQtrtlLuJD9RaJ0JS6JzKfb+TNvgxRSTeQuZTzja7xvgq2ngrNSVMeiLLI?= =?iso-8859-1?Q?0c0t/CGrQmUoI7pkEAky27M8qu/JuqsSu+eH/BBg44GLNkhraypgDwyzNG?= =?iso-8859-1?Q?AHH8AL3CxGiQLlrrDzY=3D?= Content-Transfer-Encoding: quoted-printable 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: 6e0e3279-7344-45ee-8ec7-08dd3979bd05 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:58.1438 (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: ilDy/tlk4MxbtIvNE0+RzvWdN+W0o105Grb178XDYOA1cxOWYJhBv7otDZCfoGR5n0wfsskC4DRy6eQyYiVLRjfmg+dncQQ9Ig52ac9XvmvqadmkVscFKFR1CtnJZJys X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @eviden.com) X-ZM-MESSAGEID: 1737394979239019000 Content-Type: text/plain; charset="utf-8" From: Clement Mathieu--Drif Signed-off-by: Clement 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 3c31dc1047..698e1286da 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4159,12 +4159,10 @@ static void vtd_report_ir_illegal_access(VTDAddress= Space *vtd_as, bool is_fpd_set =3D false; VTDContextEntry ce; =20 - assert(vtd_as->pasid !=3D 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) =3D=3D 0) { is_fpd_set =3D ce.lo & VTD_CONTEXT_ENTRY_FPD; - if (!is_fpd_set && s->root_scalable) { + if (!is_fpd_set && s->root_scalable && vtd_as->pasid !=3D PCI_NO_P= ASID) { vtd_ce_get_pasid_fpd(s, &ce, &is_fpd_set, vtd_as->pasid); } } @@ -4738,6 +4736,71 @@ static IOMMUMemoryRegion *vtd_get_memory_region_pasi= d(PCIBus *bus, return &vtd_as->iommu; } =20 +static IOMMUTLBEntry vtd_iommu_ats_do_translate(IOMMUMemoryRegion *iommu, + hwaddr addr, + IOMMUAccessFlags flags, + int iommu_idx) +{ + IOMMUTLBEntry entry; + VTDAddressSpace *vtd_as =3D container_of(iommu, VTDAddressSpace, iommu= ); + + if (vtd_is_interrupt_addr(addr)) { + vtd_report_ir_illegal_access(vtd_as, addr, flags & IOMMU_WO); + entry.iova =3D 0; + entry.translated_addr =3D 0; + entry.addr_mask =3D ~VTD_PAGE_MASK_4K; + entry.perm =3D IOMMU_NONE; + entry.pasid =3D PCI_NO_PASID; + } else { + entry =3D 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 lengt= h, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUAccessFlags flags =3D IOMMU_ACCESS_FLAG_FULL(true, !no_write, exe= c_req, + priv_req, false, false= ); + ssize_t res_index =3D 0; + hwaddr target_address =3D addr + length; + IOMMUTLBEntry entry; + + *err_count =3D 0; + + while ((addr < target_address) && (res_index < result_length)) { + entry =3D vtd_iommu_ats_do_translate(iommu, addr, flags, 0); + if (!IOMMU_TLB_ENTRY_TRANSLATION_ERROR(&entry)) { /* Translation d= one */ + /* + * 4.1.2 : Global Mapping (G) : Remapping hardware provides a = value + * of 0 in this field + */ + entry.perm &=3D ~IOMMU_GLOBAL; + } else { + *err_count +=3D 1; + } + result[res_index] =3D entry; + res_index +=3D 1; + addr =3D (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 =3D { .get_address_space =3D vtd_host_dma_iommu, .get_memory_region_pasid =3D vtd_get_memory_region_pasid, @@ -4915,6 +4978,8 @@ static void vtd_iommu_memory_region_class_init(Object= Class *klass, imrc->translate =3D vtd_iommu_translate; imrc->notify_flag_changed =3D vtd_iommu_notify_flag_changed; imrc->replay =3D vtd_iommu_replay; + imrc->iommu_ats_request_translation =3D vtd_iommu_ats_request_translat= ion; + imrc->get_min_page_size =3D vtd_get_min_page_size; } =20 static const TypeInfo vtd_iommu_memory_region_info =3D { 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) --=20 2.47.1