From patchwork Wed May 15 07:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13664777 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 C5932C25B75 for ; Wed, 15 May 2024 07:18:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s78qV-0004aL-52; Wed, 15 May 2024 03:14:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s78qK-0004Xy-B7 for qemu-devel@nongnu.org; Wed, 15 May 2024 03:14:29 -0400 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s78qF-0000oX-AE for qemu-devel@nongnu.org; Wed, 15 May 2024 03:14:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1715757263; x=1747293263; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=we+kjz2Cu2q6YkP/UfGNhUBZcgYGej5Wk02odB72gxg=; b=HMATLW3K4Gx9PaZ3ZqGDN3bl4xzlzSWjGSHfoUJvkxzLqTWaJH7nPhLk /h86k8w0nDmtKv1MJlJF/nPX8Vreaw5wxLlG2SZAkrCZP4dzAODCTVbLy h31snZ4PjFzkszTaU5zAOSs/3HCZPP0Nbdk8qUkhE2PrS128PVpcy2QpP 0jgrn3wYcVTUVrdHy3vKpxh5sSOuDbR3rGwy+EZRuDdGXXfyeTo9tRAu2 fwW6ikva/t8ba1uKcQmOtLfSE1p6BzAUWdFPWKchv8T+Sl6/wZedtyvVs xtcYOg2Jp9diDps/KlvlgAs2gQnlrwEt4UU2Dne7pu9Hgjyr15vD2v4xa A==; X-IronPort-AV: E=Sophos;i="6.08,161,1712613600"; d="scan'208";a="12580200" X-MGA-submission: MDG/UngeG5tFbfb74bx+GLGzcYkjaFuLvdHlwYe6Uq8ayALWL0Qiwf7vAW/Xj/Ts73458gvinrywVBBYexoTPlm7gIREys6587bBvxx65dXJPn79wOierRvXwmuaIoBsmfcvWTtfGlsUE48+SKdDpDhE70rryiw0CXEOktMSiPngbg== 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/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 09:14:18 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhUlnoex8SrpzNw33KZ8MYtJeq5KOAiyf/EX8uC9l597FQv5gXzQc/qfJgdVUMwClL8Uqq1bNZtTrH0vBqIqiBw1TXNnOg3ijBA90BOUAyshIQq4n3k/s7YY/lhWjf1gEdKa494PFObDRANfQ+8TsdSSDlzmXLHtgqlozp6Y4vz2ZRk+9arGfFsZcK4pJ2y4YeMmi0uVyW5Z1pUJdIHCteTCtx9CxRoo0oU65XY1uPn5JW+/hCvmh9xTQKXQQPWYvqlD2rXl7TRO7zlVwYmTGlAFgqGiNAaSMWEZoN6FApDRG8iPZeW5Z/zztlFTda62i3Gssfdi8C0VZfaKAQhAvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=we+kjz2Cu2q6YkP/UfGNhUBZcgYGej5Wk02odB72gxg=; b=VxxZ77+++1sCTx3EJ/zW7ywlpG/ulQAtMW1KPDPRw4/IJP5oeQ3CSCT+xat768SPJUcOBP3Qq/6fo7lk+97ymo/e6Ldy7SOr3R/rPTz1R9pUjmn2u+OLyWz0FDGONTWhkwPxrP0yGxTH28ydHeLVclPiHMFOAJyyJFdnG60KlyVKJem3lZLnALcWTrfgwy0ERIGGQr2TGcPkjTGPKJQqBRPFOSf5+5+jAEhncsVa2zkrE8JFeGK/uo8VtXhwifwiJXatvY/kzRPWnqtE1s/q+W6KdJVpkE0U6PIkPjrsdt/EqukPsddsefoRghSXiwZBa4poigOF2zRzcn6aS9TZLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS5PR07MB9896.eurprd07.prod.outlook.com (2603:10a6:20b:676::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 15 May 2024 07:14:16 +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.7544.056; Wed, 15 May 2024 07:14:16 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd v2 08/25] memory: add permissions in IOMMUAccessFlags Thread-Topic: [PATCH ats_vtd v2 08/25] memory: add permissions in IOMMUAccessFlags Thread-Index: AQHappd+1X32ylJH50OSWYK+S1O/wg== Date: Wed, 15 May 2024 07:14:16 +0000 Message-ID: <20240515071057.33990-9-clement.mathieu--drif@eviden.com> References: <20240515071057.33990-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240515071057.33990-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_|AS5PR07MB9896:EE_ x-ms-office365-filtering-correlation-id: c398351a-dad0-4328-66c3-08dc74aea16a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|366007|1800799015|38070700009; x-microsoft-antispam-message-info: =?utf-8?q?Y0aqii2CNypXPJ/qgrDVFVWNiP2eRRP?= =?utf-8?q?Ip3NbDYLKuhDNeGmxftZwsY8kvDTtVN59nuR3mIbACZvDFQSeXOQQ2ZH8tJ3B8Zjh?= =?utf-8?q?qi6IlGaWJ+7FM6yX/oAuoXYYgrM0Tkbncc9EHi9PI3G4Falwuj663IiGYUKELCfYd?= =?utf-8?q?Tw7Fn3zQK+EXMNpk/YUclJxxjQsLvPKtPehhm69Sz75v7eTl938FRjg1KJf92toa8?= =?utf-8?q?upWW7az6pMnDSPLwmgdJDzoDGg7xN1OwVvRgWUMhehfmHGFkQfDD9Vz/0P6WknSMh?= =?utf-8?q?hFwn9HOhlR6uvK88X0CF4Ec1UxseEROgon6MwcNVsSYdwgk0yUP+cl/qaX9Mlfmw9?= =?utf-8?q?/PptQJeKudYMYbhzFKTNoAVZv1kNdAuvd0RR9xk68oNqYtDR7uxzv1WgP11oqLP0Y?= =?utf-8?q?blWn+9kfHApKm4s7xL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ApcWasVA8QggWZy2RIgf6BSTvN/JDQA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?P9rq7J9KMVBRfyGnXD/R7uS49uRw?= =?utf-8?q?wz9eJNjiEkOytjJlz7A/t1jNxoz5jz3vqkUu/pdQE77LqV6i2C4WayTpYGTctVTIn?= =?utf-8?q?wI7Yg68pVNGXDZN3bAENnCLBuSisdAZL9aWPENTrMqnJ58y2kp8d9IrSgBqHbRq0K?= =?utf-8?q?Yo8sRJtvliaaxq4GAIBlp0r00dTWYL3eH1oMqtxDEIrbKifc1asRLKgsilMmknogh?= =?utf-8?q?xDUA6UxfUBXDaRIGzmIdUbwvNrmefytoidbYBFKcrh0fhi1RoToXgNEeyAEClNCXV?= =?utf-8?q?r6d0reC11KUSPxBT2KpkwKeuUBO+DgYBj82eZ7bFkLgaqnfY8nkHRxBVcSk8Bdksq?= =?utf-8?q?i9kYDUKLN2UCCekv3TwBktVVXW5DgV+b0BDnwsQC8mEV0AdInwxjG5F5CeyovIHuC?= =?utf-8?q?mHfR3ZU3rONG5xHI/OI+jr9ED5J8GhuTeee0zkxSc6Lt5HS+WN+iKsOwZSwTgz1PE?= =?utf-8?q?Ayke5QUAVa365oruA/D/0TxBSPZ4C2SqLNBycP2cK6RAjOREVvJlspIiIIkZ3MUxe?= =?utf-8?q?vHS97sPml0kyVa0NGp7yr904XT3sP0ZL8nGRVYfQq2pt0Gjm1q0r0PCibdFw2gtb6?= =?utf-8?q?jIk8LgT37el1BhP4GZqnIQWPWc9AEYdkSkJAaZBYoug/83i7lJPlefsKtsP9XQOzi?= =?utf-8?q?mda4LOvTiSR+dtTUf3ueSit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fcC3oMDadmheWy17K9ny4R72ec5AtTAT6vmFBgbI=3D?= Content-ID: <3733CE74C9BF6F41855D04A026995368@eurprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: eviden.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c398351a-dad0-4328-66c3-08dc74aea16a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 May 2024 07:14:16.0610 (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: IdDGmkHGhjNije6IwAvr14cnVmj+n3zr/7rZ7jx8Qa0j+zDVJRE2V0T0O85BiaouhNjuvaqxytckvFULF7h+fXQjH8gB93OpS5+YPwjY/jLalEhkopPA4NiG43CmBlxK X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR07MB9896 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This will be necessary for devices implementing ATS. We also define a new macro IOMMU_ACCESS_FLAG_FULL in addition to IOMMU_ACCESS_FLAG to support more access flags. IOMMU_ACCESS_FLAG is kept for convenience and backward compatibility. Here are the flags added (defined by the PCIe 5 specification) : - Execute Requested - Privileged Mode Requested - Global - Untranslated Only IOMMU_ACCESS_FLAG sets the additional flags to 0 Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 8626a355b3..2c0e964c07 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;