From patchwork Mon Jan 20 17:41:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEA33C02181 for ; Mon, 20 Jan 2025 17:42:49 +0000 (UTC) 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 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: MDFDmnptiAhGjY5mq+shaQt69PUjRRYcC6pBDBMnrDi2jMNRa4pg9PU7LK88ndkBDtlgMFsazlcfacx3G9ZI2hcBL39D6FKLhbA4eYYbgFedlwvubXbIqRbH9aUwtGovpUOFxlKs/E3uz7WMNEDlcCjVpDtQIh/G901E4atgTnMNhw== 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 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== 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 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?SE5YF2Uu0mPgiw0xKayTEAGDOH?= =?iso-8859-1?q?jQwBJrZZ0HJFHvgQL7HhPNeWgG2FsrCTI6nFPBWjRpBdwCJuLLmh/pNXo18V?= =?iso-8859-1?q?Y0bJa2+jT10+y5hZTEPeNP1eE+f/IhIB7RncBxl45WyFmPXC+7Qgsr/UIUG/?= =?iso-8859-1?q?DpUVsAS0Uig/3auzdBfea6a+2WQI+4q8oa3Miasrq0T/sdZGiqWUsJnCjRuO?= =?iso-8859-1?q?1Q4jhCTZPcgqS2V74aHGWMipcLateePTcdVykpNYTlKwElj+/uUa6ephchCX?= =?iso-8859-1?q?/0xpurnttS0tS485c4UfR6cTWZIfKMYr8fHkmFBgZZI7wah9z10xVJl/usgD?= =?iso-8859-1?q?q+2ONScWLdQVQlj1JNMmyGBKhhev+wJd+2vhoJtLPQHfvbni2c4eVYKYQ6ku?= =?iso-8859-1?q?0MFf8GstyRWSHnm/q7gGb7/JI9mRz/5nB1NFJR2Il02VycSGc+M5deSVVLzm?= =?iso-8859-1?q?P4CaHB2YE3yTQAE8u3MfxvOzd8sKYy9j00q5CFZqoZb2kmz4Tk/cOrP5ek9G?= =?iso-8859-1?q?nvF+kjEEGX23EhFD9sNzuWsOdd+v6frQ0sSkRkhhBb1BauteIICofdJznP75?= =?iso-8859-1?q?TU7YF3fUbSdOktK+zFhoqfum5+wyXwv98OIOd+DakxTz7H6tEWtBUuLTjdnl?= =?iso-8859-1?q?+ZmdZoTBgndaenIuTz5YuB03GtmZN3p4geNw02lQayNWHlKPUUYT1PfLsZYc?= =?iso-8859-1?q?/4HT6SVUNIKtLje/suf4GV8cyVlzihtjxnSNOlke8jZsI3fQQYzV+GQB+Hjx?= =?iso-8859-1?q?pt5rNwjcZfCZ+C1Db+1AerOJj2AeS7F4MybDlkMksVQ2yLllC8X139h3zzsx?= =?iso-8859-1?q?Jo40SfcUxjPfeoxLW+ULTbOCJ/ThROgzDTbz2IFkDoU1JTUoJQWpgeuCUoIK?= =?iso-8859-1?q?5bdcS9N0WJHWfp/pIyox0qz96TG9vvm4hAJu65hCGubMi+nHYcIyqSwpiQPw?= =?iso-8859-1?q?N3eNoBA2zCEyQaUZwzDpy0fkhDRs7vAnHDcTDNlNOrna+C5cMWFV1v85Oz9r?= =?iso-8859-1?q?DFVoKB3Q9zd4iwbWx2xT2HtCJIQUOzK6p1urm8GvWoWLJ+rL/6jITouWtQJw?= =?iso-8859-1?q?CYSQahR98vHrdaPYISdsq6H2hZwmWIvsnDZSdtrxp22rpKEg1BbZYQHoC/xY?= =?iso-8859-1?q?7n+9fqBTGlN7zEiSIppnMv4HYOVH2Ib1/JjwzmCmRIbC65A0Wqi1uWYjcix3?= =?iso-8859-1?q?m4DZh2OlF3UAa8/CiKIIXq70GlXoD+F9BN6NCPM30l96peHhYetH/8haDh7l?= =?iso-8859-1?q?WJK3A5YJCxXEMpbseD81vSYXEXOdaRdPyO4gb9wU0pACmBmZETxqhJstGPYj?= =?iso-8859-1?q?riF9H0EqrVo3SUOGKTEJc/YBQaLUHdntFhQqGXxHQK1GkMTyfxw11NDpsr3A?= =?iso-8859-1?q?YEo2AXbQztbUwKHsJjDqMOOIn0R6SU+v4OfmVlQ8UP/f3ku82RHbe30pHTso?= =?iso-8859-1?q?fTucVMfo81wMIrTNvnHDLEfPQ4OS2t98ydgdKu8GjE9rm0xJgUxZHmDiPEJs?= =?iso-8859-1?q?RyVCKR?= 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?fy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8859-1?q?QE38nH4E3RcX1q8bZ8W1eXAim3NWTe1UeB518eeNYNxw/ZHgRFLa05MiffXQ?= =?iso-8859-1?q?HpIh3Y42xZfA7m817V+xeeV/grj9iIL7ArX3ZRgo/9RMA1mLySgwucTM8baq?= =?iso-8859-1?q?1OU2FNR+PCOthXEqezjRsrwyJH35al4EDSuUiiGLF6wK+uaiILg2bSL3RDph?= =?iso-8859-1?q?qfORi/4wqig7D8XkZnS3IQgJ4GC5GDstqrFvDGVdyQSI3J0EYro/HAIpiH/J?= =?iso-8859-1?q?xTv7I01O/DzqrkEYuA1rV+Vge/kfd3ad1/i4PPmHpjSc4cDOKDKEcQDK6Hdb?= =?iso-8859-1?q?W3KgVWnY7rF2GmQk1GA5RR3jrmu+orPT76NRvRRHn18+PXnGd3BTVsGCymA2?= =?iso-8859-1?q?VLkWVLOpJ3rRuJX3HAPdUzMHIS2D+gEnLWS4eWKGty+H3wWfLR5FnT/Y32yB?= =?iso-8859-1?q?wk5h/DsJf/d1AeIlJ5PNe+K9S97ulnXT5WI0irIlsd/j/SB7BC5B+isK1ATJ?= =?iso-8859-1?q?Ccl+B6T4pI2DGehDlb3nFEjla7HXopA9XRXZL3vHW5tfakDDHD4gIkIZS1t8?= =?iso-8859-1?q?X/XCfLt+sqZVtDnh+kWjD2Y4pqyd7z9np9MhWytpcx8OzhnhzQB02wIIXG9k?= =?iso-8859-1?q?87JsEcaXjAv9Hm7TtmJEZm8ssEHnyqhXBTCZohms9rk7LpvTGUR+yzp85hkN?= =?iso-8859-1?q?YsOpiIMfTai1HJEPKhIZpEHcWG/RPorJZAmcPyvweCkb31CUIJslEjQhTwMD?= =?iso-8859-1?q?T+fsYA2pr7PAnJ5YesXStlmzuox+9zs15QQmn+duTrtJ6ZKe6kzlQgJMNosI?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 { typedef struct IOMMUTLBEntry IOMMUTLBEntry; -/* See address_space_translate: bit 0 is read, bit 1 is write. */ +/* + * See address_space_translate: + * - bit 0 : read + * - bit 1 : write + * - bit 2 : exec + * - bit 3 : priv + * - bit 4 : global + * - bit 5 : untranslated only + */ typedef enum { IOMMU_NONE = 0, IOMMU_RO = 1, IOMMU_WO = 2, IOMMU_RW = 3, + IOMMU_EXEC = 4, + IOMMU_PRIV = 8, + IOMMU_GLOBAL = 16, + IOMMU_UNTRANSLATED_ONLY = 32, } IOMMUAccessFlags; -#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | ((w) ? IOMMU_WO : 0)) +#define IOMMU_ACCESS_FLAG(r, w) (((r) ? IOMMU_RO : 0) | \ + ((w) ? IOMMU_WO : 0)) +#define IOMMU_ACCESS_FLAG_FULL(r, w, x, p, g, uo) \ + (IOMMU_ACCESS_FLAG(r, w) | \ + ((x) ? IOMMU_EXEC : 0) | \ + ((p) ? IOMMU_PRIV : 0) | \ + ((g) ? IOMMU_GLOBAL : 0) | \ + ((uo) ? IOMMU_UNTRANSLATED_ONLY : 0)) struct IOMMUTLBEntry { AddressSpace *target_as; From patchwork Mon Jan 20 17:41:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03AF0C02182 for ; Mon, 20 Jan 2025 17:44:00 +0000 (UTC) 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 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: MDGmXsEpqMchtTU4s8IrzGa/htVpLuB4mdB84wOjS9VMP+18vl/kxw9al2XtHJU7VztPhdES5deZePi0Q8Yi3PGqPOlpCBtblcV/A5HvC2gESVd3y4SRGzP3C/4eQfjkouY0NKCAf+xvWM/4fDGzCEMCRvNq1K8jzzD15Et+WfKnnA== 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 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== 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 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?EW3I13h6KBwVYyMrQt3FOs4Dil?= =?iso-8859-1?q?TQnio1K2ltyythBps4Gmg4oOsLdBqfVPmvZsOv5+cJ/sDWssJNbJd8L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8qLakRJBmdikHmbYD0cPUf8/WpF2nWY82/4jG+ff7K3kOiOCVV2CXhBG?= =?iso-8859-1?q?SOVzmgLhRj3r5xljVablz9JjoDyYwH3u+TJV1CK4+Fd39R/1mvTYC/dLajrP?= =?iso-8859-1?q?xcg9KTYB1pXgfvZNUAFPS8tx/Hw7f6huTqsih2Zge9ByVO39tITpAHHILCPq?= =?iso-8859-1?q?9eqYapNhSdt199Jyw3jOuz4qAtZW2sosMEP2IakPpHIxwp+WSxSjPvc+xVNW?= =?iso-8859-1?q?I9A3sFUuz2oQuunquvmlzQtW5vahH3O7Iz4b/ASNgtJrV54OrNMKNB6oWuxr?= =?iso-8859-1?q?9fPs6dXOua023i2Zl2jO75EjBAgnDNOcCLGdz8IV5e0++gzN0/gksuciCyjK?= =?iso-8859-1?q?e0/81RM1meyrSJg2JK0YiFaOUkdvP3ftboLBX/17PUj+HIvUn43KDu6RbWbg?= =?iso-8859-1?q?RGUNwkQq2QxhUpD/pbr61leU90NEYbL0wiJjD96mq0nFaarXnydLorPA8MCW?= =?iso-8859-1?q?7zL4HPQSa5trgSqDOngZ/PcKcva/5TWvGsppcz5meUH0N2zXlCEYBJjmtOpn?= =?iso-8859-1?q?B57VTk?= 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?EFZeSo4jskUct96z19TCQE8?= =?iso-8859-1?q?0dEK4pRB2Kcb3ipUJYGRDgAYlYvBofebOb/rxDvI0lGxqGj0Sc6vZRxDaSN1?= =?iso-8859-1?q?A1c73/2z4dWTmup1hNQj5e1Lu5zQ/qMvDRkO7KoxQyW+x/AKhZnMWWho1lsR?= =?iso-8859-1?q?xyt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zWfJcHh2l/eUt3YKF4XMtmFArYgCBKndQJI?= =?iso-8859-1?q?RkcoYcU5cNG8uyF5PxohbCR0gsT2ePmAimtjy0tqM/+e0/955iGtoIfAr9O9?= =?iso-8859-1?q?hqunTwS8+d52c/pDyN0ks6y5AFoAIkRcb2BmWsw7AJDx66+nijCuEJTP5Jie?= =?iso-8859-1?q?eye/wzYNArx47nftuDXG0TwatbWvqQlHuv1XjSrze0p2wMVt9D9Iiat2Wrtj?= =?iso-8859-1?q?tZdKM/gPc9mTonAhH1gHRNGUtPCHFRbhFxvI4VLUctWcudzzu6VvbZqM2lf3?= =?iso-8859-1?q?VXFKxCo+eGSGm/aJWrKwYEoUOb83bvA1b9bxurCtzXakah6k+lVUujrWc7J/?= =?iso-8859-1?q?ejOqNc5HHkU2QLpSrV6iLyIA/eez58nh5PwGIEozoFKNS2KHLojf2C+721k4?= =?iso-8859-1?q?MYlaAtHLBmTLxMX2z12J15sz1C04tbZtnHRYVvJoKHwRkcIc3DRNxbpPS+te?= =?iso-8859-1?q?MB98sZwiunoOtTwEEj5HzXo2GuHjz0XRLFqIfdfKY1kPVcrU9G62LdQpf1T4?= =?iso-8859-1?q?GOCEc5ihvudg/YEfywZQsHF/a6pj4Kk+BEpEOHg9EqW9EmfWW6n/5KR3xoJR?= =?iso-8859-1?q?tX9DE0EWU++piT0dAVb1I1gO85Md2q3qtdFTX7cilyvfzJoyXwEBzD7JBT6g?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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) } if (s->pasid) { - s->ecap |= VTD_ECAP_PASID; + s->ecap |= VTD_ECAP_PASID | VTD_ECAP_PSS; } } diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index e8b211e8b0..238f1f443f 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -192,6 +192,7 @@ #define VTD_ECAP_SC (1ULL << 7) #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_SRS (1ULL << 31) +#define VTD_ECAP_PSS (19ULL << 35) #define VTD_ECAP_PASID (1ULL << 40) #define VTD_ECAP_SMTS (1ULL << 43) #define VTD_ECAP_SLTS (1ULL << 46) From patchwork Mon Jan 20 17:41:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D953C02181 for ; Mon, 20 Jan 2025 17:44:18 +0000 (UTC) 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 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: MDG2GIIuwTDLWn64efUFBUnYq5O6WeeW7k8zbZnoo5h1BUGzkRxksP5+TU9g5EIpFIQlJMNf+1o/DC0G94xStiMMJMUt4wcK4lhZxD8+BVNtFxB7XXlpv+LESJETnrtcEgsxRxTOKZ5BY8aJVWdAbxcjzoqKqgK4iFxC5Rhehb0s4A== 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 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== 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 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+2CnukQbag9JFe89?= =?iso-8859-1?q?17vNBjyV6BZsvVuObZhmVfthIqX0g7mx3Cl1cfYRn6Q25pUcLpLq1F+KHsaa?= =?iso-8859-1?q?lkoTIFG0ImR5p8auYQSJwDHLIlSrX/gWXOnCakYWR3r9mYMXMKREpA7tjKXD?= =?iso-8859-1?q?dq9E9EqnsfeBYbCs3qOFaa6aN0doF+pF4gvahXpRu5ilfjj25Zz13FtZPDBk?= =?iso-8859-1?q?jT81n71Ocqdk/UTJfUtqrIrarjSmd/d0WNgK28gc4PTLEzqWTgur7eBs/av2?= =?iso-8859-1?q?mNLY9juO06wE9jtdidCFFXUpWAsloGJlPmFfjdLmQCyXKNzdy8aM4iDwl/vb?= =?iso-8859-1?q?gzqUagcSW7QVCyCvbgr7Fz4jn670cobjCSUR4yd6TElaUMIFSpgenvR6nW4m?= =?iso-8859-1?q?nkBK+nuQRhtoURyFVoo2wDw7/q1jrZB+hxhfF0PMVU/fbzG59xXJiGPf9HLQ?= =?iso-8859-1?q?9cCuV/HqI5wErKRd3dVCP/Z3eNkfT2T8v1Jpqv7OOZBwcKsJ6E1WjH3EMh6y?= =?iso-8859-1?q?TShL+g6b5IJeoDmCUDHKE086lsQKsdoKPwbildIi+u/S9Az6ZLCvPBCLJrxb?= =?iso-8859-1?q?Bxe1VjTaYxJ3Yd403UWBf7k0qyDUHde9T5gcGGONFIRBe2lPBCFXrgwheCzi?= =?iso-8859-1?q?cdeFMSmKGVOv4/iMR9IJvZx6xQMJH+bCyAzscN2E8/pCDBFmYnMOmiD6Cik5?= =?iso-8859-1?q?IAWKskUG9B4YBfZnCwDgBOFYyYD+5GhGUn8+76/MtjnrROVIpj+Gkbr+OlQp?= =?iso-8859-1?q?PpCiF6YCfn/op54E156udbTqEAtTgdtIigvIVNaDVDDz3FIgEAocaZ7M/HGW?= =?iso-8859-1?q?FfjUErwucfPP/T/zAwYgs7X1zHgau4Iuq3Rlp53tadQN7U4Vik9eXlrcYEY0?= =?iso-8859-1?q?tJH4OODRxFUkEMxe3mVPKlcFNTAQmnG70ai5pgrKQEJRdGgzYBfvUt1zPWM2?= =?iso-8859-1?q?X7IQmUzsTcSYBVHAj7c0xsbAm3KkbFULmw7iovQgehMpaNGEZGbrjwldCAM7?= =?iso-8859-1?q?0cuuLRq8TTUqjHqlbjLOWW8/7idMSzJnRRwCGX37duA9dIV/C3t7S7W48tli?= =?iso-8859-1?q?XnjXwzSkQ0nQR1dzvkLTjLcnlYVsFfQd+4WnfUZKlzgN/etQLxCAxWUwjHAr?= =?iso-8859-1?q?YLAIbnJOr6OyPSXi8ref6sYR3+a+1V1Ja+9Pp9SkpTyCBszQVxAg6niQePzA?= =?iso-8859-1?q?lAsAAQTudFBN0y0knrAKQoFM9flSbe7KvTBwziA+GX2wJYtZSa0nkDqjVDny?= =?iso-8859-1?q?O458ujMCuzuuCJYJ/+NciJ+nJrE0AFQPHu1VoazGPPOkxfbekHbAXOdfLyye?= =?iso-8859-1?q?qvvXzl79W07sfmGDVrh6PxM8zb0PXtOP5Z9NkmpXuwWOpFNbijdKcJrte5bZ?= =?iso-8859-1?q?coHK9pzyQsOhC2GA43b6ggZuvn0BXGMnAox7BX3BF7qtIZBcN7nfX5BeRILQ?= =?iso-8859-1?q?aNNUq2Hb/yIPquMGTMZr5scuamb+fpDQ6opLlFQj2JO32Lxbua/YM/Wnyagw?= =?iso-8859-1?q?ZdPCKy?= 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?81Jbk9arfr6BxLPTrKuyDEv?= =?iso-8859-1?q?4UVcpkABC8XIMUxe5ZgEBZ1zuRpTUM65NMHBrbC1N1K3DYy8bCNtxi4D65dp?= =?iso-8859-1?q?615yf9Z2RxvkoTtfvJFjP5PlQsuOsucKN6f/y8TeKeWD0YSW3D/GlwEZ/yD2?= =?iso-8859-1?q?QFphiYnR1jBRcxVFXtAcrPIa6T0dPcGYHvPeY6rgXUeJdB3gHl3WPRs5+KBU?= =?iso-8859-1?q?rL08o7kpK2VncF/B0jg73VmLmigIytiFNeq8v/hk6J9NHs64R99TDFSndw/g?= =?iso-8859-1?q?fkgqURtymxhMaWOlsl8rOq6O9NzPsPZ+eHLJFe3BLqK6CM46NglxiJ7UbOrX?= =?iso-8859-1?q?8b0KNJrtb81gBBoLB6y9EdXeJOdZSHKqJqZOvC8gcYgLKlnFfhjYn5fNuyNm?= =?iso-8859-1?q?bY77J3H9NGIHqANc9jSdAYg1Ug8CHvwjL3EIgU3ZhQ7szpaS8neTDFvPy3/O?= =?iso-8859-1?q?E6zpaOJjXsN4l797O6TTljDq8ow48fHYz1rELU1RP3O8ueHEqn4hVzpfF7ey?= =?iso-8859-1?q?x3G+VPh+Wqk5D9obHuYxZZ4rYN4AD/2mKbeHABIa7f0D7nwYH+6QaLLmrede?= =?iso-8859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VEqCjud6epWBlE5H/YcaYI5D1LCKjzaebMKcyZmfuEQk+?= =?iso-8859-1?q?WLooeJrBybwK+B4Jwn6d6GPsKsHJGue9WbWxWTGpan+7+FEkoNCfe8hGcUS8?= =?iso-8859-1?q?Sjtz4cu7iDJdE4tcr5xnxkc0Muih3Obu9l9kbyuTInpFO4njY+gghKYNELCW?= =?iso-8859-1?q?MkjeIbAw1XjHkH+Nc05HfbQS0I8oFa2FOT3640YwgiV/o4dERv+R15krtdB0?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.83; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost2.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 = 4k translation */ IOMMUAccessFlags perm; + uint32_t pasid; }; /* From patchwork Mon Jan 20 17:41:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29D9AC02185 for ; Mon, 20 Jan 2025 17:45:15 +0000 (UTC) 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 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: MDG/6lSJ2nWNtSvvvMbTYkjUCjJuxxLnbWBUludkX/wQz4ZAsxYNfW6gGYVkpaELUBxiwEXuhqDsxqD97GjOq1YL9VC2BZ8dYy4CGBjfftpVVGPzamJooFvJfC0RyvemSrEGof45VE3g17XH+yN2rUKGmgC7YpOo7U04d4+qA+E2tg== 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 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== 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 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?RrtJGn5CO09ADkbO06oTjsMkXp?= =?iso-8859-1?q?it4IrzYun07TDmr+BAlXGluiflnd0e/16vmYAHLD8BC/FyMQqlojsLK6glWS?= =?iso-8859-1?q?/aqWnkF43s6uT+PLkqfgbbLbo4nsLozaqWbQzk9WIPgr8QFoDW6WZ/yvikW5?= =?iso-8859-1?q?Bef9qVRGhPIuo1xsEM3rzCoOkQl9K1pWdjp4LcgH4qnoROUC4rDHC49qXszD?= =?iso-8859-1?q?0+wXz1oz3+5nKLvxdweYKBjaYQ9gIzqgUxC1fVyBN80MlYAFwsnRnoIyk0ox?= =?iso-8859-1?q?KTjbXC/FQk3pvD8AYlCfKe2eF+BnaX6MkaL9UwQRYe9fOfGl2RzxE66PpfVL?= =?iso-8859-1?q?aAUBFkqL/VlviuanbzY4s+GycBfhs6wNoEb4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A481Ea2?= =?iso-8859-1?q?4ehT68h+aM9eq/UCkltDXAOYWumm5UtQ+ofywUWmyRkQayouEhaitzwLDm8D?= =?iso-8859-1?q?BFrrWV0jn/cbCYojBnUGjKcwnI6wpJAhu1V4Q5dDb+T1gR8JsgMw29ITMaVQ?= =?iso-8859-1?q?xEGz6imoq5fv51Kw+/HV7vvtQDAFlRniUq64hH4mjH6m+oKB6ngCBohbbGZA?= =?iso-8859-1?q?BzMGWjAfe5ybtnLTzmjgMsOcma1Pi5tWmBCwck7+zlOs+2mPQeJry0DbUnvE?= =?iso-8859-1?q?QP1erH?= 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+nf?= =?iso-8859-1?q?1CN2FX2zhTbffC3XEFIl0wmv30mxYg2rEJDi6TVjkHHv0W/5Vg61vOaCeoGM?= =?iso-8859-1?q?pkVYUyyphDxUDuPXiE2Fkz8zp33qMNSiRXGKzglHnOxVO+2t1M92wFgo+9YX?= =?iso-8859-1?q?kVMVhbEfIvnr9ccgj85rqMLA2wtx1F/fF/23Z/gZ8bmYFH4FdDh/ltnHiWnA?= =?iso-8859-1?q?sXpHjAvaD5QWkPCD6WzrmHqbJx/a5SrrrpICiOKHZO+NNNpXB912TQgMDXz5?= =?iso-8859-1?q?rfOXMfDSAt7Mq2llTl8r9tIGh6LkasWCDBIEZqzZ90Z7mJ8dCFAhPLjXl6m1?= =?iso-8859-1?q?Kyv9xv/xjcu7URolRqX6z0PrKPMbcTmpVD3F/XiVrQ6Xi3w0RSedQCpB1xz0?= =?iso-8859-1?q?Lgy/hUmGkTRdv+dSbRERE7rkq0VgYd8JBQfqgqnozZAPfdsjeoEtYn0uJ0co?= =?iso-8859-1?q?K76+Trudhp3Iiezh6mpcOingVnDI1x3tTJfKQjpnW6bKrjaPyGLIzknbgfTa?= =?iso-8859-1?q?ZCh5NALFa7iSDMvhB60aLuBoJvg5YKUE7boXDKTK9+AdXGuBM7Ll/3nilwDF?= =?iso-8859-1?q?vo2Ek99CSgyKjmTfwhQZEvSxNYNohjwy9MPDY8VlVKrzupFiR8NMTJBZVLbn?= =?iso-8859-1?q?jNUaTMeGijrubUm32V2dqmeBuiGshebDZkNgyKErDuy/w//oFI/prmu3+W64?= =?iso-8859-1?q?1BiAJjIyUdfNXAvus4wy++BQocCySGaLAqM7LAlL1SAhJJjLQO0Lk84hu/9e?= =?iso-8859-1?q?dbabCwqx+ovRI16nEl1XUNk/CS2t9ad915VXuq1mkGm6NCXMdZ+cc2ixZzPG?= =?iso-8859-1?q?/7K/9qZ2tc0etUCSECqzqmWrW/V3UHnUW43T9p+pj7q+eh4w1pu1AXPtlptS?= =?iso-8859-1?q?ikePm1HbryjIm/87dv+TARIA0E2kO25/syHgjUXegSRvA9M7qDh3Mwso4iEH?= =?iso-8859-1?q?G0sKOINrkAcoKzXHdeuOv9jFeKiS+8m+yJ+TiUK97fsflbZPKocpO2EVSvG8?= =?iso-8859-1?q?TjiUuGCZ63/TgD/qCo5G+j8Q9ecsF/MeVaJvchtCUydLaCDYgVkyr6E3NDwr?= =?iso-8859-1?q?FJsxffrVjTvmcBzF1/GYUPejwpnKIbJjktlSPXMys7Sugqsxk1xxPeW3o00R?= =?iso-8859-1?q?UhnVCGVsNd262T8yiRfdQXfxXkhBjyrJ7PAUByC41sMD1XtC8qGB+eMwWFig?= =?iso-8859-1?q?ZjRsDspbxhU7OPIq4LT871rysiWk0fqXJguw5Ik/D8iZSHZvKZ0GU9I61ylF?= =?iso-8859-1?q?6aIRi/N/Qxz5QWn0afc5rO9X+iInNO8tvN3WolFMEY5ZB02nvvgKsH1m/m6n?= =?iso-8859-1?q?4F4p7mdbWDmxgkXCh5M3Ntlo2baRmq+WtUUuc8leXKi7RgSKA3+A2GFrkEN6?= =?iso-8859-1?q?o9M15puL0pfuvjhMjqq6sf0DaInhF29SkQy5+gOB/hvQg+nJvoz+HnEv+kvf?= =?iso-8859-1?q?9U+fHVt3eaesJKu86WKMJP8HY+yQ+GRuXLhWfluC/B1nmyIWcl0tPCGRkmp9?= =?iso-8859-1?q?Hn+cQPr6kSAADMMAv5rYuKoaU/nVlJbgrbET+tB92E1sfexBV8GoVVvutWsI?= =?iso-8859-1?q?M2O8CNXefpMpzSNfjIVbZma1L8rG2+194yRo9n9LLhgKG+aIKRPZbvrjU6f4?= =?iso-8859-1?q?KVFFkE99hEC8JkXlj50k+opqwM6aUAodsgZBM2jyB0LdMCVrqKkN9rZQG8Ac?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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(IntelIOMMUState *s, .translated_addr = 0, .addr_mask = size - 1, .perm = IOMMU_NONE, + .pasid = 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 = addr; event.entry.perm = IOMMU_NONE; event.entry.translated_addr = 0; + event.entry.pasid = vtd_dev_as->pasid; memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event); } @@ -3680,6 +3682,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr, IOMMUTLBEntry iotlb = { /* We'll fill in the rest later. */ .target_as = &address_space_memory, + .pasid = vtd_as->pasid, }; bool success; From patchwork Mon Jan 20 17:41:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2BBBC02182 for ; Mon, 20 Jan 2025 17:43:54 +0000 (UTC) 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 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: MDFokaHJggJzYoAu1CA7H5E2Ip7Ta3KC/vNCO4/MzMCKXhA/QK60TRK9V/8Ufxv9+NgaUKniRWkSpCwK5bh4Z5E2gYH5+F95xJsCVQ8xAUUkkwL5WOI7Lt4JcUt9QIBudEu0k30CsHDe5an90Il3+LpJj/gjolzMoiBE5mCJ8kNz3w== 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 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== 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 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-8859-1?q?5UBJbyqHUTuKB/blzUELk9TRgV?= =?iso-8859-1?q?tVsC+A6sLXLpYKrJdo9LYXK4ljhsGhg/etz6FbDwC9np81ZYaCkrCnoH9RE1?= =?iso-8859-1?q?Yo5ZZgd9DyKEiMUBag0c8vUGKUr5z9FgTEBKuZ/6Teq+VHXGkh68BCLxuwLQ?= =?iso-8859-1?q?OoiCCmx5iud3Fra3LKKqWAuYa7iDufI84QH68xqMC2wvKL0o9vxnu0VJO8c7?= =?iso-8859-1?q?NaHOynLRotueIBSN0L4Py61zfiF5rSVXPBTi25iB2ZMz/n0HHm/0suBbx4Ss?= =?iso-8859-1?q?1XVdpXHqFFRHmm4hmlloxkveyYkTT2HaMryDwFVm92x+MnWa9laKfrhiK2op?= =?iso-8859-1?q?Mvyh1FspEHC19tnRCBuJyW3IL1eUv1pMEb2uTatXH9oFjXZzE9/fF/bp+gNA?= =?iso-8859-1?q?P7n6N9JWhyh+XkJ38HhUzCMA0if+pChbuUCHb0yxh1GqZxHnqexCaLkcAW8F?= =?iso-8859-1?q?TR8LNH9GYfrwxkA5GHiBaH6qKVYeghDyv9mjyLuSLJfJsOhB+2k5xs6k32s/?= =?iso-8859-1?q?/fpjzW0i2CvN/Yi6QYOel2LddOze3PnfaVHN6sCE7HK3Vo2cmJwXZZIasUqz?= =?iso-8859-1?q?Eg0pu/KH4P4ly+iP/j2+7ybvmRMsOn0EEcAeZ3uwNJTSma/ba7RJ7vqOa/u8?= =?iso-8859-1?q?6FuqGicVhzKRoSnK3CktPfhzuuago7z4FdtBvZwpi1XG2n9gd3UPSud4jvb7?= =?iso-8859-1?q?EyHXd/JRAsjpFqJTUrxYqoRJ7xEX5a3pqLi690Kk4jBTh0WbRDAzB1IPlNKb?= =?iso-8859-1?q?b3sNPC4GMheimp1oGIDHWcJiAh8blMXr4dtXCigOw0NUdtZt5ZlqXcKTJs4C?= =?iso-8859-1?q?SOLC4SYpZCCForK2Ak3tWp0QFsJzBSCeLQp2jKcTnAyAuNrVpRVhc++U8FTB?= =?iso-8859-1?q?DJD58RLgjdvAO3ljhLy5DriMKBO/VMEDiv7FBo3g2jguDdbHzJzA6/xy0+FU?= =?iso-8859-1?q?VRH2SqYQMoh2V24yNTSlWbxJn4LBHIPWnBXCIKlt0vgo3Tb3jO6kXukEN1H/?= =?iso-8859-1?q?YN5xpUK1portTZFEJqQaYBVwz3L0Uzw/pH13UoNO1mcnSw2y2bPEO65UX4AC?= =?iso-8859-1?q?14DkJPjrmccY4fW2dmrPjMjtEc3/qT/Dn2SYem/O0X0vZ7y88/ggNWyL79OP?= =?iso-8859-1?q?9rZfXIT2ocGlifw2jlEKL7ZUqObgeg7bMfcEVs1IjVuzgXgnmR7a4ICObSsG?= =?iso-8859-1?q?UXFGWXUYsshF7FM61VlaLMiznlLqdkvaNb2j0+pWwVkRCxtCMmREBofKJSqC?= =?iso-8859-1?q?er1LkbplGkfKUVPBreJcRj5ATsbofqCioSL83my84++BxFkwtbNOUAWRm0SG?= =?iso-8859-1?q?o7lykxmk8CHQg4KMlORZdRBcxHpDvLz/7NlruVy3HAvxSr2cmXd2KWqulTf/?= =?iso-8859-1?q?C1GiMDor3AOpLmYu4c5N2i9wKeGyQJsOWqvQbgCoG3ASFLuDLVAwfzE3jCRm?= =?iso-8859-1?q?RiV7dH17ECUFatJCzJaQyhzkSM6b2SvwKrCWF+7+8h8DijwDqW4g8Dx33cm7?= =?iso-8859-1?q?zjmmdS?= 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?reMbc6pHt5V3Hl2XyFnEfXp?= =?iso-8859-1?q?uSv3iO0CMiBd2Eli7jAhG4GikZ9loN/gGf8S4l8egBna3okfPnrYw34H0uYU?= =?iso-8859-1?q?tG3uKJK7kvgfGx9cVcA8LQ+DYroPCc+H0DO7Dupdezwbs7B3BBLGNdpJT05t?= =?iso-8859-1?q?kx/eYefnFj54X5AJAhgcewBFo4Bw/KodkoQkq3/wryUydg86p5JpvlQjbABG?= =?iso-8859-1?q?VkRuctMwDzmnuV56EMOrezJbsUXXDl/v31wcHzggbHHiqjgGpp+njTWJicoI?= =?iso-8859-1?q?sSIYUAXQPU4CtuC44OW4B7hgRMl6NQl2wr3A9W4cNvCSOm0oAt3gsVGuvbzH?= =?iso-8859-1?q?fj1A2VMCBvurklaOn3ZLquIoQInYoD28cRaf5O5H6DP2Dm9t0WyTz/9XDFhO?= =?iso-8859-1?q?llRZmzUULBbYFdKit4CYBSIk8UuzGIe5hGhFOtYrKGXxn5b851+4LazCTTxB?= =?iso-8859-1?q?O1Qa6S3ai9yUjaKhWu0X+LiSnFvyW3klk/8LNptmanBhymQJCiyjcmWw85+L?= =?iso-8859-1?q?aNnE+xjPxON315KaiDsqjuONb2wSdkRHoamf7J3byYn5RcK0NbwkK3syeGhB?= =?iso-8859-1?q?PS7Ia/XS0D4r+WoU7I6V3Fzw3TgKmlKSuelBVHMK8APHhRpPOIggonkcEoq8?= =?iso-8859-1?q?tDv+vz1I0+tPutdcL+4ZzLaSRSx0NfPfK3BTA4rkwOESF8pYs8jDlLGNX/F3?= =?iso-8859-1?q?s6ui8ADlIEPpadcRXpW4kOcnk1uhteRzQH6A5DFLFhWyj7lw7XDV4QlOWL5z?= =?iso-8859-1?q?v9U7fMHm0LC1iB8YX0nesiiANhr0+tuVGw6jxgiqFccD6aNt53u7nACU2I7q?= =?iso-8859-1?q?QtyeUEOQ1uHs/9+x0hXmSb14mi+PtZH0tU6PAT33MVv7MpbyNCiXJWvsg4TV?= =?iso-8859-1?q?jloI5qLYHZkgAaR66XP/brb9xjAZgLPaIGvWnMfZsdtqqJWW5XwVqe7PvsN/?= =?iso-8859-1?q?ZusgTxRdbfwpoVpEccv/RzGS7+1xvLYlDbj12IqctmyufLk3GIz3U4G6DTiQ?= =?iso-8859-1?q?DXkjSTKhWR7chk8POveN5/40q1CKepMCDRjwgfkjqPlYTaXcRws2C+uhE2IN?= =?iso-8859-1?q?Lr9+tAPv2kZWZ/v6ffdfMTmndVY9UAmFT7c9YQy3qIJqe4cl6IYdu4MwLfrM?= =?iso-8859-1?q?DrTXNbP3a0tXBzYrrxuNGv5qN7sI0lYoB5p6/FNEwqADIyU5PEEUAadOsx74?= =?iso-8859-1?q?jyZ5X0Mg2AqSoT3UgYiS2GRE1ZDgeu28z6un1xojgMtJ/xwo+7YX9ey7V3AV?= =?iso-8859-1?q?tuIGqRFg3ZFqxQB3nHGvSZkfRWBZ2NP9H3zN8SkRgJT1njx7Tr5oa4l5PT0K?= =?iso-8859-1?q?uaA3ex8gUhoXPV4Ua5zb4PqJUHDJBXzkXSKEqIhUOm2fhqkoi6JUCpXAc+oz?= =?iso-8859-1?q?RWN83XPNiTwePGG8wY6w44zO5O7Km2EyGLOwc+GC7GjX5aqXvEXYpP7oqm09?= =?iso-8859-1?q?KjDY2Ur8B2oarGcr9kmN0CN0rBPVPa5nGQo9Bhc50oyPNWTpiTMDZPxfZlRP?= =?iso-8859-1?q?0ejoQJOWrkohauyguzgZcWVrG6nOWJq46RLBqlGnbW3PJyJmtnWzzLwDRdiW?= =?iso-8859-1?q?3Nr+o46zCoAsrTDueR0hC/KFrqYMQCPzWKrxSBeZVbDFYybqr/+qtmCrLuvS?= =?iso-8859-1?q?pGTV1tvmi/1rXhkRiDMEV20pz2p4cDCX2JxoQc3ImpJPMXrJzkoVjwmKAkgs?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 <= PCI_EXT_CAP_PASID_MAX_WIDTH); + static const uint16_t control_reg_rw_mask = 0x07; + uint16_t capability_reg = pasid_width; + + pcie_add_capability(dev, PCI_EXT_CAP_ID_PASID, PCI_PASID_VER, offset, + PCI_EXT_CAP_PASID_SIZEOF); + + capability_reg <<= PCI_PASID_CAP_WIDTH_SHIFT; + capability_reg |= exec_perm ? PCI_PASID_CAP_EXEC : 0; + capability_reg |= priv_mod ? PCI_PASID_CAP_PRIV : 0; + pci_set_word(dev->config + offset + PCI_PASID_CAP, capability_reg); + + /* Everything is disabled by default */ + pci_set_word(dev->config + offset + PCI_PASID_CTRL, 0); + + pci_set_word(dev->wmask + offset + PCI_PASID_CTRL, control_reg_rw_mask); + + dev->exp.pasid_cap = offset; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b8d59732bc..aa040c3e97 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -72,8 +72,9 @@ struct PCIExpressDevice { uint16_t aer_cap; PCIEAERLog aer_log; - /* Offset of ATS capability in config space */ + /* Offset of ATS and PASID capabilities in config space */ uint16_t ats_cap; + uint16_t pasid_cap; /* ACS */ uint16_t acs_cap; @@ -152,4 +153,7 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); + +void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, + bool exec_perm, bool priv_mod); #endif /* QEMU_PCIE_H */ diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h index 9d3b6868dc..4d9cf4a29c 100644 --- a/include/hw/pci/pcie_regs.h +++ b/include/hw/pci/pcie_regs.h @@ -86,6 +86,11 @@ typedef enum PCIExpLinkWidth { #define PCI_ARI_VER 1 #define PCI_ARI_SIZEOF 8 +/* PASID */ +#define PCI_PASID_VER 1 +#define PCI_EXT_CAP_PASID_MAX_WIDTH 20 +#define PCI_PASID_CAP_WIDTH_SHIFT 8 + /* AER */ #define PCI_ERR_VER 2 #define PCI_ERR_SIZEOF 0x48 From patchwork Mon Jan 20 17:41:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945428 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E87AFC02181 for ; Mon, 20 Jan 2025 17:43:44 +0000 (UTC) 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 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: MDFpzbeiaUZhiNazcwuLI3kO2akcxy7lRnst2o85N3lAhz64BtBl4rvRz8Nwv+iwJRFxzx8a5D2RsH9i9d6lszY2pDxwz/pFxt/fZ813swOD6KTvJE0FqladSvm7xEuTB8luUVx1/W0egNGrLsFnhi5C620eVMaWP/hYxNx4R5379w== 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 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== 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 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+OwsRU8l?= =?iso-8859-1?q?mmotqSXFQjo6h4m0lLwaJ1Ha3/Efp/g+iS9cyKe6fT4WxABbOP7RIVHcvk3T?= =?iso-8859-1?q?Gl2bLo6IEAqfLvBUuXm7Apd69xCYmMUOsyhdQNrd8EBAYa6kf4c/ecN9Ez4h?= =?iso-8859-1?q?xd7ofSCRUy2xJqA2am/rQkWip41wowJV64giNFsNX/1LYLQnDKKgFaTw9W+t?= =?iso-8859-1?q?UOU4QtqJNrw14cKNYS7gcEDzV+oMC2nXo2oP95BP6YdXwsiKecjcwpkdiza4?= =?iso-8859-1?q?hHF80d8fnJBL5lK3Sdq+G8euZKJUxQ4J+NkcBIL63Mvt9nAexEIbE65eyb2S?= =?iso-8859-1?q?rXLeiFhE7pqSt8ddcbnufaNh5JBgaO0u9MD4Tr/QGVnWVue5C/d9dPTDpCVa?= =?iso-8859-1?q?cGniqxmeZ1mPXh2WDcmazv6xb7OjElhkj7pyxnAxJa1X7IF8p4Mg7Ml7qtcm?= =?iso-8859-1?q?stSefGHe+arkJ4XhXSoOM+5zcV0EQpCd7+Whh3+Gw1kTTztdkNXrhoTfT8k0?= =?iso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G6oIqChy5Qvpv6R1EZ5+FjiyR7CmjYZ1n5XOb8L?= =?iso-8859-1?q?UrTNYZ3zAhuu0hVo2h1qMCW6ttVzXapVxyiR2oXDBJpS/sEYr5LUuSAqsc+Z?= =?iso-8859-1?q?Kmrl92?= 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?= =?iso-8859-1?q?/I5/bRIp7XcdcTygvRYVdyVEL+8OTWUTafbBm+KH/BpsZ/7KrtJ/iVNujz0u?= =?iso-8859-1?q?Pm7Hm4pIH7OGAZYRw9G8gtpy1mXtyqHlIQZGsB4GEBKI/a4GENc8Tt3/RS0j?= =?iso-8859-1?q?p5Pfqs8bSIi2frM2y1l9gsMnXKUk5E0syn+J/4c+OS36FuFywUCXTEaPA9kV?= =?iso-8859-1?q?3bzc7XBAbfomv9c0K/BmHElhg0xp43yDttwb5keALWPOlGQeKSGFkn3HZwNu?= =?iso-8859-1?q?Z9T4bwk5qtAZXVn2dwdNCYJzuVPRaiOGEQz+OdPIDDcZUazFfT/FXDhnPXRY?= =?iso-8859-1?q?TIjFxqlaOVoSvNwzpAvrTtRnDn8kSAoup1ppawFiz+7KoJU3zdX6DIIaYcdd?= =?iso-8859-1?q?m7AQuMYIISiiR0I4ldjU4Oe6C42VsCS9R6owImFd4hJChTUlndGkvS2OaU1B?= =?iso-8859-1?q?lL8Bi7DUtWtuRxs+S6m0hSDFiBWm9uQK2wJgRzkxLu67fHouItfNfhFqgayV?= =?iso-8859-1?q?3ZYqSvLxEDN78KGlSjbw3No3IVv0rBMF4Ltk/IORxqVXiB+wBw/sLD42v7Ky?= =?iso-8859-1?q?cfOSgUMltibTgwY6k210nOaWNw/wZGyuN8NtK2gIaYnNI7VMlohT5tVOI5qA?= =?iso-8859-1?q?hZjguUy3FBfU2Ythy25UuKE5MEgACdkLIw/VdPPfS7aN8PVZJ3D+FabMQaLm?= =?iso-8859-1?q?Q8XKPLhfj0D8GVWGdUQR2FzjsvS7yphvXiecx+DN8H+NZfAvdhF7iFJzkIgb?= =?iso-8859-1?q?NVTkDZZLl4x94HcFD9CtSIAff7pXMkXsKWpXpTh/3I42MRDgOl3gcDgxEECH?= =?iso-8859-1?q?suEdEzwtqHfeJu0+YsEzlZF96x3TB56e5Eb7fq1CygBL5sxwPdzcEwKGsO0o?= =?iso-8859-1?q?ekGXG0JTeVsIpOcTSotEOlhzVktbqMWGqRnztdBeFshqqht9EVwTGBs+ML4u?= =?iso-8859-1?q?shnPvmZx2PyM9LnLYZSSnF3EDgbyJULQ84SLSM7U7jChl+L30cxL5Ik6gW2x?= =?iso-8859-1?q?eq/TlSJ7bkP5Rbfr3TF0O1aGS/JcU7ZQu06PXFKZoGjMqUiI2ikmwHdg9U5a?= =?iso-8859-1?q?kkyxpTsV1TV6MQoq196LKd8HG6OR+BRU97BmL5RgIt5SVBpPrfuxa7a0UqbV?= =?iso-8859-1?q?y2gDTHIFVe6ldy/w928VMISdjUDi1XnIZTRwZG8Boyschq1pK8uGxVLpifBV?= =?iso-8859-1?q?deVXS2t0iPliM+SdUrcTrwlJfrtq/TzZ4HhEXISV+sLHLlppRtOay286IrtX?= =?iso-8859-1?q?8WfWqEj+YTxOwl9KfNpIwarmk+jZPHf7cRKUsjYLuh1D2sbvvRWmxuTYxoXa?= =?iso-8859-1?q?MTUvNMIdz6wGvP+dT9DEhBR8K+WRxxoKLTZt7R1kl7eYe4EYFLb0WnUGiATo?= =?iso-8859-1?q?ED+BEKzlth9LxDtsryN8DXOWz6yhYmeQZLuRS+HTi90z2rb9MnqwF4eVIh46?= =?iso-8859-1?q?3avlrssp6O4I5Mw6dVBrJ1kU6sHXo9CwkYv9WsmM+Qm3PjD9B9QuIagnZSQR?= =?iso-8859-1?q?BmYnwXVZ5fwfwQINKxj25Z/dyjRyFbVj35R8TU/FSu97Whjft82m39iJcq/T?= =?iso-8859-1?q?mQ7K/GmmX/KSWXE/fwBmuLIOWXUftlX0v7QpAQTC3HQBvZ/cGKQLTPerM/sc?= =?iso-8859-1?q?wbES9rqdyN4EPZOME1yZzKfn3cAqvK13OJNEiGvO7Mgjd+n1qvt8FmEvbYk8?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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, dev->exp.pasid_cap = offset; } + +bool pcie_pasid_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.pasid_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.pasid_cap + PCI_PASID_CTRL) & + PCI_PASID_CTRL_ENABLE) != 0; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index aa040c3e97..63604ccc6e 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -156,4 +156,6 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, bool exec_perm, bool priv_mod); + +bool pcie_pasid_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */ From patchwork Mon Jan 20 17:41:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9BF5C02181 for ; Mon, 20 Jan 2025 17:42:28 +0000 (UTC) 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 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: MDGCNDPG0jb0gvufw9cl56ciFo57gjLkKQxnxppgeESJObntp6ePeZkBODaLibps6zj0SgksxOnyouP9006HcLcjHJldMh/8aBpZDiZZ+AYnDK4rCf3MD5f3zt2aLX/tZLwVdWvpstp/aD4Fmv2cgAI4xTc7ngmd3QbrQixQndxPwA== 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 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== 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 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/toeyns141XkWb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QDSfr1PI0XZnyDZQt2P+bXffY9WSl6ePKaiUoNt5a3rhz1h?= =?iso-8859-1?q?R9iBUgs73XvmE5is6pj3dqWv1Bd8jOM/QsxJqcRLzrv8Ye8VGyi/PXpMLrZg?= =?iso-8859-1?q?jDmj0pemX40M6RPOotxMXAhh/18hXArWomfwcOriAMIRKrDhytMjsTbCDNX/?= =?iso-8859-1?q?/BaBK/v4pW/pnIRB9BITSaw08XI1J88Ouj+ZkAL4SQOguPRAOGGPARtRtrIP?= =?iso-8859-1?q?CShXbnD3lWqfVkaTs3FyaeESbeof6hIcceeao2a7dTZVN/6dpf55RYlDW9iX?= =?iso-8859-1?q?tvH7fiMkVzlkjfDUHx56QprJJW6WZd6FdCErWQ1lzO8RQEuAuHmt1haY0JwY?= =?iso-8859-1?q?qQCFiLfr45+U+crfBnO/LvPBFu7qqou2UYPvKxbWftz8Aroq3dcybW4Drg3g?= =?iso-8859-1?q?naRCC+voMs4DWbTaGX7DrJUOZu4DNapKzo2DG5RQWl54+LWtqEXV+eQgXIjm?= =?iso-8859-1?q?15xlWWxG4BEeduhOgAH6zcvUjMx5J9pvug0cQtY6b6SipYYozPEqnULOnX77?= =?iso-8859-1?q?10JKC3TQzmRY2GyPUTck0Rm8qRTJtTHOulsb63olgVEXVvHK99OpWKuzxMt0?= =?iso-8859-1?q?s5eOmH?= 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+k28B0Io9?= =?iso-8859-1?q?peKTJiH8JuVEoJLzjk/HmSgRV/MfBXifTXvwIvVmoP2svzZntCDCeb9ijuWQ?= =?iso-8859-1?q?5ep+lsEhY+v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KQvlYcReIE+1zehzly3NlFw?= =?iso-8859-1?q?33tQnhhcjnmuoFK2Y5oubfBwBk3Pu9YvRjWk4uTecHe3TGTcL+Ye3jn5vXa/?= =?iso-8859-1?q?+X7+2m8AelwpwLsltLr7FKBIHfe/vmkbeIU2IIqo1tF9ifv98XxpoAZR9E4P?= =?iso-8859-1?q?xXSI6ArS1zj4Kocf1VfbCZfuK5doo/+O05iCt8J9S5i+RH3ye+tC4981XOVK?= =?iso-8859-1?q?dz2VZ4OKyVWEND4OGhgKeCun4O7HVMYeN8XM6zpw3yF4VogdLrirNY+pZKOc?= =?iso-8859-1?q?gROajgZEFq1zIYuYC2KbevqQLgsEAwCvwpXJ2v92uhpunLliFrTdMj9ncY1d?= =?iso-8859-1?q?XLyXDhA2ahLNKo/khTvXHWIUCJgUxWAP7qNGoCLv+8c+zgRYefje2au3gUGv?= =?iso-8859-1?q?KFDWTti7fVUjv4sw80T+Ba+H5IX2ZSBd+WMs7HrQ1MDq1oiaPhJkOpXLxWUs?= =?iso-8859-1?q?dq1CFXvYmYMdN0f4IwYcrX04uZJ7LGBxqX9OgdKAdT0UpQgusNsN2lx/dl4U?= =?iso-8859-1?q?vHvyM96S5t2FlbYq2AB1ahltsTxi7KbvG915tVktQzk1RkaNCBepX6R/3rxt?= =?iso-8859-1?q?YuJoUAxQnymB24Gfw0f2I4aHIvnqGbY22baITeVx1MmTODfR0JqRJ+wp2iG3?= =?iso-8859-1?q?UgYcLNpe5mHzpP8K+bAdk1ppV2WBlvOb8kHkNytLZw6rN8+2As4WQkgS88AE?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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) != 0; } + +bool pcie_ats_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.ats_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.ats_cap + PCI_ATS_CTRL) & + PCI_ATS_CTRL_ENABLE) != 0; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 63604ccc6e..7e7b8baa6e 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,4 +158,5 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, bool exec_perm, bool priv_mod); bool pcie_pasid_enabled(const PCIDevice *dev); +bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */ From patchwork Mon Jan 20 17:41:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D63F7C02181 for ; Mon, 20 Jan 2025 17:44:20 +0000 (UTC) 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 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: MDH/PuE3+IHgGnkr/orbSoNEJwueGtca4u5KhmRlVZtzg9z+EcdAiw7xYTC1EqR7IaE7W37oFP3y6ycpMSQ7YYIB4pVe4jqFOYx0Hh4Y0mtsccZPA2Ux7z8z8M3ESxe/1/a4hUfKo5ercm87DH2YICVhG65rzzChP7SzqApHEFAn9g== 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 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== 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 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+ZTw9aoUctqZj9cHwE?= =?iso-8859-1?q?X1jzXoImGCfbUL4otz4j8jehXk1RsdwFjOwdiK1aXFxr8h1x/EDGXAqzGeoe?= =?iso-8859-1?q?fFJ4bJr59qkXTjB3NWOlOVkaPrQO97+t/Gdx533ReGoiykgnAFdfhNY14Ild?= =?iso-8859-1?q?Viu+YRSf+vDsuMMY+oENwtfh6k5H9bzqWi07ggyejA/Ce8+dO7unBOZYOjWc?= =?iso-8859-1?q?6FjVOv6YQE77ousyyqzUvQxmxYXQcLonTfR3IdpxbkQRHH2S/HZ/6UEHZcls?= =?iso-8859-1?q?EtKlkq1pDzEACfAj3JurLAM6NhMfLoy3Eg9A3NIjA5/CU9r7VQFPRO6txrAK?= =?iso-8859-1?q?gH41bG0/w9vMZ8BEDNOGv3PMt4UighgG3K0unJPgKWXd0Vt2BmbLEkgfmxIS?= =?iso-8859-1?q?DLVdf/fI/Te7MqWqMU1SatIJ7z3q4rBmUy3IP5/6SUx43OwC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q?hfmY6i6CFF01tz+wgtA1RG5M47jN2+YGD61TSB5fTAZNL9IS5cUo+e4qq/tA?= =?iso-8859-1?q?hzUhbLK8kKYj76bGsOiKrAZqw7t5c/o0JKEznuhiu22GilJmHj2IpoqdAUYS?= =?iso-8859-1?q?TZeQOC+A9C/Edp/kKZmza+syNnVLVSnIzgWXFNnD090dOev4hHX0/xG+z4L5?= =?iso-8859-1?q?ktVzjT?= 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?domHKLbMdylHvTYUYym0qxO?= =?iso-8859-1?q?X5gBbcI6lMV64n6QyelmbpdQdEM762TOaNr0vOyVV2OpgvcMTqwvE7AdSjCQ?= =?iso-8859-1?q?ANxWJwTCNC3u/ooJCBctSzicVqbgeBfJAiTbSOR+9LjBomzPaZVknxD5Q/ir?= =?iso-8859-1?q?HOUgU6jQLog68kqE7rpU0xR/5WCmUTU6a/Mqz0igrAZQBpp9j0l3UK8Lm4XI?= =?iso-8859-1?q?1Pe1jgOcOhftT2mdhy0jW5zFgugsmwRigQL8iWXmOg30stu4G/UYAVO3z841?= =?iso-8859-1?q?iZ87/grdJXQNxgkqdi4JBssQCymyN2RxXrHNjWkMXki+LnVy5rXxkR79r112?= =?iso-8859-1?q?Zan/U3L/ujGKcOpy/wpzldQsrNcY+c+dAjjMkB/J+KEKrL+umlwzE/Pmr50O?= =?iso-8859-1?q?BGCt/+r2wSpW7bOnPewrFuBcecHNk9Cziv6TGycHxkCSfxvNm+QNfQkBv2pn?= =?iso-8859-1?q?cbru5nO4JdPjwWGjJDXuA/BIjLbfi6pE8yR0vK9Ba3d/ruqc37dGl9Qqo/eE?= =?iso-8859-1?q?vRS9yIaVVOdSmYq9hkJYHGPZpPIL4c0doPZS06dD+Fa4J379RrCGkphgNLqg?= =?iso-8859-1?q?yWk1KqTs4dLV1vlkspZA0qGuaf+6IjiDbn5S/7wCJK7wInUgmWaA5liMWeVE?= =?iso-8859-1?q?pbhiuVfG06SkzNLQNkKITW6jrefcfEeKBhKSKLq+/LvBGQLI3aaRf769wGqu?= =?iso-8859-1?q?TF8B43KTc7YSS6edDWRo8+KlX955V+xrVAdljQFQbq+nmpnKEP//u7eOqeSm?= =?iso-8859-1?q?GrnLQWfFgjND2u+amvs5IeZ31ygdTNTS6yR1QcMVQ0DRUNHyWOjRU95BfnMk?= =?iso-8859-1?q?Uss4SjvRmj6yighzz7GLLDNscRxo0v2ZXnttCVHWJ1WvNJic82w+VHmZS84R?= =?iso-8859-1?q?qWhzDOstPqUN8gSAZcSc6v8ZuXoNlf0CMRNCsU54k2hyrxj07bg/tB0QNjFP?= =?iso-8859-1?q?yEmZzhhfN04dG8D7m5qy6V/tgxREnJLGXwLfAshKXL4uqCbMjTUHQnljNfqr?= =?iso-8859-1?q?Kt/rpnYDkEwXe6W6kb+NCdA4NgvJf2ltVIqJiw4KC3/yT69FRtcpYJ6cKczE?= =?iso-8859-1?q?a0UwjHJrNuEJjk7GWociUIdHQCbqtw+IPxwu/fMinzD5BGHRiIwYYSEuxazE?= =?iso-8859-1?q?kNiQZ+56uoOkYskFYQq9pzztK+0qbF/uduwgqpCTlMFA3rl9KUC3wbO78eoE?= =?iso-8859-1?q?BbFGQvRNAVZzzXlk5HW7aTliohZ3eOm1EzYAAg3SJh/x/H73P+qgjWjSGUhP?= =?iso-8859-1?q?COUDS0GNczagcpLSm/UzzEbuW1vc0cAHQbR2x+WHtpqLl9A3QQMyJCH10UN7?= =?iso-8859-1?q?QZyOmdSf/y7W4VMnJydbpNUn9KnbOxe/Eoqk2fxqWAzOJRYUFfGTJV9pqFVK?= =?iso-8859-1?q?zfmjNym1FAxKbtRHNrcovrV9/GTt3BTjabrFWNBoNPFyKOV3vIxTNWkpYo1J?= =?iso-8859-1?q?gYypSxsNFP0p2nUlAEXsmIvuE99f2TALCHxj9JugDoVqMAZ+IvxVWym0gwxI?= =?iso-8859-1?q?2xy4CrMabfjfk6q2xOmjnMYSKL9OOlAWDjYikoZj2Y0W34K90313BbX+xQaq?= =?iso-8859-1?q?R9ZgwnVOLNm2499g01Fu1H+hdAR28YQ9v+XhpVrsyZ6O0bRAGOT78fs9oRLG?= =?iso-8859-1?q?88Ry4vKKTmCzKLU9z/JMko9nFta0cHiToZVwHjdwFFrb1wZFRdN/iwl2vZs0?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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; } +static void pci_set_master(PCIDevice *d, bool enable) +{ + memory_region_set_enabled(&d->bus_master_enable_region, enable); + d->is_master = enable; /* cache the status */ +} + static void pci_init_bus_master(PCIDevice *pci_dev) { AddressSpace *dma_as = pci_device_iommu_address_space(pci_dev); @@ -141,7 +147,7 @@ static void pci_init_bus_master(PCIDevice *pci_dev) memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); - memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); + pci_set_master(pci_dev, false); memory_region_add_subregion(&pci_dev->bus_master_container_region, 0, &pci_dev->bus_master_enable_region); } @@ -727,9 +733,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size, pci_bridge_update_mappings(PCI_BRIDGE(s)); } - memory_region_set_enabled(&s->bus_master_enable_region, - pci_get_word(s->config + PCI_COMMAND) - & PCI_COMMAND_MASTER); + pci_set_master(s, pci_get_word(s->config + PCI_COMMAND) + & PCI_COMMAND_MASTER); g_free(config); return 0; @@ -1684,9 +1689,10 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val_in, int if (ranges_overlap(addr, l, PCI_COMMAND, 2)) { pci_update_irq_disabled(d, was_irq_disabled); - memory_region_set_enabled(&d->bus_master_enable_region, - (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->enabled); + pci_set_master(d, + (pci_get_word(d->config + PCI_COMMAND) & + PCI_COMMAND_MASTER) && + d->enabled); } msi_write_config(d, addr, val_in, l); @@ -2974,9 +2980,8 @@ void pci_set_enabled(PCIDevice *d, bool state) d->enabled = 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; From patchwork Mon Jan 20 17:41:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D8F6C02185 for ; Mon, 20 Jan 2025 17:44:23 +0000 (UTC) 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 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: MDHnk0s8qWZbw1BrlGt9IYR+THA0M0DDyYTKj6JAIDD9IzEzk7y+FLx0C/PVz4+uLhDhpmlykOEeub8R7rU0ur1KINHMVM0TRDX/CJxud/K+gy3eW3cxa0B1YaT/LDx0XgxLOMP4g8jQ495Jzd0eLjgiBNBiMzBeW8WHZlKOiw2BCg== 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 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== 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 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?3ecSMNxJk1wR1RnNawbgqeovNr?= =?iso-8859-1?q?Hml1mCDSj9mNgjcvmjWgRgm+lfATSydmWeYKQprlty57cSVPAFftg9o50aD3?= =?iso-8859-1?q?d4IetT5g6qBBzerBuLoSfIaVBh0V/ASh8e5iDsH3LPWhEcQfUx/IcXWuRNZB?= =?iso-8859-1?q?rOBGaGW9itJmmiRUlv83iy4vlw4EF1DVl+NuuayI57J7MV0V71ov4IYsIIFT?= =?iso-8859-1?q?7bpxmfdjVV89qBOLQdEH0PeHclhjWNmfVgX+rq9uvPI3bIqzw3jmfCHcFdXT?= =?iso-8859-1?q?ms7TJSknLBuO+YCCuANX6LSexH/sYlZUrIrASSo6s5jV0Q2mentfQN1d6mpK?= =?iso-8859-1?q?d3wOWzaR9q2QaDv3FmSkSqCOjb6kHsb+X9+592xrjXCIs1R0VC6/5CuihR7O?= =?iso-8859-1?q?TSriZxYvIradPr51wuxa9K/oms09I/9WP8mj28iXOh75YueqJWKMt5t0KhGd?= =?iso-8859-1?q?0yYc/URWBCwaHIgmRqlzMYU5E71tQbQQiLtgBoVz+1i2FQXHjevM8Crr6H/O?= =?iso-8859-1?q?XTeTMnKRCb7FvfcrdIDTXYazOR3+qzINJ9ADkOjtwmG/0GpUVabWA9FX+Yi+?= =?iso-8859-1?q?8OYxFdHqgUXi/BXmsZKfIUoThNpL0QKWUjQWYP+RUHdQidZu0lSgKfusonXu?= =?iso-8859-1?q?7wVW2CTuL10emDCTZM2s2E2pQ229KY3lMmCpyhargMI30l5n7HetaMoIFzvc?= =?iso-8859-1?q?iqjqhrPQO8e7pEHnn3WmpObAz6bT1JhCjPwsal0JEnI1CxH1zHkKir2s1MGd?= =?iso-8859-1?q?8vUMfssANKIaeVKoFygi6Of2Ch2FvrYvsZ9cpG1ST/g55QVGjpDWyMNAZ9nt?= =?iso-8859-1?q?fAHBps1sQULr6MyZc1Z1nzifJsFkeQMH1k0hsyGoxopNmpg1P6XWK70SKCwl?= =?iso-8859-1?q?S/oBbOIGV7o4+uRl5NqqpbObf99s8P1LqWr3mPRs1yszIe7adkTGWf8pBxZs?= =?iso-8859-1?q?MzA84Vx6zytnVo+CFq5FNQmhiO4jCRoLea5VhvhwIJVziKRA2unO1rw+wf0R?= =?iso-8859-1?q?fkMcotUO8pk+n3EZ9Anx69Lbxqr3L7mrUgmSXWou8rjKcxWtwzQNVlSaXqUq?= =?iso-8859-1?q?NqBMQgTU9taJ2cDBVq/VOhzbnaoXeLuMSFzpt5B/UUqqB5qIowIPSO0GrDAX?= =?iso-8859-1?q?CvRLQwiKdho32TnE0TGaiuL2kLClEs8lZVCSM0MrdCCM3VF4wYHNA1mrxeZn?= =?iso-8859-1?q?huNPytx4Ae3bOUa4nkrgxuQgGsrhHZ0Xq9J1T+N+Dm0e65dtmU7sFx/1yN4t?= =?iso-8859-1?q?mCXWQ5gXIQIfklDfDSsoLzRjBGhCnS4XwydEe2tVvvIA4np3gdLc5ZZ8QfGs?= =?iso-8859-1?q?jZJU/o+Zh87d9SKN8erYK9gFy3YiphXbaiiZECOJRsjkpQgDRPGmJ0wm75Qi?= =?iso-8859-1?q?jvhtrvVyj+/2GnLz93fcT0KYVwq9YqhKnX6HZ6TVej1idPPILZgX0CHM/Faw?= =?iso-8859-1?q?N5nwPI1hb4J/+mxd2OpWG70+UTK0Qm7lIsqaXwHuis6R8J1l2E32Pj7frAYo?= =?iso-8859-1?q?IonFp5?= 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/97Ok4ya?= =?iso-8859-1?q?OaBHGg5bZO5z19Eg5vakmmG8p8+qGMKNWSIh7S8dYkhs2Zkau4qxpef6Wp4s?= =?iso-8859-1?q?C5OdN3F8zeXcc3/tUZ1fetTNXSB/BLlG/Fk2ns4F3Z1yW8O08f3hLPoSdEOe?= =?iso-8859-1?q?AwbarhKT8Z8eXq2KdmCGuXNDyV5DABtsr+a4gKWeUQhgVVXSsOhxKt+ktdSO?= =?iso-8859-1?q?WQdvmrvjxe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eFzU7t31f09B2VkV?= =?iso-8859-1?q?/6EhYmNmLhEgv7ec1G9SqIEyZ7kn7pOoWM+3UfiBCnNfScIEnyl4a1Hg6Mzn?= =?iso-8859-1?q?4xXVXtCIUk4e0rg3UkfPkHbMR0E/ruK/5j3vU2bGHJZXtVIbE63XnxSbDXrz?= =?iso-8859-1?q?8Q6TceDmzBz01HItM7ka7USpKqJav/0cnDI/FdgQqJXXHQ66ROhuMXQRfspy?= =?iso-8859-1?q?GOGF0D+ZqqSiQCNeB7kAsrwuEEGZPihkhef0mdoXec5WLypfcNA+jAAyi7d/?= =?iso-8859-1?q?vlwXvIB4gZIpjvsrUtxoCZ2+97aCFmQV7/fdMzbDL+lI6/EKllO+Yhh/kamK?= =?iso-8859-1?q?jOaBo/HtXeVfJCz9UgzPFmFw7EQvLbhbSBg5wHJRB8WMx8jbBUw4gDa0etLT?= =?iso-8859-1?q?hH+6XgU3eVtbU4I5rdwIUUgzRuVxFSXmso/WOsYGQlDj0WNnQka/4mBwgOIT?= =?iso-8859-1?q?UwdCnf99DEWy10m1P7/VRdTkc3U+/DDdi8AluEEWokZ1TTKN1X1SGtD/7o2V?= =?iso-8859-1?q?emD6/XbkhWsk2AtQxkhAB5WvM1lbI+3p/fP/Ykr/L70S2WEsAhUN3g+H/ON0?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 devfn); + /** + * @get_memory_region_pasid: get the iommu memory region for a given + * device and pasid + * + * @bus: the #PCIBus being accessed. + * + * @opaque: the data passed to pci_setup_iommu(). + * + * @devfn: device and function number + * + * @pasid: the pasid associated with the requested memory region + */ + IOMMUMemoryRegion * (*get_memory_region_pasid)(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid); /** * @set_iommu_device: attach a HostIOMMUDevice to a vIOMMU * From patchwork Mon Jan 20 17:41:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945422 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66094C02182 for ; Mon, 20 Jan 2025 17:42:22 +0000 (UTC) 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 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: MDFwS7EzwZ0/GqQfpjUE5NU3KzO3kblVwk0PDMrLWunapABapFPWvISHUXuFF/DdEYiVYrgfsUIa41I2Ck02Y75yNl5iDjPZuB/sGkZcB67jbpyrNryRHhL6uTr50NIwWQdd5I3SXVKJT57hAc0DpWpm1leT/GhJoMR2XrBkM13QEQ== 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 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== 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 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?c4f0R5yEHUoiR48Hhiysjwlstp?= =?iso-8859-1?q?IWF1GxP4tCo7ea9QsQ8GgSK/kTMRpNKoKwKRRTQ4txC2qNjfuBVmpH7h8mr7?= =?iso-8859-1?q?XPnoRLavhJWhSc1k7eWc2H5HEsuHn62bmitafb3ujG+8ggGpDJII+Ka8/6a9?= =?iso-8859-1?q?iFDi4gJvrPT8n7HsDXWBUtdtp/Ab+uymGUj/l9ZYrYjsAM2dexuGWkVSWuIN?= =?iso-8859-1?q?bQ0Nza0AYK9fxwpyO37P3ft7GEbstEejvCx0C2NN04G+vUL2Jta15PHSXtfr?= =?iso-8859-1?q?vHUtq1nSl0hcNt/J+kHc3pGf9//amMP8orCUkNXeGM5rDB6W4tXoGdmoJwzl?= =?iso-8859-1?q?OVLHqaHvr28HB3PjR8hx6UwYKJzAvJV3L6WuJ0lqzcaXkOlZJmznA29p6t7m?= =?iso-8859-1?q?OS0octSOxNizTru+BCb30qKyP0cRQ79OOHxGT5ynd8zgkxCPx80UQULubV8p?= =?iso-8859-1?q?cJdYNCgf3BTTKBujQGy/lwT40aVfhSYhcUMcDKe2cszCEpllorlnUu75hn2R?= =?iso-8859-1?q?yuwQXIKkWwOJGrcifz5s9Fi/4cAkHM27YaaTvNZU8S8DNQYQRDHNpy+Yt5/Y?= =?iso-8859-1?q?uaClmv/OC2iV7GYYrC0kKcBAIKfmZcO/03Vpbx9fMVJ0+aE04XcVed8cUtK/?= =?iso-8859-1?q?rOhqZ/Owkm2e7hpg7JHD+wbafXBJN/bGsqjK38K0IZofgGICMGv7S4EgvkX4?= =?iso-8859-1?q?yYxKXc4tu/6ltHlnIf9Q6Nv9TU4O9YQ/ZwOwL2ye7ThYTkSpF0bC5/1/bIj8?= =?iso-8859-1?q?TslSRcYgF95HW3l2ZZPa3te9wiBazmplY7leOoIVuVwrMAXCMkl8HzCu8757?= =?iso-8859-1?q?J0/1X/dSxuse+D9NRgGtrEWuSfE/gHChOeZJPqGXsyxtcdnWNdQW1cSzFJPc?= =?iso-8859-1?q?NfTpwxqRJjmq7EdoEA70Ax1dq27PTu/Mw5JbiShRWU+dLCqd3GNBSBlwnNXL?= =?iso-8859-1?q?7cD0Flljx5MVSIjaD/MyLrF/9b2aVH8JbO5dbq29H0od5pA6qZpBqwcFJPLu?= =?iso-8859-1?q?91BUGJ0eiRNir4SdMu5vcTQb+kUKBp4NdxuuEDXolI6wTU0LjrJ2eg41CLB5?= =?iso-8859-1?q?td4eqrGgRuLHisO7BfwwbGRvASM86EjHlZq7To+EQs5M8wr2qbLtA2w2VdEa?= =?iso-8859-1?q?6Yo29+JhaYtRARnmG6Y5wcSe7UI/SmNJS3UaYo7wPTvBOFAuqZ3mk85uu8Wf?= =?iso-8859-1?q?Ww79Dff8zg92nksM/gE7AAP2qrkrql6JBSkUE8EUR49rZRgFJI/DG3bzDoOw?= =?iso-8859-1?q?vtm3Slno3S0kT3oL6uOp+je2EM6AZxUYyKHhFbiRcs5xmweO71azS4ajUtpV?= =?iso-8859-1?q?jVaNYbybsTJ+cp+DUdeKS809n9u7OlExmIMetYWbLOuPGjWHbDLMBofEPH2L?= =?iso-8859-1?q?YUtFDCtOJragxRq2b0LU1cMrv7odwu9ig44lcAJ7b0Pk3TBQPOEX7iJPlEmV?= =?iso-8859-1?q?9no+5dp9unpGKlubPpOUReNSnBbshSM8rGuQfArjPonw4pq0uvzKrtYmE09g?= =?iso-8859-1?q?Cn/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+QJpTzRQQ1n?= =?iso-8859-1?q?v/VGb5O0Dx6jXSkZrP84wHmZ30xUq2YIEWydRSO2RdZHYnpl5MY6PyEkziqs?= =?iso-8859-1?q?vQje5IbSqBu8YTNPlifgE4w0MJVqTRFt5RcZwbeCtMsydqFt4ViljNR6owWA?= =?iso-8859-1?q?ANjKDTUVM3svEx3d2P9eDU5htFSODZTbqHdzRReZ+uXBZ3KVU7073ySzjKrN?= =?iso-8859-1?q?td485J5x09JkSkxMa1KhzeFgk7f9Jcq8Aphr5pnoirmW5twfyZ4vzFbzWfCU?= =?iso-8859-1?q?09U8n/+rxOtdbWiwcxgBFQCI4n2QhDnMdc+5ilKMp8Iw6Qg+jIe5xAl7/qNm?= =?iso-8859-1?q?wUHR2NsGQTTrOD/TIePJjM7gCncrqraEN4jtuOD1wf1zspAamNBse28AZZv1?= =?iso-8859-1?q?RKRhmzaZenJ8QtK49umdj2PefXlRewjvUxyyujD4IBB2bTBH04hDv3G/E7i1?= =?iso-8859-1?q?qVBeNdtnEfn2whm+KX/uUMwaFrv5H/kJRLhOz/LeTt1VmewrMqlVAri+RefH?= =?iso-8859-1?q?kt2WcYpcn2LTVaeEB7Qxh1GNo4sZL4RI0j4ubgTLdrNslrW1ZKOik+Brs57K?= =?iso-8859-1?q?f0cmZ8BCSsf8Mn1ydm48nOM+/l3F7Zx6FaVro3R3CVjHVBEtubMd/xaI8Hka?= =?iso-8859-1?q?sOihQ6aThYqOenzmjQBBWWHFUeK1AtvNAPKDVq4gzStsk1Oss+XtDil0YHPb?= =?iso-8859-1?q?BwU2r9OUiWmJJNnclezY+2l1KQe1SZDF1MtP4MIEuyxxD55Nw0Gxmy2ug71G?= =?iso-8859-1?q?V+K4tBhuG6XbayFnv4+cNomTFTOAGSNYxSqAX55T1K3zoTuoj9M3G9NZokHS?= =?iso-8859-1?q?Q/TYetg0XI0JFib+75Tfwh+HBbeLW5zpnWy3ONxxOiqn/0pctWOkegLDyC6y?= =?iso-8859-1?q?Tn28XqitsATWEIRN/Kcf02y5ZxtPMMfJu5Pn8TFLlljuJfRb6ZeJLJcXtW7p?= =?iso-8859-1?q?FMuhipiKB9OFlVyWbnx2PmADv10677kecaoiVrJ4vODmmybM3qiiu8xMpPi6?= =?iso-8859-1?q?HFOfER87JYKueaUmdpOTBv+Lc2vYYaiab80VkQ6wRI+38WnBfjNsEJYCwBPY?= =?iso-8859-1?q?Ny7nTKBHeBXJKUAH9dp2jB8wcS5E1GM4Xou4txMKJuuxpTYNNZCowjF5LXbB?= =?iso-8859-1?q?pOUi9nvqzEhL7sin92JA3CxLXCaewan3m7g3dESK+ByBPsNaIOq0wD0KLisV?= =?iso-8859-1?q?wWvOD8AXKHHhzhcKISp3pz8JxmFWQg3SE2ADGRv6weoejXNEXReG5Grph7a1?= =?iso-8859-1?q?Qyf8YxLEGRmZW2udgEkpncVyN5ebLX6kU3Dj8FgkFk3ZbNsPinp7q7WgdHEm?= =?iso-8859-1?q?cAMvibnSGtsUsyY5Rsi6SZNgY3YboAJEEN0kmTP5XIV8czOJT0Yx9F9On/iB?= =?iso-8859-1?q?pZ06bzwPelczy7Nkx3p/WBqZEZU3vmePVMjYU0+q+1tDMqYoGVr0i2fse0Xi?= =?iso-8859-1?q?9wXgnighk/f36YmKhlDdE3ka91bcsDuI8vN8CTXCLvZEG6svOCC4t8LdnW0h?= =?iso-8859-1?q?duBmuF7TmpRVSwbdCTVzbZL1I5tRxsHR06rcisY1eeWm0FSQuspRKOmSvpED?= =?iso-8859-1?q?g9xtTa9uCKipcSQNXg+MvAP68mxTKyoQIerYAplAGoH5v495ohOYWa5Ox3Qe?= =?iso-8859-1?q?2T+QgdbPRJ1uewiQNfyXKnK2yJ22wIWbQAjmRQOHLyRjFPwI3Y4GMUp5ZR/s?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 = { }; 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; } +static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, + void *opaque, + int devfn, + uint32_t pasid) +{ + IntelIOMMUState *s = opaque; + VTDAddressSpace *vtd_as; + + assert(0 <= devfn && devfn < PCI_DEVFN_MAX); + + vtd_as = vtd_find_add_as(s, bus, devfn, pasid); + return &vtd_as->iommu; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, + .get_memory_region_pasid = vtd_get_memory_region_pasid, .set_iommu_device = vtd_dev_set_iommu_device, .unset_iommu_device = vtd_dev_unset_iommu_device, }; diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 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); #endif From patchwork Mon Jan 20 17:41:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C886DC02181 for ; Mon, 20 Jan 2025 17:45:14 +0000 (UTC) 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 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: MDHETIQ0OR06QgH1OdvMEK/9PDR6gHrflINlhFiiLlI8ZeLcVB6VFVJplMy6xMITbgWIqJHCPRJy8EK7mdIkxgSfdr1TAM/5pGVif0uau9fdtO9TE8fNfS/1zz3uvk0/+HrPsK696Pl2Y/q3IMAMPcrQ4m/rV3cBqoZkRWQHz1uOOQ== 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 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== 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 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+pDqtT8ocVl7dJqW5xgkqsncq?= =?iso-8859-1?q?LnWqpo6o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COd7s95/xG03npz8edxkdHLoLZ0?= =?iso-8859-1?q?txbcZRBIOXcw9c+jax7rLjgCqYClPth3E2m3Mv8bE+Y0NxheCfY2rP7Clx9e?= =?iso-8859-1?q?QIm1ig8vJWh8nrBOBgg70cjMO4wVq5eNPwTGB9woJAuEsAsfVBCwDy92z1Up?= =?iso-8859-1?q?y9RVri8x5RRDbYXjs7oQemIWhX1ngXXV5vqD5Pk7vnY6KOLeTK3UKzA4C0gy?= =?iso-8859-1?q?k7HsWgjEZZJgRUyqL929tajcA8gR9YEff4t7GAhZy9YukGG5LxjXFGYtir3d?= =?iso-8859-1?q?0tOYfDYmlNGFmzzTFd9uGaQCjh9A8eqWeAi2Oho30MWNlt7AyYC8se6kIoPA?= =?iso-8859-1?q?yyqSHwmluKEYNnptefqO4uEMU7iBjXbz2HbCldKn83eqr/XrsQ68D1ftFW8t?= =?iso-8859-1?q?jOcdtaK46HLnICrg/pUuTJDhrFJB+YPV7ASvW6NPdEJYXjc5E20qoAXuDbhE?= =?iso-8859-1?q?dDYZ/ISF5yEZ8f1/a9GGsIMYGinfj0ceZwssDv+OUMsrF6Y2WSHtJNNgY6eM?= =?iso-8859-1?q?j3eF0Jbk2Lol/xFjT1obc0HDvMG2+Sx1PORcOwWPLkSbxzNzbQ0rDs4C8Fdf?= =?iso-8859-1?q?Ibbzsm?= 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?uLKfCXTZ3Udm8s9EaPm1JQU?= =?iso-8859-1?q?VqdiJM47UtngT2dke8XB0Vxjwap5s0O05oqq4C4VgO4F7k1WGDOcWAGKZ0CH?= =?iso-8859-1?q?Km/230pT4GmagKxY+LNlHhkGVD8oZJchKIYHaMikxkstlOyzb5TDn+ruG8VT?= =?iso-8859-1?q?OAppqC92zDmtWUPbksxf4uD5XWKTP9WAwiyyYpxtEKXqHef8XBC8x59ypplE?= =?iso-8859-1?q?aKbAotZO2/QXmOlmfz1ayyQxLfT0m21hkVzlCukFUn6xqhVWetBvlAt23AB5?= =?iso-8859-1?q?Smh/D8kCltiumPJRx6pYgxpvKV8bM6ctuhB+BjOxr+XAxJxRbSVewcQYgAZl?= =?iso-8859-1?q?yrYGSWQ4AUdE3nX0qQRbhib6skDwev+ciRNnNhA0ZSIXUIK0tPhgytmiB5AV?= =?iso-8859-1?q?rKIX82nv+uP68S+puW/tGdbxvE7bqizLyDaH0hvB/6dU619lmL390TATq2lv?= =?iso-8859-1?q?6oxpaUtFK6f8Y5eQ+n/tuUpgijOC3EsW8ITlhkstvepUupsCN21ou1S+sHQZ?= =?iso-8859-1?q?XG9GQU4LAWKDweQVpFdAgG36Lgcyp2LOaVym7VJpEaODQBHfojFnazB/pUdv?= =?iso-8859-1?q?McBRbxFoaaoTLChMhgkLvbLboZXCbGCUIh3NB86XjmimpcFRbDxQkyjWbTMr?= =?iso-8859-1?q?a972QjkFlpzmL9vrPOJrOJO0gOaY3rsKsJvqWFLPt0+I9MvgQUTbe2CyKL7n?= =?iso-8859-1?q?HPaK/gBt8fsklFHm33ateJzAGSzy93PCGfY2bsvlbL1uzROK5GbGnGdn5jrv?= =?iso-8859-1?q?/+LnMI3qE7yQc5ZRVXCgtwIGd3TVYepv5cX4TzvBdD3bAp8erIoLsn9ub1p6?= =?iso-8859-1?q?MFpkCr8rEknOa1FgW2gXquMEPlxzDvRK0RSl7ae1Acqe6mGj2HvUvJtLrBCI?= =?iso-8859-1?q?j4wdG45CgzgV3Uve1X8UQc4u1UnyKZOjS60+Yy4cA4aX2CDqX9wn67rJ8TnH?= =?iso-8859-1?q?08f+qri+5WTeWd/2smFyksEy8K71BlPgLrjPadAIIAFo6P2KopEd118VCnWn?= =?iso-8859-1?q?mO4/GeKZwariDOHMb6INxn/B52wVNokVmQGSh73qlWsnE/T2Dxvf7bImChox?= =?iso-8859-1?q?aG1zX3yApx6ynCrPoZ0DpVvkrS2B7I2wQ51BitXugN9YSlpYTtCnuQLiYLiM?= =?iso-8859-1?q?JK05Gg3B41e77XuNzyuFuSCSHqRjn5TzKpMhl8IqJURqYEub1ScyCNDNKk0W?= =?iso-8859-1?q?LvggKfnHQrSSSoTV9opoOUjw8dxOcM3vqqa9Rxok8XA7BVRzuLPUJLVpKLcy?= =?iso-8859-1?q?Ieq28ye0my5fiB8gzvVO4twPW2k1fgr17obnLpzgcWGaT+LafG9fV3HA8gJC?= =?iso-8859-1?q?oe4esuVLgkve38ODbS1+QdfkiGINUrPzZ3ZjzY5J4F+ExAZQGu2Jua0g3J+s?= =?iso-8859-1?q?zPMkgQAqC6Pn3YaKSkEB6RgwKkrS4GiK5nDeFnzTnskMfqenP1bm2WGpt8C9?= =?iso-8859-1?q?tL1qP6St48cUWPP+mMB/yivMQLEd5YhYV00QovY4pKrm8jJ8g1bxv7INVQB5?= =?iso-8859-1?q?4UZaEOApw3y51giDCGq0QNG/FANsOPc5aX+Db1Kxuo4AO+yIbKXihGXO8sBi?= =?iso-8859-1?q?fG/3wiyEV/xA8SprcxEKfSjZj2Ta2K83nPBlgMjt39nqegFEIWNqB95rlj1G?= =?iso-8859-1?q?upzYheluEeaRz1AVQnI/Pv275VdD0gPhZR6DH0q0apWtXjxDo7btKivbFSIQ?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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; From patchwork Mon Jan 20 17:41:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BB2BC02182 for ; Mon, 20 Jan 2025 17:42:48 +0000 (UTC) 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 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: MDG3E9SiOOAubCfPZA3XNhr4iuV/tOU12pFzDF1aYJswel0i5nTynKiLeOPyPiiUbokWfycUnXacXMQ975zg+pArpZUCHHyA7tRzGwdSlkmBYM8c4gBi8HYNMPfQ12Ev49gUcp5q376+A4Nyn6Bb8xAC9s4rG6Uxt5Rs3FEcZQpkwg== 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 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== 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 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/fmg?= =?iso-8859-1?q?3KNph+j4z0OZO1ZQQ2P+qewrxYiIC6qp444WdN4gGupdWkt4oFWljEa6Idep?= =?iso-8859-1?q?zGC0um8otgoz+PZ5m96EgLCf9IicDEdupIKnj4updGeyKUA40oDsQx7j71i0?= =?iso-8859-1?q?AlLMAfM2Fhdosn6+encuUNGFaIfWFg05JdJPocOMTCFkCsTefks3pZwbosnt?= =?iso-8859-1?q?Naih+sATO31Q7PPBUsVl1uxDq8CHyfxuocs9NUViTa2bEGdccIpDMTfwQOWP?= =?iso-8859-1?q?TYAEvQ9sbv3RpXq+NeSrnGXlnKGA7t7uoARXnqIy/E3J1JbfbLTy0H4lhL4p?= =?iso-8859-1?q?rMJfUENsguP/CmiEV3FaNGtfoAKj+8hnZteMpqOkkYI/KZSeQeiSLwo5FFSc?= =?iso-8859-1?q?YSgcxUu/YBH+jycQE1UwmWbc0iMT5ZGKoLXO/lJNmFRCiJXQfqnwQCHWmQig?= =?iso-8859-1?q?MDdEdhk/enmiH6nF0vOG8Iag/faY7lD0xtGVaKG7+SL8/KGbR2ijFNUUbBev?= =?iso-8859-1?q?Tzy3Spo67sGJ5i18jBLN0xNSEt5FH1mu0/Ru7d/To+cjI5Rj82HxRx/B9h8y?= =?iso-8859-1?q?2X1ZDAZPzpN13vwIO91izxKrdjDiyBZr1zOn2o5VUAL0EBTfQVAxeCdgUFQ5?= =?iso-8859-1?q?STkYuR44iT5QLr4scmXARIpHrguwBtgmrD5JkZf6VqmaJeTP7QkW8r94TFJT?= =?iso-8859-1?q?hQUaY5K6Nx0/m4tv6VeJ0Dln7+90Zrmxr5WNtLzhwK3nItiQjBpapWPRmenG?= =?iso-8859-1?q?QPmeJkEEslPIemWfsQp4/n3QKPG1dpfI/voNybWVa4fSvBuP2nncul1UzW9E?= =?iso-8859-1?q?0NgKRJ/s2Ha0sn/yMPb+IE89RWT+FBOkMy9mZRqUeb7dMECpkjJbEMNJd/R5?= =?iso-8859-1?q?EQ7/V/J8PUsz5FN0csD+MwHe5I/vUDvCWL/YH+au9fvwFMn7AEKa2HCMZFtI?= =?iso-8859-1?q?KaTA9s7pXJBmLl3n/6MTMD8DXlIDLRxZps4+3MlcryUKIcLY0OVp+akN+Ep7?= =?iso-8859-1?q?O53cTm6q77Dia1o5rRCx9y4eD8rcsE3lr9vv3IDDzv/JQ7rN6VQ6Lx4a6Di9?= =?iso-8859-1?q?90ywEWHzJwu8/bfGBnmHaVl7+K9eL2aZMgG/2djkY+IvNuUn9wm4Oqte//sB?= =?iso-8859-1?q?cL0iDgl5Cp5eLmko5r2W9tQemJomuMD2Nynh0LLhFuwwjRKi/MCp3dDKOlkk?= =?iso-8859-1?q?9kzTOfV5s3CyYicrMr+K76DXlzA6DmMkM+HRAuthURuoccGUw2q81bKj0bax?= =?iso-8859-1?q?k3hNqi89VLvThkEKBTbNgxpL7rgLJjdy9UYLwSAZ3/JyFe9yrKQwqvtuitN3?= =?iso-8859-1?q?Z0ooVqoZrBhBu7jwyznPFwDQDLbRjmNgow9cGBU84MNEIeMOlDvmXUctkRHW?= =?iso-8859-1?q?k2yMTEiN2DbnonpSFrXfKkRnRqFnur4EtMs9gslx38pz+deX0UmRbwOH9/5w?= =?iso-8859-1?q?O2Wol1UTIXgvPsKDvJY6UNcVuUUtbQmP3/V6UcAHo0Y5HfkqaV6M3LjOWyVg?= =?iso-8859-1?q?DfVeMi?= 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?WaUaBSDpSjB4pchA9MYLV2s?= =?iso-8859-1?q?VVE2r1eIAFbStgYUTLP+sJ5DbT8UXn1P8Enqmh6UxbtRAEchIdcGuAHf7pl/?= =?iso-8859-1?q?hY1/gtL6V5q/IJv+8Ifzyn3bfk3sdouitwJD/14iBIJEC/cnVlDy1CdtMlNT?= =?iso-8859-1?q?5Y4lPs09/GWzvub40K3dQyt1wdE3l8Si/3iwt7P0TqB8WtDVGUFBfyce+gIY?= =?iso-8859-1?q?jUTQUUJjjk4udqPngH3BEZXK0cUfCR+c8PK99A0015xKToc3k+MrBMf/f04m?= =?iso-8859-1?q?Qg7AIQA58S1ueq7VJCUxU44ff6S3V++cmRiuKmgIhZumQ7tHL4pPATPikPBo?= =?iso-8859-1?q?GSnv15DQ/43wUp7RonJiSTaOPdeROZvcwOgE2xS9z27LJUbcnXmbqDcTny28?= =?iso-8859-1?q?NOIhnTIXzG9N+43O31oz28HQShHRjVWPe8IOtsc+gtubgS5iw79YX+KXlECS?= =?iso-8859-1?q?ENODPcRiwwSimAeTtS3h/wUTxA7JIP2FekQbTHl7JZaCIfknh0aWSWvXwZFs?= =?iso-8859-1?q?Ke3f4rZYUQ9JGjHYU6kU/LjEseXxSQ94BjGU0fxl98H/mGLlaR13ZtD73dpS?= =?iso-8859-1?q?/dOR0RcmvjMHd9g4kXbkmAJfE1F72A89L1RhT8npEYBKPmEWqqcuM3jzFtR9?= =?iso-8859-1?q?8njZOl5JL3/Rk3U466k1c/p54ztuw3+f7Ymzd1wcpbHKY/NQYJxtk9RDhKgD?= =?iso-8859-1?q?mtO+Lo2vNdCHn9/bRHd69K+ttQGpRmSG6bn5ze1VlkunoG+cmec3ggf/HUoj?= =?iso-8859-1?q?XIzjKGDpnkVIjG8ugMpUoxd9NJceil41g5RF6HYFUBvtIUP6oufLV9BhqV2m?= =?iso-8859-1?q?E9eeVS4jyRNlxyfFJiJqhOFHKSlGqb+/rGkERIjcg0g2YZggZ79b9caDELQV?= =?iso-8859-1?q?DFTXM8vpsv4fn9SwbsoKfutG4/7PHYOMVZ3k6s+ERcsJw8BKMVMnMvy9whI4?= =?iso-8859-1?q?rag9LR8ylf9trTOSLjrEh4jlbKQUf6FMQZE8ndbkpZxC5hUhU40OF9mjCByw?= =?iso-8859-1?q?ZHA2y5VqtMvs5HIlu4wdoFZwD9FzONGDstZffznqVk1i2T9qSsmBVfmnoXOx?= =?iso-8859-1?q?jWSjnfRmzOBx8LsEIyryAAHBA7IamqxRNmymAE5HM0cCCqsgihIChmPWWQWa?= =?iso-8859-1?q?pfULI6t6WJDZKLoXL2JrsuQlv91JvSGlsX043gDukl+AsnTFWphtSaHtVP3s?= =?iso-8859-1?q?PHcAXsJSWO3lWY/CK9Wj30XoyZwhSkikAUKyvwzkhwmHVH95du06rJvov1RO?= =?iso-8859-1?q?pe9cc3EyEAy1mWuNp8Nd2zpaKPP0/KNJT569ewKfQJcjMoxtfO+hispZRao4?= =?iso-8859-1?q?AtZ321V1mrTFnSKZksDFb9f8vR0M34uQ6vUuroCs+FTsB4BtsvFOjucZkZU3?= =?iso-8859-1?q?KWbdNLCFoKRRrm4YHjRvW5WkGcD4ovl4o/xiyxq+5Z7kVXJW9nv7bLdt4/rK?= =?iso-8859-1?q?IVybp3WuwmU3lSLj8U7XO1FZmBuktbyNSFSyNAEaC20i+2F4m2KBg7YJu+eM?= =?iso-8859-1?q?4azQi2lajJTYwPH5hZJe/zujJe1OdV6ior3n1PD8/r2zK/mp4CMODVvq1ayy?= =?iso-8859-1?q?pVY5GBEbaJ2UZ2iEnfCXRm+jtFl2QhFkuBUFIImDmu4/C754UH8cwezygHk3?= =?iso-8859-1?q?EeKQuYx6QS8ZUu6uzSPro2xmWsRji2UiLG08knzav6qCokP5ZodiLA4RmP6c?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.83; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost2.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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(PCIDevice *dev) return &address_space_memory; } +static IOMMUMemoryRegion *pci_device_iommu_memory_region_pasid(PCIDevice *dev, + uint32_t pasid) +{ + PCIBus *bus; + PCIBus *iommu_bus; + int devfn; + + /* + * This function is for internal use in the module, + * we can call it with PCI_NO_PASID + */ + if (!dev->is_master || + ((pasid != PCI_NO_PASID) && !pcie_pasid_enabled(dev))) { + return NULL; + } + + pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + if (iommu_bus && iommu_bus->iommu_ops->get_memory_region_pasid) { + return iommu_bus->iommu_ops->get_memory_region_pasid(bus, + iommu_bus->iommu_opaque, devfn, pasid); + } + return NULL; +} + +bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n, IOMMUNotify fn, + void *opaque) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr) { + return false; + } + iommu_notifier_init(n, fn, IOMMU_NOTIFIER_DEVIOTLB_EVENTS, 0, HWADDR_MAX, + memory_region_iommu_attrs_to_index(iommu_mr, + MEMTXATTRS_UNSPECIFIED)); + n->opaque = opaque; + return true; +} + bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod, Error **errp) { diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 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, HostIOMMUDevice *hiod, Error **errp); void pci_device_unset_iommu_device(PCIDevice *dev); +/** + * pci_iommu_init_iotlb_notifier: initialize an IOMMU notifier + * + * This function is used by devices before registering an IOTLB notifier + * + * @dev: the device + * @pasid: the pasid of the address space to watch + * @n: the notifier to initialize + * @fn: the callback to be installed + * @opaque: user pointer that can be used to store a state + */ +bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n, IOMMUNotify fn, + void *opaque); + /** * pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus * From patchwork Mon Jan 20 17:41:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD408C02181 for ; Mon, 20 Jan 2025 17:42:19 +0000 (UTC) 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 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: MDFpWsZcjXj9M2pdSgdHocGPS2TxOwRToOK/nm13cI6Mk4EzgmgNHaH+ePhsBt0Cv/zddz4mya2chrckG0bQMEN3unwRzLC8ZAovyFWy0LvcvBdE3kcHzzuGSc0CFesmAm9X+ULqFlRTvtukCLarLsTSy3X4VEv1y0HuNDTlSRrJbA== 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 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== 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 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+T2wJU3KUQJL4Zr3zFH5TlAmO?= =?iso-8859-1?q?O5+vAKxlyvOU29aYrirHRgFiUtJV7CkHb2BUUQKXNUal0K5TQRzr0oYEbphm?= =?iso-8859-1?q?PsMc+FsOe3xdspJTIAS/D4+esH+pGoVWu02vt0two6kiBBxhm5RlPAOUZryL?= =?iso-8859-1?q?RB47KnsMK6U7Viz5nhPINXCnVVKvOFJgDxm8nlbvJ+FpkSxK/b7QpVkNOblX?= =?iso-8859-1?q?oj4IzkyaBlZjhkIl+d1zWxKymSx1qKrR+v1fQlsBFwypRCmbnVwBgwF5usTi?= =?iso-8859-1?q?ulaMRv/SfiYcf/f8fLP1RLW3sfMni7miBw6rFfNLPvzJbSPs/S/ZrXTNUzTw?= =?iso-8859-1?q?c5LaSpfpiAc2+q99/10ZjLE3k/M/R4rjOsIwpW/qTiJA3CsglceMyslEAKs6?= =?iso-8859-1?q?J9FybAlSY5MJil4G617D+gGRZM2IZPdQKemH9Fba+K37LUHRdgDk6JB757BP?= =?iso-8859-1?q?yI9KuTmteB6f0CjpHZ4sp7OAtlAz5/LqYwBq/EuJ/ucgp0VEp22jzLhOoR71?= =?iso-8859-1?q?KLP2PoLdFyQ6rLEWxXFGC5eKj/BOnqDmwgYA5MiC2WfRPpwZjKCsW1TxFD6u?= =?iso-8859-1?q?5slHwyYlgXIxbQhtWDuezLuYbiHHKkPwi7e9Cs8uT/T6948ljiRad1lQeig3?= =?iso-8859-1?q?oXNn8YT/h4PwixWoH/94L/p8wZ1Zuxt6Ne3VaXKhXeBjCqjySnyFjMmKx5CS?= =?iso-8859-1?q?4qxwMhU8lpD7kuUnFt0kBVIHKBuEQBIAXDTMlkMZsP6Z79IEKmU6L6gi3sIA?= =?iso-8859-1?q?C3UnUUdoxiwRZIExFVjXGIeooRCQ1DjJCFe/0C+i3FVedbN0X+ln5mq/6uH3?= =?iso-8859-1?q?5GHqLalAJ/gMTi7LVW63djk26RoJ9mIcAA7cTknoJg278co99eFCcEFBPiCF?= =?iso-8859-1?q?VFoEQJIku7FlDqi5QVCw+dRmcDvQSXlwVdxKzZ8H3Aric+7mR2P0IvgcpUpi?= =?iso-8859-1?q?1JPabTaSWvjjJ69VdkI6prdWta9DfXvETVb275cZNrgY31x7cI5qfoVQuwpN?= =?iso-8859-1?q?1BnaJYpoOU7pABbG32Up9pv22bZ91ZwZiUlm+d62goyJA4vtmQIB0HYfB8FV?= =?iso-8859-1?q?+777Pp2jJSk8Kwf/fpuikDy5CnU00BU3dqNmOpOe2uFdg4nsGl/C5IXWBVyE?= =?iso-8859-1?q?XuAZDdRY2yIyZAfSLSModMmDD4T8Hw11zy072Xm/Xj7PJ2ljyPsaKs3wtKk/?= =?iso-8859-1?q?3pSiRoFuuFlq4Npc5wHN+or6Gox/OOJhiywy6mAGGa7Bhq1hH5zd+i1cO6q5?= =?iso-8859-1?q?zx9cFU2KrZaKcd8liZ2zX0IvTTQmAQ3h/XSloLf0226TVCoedOaYmYruSvd/?= =?iso-8859-1?q?ZPeHP3m5W0Kr3UPivDD2MKslDYfqw8I72bmgSNnamp+yGqbtG77gnt27uTFy?= =?iso-8859-1?q?RitwG/N1rQQriaNqxtHZxPY3fkBunt2ez1cSKAEA/7toNjusEefpnGWnBch9?= =?iso-8859-1?q?j3GENGcNuqmDgIIUTVEZsP7A=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+SHcewOW?= =?iso-8859-1?q?d6AWmVOs8t5kqeXYnkWKJ2eO3u/e6L9sYb8RCLKZC+5tHQGnnqcmwWu1BM9k?= =?iso-8859-1?q?B06h5c1PUGOIiVfMhi5k2c2p17ho3CAcdGqUjeePUL2zgqpsO6ah3o+Y4a5M?= =?iso-8859-1?q?AKnf0WkV5QP93TqpMxXP+mpilNS+CaDXLb1CjfJDgauilzNtc6C8X5COOCcG?= =?iso-8859-1?q?nSKOXd7W5A6u2jlRWDySMkGDjei1u/O9MZIDKmW3E4P3QQIYmOGd0dN7OhHu?= =?iso-8859-1?q?VlqctmwESa92tKau592P9GEAMqtgzV8oZlACQCoc8vtFBLpJn5ym+VKJrE/h?= =?iso-8859-1?q?YEvlrs45OocBPpcFkZqIUakgP88Z+iwunN3AY9uC66mqygnV2OqjNIVvPCLb?= =?iso-8859-1?q?wge31iUKFlN5Gy3F9vJ2r8RvoyRpOTc00nbh9Jp3ljqQBEpL/pR+wNoB0bAL?= =?iso-8859-1?q?ZGfZ+skVqYvvXyqrGGFBY0Lrre+v8MTQPxHdZ45+iNFnVBtqF++9E0xXcOU2?= =?iso-8859-1?q?/2/TysJ+9UgJkZ0ioahXXIuAsLX2RC1NOdku4MSJUerNFpdavOh9m0uQKXX5?= =?iso-8859-1?q?HAF1BJANLHn+er0AqJRhpAdyIUb/4aeqjSHb6ddWcbBd/Lt/VqWTVIMelvIb?= =?iso-8859-1?q?2gA5oD7SOVoB4pOTZn8uljzOi9fwEpzqSFoPOzUFyZVj9H/yqJkDpUJ+Ky0O?= =?iso-8859-1?q?L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9/EDKgEUEmexAqr7px+0zItQG5Nl?= =?iso-8859-1?q?VbrvhQFO+0YDgFQddnixcZCzijlGFcXbfx6UCimfpn7+OqMXXQGAkIzGrQaw?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 == v2; +} + +/* Hash function for IOTLB entries */ +static guint atc_addr_key_hash(gconstpointer v) +{ + hwaddr addr = (hwaddr)v; + return (guint)((addr >> 32) ^ (addr & 0xffffffffU)); +} + +/* Equality test for IOTLB entries */ +static gboolean atc_addr_key_equal(gconstpointer v1, gconstpointer v2) +{ + return (hwaddr)v1 == (hwaddr)v2; +} + +static void atc_address_space_free(void *as) +{ + g_hash_table_unref(as); +} + +/* return log2(val), or UINT8_MAX if val is not a power of 2 */ +static uint8_t ilog2(uint64_t val) +{ + uint8_t result = 0; + while (val != 1) { + if (val & 1) { + return UINT8_MAX; + } + + val >>= 1; + result += 1; + } + return result; +} + +ATC *atc_new(uint64_t page_size, uint8_t address_width) +{ + ATC *atc; + uint8_t log_page_size = ilog2(page_size); + /* number of bits each used to store all the intermediate indexes */ + uint64_t addr_lookup_indexes_size; + + if (log_page_size == UINT8_MAX) { + return NULL; + } + /* + * We only support page table entries of 8 (PAGE_TABLE_ENTRY_SIZE) bytes + * log2(page_size / 8) = log2(page_size) - 3 + * is the level offset + */ + if (log_page_size <= 3) { + return NULL; + } + + atc = g_new0(ATC, 1); + atc->address_spaces = g_hash_table_new_full(atc_pasid_key_hash, + atc_pasid_key_equal, + NULL, atc_address_space_free); + atc->level_offset = log_page_size - 3; + /* at this point, we know that page_size is a power of 2 */ + atc->min_addr_mask = page_size - 1; + addr_lookup_indexes_size = address_width - log_page_size; + if ((addr_lookup_indexes_size % atc->level_offset) != 0) { + goto error; + } + atc->levels = addr_lookup_indexes_size / atc->level_offset; + atc->page_size = page_size; + return atc; + +error: + g_free(atc); + return NULL; +} + +static inline GHashTable *atc_get_address_space_cache(ATC *atc, uint32_t pasid) +{ + return g_hash_table_lookup(atc->address_spaces, + (gconstpointer)(uintptr_t)pasid); +} + +void atc_create_address_space_cache(ATC *atc, uint32_t pasid) +{ + GHashTable *as_cache; + + as_cache = atc_get_address_space_cache(atc, pasid); + if (!as_cache) { + as_cache = g_hash_table_new_full(atc_addr_key_hash, + atc_addr_key_equal, + NULL, g_free); + g_hash_table_replace(atc->address_spaces, + (gpointer)(uintptr_t)pasid, as_cache); + } +} + +void atc_delete_address_space_cache(ATC *atc, uint32_t pasid) +{ + g_hash_table_remove(atc->address_spaces, (gpointer)(uintptr_t)pasid); +} + +int atc_update(ATC *atc, IOMMUTLBEntry *entry) +{ + IOMMUTLBEntry *value; + GHashTable *as_cache = atc_get_address_space_cache(atc, entry->pasid); + if (!as_cache) { + return -ENODEV; + } + value = g_memdup2(entry, sizeof(*value)); + g_hash_table_replace(as_cache, (gpointer)(entry->iova), value); + return 0; +} + +IOMMUTLBEntry *atc_lookup(ATC *atc, uint32_t pasid, hwaddr addr) +{ + IOMMUTLBEntry *entry; + hwaddr mask = atc->min_addr_mask; + hwaddr key = addr & (~mask); + GHashTable *as_cache = atc_get_address_space_cache(atc, pasid); + + if (!as_cache) { + return NULL; + } + + /* + * Iterate over the possible page sizes and try to find a hit + */ + for (uint8_t level = 0; level < atc->levels; ++level) { + entry = g_hash_table_lookup(as_cache, (gconstpointer)key); + if (entry && (mask == entry->addr_mask)) { + return entry; + } + mask = (mask << atc->level_offset) | ((1 << atc->level_offset) - 1); + key = addr & (~mask); + } + + return NULL; +} + +static gboolean atc_invalidate_entry_predicate(gpointer key, gpointer value, + gpointer user_data) +{ + IOMMUTLBEntry *entry = (IOMMUTLBEntry *)value; + IOMMUTLBEntry *target = (IOMMUTLBEntry *)user_data; + hwaddr target_mask = ~target->addr_mask; + hwaddr entry_mask = ~entry->addr_mask; + return ((target->iova & target_mask) == (entry->iova & target_mask)) || + ((target->iova & entry_mask) == (entry->iova & entry_mask)); +} + +void atc_invalidate(ATC *atc, IOMMUTLBEntry *entry) +{ + GHashTable *as_cache = atc_get_address_space_cache(atc, entry->pasid); + if (!as_cache) { + return; + } + g_hash_table_foreach_remove(as_cache, + atc_invalidate_entry_predicate, + entry); +} + +void atc_destroy(ATC *atc) +{ + g_hash_table_unref(atc->address_spaces); +} + +size_t atc_get_max_number_of_pages(ATC *atc, hwaddr addr, size_t length) +{ + hwaddr page_mask = ~(atc->min_addr_mask); + size_t result = (length / atc->page_size); + if ((((addr & page_mask) + length - 1) & page_mask) != + ((addr + length - 1) & page_mask)) { + result += 1; + } + return result + (length % atc->page_size != 0 ? 1 : 0); +} + +void atc_reset(ATC *atc) +{ + g_hash_table_remove_all(atc->address_spaces); +} diff --git a/util/atc.h b/util/atc.h new file mode 100644 index 0000000000..8be95f5cca --- /dev/null +++ b/util/atc.h @@ -0,0 +1,117 @@ +/* + * QEMU emulation of an ATC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef UTIL_ATC_H +#define UTIL_ATC_H + +#include "qemu/osdep.h" +#include "exec/memory.h" + +typedef struct ATC { + GHashTable *address_spaces; /* Key : pasid, value : GHashTable */ + hwaddr min_addr_mask; + uint64_t page_size; + uint8_t levels; + uint8_t level_offset; +} ATC; + +/* + * atc_new: Create an ATC. + * + * Return an ATC or NULL if the creation failed + * + * @page_size: #PCIDevice doing the memory access + * @address_width: width of the virtual addresses used by the IOMMU (in bits) + */ +ATC *atc_new(uint64_t page_size, uint8_t address_width); + +/* + * atc_update: Insert or update an entry in the cache + * + * Return 0 if the operation succeeds, a negative error code otherwise + * + * The insertion will fail if the address space associated with this pasid + * has not been created with atc_create_address_space_cache + * + * @atc: the ATC to update + * @entry: the tlb entry to insert into the cache + */ +int atc_update(ATC *atc, IOMMUTLBEntry *entry); + +/* + * atc_create_address_space_cache: delare a new address space + * identified by a PASID + * + * @atc: the ATC to update + * @pasid: the pasid of the address space to be created + */ +void atc_create_address_space_cache(ATC *atc, uint32_t pasid); + +/* + * atc_delete_address_space_cache: delete an address space + * identified by a PASID + * + * @atc: the ATC to update + * @pasid: the pasid of the address space to be deleted + */ +void atc_delete_address_space_cache(ATC *atc, uint32_t pasid); + +/* + * atc_lookup: query the cache in a given address space + * + * @atc: the ATC to query + * @pasid: the pasid of the address space to query + * @addr: the virtual address to translate + */ +IOMMUTLBEntry *atc_lookup(ATC *atc, uint32_t pasid, hwaddr addr); + +/* + * atc_invalidate: invalidate an entry in the cache + * + * @atc: the ATC to update + * @entry: the entry to invalidate + */ +void atc_invalidate(ATC *atc, IOMMUTLBEntry *entry); + +/* + * atc_destroy: delete an ATC + * + * @atc: the cache to be deleted + */ +void atc_destroy(ATC *atc); + +/* + * atc_get_max_number_of_pages: get the number of pages a memory operation + * will access if all the pages concerned have the minimum size. + * + * This function can be used to determine the size of the result array to be + * allocated when issuing an ATS request. + * + * @atc: the cache + * @addr: start address + * @length: number of bytes accessed from addr + */ +size_t atc_get_max_number_of_pages(ATC *atc, hwaddr addr, size_t length); + +/* + * atc_reset: invalidates all the entries stored in the ATC + * + * @atc: the cache + */ +void atc_reset(ATC *atc); + +#endif diff --git a/util/meson.build b/util/meson.build index 5d8bef9891..f2dec01300 100644 --- a/util/meson.build +++ b/util/meson.build @@ -93,6 +93,7 @@ if have_block util_ss.add(files('hbitmap.c')) util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c')) + util_ss.add(files('atc.c')) util_ss.add(files('iov.c')) util_ss.add(files('nvdimm-utils.c')) util_ss.add(files('block-helpers.c')) From patchwork Mon Jan 20 17:41:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2836C02181 for ; Mon, 20 Jan 2025 17:45:02 +0000 (UTC) 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 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: MDH6TmX8E4XUuBXgITKzvDkz7UUUuG7OGXDYzi7xRXLIsUT7D+m7D7sPQucnOLkmqG3TzNbY/7+xTuXZx7r1x01NOl8JPc2wJqf7nCB+l+7dHsCUmhXJS5Q8eo/YrFwidHLoFCOAgdxCIjdusGFGb1B+hkxoMPeUrsxGh665EkYNcg== 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 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== 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 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/w9?= =?iso-8859-1?q?F21L1lTFwvs6/KZEca8hBlkokcY/tD4BIVgIWWO56uEXQpmhOOFXSbP6DAKF?= =?iso-8859-1?q?i+H5tjHJdwqqC3LXKNLyu2Jn5cuejZ42T9u7aSqt2usT40lL3wewvgzG7Q3b?= =?iso-8859-1?q?4PL37lycCkm/b7PW7lB9lo8N5mYF6fDjDFb8GNKEYv2+lgoLPPuxJpIrqyom?= =?iso-8859-1?q?0hpOg83P4qZDVlY4Enk/t8iSq3MS/hiEIhRu7cND+KMr5tgxX59TrTzlTjfI?= =?iso-8859-1?q?x5XpUWJir4+JOWlbEwCL1U4yiR70gSpEwOmujUX9nB9dc1HxJ6fTxv54ypLA?= =?iso-8859-1?q?mBpPwKLcInNkPwNFr59jrhgCS6Z3UTZIsqeJgpg8TV2vavllahHFs+wTlaaK?= =?iso-8859-1?q?yWd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amvLROlLkTWsdMkRYxZq/Ye/kLHMLM?= =?iso-8859-1?q?59Kr0piRqfLLCpEzfv/DrVIWHNF1m+PPcw3sZ7+lc1sV1Jc/ajPiOob4ZCcK?= =?iso-8859-1?q?VU+oDVgLEC//ttBeu4rKc45wHPvtnyS6H7UTPQhDkikmoC33MvS8E6l6269G?= =?iso-8859-1?q?gO1CQHYDfVsrVKgeTLfqf1SA=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/4k?= =?iso-8859-1?q?m96bVd2tD5UVh0evAbT/GBDPpHs8xBtKfrqgrgxRz7DB7s+ceLtveXDjzHUL?= =?iso-8859-1?q?JVcRfWdlO5uo9bCoJR1jhjENaDrq1hFXT6uEjtqECyGOMUsIP5VrGvu71gO7?= =?iso-8859-1?q?FWrS9Ngir9muiiD5NVIxuzUS85ZZR0lHHOzyAh/waV9sh41P0InqY3bR9eci?= =?iso-8859-1?q?dkG7uk08tk6bA9cmJRG0WPRBNcsQQIedv9+0LBm/MezEo7bJQB2VeQYSFpMA?= =?iso-8859-1?q?3PrDZQF/WbFoGOdDET+/CX2RZS0LIlhfzFK9N/Ur9nIRGYrttrmm4wQB7sz5?= =?iso-8859-1?q?oPiUlpCPyzZ3X85b54dP6oc12NFz163n73+8k+3xWdIsW9STIuvQjzM2gBeM?= =?iso-8859-1?q?KhrRLVQ5Sj9r67LKyadLhjus8VAtkyedhOaVdDPjFOz+Wave4haunq+VlaF5?= =?iso-8859-1?q?o0QgMMdgfDNw3inamGCVh5g2V3OwoZcaYxoi/yx4Lwf8ualU/iKD2RIWgD08?= =?iso-8859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e1OH5nSnm6bhgErPa8ziMa5/7SjTETyZ43L0NC11nE/4V0gIkEVqKnnaf/z/?= =?iso-8859-1?q?c4b5RESFkwE99BWTUQRDhfpipKumzZMTQRRZ3wUaDt84iQS1nAnqJi4Zm2p+?= =?iso-8859-1?q?RJ4TN9Y81UmYq25kFS21l5eZ6ZUSXD7eLu25jPkvq8JmlBx09o8HTiiwYkew?= =?iso-8859-1?q?xby5bqjFphhZQ90Ir16OMP39qqMM6OAO+SkdN8EVJWJum3tCTillW4usGy6a?= =?iso-8859-1?q?QydaVWs1Jw/bWD9ngHlyS7awcqRaxRxt3sjiQy3Ff0tC2P2NwgSCzuiXYmsk?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 = { 'test-qapi-util': [], 'test-interval-tree': [], 'test-fifo': [], + 'test-atc': [], } if have_system or have_tools diff --git a/tests/unit/test-atc.c b/tests/unit/test-atc.c new file mode 100644 index 0000000000..0d1c1b7ca7 --- /dev/null +++ b/tests/unit/test-atc.c @@ -0,0 +1,527 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "util/atc.h" + +static inline bool tlb_entry_equal(IOMMUTLBEntry *e1, IOMMUTLBEntry *e2) +{ + if (!e1 || !e2) { + return !e1 && !e2; + } + return e1->iova == e2->iova && + e1->addr_mask == e2->addr_mask && + e1->pasid == e2->pasid && + e1->perm == e2->perm && + e1->target_as == e2->target_as && + e1->translated_addr == e2->translated_addr; +} + +static void assert_lookup_equals(ATC *atc, IOMMUTLBEntry *target, + uint32_t pasid, hwaddr iova) +{ + IOMMUTLBEntry *result; + result = atc_lookup(atc, pasid, iova); + g_assert(tlb_entry_equal(result, target)); +} + +static void check_creation(uint64_t page_size, uint8_t address_width, + uint8_t levels, uint8_t level_offset, + bool should_work) { + ATC *atc = atc_new(page_size, address_width); + if (atc) { + g_assert(atc->levels == levels); + g_assert(atc->level_offset == level_offset); + + atc_destroy(atc); + g_assert(should_work); + } else { + g_assert(!should_work); + } +} + +static void test_creation_parameters(void) +{ + check_creation(8, 39, 3, 9, false); + check_creation(4095, 39, 3, 9, false); + check_creation(4097, 39, 3, 9, false); + check_creation(8192, 48, 0, 0, false); + + check_creation(4096, 38, 0, 0, false); + check_creation(4096, 39, 3, 9, true); + check_creation(4096, 40, 0, 0, false); + check_creation(4096, 47, 0, 0, false); + check_creation(4096, 48, 4, 9, true); + check_creation(4096, 49, 0, 0, false); + check_creation(4096, 56, 0, 0, false); + check_creation(4096, 57, 5, 9, true); + check_creation(4096, 58, 0, 0, false); + + check_creation(16384, 35, 0, 0, false); + check_creation(16384, 36, 2, 11, true); + check_creation(16384, 37, 0, 0, false); + check_creation(16384, 46, 0, 0, false); + check_creation(16384, 47, 3, 11, true); + check_creation(16384, 48, 0, 0, false); + check_creation(16384, 57, 0, 0, false); + check_creation(16384, 58, 4, 11, true); + check_creation(16384, 59, 0, 0, false); +} + +static void test_single_entry(void) +{ + IOMMUTLBEntry entry = { + .iova = 0x123456789000ULL, + .addr_mask = 0xfffULL, + .pasid = 5, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + + ATC *atc = atc_new(4096, 48); + g_assert(atc); + + assert_lookup_equals(atc, NULL, entry.pasid, + entry.iova + (entry.addr_mask / 2)); + + atc_create_address_space_cache(atc, entry.pasid); + g_assert(atc_update(atc, &entry) == 0); + + assert_lookup_equals(atc, NULL, entry.pasid + 1, + entry.iova + (entry.addr_mask / 2)); + assert_lookup_equals(atc, &entry, entry.pasid, + entry.iova + (entry.addr_mask / 2)); + + atc_destroy(atc); +} + +static void test_single_entry_2(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xabcdef200000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + assert_lookup_equals(atc, NULL, e1.pasid, 0xabcdef201000ULL); + + atc_destroy(atc); +} + +static void test_page_boundaries(void) +{ + static const uint32_t pasid = 5; + static const hwaddr page_size = 4096; + + /* 2 consecutive entries */ + IOMMUTLBEntry e1 = { + .iova = 0x123456789000ULL, + .addr_mask = page_size - 1, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 = { + .iova = e1.iova + page_size, + .addr_mask = page_size - 1, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0x900df00dULL, + }; + + ATC *atc = atc_new(page_size, 48); + + atc_create_address_space_cache(atc, e1.pasid); + /* creating the address space twice should not be a problem */ + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova - 1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova + e1.addr_mask); + g_assert((e1.iova + e1.addr_mask + 1) == e2.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova + e2.addr_mask); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova + e2.addr_mask + 1); + + assert_lookup_equals(atc, NULL, e1.pasid + 10, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid + 10, e2.iova); + atc_destroy(atc); +} + +static void test_huge_page(void) +{ + static const uint32_t pasid = 5; + static const hwaddr page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x123456600000ULL, + .addr_mask = 0x1fffffULL, + .pasid = pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + hwaddr addr; + + ATC *atc = atc_new(page_size, 48); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + for (addr = e1.iova; addr <= e1.iova + e1.addr_mask; addr += page_size) { + assert_lookup_equals(atc, &e1, e1.pasid, addr); + } + /* addr is now out of the huge page */ + assert_lookup_equals(atc, NULL, e1.pasid, addr); + atc_destroy(atc); +} + +static void test_pasid(void) +{ + hwaddr addr = 0xaaaaaaaaa000ULL; + IOMMUTLBEntry e1 = { + .iova = addr, + .addr_mask = 0xfffULL, + .pasid = 8, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + IOMMUTLBEntry e2 = { + .iova = addr, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0xb001ULL, + }; + uint16_t i; + + ATC *atc = atc_new(4096, 48); + + atc_create_address_space_cache(atc, e1.pasid); + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + for (i = 0; i <= MAX(e1.pasid, e2.pasid) + 1; ++i) { + if (i == e1.pasid || i == e2.pasid) { + continue; + } + assert_lookup_equals(atc, NULL, i, addr); + } + assert_lookup_equals(atc, &e1, e1.pasid, addr); + assert_lookup_equals(atc, &e1, e1.pasid, addr); + atc_destroy(atc); +} + +static void test_large_address(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaaaaaaaaa000ULL, + .addr_mask = 0xfffULL, + .pasid = 8, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0x1f00baaaaabf000ULL, + .addr_mask = 0xfffULL, + .pasid = e1.pasid, + .perm = IOMMU_RW, + .translated_addr = 0xdeadbeefULL, + }; + + ATC *atc = atc_new(4096, 57); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_bigger_page(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaabbccdde000ULL, + .addr_mask = 0x1fffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + hwaddr i; + + ATC *atc = atc_new(8192, 43); + + atc_create_address_space_cache(atc, e1.pasid); + atc_update(atc, &e1); + + i = e1.iova & (~e1.addr_mask); + assert_lookup_equals(atc, NULL, e1.pasid, i - 1); + while (i <= e1.iova + e1.addr_mask) { + assert_lookup_equals(atc, &e1, e1.pasid, i); + ++i; + } + assert_lookup_equals(atc, NULL, e1.pasid, i); + atc_destroy(atc); +} + +static void test_unknown_pasid(void) +{ + IOMMUTLBEntry e1 = { + .iova = 0xaabbccfff000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + + ATC *atc = atc_new(4096, 48); + g_assert(atc_update(atc, &e1) != 0); + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + atc_destroy(atc); +} + +static void test_invalidation(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xaabbccddf000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xffe00000ULL, + .addr_mask = 0x1fffffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0xb000001ULL, + }; + IOMMUTLBEntry e3; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + atc_invalidate(atc, &e1); + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + + atc_update(atc, &e1); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + + /* invalidate a huge page by invalidating a small region */ + for (hwaddr addr = e2.iova; addr <= (e2.iova + e2.addr_mask); + addr += page_size) { + atc_update(atc, &e2); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + e3 = (IOMMUTLBEntry){ + .iova = addr, + .addr_mask = page_size - 1, + .pasid = e2.pasid, + .perm = IOMMU_RW, + .translated_addr = 0, + }; + atc_invalidate(atc, &e3); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + } + atc_destroy(atc); +} + +static void test_delete_address_space_cache(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0xaabbccddf000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + IOMMUTLBEntry e2 = { + .iova = e1.iova, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0x5eeeeeedULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + atc_invalidate(atc, &e2); /* unkown pasid : is a nop*/ + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e1); + /* e1 has been removed but e2 is still there */ + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_update(atc, &e1); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_delete_address_space_cache(atc, e2.pasid); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_invalidate_entire_address_space(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x1000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xfffffffff000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0xbeefULL, + }; + IOMMUTLBEntry e3 = { + .iova = 0, + .addr_mask = 0xffffffffffffffffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + + atc_update(atc, &e1); + atc_update(atc, &e2); + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + atc_invalidate(atc, &e3); + /* e1 has been removed but e2 is still there */ + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + + atc_destroy(atc); +} + +static void test_reset(void) +{ + static uint64_t page_size = 4096; + IOMMUTLBEntry e1 = { + .iova = 0x1000ULL, + .addr_mask = 0xfffULL, + .pasid = 1, + .perm = IOMMU_RW, + .translated_addr = 0x5eedULL, + }; + IOMMUTLBEntry e2 = { + .iova = 0xfffffffff000ULL, + .addr_mask = 0xfffULL, + .pasid = 2, + .perm = IOMMU_RW, + .translated_addr = 0xbeefULL, + }; + + ATC *atc = atc_new(page_size , 48); + atc_create_address_space_cache(atc, e1.pasid); + atc_create_address_space_cache(atc, e2.pasid); + atc_update(atc, &e1); + atc_update(atc, &e2); + + assert_lookup_equals(atc, &e1, e1.pasid, e1.iova); + assert_lookup_equals(atc, &e2, e2.pasid, e2.iova); + + atc_reset(atc); + + assert_lookup_equals(atc, NULL, e1.pasid, e1.iova); + assert_lookup_equals(atc, NULL, e2.pasid, e2.iova); + atc_destroy(atc); +} + +static void test_get_max_number_of_pages(void) +{ + static uint64_t page_size = 4096; + hwaddr base = 0xc0fee000; /* aligned */ + ATC *atc = atc_new(page_size , 48); + g_assert(atc_get_max_number_of_pages(atc, base, page_size / 2) == 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size) == 1); + g_assert(atc_get_max_number_of_pages(atc, base, page_size + 1) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, 1) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size - 10) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 1) == 2); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + page_size - 10 + 2) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 1) == 1); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 2) == 2); + g_assert(atc_get_max_number_of_pages(atc, base + page_size - 1, 3) == 2); + + g_assert(atc_get_max_number_of_pages(atc, base + 10, page_size * 20) == 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + (page_size - 10)) + == 21); + g_assert(atc_get_max_number_of_pages(atc, base + 10, + (page_size * 20) + + (page_size - 10 + 1)) == 22); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_func("/atc/test_creation_parameters", test_creation_parameters); + g_test_add_func("/atc/test_single_entry", test_single_entry); + g_test_add_func("/atc/test_single_entry_2", test_single_entry_2); + g_test_add_func("/atc/test_page_boundaries", test_page_boundaries); + g_test_add_func("/atc/test_huge_page", test_huge_page); + g_test_add_func("/atc/test_pasid", test_pasid); + g_test_add_func("/atc/test_large_address", test_large_address); + g_test_add_func("/atc/test_bigger_page", test_bigger_page); + g_test_add_func("/atc/test_unknown_pasid", test_unknown_pasid); + g_test_add_func("/atc/test_invalidation", test_invalidation); + g_test_add_func("/atc/test_delete_address_space_cache", + test_delete_address_space_cache); + g_test_add_func("/atc/test_invalidate_entire_address_space", + test_invalidate_entire_address_space); + g_test_add_func("/atc/test_reset", test_reset); + g_test_add_func("/atc/test_get_max_number_of_pages", + test_get_max_number_of_pages); + return g_test_run(); +} From patchwork Mon Jan 20 17:41:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E1FCC02182 for ; Mon, 20 Jan 2025 17:45:04 +0000 (UTC) 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 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: MDEf8bepAENXnAdZCGtLsxUOXsrupHjthICINDhJ6f4/YzxG4W5vrhaAm4mG384pd0rf5p82MsrUdPii0AQs4mX4GNKC5r+WxKWv7heq25R8QFgyZ+Wfm82Xqnf8MGR68ItsbSMiOuj1gbb67H6W3zVBt5HjN+VcY4T73Pe2Axz8iw== 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 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== 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 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/bzH?= =?iso-8859-1?q?E+CAfEVxL/yRB8vKoJdiLv8JR+Nh0lh4v6Q7Zga8JIV2qazRzshonDp0W6Dy?= =?iso-8859-1?q?KVPOZ+h4/iIZVu82pnwe5eXkugpBaPq6ElDUiBaEzam47LkkRa7hhZ5tdoFw?= =?iso-8859-1?q?r+nxoRQLMRL2cYGlLlEs2n3O4y5HVdK69g88SRQDjjd0q9xW1Xx+VaSTWr2T?= =?iso-8859-1?q?XaoAeo3AysSPQXPNJ1wQc6I3mbR0R+6lwz6YoILcTw1b+3MG9adJ+/NtLmn2?= =?iso-8859-1?q?gmNJhVYRu7Z8nifL4rifJQ8DmTZooSOPJ1EhljKUq7ZTnFOI1FCIb+3rMyQe?= =?iso-8859-1?q?An5KWBqvFUq/sDGUpGGppW8MMBUUuXuzAU+pUM1Q4bDLtOUeHc1C9ZlwzGu0?= =?iso-8859-1?q?+y4OOq8UuyWmLCyE4GQUsySJNd99kFXd9Xo52KcWC5rTZJQPEPPhAfFLOMqR?= =?iso-8859-1?q?aGdsv+SGOCa734IV1JjoWZUAhG1bIe1EQ1zegVPnkN4+sIqTmL/5PuSBsVjp?= =?iso-8859-1?q?bwLSPyeY3n4EmLzBYbbUbRaHs1BYFtaG4QL1hi91Xv+JfALB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q?W5jwDydSY6Ja08kp7FcrOsTA9GfHqmbpiR7O32goM1+qDUyxIL+PSkw+YTit?= =?iso-8859-1?q?zrQJv5?= 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?VvFJLeHCpl3hkzgaMqoskqs?= =?iso-8859-1?q?XMJjUWJvGofX4+WwyWK+uqt0Ebxy8+wPzVW+zhryNMFrA+oQFvFuj7P4L3PM?= =?iso-8859-1?q?ktpLe9G9nGtoo5+Y5TbPZu3XuvkIlK1xgS/MX14sKccTiDNu9eHlqW48QHqz?= =?iso-8859-1?q?UEq19mC8RqiNSjIirZLIKv/e+cqqzadAE4+eAmlO74LCuUPG/Xs7H6OKgwcU?= =?iso-8859-1?q?QF2Mn2jEERceaVN0E9DSO33L5fdAdguW4I+ZNXN/WCbTgPsFmVyiu2MrmU4k?= =?iso-8859-1?q?/ebMr4kIAihVy0cDbmcL5FHQRAxmMwnNHh9FzSOpmKViTwY20RLuahR0KL+v?= =?iso-8859-1?q?7FAgS3rwZfJQle7cFWdG4t34jNx9rz2tkshro/PwW9Ytljz0IpMy1ZApbhWy?= =?iso-8859-1?q?69GF7GzcTPBGuSxuozTpJrVtDmlQ9NLuf655tPThEjcwuLzLjef9PH6tooom?= =?iso-8859-1?q?oYyd+rDRfC7v+bmRjNxeWVSeWC/CkahzcW8fKszZZrjbSnNOFOsEFGgqEubk?= =?iso-8859-1?q?sP+WFyKYct54V38XpVq0MIx+fZ3jvSwZRIbWRHMNj7G9NStc+XzI6GpFkqdL?= =?iso-8859-1?q?vXbw9i8iWGenHVzo5uRieIKi0eoHy4DxK9GJ3SXgxcE6e7wpR4LlpolxE0dj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qBt7SWCNVWU3nqMiCekZ+kTran6JOg4zB/WSt967Ejs+azrDWp?= =?iso-8859-1?q?2vOEdPU5L8n6o1EuzLmhiJnKGZpVx1AtDBYxTi213Ostyd5B49+SxV2p8mB9?= =?iso-8859-1?q?TxQ3n55U8FBEvFAby0OTxi4FVGLHjIAzaONOKY4PbdehNPvYBLbqpjQ6j5kk?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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; }; +/* Check if an IOMMU TLB entry indicates a translation error */ +#define IOMMU_TLB_ENTRY_TRANSLATION_ERROR(entry) ((((entry)->perm) & IOMMU_RW) \ + == IOMMU_NONE) + /* * Bitmap for different IOMMUNotifier capabilities. Each notifier can * register with one or multiple IOMMU Notifier capability bit(s). @@ -525,6 +529,20 @@ struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + + /** + * @iommu_ats_request_translation: + * This method must be implemented if the IOMMU has ATS enabled + * + * @see pci_ats_request_translation_pasid + */ + ssize_t (*iommu_ats_request_translation)(IOMMUMemoryRegion *iommu, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count); }; typedef struct RamDiscardListener RamDiscardListener; @@ -1882,6 +1900,14 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); void memory_region_unregister_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n); +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count); + /** * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is * defined on the IOMMU. diff --git a/system/memory.c b/system/memory.c index b17b5538ff..0a379a72bb 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2011,6 +2011,27 @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, memory_region_update_iommu_notify_flags(iommu_mr, NULL); } +ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, + bool priv_req, + bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegionClass *imrc = + memory_region_get_iommu_class_nocheck(iommu_mr); + + if (!imrc->iommu_ats_request_translation) { + return -ENODEV; + } + + return imrc->iommu_ats_request_translation(iommu_mr, priv_req, exec_req, + addr, length, no_write, result, + result_length, err_count); +} + void memory_region_notify_iommu_one(IOMMUNotifier *notifier, const IOMMUTLBEvent *event) { From patchwork Mon Jan 20 17:41:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD165C02181 for ; Mon, 20 Jan 2025 17:45:23 +0000 (UTC) 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 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: MDGq8vuSmi7KJJX7wW65eeqoURloQ9jl4fbRL9CsNVOx5VTkBGHGXVwKKb+PdDNfcN+UXv+wTcZuhJNnBQ6CFbUylX46q5zKHNV4CLMwor9w7vwPROg3ogXtmXGiRxT6xZ9hXSrvieveNWfghZ4MCyTS+vcXBWY4JylEGP+3wdpUtA== 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 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== 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 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+kcvlpG9O7o4oHDo9063?= =?iso-8859-1?q?nM4TirdwysTJfss122GPHYmX9dkL3BFTynb/BlnW/r4nWdcLrsW2AEhJFBTW?= =?iso-8859-1?q?McYY0uIOrEHPvqlvvuTUp7yHzoCL6HQ9wCi21Ztk9Shp6V/HZP55DMB4JBBn?= =?iso-8859-1?q?ju98sCsR6OFB/uNJ/S9jLk1tOEbbmKWO4PevyWZEl4WMX0w/nFdctAPf5GS+?= =?iso-8859-1?q?ohbNubya/Q1OpGro9hIBjcLwVHkA1LimLMI+UvmUF3b45QbFl2ZdWADBC8gn?= =?iso-8859-1?q?39ZPkcNAmjRrGgDf3YSg/zgHUTMg0pRgX0E40yYNab2H0OJIWTV+NuOarxqC?= =?iso-8859-1?q?wX38v8be7ixmf29bU+NDVSuYHbjGRxJ3LwphMJB30JycD5JpEHPjLyhMu8NN?= =?iso-8859-1?q?pz9YYMKlVEpBVphfmHNsTPMuhpHWp4oRMj8Wtgn+XnIqG7v4DZMBOY+sXcKE?= =?iso-8859-1?q?m8azsoLgPQaYZ3LSNg0QdsKj7UJR2L+ZbPw4nNZfWLOOWQdfnQI/qK2fPQkq?= =?iso-8859-1?q?ESVdKpMCAYrL90Xq6HsKR7pcpJBGu/38E5JecmJcrtULqY0WXXCa8sCZaA4v?= =?iso-8859-1?q?XPopLt5VfCZBv3rtHPzzeobF98i7010YZNXs4NoDYKUjmNxWgMRxvJa29maN?= =?iso-8859-1?q?30dZ+TUPI8SGAfc+kRU956vCYyyS6ZlHUROZr/52vop8i3zqK8V5RN/XowUO?= =?iso-8859-1?q?O+RWt5qGemiv12jOH947CmJNpQ3FJRQrgUl2xDP9r721eZPY5RSBf+rR/mql?= =?iso-8859-1?q?vM3eqZwecou7OaALquNqINAs32A487c23Wm8A8VLdqna05VNLKLHlOACmhHN?= =?iso-8859-1?q?GQMYyeZjKelxoGndyP0zDGA28kW+tt6qfelBOFxa/iT4PAFnF05PZzu5pZgN?= =?iso-8859-1?q?NdYPJZHe/8JLPf/h405rLeK0bV4EnlZyHZlMfxa8CJGaJMVTM7nYgV23qAe5?= =?iso-8859-1?q?UisGCDB7bHmh8Pl6fFQOF+NdTr8tYyYM+Kkd9iNFPRCbBV/8fJf3K2kZn7Ly?= =?iso-8859-1?q?IDMpFFz/Wq6yaWZ7deZGy7dVaVUdmv9jeMYhLEv0JLOsUFTh7Q+U77SNPLj2?= =?iso-8859-1?q?zijTqZq3mHCpIC0qEX73XcbLSuywlcj1K6bhrnz+RxL7b2CFGiFESopX7Zmk?= =?iso-8859-1?q?Vjn6rVIOWuOwmwUk0KAR9S6IVpQ7fXBT8gYr2+zrP2d2i+EJO0ncsYVuV9uj?= =?iso-8859-1?q?1imyAMSttiuygkx/nYCDeIvYxLldEsCmkwAPGx4UrklN2uydRMibxVXEBp+s?= =?iso-8859-1?q?M4HgdQ6bNMpApJy2gPwB3UucRVO/lDq5x3LQs35zli9IRUkGQxfT/0W9carO?= =?iso-8859-1?q?dOSYp+1V3KZvwnjXSB+u37rfhcSjXWyHMrlBwAD8Z/aCSCja9CtDNMUSuc7m?= =?iso-8859-1?q?Pwm1l28vTB93GC+MhERmOthOeXV+QqG0rTKpe5TK1Y3J2ZuHPRfxoWeKMb3j?= =?iso-8859-1?q?8e8S0+oOfrfYhFER1c9UtjYd+GDiTdjr3MLYE/4twmfrAyvgKp99rZCD07gH?= =?iso-8859-1?q?2vmENg?= 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?Clb8Msjfb9jJfKGzczeZh5R?= =?iso-8859-1?q?2XPUqqqrSCK6C3CpVnTsIJ2NYJBoFrTk908RiAkXTXU+AG12CXDUrilGW5qF?= =?iso-8859-1?q?zi5IgplMOwLfPX42gezEuPvNdYHFiBYdZbiLc+aXZeDB4LTEEGl/fKthJ6I+?= =?iso-8859-1?q?SU9a2qSvB89JkmlMHb8wztPO8NOYa0VdzyK+Ml7CptlNG3sh2WGFiwgKEdFY?= =?iso-8859-1?q?tUhrRPz/5VkA/9kxczimYy9IA0VcE+rDldIZP8+PU/6R4Se8UCZCzAiIApyG?= =?iso-8859-1?q?smuXDSGXKo06k8YZjT1plML4793MI68LNNopQfsi8kOrK3JeHFJVWlJAjWt4?= =?iso-8859-1?q?Zb8hX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nC+d5Iaej2v91BnvFRK+U?= =?iso-8859-1?q?8X+SC8guNuRnx2RoPAj23bpwgMtyNoeAbikxBYZLoT/CPLbN89MuJ0EGx2NE?= =?iso-8859-1?q?FzzpRoCI/IyVpNxDpfdH7nNmN2SI1dYR2Vi/PkppCb7sdiuEa9syisoMwm2F?= =?iso-8859-1?q?C5+1BjJl6mDwTsh6IhmRNeGwCxQPWiwM0gaxO68BswAGLmsb81LNYzDQ7tq6?= =?iso-8859-1?q?16AKu9xF2N2WK1i3TIWKSNUBcIgzujKnkphH4bsXvBup4mJiWHpkK8/rvfPq?= =?iso-8859-1?q?wDCxpHbiGRf4AiYyaCBlCkMyM4k0YQO53Ru7zGgV4vo7nKrvduCZIwOFDJ2V?= =?iso-8859-1?q?ZvLtjaZXIgnx0IF1vZnTTvaNUKP+sg8EGvbWoDKzWnw9fTAMK9VzCrWCwQzb?= =?iso-8859-1?q?QCaw418mwcX9QiZfBfaanCfw7ZvpgDPEWMxjvRNcbJyq4FdNhqrb09LdMn0k?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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) } } +ssize_t pci_ats_request_translation_pasid(PCIDevice *dev, uint32_t pasid, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + + assert(result_length); + + if (!iommu_mr || !pcie_ats_enabled(dev)) { + return -EPERM; + } + return memory_region_iommu_ats_request_translation(iommu_mr, priv_req, + exec_req, addr, length, + no_write, result, + result_length, + err_count); +} + +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr) { + return -EPERM; + } + return memory_region_register_iommu_notifier(MEMORY_REGION(iommu_mr), n, + &error_fatal); +} + +int pci_unregister_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr) { + return -EPERM; + } + memory_region_unregister_iommu_notifier(MEMORY_REGION(iommu_mr), n); + return 0; +} + void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque) { /* diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 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, uint32_t pasid, IOMMUNotifier *n, IOMMUNotify fn, void *opaque); +/** + * pci_ats_request_translation_pasid: perform an ATS request + * + * Return the number of translations stored in @result in case of success, + * a negative error code otherwise. + * -ENOMEM is returned when the result buffer is not large enough to store + * all the translations + * + * @dev: the ATS-capable PCI device + * @pasid: the pasid of the address space in which the translation will be made + * @priv_req: privileged mode bit (PASID TLP) + * @exec_req: execute request bit (PASID TLP) + * @addr: start address of the memory range to be translated + * @length: length of the memory range in bytes + * @no_write: request a read-only access translation (if supported by the IOMMU) + * @result: buffer in which the TLB entries will be stored + * @result_length: result buffer length + * @err_count: number of untranslated subregions + */ +ssize_t pci_ats_request_translation_pasid(PCIDevice *dev, uint32_t pasid, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count); + +/** + * pci_register_iommu_tlb_event_notifier: register a notifier for changes to + * IOMMU translation entries in a specific address space. + * + * Returns 0 on success, or a negative errno otherwise. + * + * @dev: the device that wants to get notified + * @pasid: the pasid of the address space to track + * @n: the notifier to register + */ +int pci_register_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n); + +/** + * pci_unregister_iommu_tlb_event_notifier: unregister a notifier that has been + * registerd with pci_register_iommu_tlb_event_notifier + * + * Returns 0 on success, or a negative errno otherwise. + * + * @dev: the device that wants to unsubscribe + * @pasid: the pasid of the address space to be untracked + * @n: the notifier to unregister + */ +int pci_unregister_iommu_tlb_event_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUNotifier *n); + /** * pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus * From patchwork Mon Jan 20 17:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D27DBC02182 for ; Mon, 20 Jan 2025 17:42:37 +0000 (UTC) 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 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: MDGKnAO0RElry2rBfSfDCDFDmDHYrk+dO1AEFaFtvMC6rcKPS94LRtu4Us075ROGM8LjOASbibjE4HrKDoYaU/kMTk1ANnvg/v47B1GNyWUWUoyMEemQvMaHS4dk9L8ebF5cyWMnuZe3ILmgySq/Mb41IXlrQSsAj4r2RMVxQOqyfw== 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 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== 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 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/9b7lUUZs3U35?= =?iso-8859-1?q?WnTn8TeEMwfwM0Mh4heXGfKVAbfHVAI/p+I/zObTGN0L9kHP8xoEso9XsWrR?= =?iso-8859-1?q?5s2CiTrKjfbMtBa0g47CBvEhQx933vb+9OQ+lr36FnZLOwWjhsyzlQsWxRjW?= =?iso-8859-1?q?q/dMEbdq1sXaQw1apqDKVfGiDE67uD2rMd+PFzfJvDqN3aTXS5azu691iyqS?= =?iso-8859-1?q?xzf7tysak+G9FJULBV1VGpOxQ5LMpDCAdp3QWTy320jQXEFCWl4BnQshZyGG?= =?iso-8859-1?q?X1Q1+CbQ4bZod+3cc3xl7ybal822u1GY1JsBfeKjVDwLZgXUDm39SffoYsye?= =?iso-8859-1?q?ZrZo08tvwPAmBONEBOUqKbkd/LUA2FWNI4x1QuRpItIz/TLdZWWMzrZNsbE8?= =?iso-8859-1?q?9RtXOVniWp9h0gucYNe/vM29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vzKIAHLPyy+PVn?= =?iso-8859-1?q?dIhPe58CfN0Gv30M4kRaQ5aSnQhlto08Pi9fPfvQrq+2KgGoFitAoGhKMCC6?= =?iso-8859-1?q?Kg1jncHExB6n29QuHMHH+dn1TOvlxAhis5vm9ztgKYMz9NAajn9olKlJqMt4?= =?iso-8859-1?q?PcHqoriqzEaO8qxQtMwxAzskMFptIAJKWczQZwlNoTtMVimShSjF+o0uK3h7?= =?iso-8859-1?q?YGHmCZ?= 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+cjzXYwTbKTj2eif5uDR?= =?iso-8859-1?q?hpXvrSApGlG8MfcXPG617m5lcDUmpu7ctOtH1nrFqwglDAST4qD6qNAo+FDL?= =?iso-8859-1?q?Rz4+GzdtbVTxYywcfmgIFS0lhVddgjmiNRvfWFLewcpd7mie1xxSu9kZPkI6?= =?iso-8859-1?q?NJ1b7LezoFauhpECYfNTYTMl+xCYXEe82BzhtaIxvq/0xsAmnveMA78NVH1C?= =?iso-8859-1?q?FcJDPKfz6EChX+mZVyyR0O7tYnUT8FFffo4PN4RiLeCscYf4rceMHk8x9faR?= =?iso-8859-1?q?w/DP1piLiEIwUWshAfSHRWUzsiEu4RFtA5CrRifrZ5pvGvrP5/WywGc+sAHC?= =?iso-8859-1?q?5v0x/rlJeJoigQYh3FqRowehEoVv4nwmHH3gpQIpm6wyup7vAKiuaNatuuLu?= =?iso-8859-1?q?AnoEKQe9LnL6ZLJiPPkZ6+0jSTCd7NMRjDpbMOkiQQ8ZJA1FMOEjIh52Uqt5?= =?iso-8859-1?q?CGJi7QvU2u0nMCkC5QSugzDAsQYQZg/hV8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=?iso-8859-1?q?mKSfnJnEH+9AdoH8u+rT95vJUVmYqmMuR2zjxzzlT8tqsglw4TnhD0RlOoYN?= =?iso-8859-1?q?6+J9dpz143ro9kK/xZqoBZmIjn+R5WPIka34wuBsXN6NZZXKVN2lQjO+NGWh?= =?iso-8859-1?q?mK/ZZ5Hor+Il4+vXGMYSfZW2RFrinD3u2l3D1yMxdRu/mrA3jUo0coLy5Sqg?= =?iso-8859-1?q?4wvPZa2C8O/0b/BI3U3AjQX9YAG8BxCTRWzrS4b0wJQ2k3SzaT4GHAitQ677?= =?iso-8859-1?q?oO0RAVUhuBhOx1kWwlVvuuaQXbP31CSpnxZB/DIYC4StOQ0DSP8rzUOopww4?= =?iso-8859-1?q?=3D?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 *vtd_as, PCIBus *bus, uint8_t bus_num = pci_bus_num(bus); VTDContextCacheEntry *cc_entry; uint64_t pte, page_mask; - uint32_t level, pasid = vtd_as->pasid; + uint32_t level = UINT32_MAX; + uint32_t pasid = vtd_as->pasid; uint16_t source_id = PCI_BUILD_BDF(bus_num, devfn); int ret_fr; bool is_fpd_set = false; @@ -2259,14 +2260,19 @@ out: entry->iova = addr & page_mask; entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; - entry->perm = access_flags; + entry->perm = (is_write ? access_flags : (access_flags & (~IOMMU_WO))); return true; error: vtd_iommu_unlock(s); entry->iova = 0; entry->translated_addr = 0; - entry->addr_mask = 0; + /* + * Set the mask for ATS (the range must be present even when the + * translation fails : PCIe rev 5 10.2.3.5) + */ + entry->addr_mask = (level != UINT32_MAX) ? + (~vtd_pt_level_page_mask(level)) : (~VTD_PAGE_MASK_4K); entry->perm = IOMMU_NONE; return false; } From patchwork Mon Jan 20 17:41:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F811C02182 for ; Mon, 20 Jan 2025 17:43:57 +0000 (UTC) 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 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: MDEJ4Wc6wyL4sE8+RShbBIHvVrnE8P6itHe7K0W2Ut+8/SnwWC9GURbfTBLJA8jbAQVjDRDh3Owu/BTPtM47zox2SH3mDhDYWPGj4E5HHiuEUixT47IxsOKvV+TBAgLRbQexVTk9YNbx/HM9oBbnMuTuY5Owr8GYV+Myr2Uaz0mu+A== 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 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== 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 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+mhf?= =?iso-8859-1?q?7kFn5iLLecRN8otN9wnphpphYJTFtuKBXIjpo/Q3DhXWH4Zr5MdJ1YK00lLb?= =?iso-8859-1?q?vn8EzHWKu7Mbf9GNl3QH+BgcYj+uMBrccGKOLbQsVEwMldNsWyvGzvXxtMGA?= =?iso-8859-1?q?EZq5eZYtCDo/93csUp5uon4pfvNFVHSfZiMQ/lsJm7ja+eaAPuZA3DvlXM6E?= =?iso-8859-1?q?sf0FiVA0UzqN8F5aUgyJY4MfsStZeF/cmABVr0SXGBwIR6mT2jmLg1zKCXuX?= =?iso-8859-1?q?RlLSecJ2HeY8h/J87wsqkuTO2ByuVvbF+53bjqKiOF+hmk2jpg2W2br0XBId?= =?iso-8859-1?q?TDL0BAQmCjWjg8FhJBpIlac7oa7kZEyiYVZB4xr3F402ItvyQZzkSNmm9gQm?= =?iso-8859-1?q?WP40Xrs1bl87o6s1nLgChjaOhVcyV73NHmGOkUPH8EiUnYSW9552BrlIryfT?= =?iso-8859-1?q?GOzqo8qKvBvsb7vSRLFrNr5GqX5n+Gljj7TgVPRoV8LnxnjP3H+CJiOi/OxN?= =?iso-8859-1?q?SpR5k6AjUjYqlK8DHK1GfOu8cjBM/MCiZxB+UWdrZ3e4PQYXirw9mdQp4/c/?= =?iso-8859-1?q?cmOg7u+UvFsKxBJiX1sYY/binOD2gDOEGzIf7Vaa/capyzJGggEFSP6Oz7Te?= =?iso-8859-1?q?7s3SNhDE/CAwEbz1anrhKnucBzIlIntz9B4kYFEYX4kjswqzuPg1x+EXs4id?= =?iso-8859-1?q?Oe3mO1aL+WDTdU2svZBuoFIcdXi7HOMqZ7R3jn0LNB8yCRZeawBTWcoTQZYO?= =?iso-8859-1?q?8ZYvCS23U7zIQklv0EaWxM18Sol0ZJ8XAyXO5ogWeid9HmB9sDqkNX70Krk+?= =?iso-8859-1?q?cgQBtXJQyohQkbtgEkrHdV/gZULwUclDO47f9bftQ2WjXoWR57YAkK08gqge?= =?iso-8859-1?q?2b2LmiuPOZxm/y0wfU+kCbxfL7ZVUkQwqAMv3CblWeWJblQ4K+zcujgklAVB?= =?iso-8859-1?q?GDMldA5zJnOGvOZhU9y7E7ovFS2CgF94+7x0//G8HFX4KWQCcckv1jfR5SMT?= =?iso-8859-1?q?Yu2RMqBCqpgyqZqike3CFGGC5FvRu3RJDYTEWDy/HBHmDj5C2FLrJkBqS04m?= =?iso-8859-1?q?wffqj6MVtu1BsNBJhVmFTRQyv2PlKQ/K3OMPa3ylv8SnF1o4eGEFTi9joEIj?= =?iso-8859-1?q?8Sm21Cw18Unx5gX4xXXeZvJqomZRb/QRuQtheRZM3T62s0Aq1INfnJ0u5W75?= =?iso-8859-1?q?eRdfBBb2C1lg7r1s3pEgN+VvG3zg6irzRU/IEgJbeteNTD3pCmvAZOmecQIb?= =?iso-8859-1?q?jUYQvv5KYvsXJsBTMciMLWAfhRk6hXHgnzQ6YEUYTH0Uc1HeWK35QELDeHtP?= =?iso-8859-1?q?RSRB4yzkzjH0nynEbOj2HeQ3vTtdyiHk6oq/kH42wkOOSAfxGBcXVJKCo/Lv?= =?iso-8859-1?q?GHlmyHHqlTi1a7yE29pNGs3Yfz6Lwpxb3NUdLcnp5xXVeyXQOjlXwHZMIKcy?= =?iso-8859-1?q?uFOs6edPY4mZtIoFYEjfrx1oi1M/egStwqcjTzgbv/boQXddonzEKm0hEXKz?= =?iso-8859-1?q?venPpH?= 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+daiZkJOiYiqfS?= =?iso-8859-1?q?p/XPInGfVl//2FEsuU+/6qdDrLx4o8/bWhtL8SOf038J7IVvgnJiXyes54QL?= =?iso-8859-1?q?VNkIwrbyWXwyzmgdub/7Lrj5E6via3nIYJDcsi1PkBREufDii29GgZezpg28?= =?iso-8859-1?q?54fgMftQFFIIZG3Qa7f0CsPFSOKpsZGh5sSOWjosRz8wyRCeqhNaO6KvqwWw?= =?iso-8859-1?q?1S/92dHvkXu3fI1xNO/1qYECiUt7AMRJEV3ljfQvp5MXZjOACRC1Q92s8pgW?= =?iso-8859-1?q?ttFFJQFzvKuCYmy+rbnS30wwWPG/g7mmsvjAKFGscMzP0Ls69etYVNnvTVHC?= =?iso-8859-1?q?3/V0iw6z06lA0pNMwh9S2xBiu8LJ3RJ8SU3/vXRjnxGNMw0n8wJWbyZQ77Jc?= =?iso-8859-1?q?RzR5PthVwqd6Y/+7kECGN3t2K/UbqetolZZwUrn5Pya9N1n9OEUBN+xNYFHk?= =?iso-8859-1?q?StJ7NOCP63j+HHe2oef3NNmKJfzcw8kDOJtPNeszb6GQb2KWXE9OXw9Ve0rb?= =?iso-8859-1?q?dBf5lg8oToCk1aePZ27Ytd0kRH/iorLzSmlIpuAw/FJXbCmRgMvqlno6Zgf1?= =?iso-8859-1?q?ANXOveVrh1TUETt5MEJf5y1uORf+0Sn59bIyVYlwrzYSN4p4LlUB38dnp7tz?= =?iso-8859-1?q?6S5eozHV0mWxmZFkqPsmbtT3OLZ+SKTC+cqqNqj+xa+KwKrrdSTxBl+cSau9?= =?iso-8859-1?q?aqhAqp0oJvobN+Ckq72uJpsqsrelQlVHNoXDEhpiygaF4RnoBRFpGl/D9Uab?= =?iso-8859-1?q?2MtfQ11x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xDm9OHidcZJZqjf0yirsRlqvVVcENM?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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, VTDContextEntry *ce, uint32_t pasid) { dma_addr_t addr = vtd_get_iova_pgtbl_base(s, ce, pasid); - uint32_t level = vtd_get_iova_level(s, ce, pasid); uint32_t offset; uint64_t flpte, flag_ad = VTD_FL_A; + *flpte_level = vtd_get_iova_level(s, ce, pasid); if (!vtd_iova_fl_check_canonical(s, iova, ce, pasid)) { error_report_once("%s: detected non canonical IOVA (iova=0x%" PRIx64 "," @@ -2006,11 +2006,11 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, } while (true) { - offset = vtd_iova_level_offset(iova, level); + offset = vtd_iova_level_offset(iova, *flpte_level); flpte = vtd_get_pte(addr, offset); if (flpte == (uint64_t)-1) { - if (level == vtd_get_iova_level(s, ce, pasid)) { + if (*flpte_level == vtd_get_iova_level(s, ce, pasid)) { /* Invalid programming of pasid-entry */ return -VTD_FR_PASID_ENTRY_FSPTPTR_INV; } else { @@ -2036,15 +2036,15 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, if (is_write && !(flpte & VTD_FL_RW)) { return -VTD_FR_SM_WRITE; } - if (vtd_flpte_nonzero_rsvd(flpte, level)) { + if (vtd_flpte_nonzero_rsvd(flpte, *flpte_level)) { error_report_once("%s: detected flpte reserved non-zero " "iova=0x%" PRIx64 ", level=0x%" PRIx32 "flpte=0x%" PRIx64 ", pasid=0x%" PRIX32 ")", - __func__, iova, level, flpte, pasid); + __func__, iova, *flpte_level, flpte, pasid); return -VTD_FR_FS_PAGING_ENTRY_RSVD; } - if (vtd_is_last_pte(flpte, level) && is_write) { + if (vtd_is_last_pte(flpte, *flpte_level) && is_write) { flag_ad |= VTD_FL_D; } @@ -2052,14 +2052,13 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, return -VTD_FR_FS_BIT_UPDATE_FAILED; } - if (vtd_is_last_pte(flpte, level)) { + if (vtd_is_last_pte(flpte, *flpte_level)) { *flptep = flpte; - *flpte_level = level; return 0; } addr = vtd_get_pte_addr(flpte, aw_bits); - level--; + (*flpte_level)--; } } From patchwork Mon Jan 20 17:41:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7089C02181 for ; Mon, 20 Jan 2025 17:42:58 +0000 (UTC) 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 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: MDGmhSgbKL5sAAE0UseJojG6mRYDFo8OFpDe0bsAXrJG7YDsjLvyP1QeLDsNn43tUzmyP30qqz/WV+m8uQY5fA5Hu32zrDy74ha2fOQXhd2sBGYvDRseNEn1Qqwqdv8Q+mId7/Npi6xpt6MeV9HBu5UFMjYD+gtfQp/iNWB/UMvyCA== 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 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== 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 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/wpB8v?= =?iso-8859-1?q?w4jlp4z4TC5gYyRRBRCuW+6TLMKN+E7pGl+2LUQ4VJaxY+EOSHvLJfkbJGra?= =?iso-8859-1?q?6jWi5zxxWZdrkI4EOGG9BLYEe0spnJiOofVq8fOY+A23wD/qxID64gg/A1HE?= =?iso-8859-1?q?LSIplF09X4LPfXgkQUyGK55FcNbiSOs1wRwqt+37ovTnQxWnWWodGTHLI0s+?= =?iso-8859-1?q?jWBY01wEisXPqiMrOaO3ezeZ4T/AnFfTHaYCDY8UG67U8iYJ7N+82ePt9Ke2?= =?iso-8859-1?q?ixStxmnTrj10g70E2kNSk3Bwwf6zM9W6zWDozyvHDU2YF2yKlZvapObSS7bE?= =?iso-8859-1?q?ECrPp/d7RgKEIVe+ePHytrrUvnkSiapPeZ6CdndfZxgtlj7gU+wLipLvwu8C?= =?iso-8859-1?q?7b15lEI45LjbVVNa+SgVChpMbNmZtTFDka5zu+T2257BvcVnq/ePMi1qvQNr?= =?iso-8859-1?q?fJojLVXBsR+ZdpNd84qRSKMINAI9Z9maI10iLPN49eqFHPaSJmS4H10UljDq?= =?iso-8859-1?q?Q/R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Ri0zchA/K/3Hn7+Zy0gDkcG8?= =?iso-8859-1?q?WDVd1tSMPhkQPW8ukItRlZrcQkojjkjFS+ehi0TtmXg6FTsHb+Oox1YFu+9p?= =?iso-8859-1?q?uyj2eC?= 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/IoIH5OZwp?= =?iso-8859-1?q?KcyNsHKAdFzMLSW0hDlsUyrxGCLntzF6Oz0esN3YbwX8+JVbCabLf0DcE64z?= =?iso-8859-1?q?VEaivKTdQY/1e6d+0lBpI5CodZkIvxtDh+dDDHEaYERsoswaKH+YIV7LzYmm?= =?iso-8859-1?q?3aIfDH7VyxFb+JJQysP4xsPXz6MompBNth2uPq5i8gDFoaLBtHgCphGAwyqQ?= =?iso-8859-1?q?C0dE+vesTj7IhbK1xpy/U1a08vxRZlAT+5ESYkSvSoXWQzI0J+m/eiutKVJO?= =?iso-8859-1?q?hfkDe3Ca/FHBXarc1xfZv8io8ATLZ+3RKPziIK+kf2PjtMOyKgmq0jcIQLHO?= =?iso-8859-1?q?/gPE1xDuD3GDTAzNLixjMWI5cXaH+1q7YkYLdfs84d5D6N2boRLS8HgQHKUi?= =?iso-8859-1?q?fQcPJbN1G2EqRx0U8LnPCuzH8lC4r+G6K4agZ39MwXc0wz5QsZXf7TaHAWiz?= =?iso-8859-1?q?IE6i+3NJuO9TEgyPW+pb23ahy6gxjB/8+bFLmSBCbJRqQ9KngoZsDKN/DbPd?= =?iso-8859-1?q?K73nSY9GzDSbVVgvgt3okxw/z5+28gVXB2SL3YIz9RjE3v8cia7BSYg6d1fi?= =?iso-8859-1?q?pmPlDMhzBmzHV8yVkaySorNQbjzaBi7HXw5pnUFU/8cwb6o7eh5IvpjndtFU?= =?iso-8859-1?q?cDGhZzTlooTDo2eZadp0wTibKhBOzLxklWuP+QkZGR078gUd2ou7MkKu/s7z?= =?iso-8859-1?q?HJhsmn1qOwWj4bovTAS+azK0E3DbCIJHzWFABxU1vwRqo5jL5ytmfLIZbnIv?= =?iso-8859-1?q?OSNQCMLjrMAEMqA86rqBy2dfdkI+fnaUQLJYUprd1eTqfiQntNSdFiwKZPbg?= =?iso-8859-1?q?weZp5jhVeXy/iPfvc8LnMktFP8rRV8/vvcFeR6gNwmRATw8fs8KhSPNDUJBV?= =?iso-8859-1?q?DEdO1+jtV9vVJkUk3ZihDBTS97eZFIp3nPuIK/cwGi9EtuQgQLI3WXAUMJLd?= =?iso-8859-1?q?iQnRqe3Mro7sDiGewy6dShotQvXK1bdD9dQv6fLX7kzAm4CzGa0KOcSctUkg?= =?iso-8859-1?q?4H6SRzp80oNpkGVIRCl73DUDq424uqspZhrDvJXg5l0gsC19Qv4hBEfk8zQz?= =?iso-8859-1?q?Ub7kloUggvUnocsVuwLgpFIpdOqhG8qpL6ln0257J6bmLYaYpQxylFmihiQN?= =?iso-8859-1?q?Ctk8ZjYsrtU7zSwgyL/uK4AEBlvBwXRrp15PBzqk3tCcjzpAC5D2FkdEJLyA?= =?iso-8859-1?q?7bL1UW9BVGvstBwqID4Ejbexc9t3X1bdnnscuZe4xAkMOhmaGd2+KyNjetpQ?= =?iso-8859-1?q?3CS27OhIkefwCfQeakF/sT/WYrAk73C20g/2d6M0m+e2T1rKSTWV65GXeM/R?= =?iso-8859-1?q?qwvq3HazgoX9ZZIOVYI1pPr+PYz5pNEudJsZrhLZINF6nrl76+8NKWiLFYDb?= =?iso-8859-1?q?B6Un/aoYS34UYEWCFyCI0SMeQ9UBIvvz/Pg065zVn4CRjJPoegQl4sIqbea5?= =?iso-8859-1?q?GbuY5pmvC3QdfAs2wIIY1M+GAMMMvD5F89yPIZVpwF4mmgUXp2KF/2G22PvO?= =?iso-8859-1?q?eo4IAc6i+ixrN+7nqfzvrdpM2NbC8zTRjSAFpVVzG4ePqmQtrtlLuJD9RaJ0?= =?iso-8859-1?q?JS6JzKfb+TNvgxRSTeQuZTzja7xvgq2ngrNSVMeiLLI0c0t/CGrQmUoI7pkE?= =?iso-8859-1?q?Aky27M8qu/JuqsSu+eH/BBg44GLNkhraypgDwyzNGAHH8AL3CxGiQLlrrDzY?= =?iso-8859-1?q?=3D?= 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 client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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(VTDAddressSpace *vtd_as, bool is_fpd_set = false; VTDContextEntry ce; - assert(vtd_as->pasid != PCI_NO_PASID); - /* Try out best to fetch FPD, we can't do anything more */ if (vtd_dev_to_context_entry(s, bus_n, vtd_as->devfn, &ce) == 0) { is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD; - if (!is_fpd_set && s->root_scalable) { + if (!is_fpd_set && s->root_scalable && vtd_as->pasid != PCI_NO_PASID) { vtd_ce_get_pasid_fpd(s, &ce, &is_fpd_set, vtd_as->pasid); } } @@ -4738,6 +4736,71 @@ static IOMMUMemoryRegion *vtd_get_memory_region_pasid(PCIBus *bus, return &vtd_as->iommu; } +static IOMMUTLBEntry vtd_iommu_ats_do_translate(IOMMUMemoryRegion *iommu, + hwaddr addr, + IOMMUAccessFlags flags, + int iommu_idx) +{ + IOMMUTLBEntry entry; + VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu); + + if (vtd_is_interrupt_addr(addr)) { + vtd_report_ir_illegal_access(vtd_as, addr, flags & IOMMU_WO); + entry.iova = 0; + entry.translated_addr = 0; + entry.addr_mask = ~VTD_PAGE_MASK_4K; + entry.perm = IOMMU_NONE; + entry.pasid = PCI_NO_PASID; + } else { + entry = vtd_iommu_translate(iommu, addr, flags, iommu_idx); + } + return entry; +} + +static ssize_t vtd_iommu_ats_request_translation(IOMMUMemoryRegion *iommu, + bool priv_req, bool exec_req, + hwaddr addr, size_t length, + bool no_write, + IOMMUTLBEntry *result, + size_t result_length, + uint32_t *err_count) +{ + IOMMUAccessFlags flags = IOMMU_ACCESS_FLAG_FULL(true, !no_write, exec_req, + priv_req, false, false); + ssize_t res_index = 0; + hwaddr target_address = addr + length; + IOMMUTLBEntry entry; + + *err_count = 0; + + while ((addr < target_address) && (res_index < result_length)) { + entry = vtd_iommu_ats_do_translate(iommu, addr, flags, 0); + if (!IOMMU_TLB_ENTRY_TRANSLATION_ERROR(&entry)) { /* Translation done */ + /* + * 4.1.2 : Global Mapping (G) : Remapping hardware provides a value + * of 0 in this field + */ + entry.perm &= ~IOMMU_GLOBAL; + } else { + *err_count += 1; + } + result[res_index] = entry; + res_index += 1; + addr = (addr & (~entry.addr_mask)) + (entry.addr_mask + 1); + } + + /* Buffer too small */ + if (addr < target_address) { + return -ENOMEM; + } + return res_index; +} + +static uint64_t vtd_get_min_page_size(IOMMUMemoryRegion *iommu) +{ + return VTD_PAGE_SIZE; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, .get_memory_region_pasid = vtd_get_memory_region_pasid, @@ -4915,6 +4978,8 @@ static void vtd_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = vtd_iommu_translate; imrc->notify_flag_changed = vtd_iommu_notify_flag_changed; imrc->replay = vtd_iommu_replay; + imrc->iommu_ats_request_translation = vtd_iommu_ats_request_translation; + imrc->get_min_page_size = vtd_get_min_page_size; } static const TypeInfo vtd_iommu_memory_region_info = { diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 238f1f443f..7e2071cd4d 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -192,6 +192,7 @@ #define VTD_ECAP_SC (1ULL << 7) #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_SRS (1ULL << 31) +#define VTD_ECAP_NWFS (1ULL << 33) #define VTD_ECAP_PSS (19ULL << 35) #define VTD_ECAP_PASID (1ULL << 40) #define VTD_ECAP_SMTS (1ULL << 43)