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;