From patchwork Thu May 30 12:25:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13680335 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 7472DC25B74 for ; Thu, 30 May 2024 12:26:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqP-00074q-03; Thu, 30 May 2024 08:25:21 -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 1sCeqO-000741-6M for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:20 -0400 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 1sCeqJ-0006BP-Pj for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071915; x=1748607915; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=ikwo6pFWmWJPmsLVz9EZY1puQ3UYZOPOUaqaZRcgXFs=; b=J9rd3n4f4yl3AHmfHsnlu1ilvV4G73XpXve9R5HmQ9IGjwUC1j9z9Yog lGrd/HTN9Ot8mKfEqGOthtzsqThz0vZdTdEuX5P57N6lSW6XtTm4N1qwZ M7NX9SOEzoieIBEs5Q0tfp8yHIUAZmrNEkyhSSL020G6t1lPeUm0InnSO N8o7U4mvp1xNLOhakMrVHv14bUIyic6bKnTxuSCCXbxdk/bQOi/J2yUSo A+r9x2X+IUXiXD5o6hOIzobI6iiK+XSkUUOn1jlMvtOLgqIFD8KdK1Yl4 LPHfhGfgGKfYxzlcz6ARNzAGCnprBWCz+eh7+1aPWysugMRr5yOwcKPB6 g==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13582415" X-MGA-submission: MDFrA/4WdAcxka9Ck3g9hbqn24B5MJmBdxxT0UnmCl2DqIzzIaFCFd8dz9w5FzFuqq85LmCaPuIy7rs+pPXJPn3oFIgDbgeqtO4NX9CAi9i/GAx+QeGT0hARs/bTYugy2SFOADXBy4jEIOC5Ag6wNdDl3lAjX/m20eYhEs7dui/nMA== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:03 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HO+yYRY2wjT07uuZ4DcND3xbH+HyHi32pJgezq2HA2migPN1RSEubW1krDhVjD8qa45SbgQU3QYS6BcZ/GhxKGHI2gBPt4YV5wO8qqnBQjqO1W4b9544Ql+yRUuh3xvbuCAix58Q3XTvr5n1hLjGIzfewp6uZwArBa5gUjbgJEz5TY9MbGM9dQzC/go1EumzmRS+IOZ5jQaSrsSiSvOgNpmq/RCcU8oO4pqNBwbaT93Pn3pAPP3h5eFAwiotYsxFEb06Fd0MLevB7lpl8XmYDqEIXQExdno/NnEylkTJmfB/8xTTxnTr0aMEiiVGN0uU2hNj4j4hMLuAu3CIZr4e7Q== 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=ikwo6pFWmWJPmsLVz9EZY1puQ3UYZOPOUaqaZRcgXFs=; b=l4q07WNHszBRHENwJpB9Vji4lFhloUEzJ3s/DWzmnp0aXzMjaSuXZfSnUa1/cvsGhvnsPrMO0Z/4YFyql5HxGHFWSJS2hjCgxDpKTz7fiKsGGQ9OBXkXx56YWnQp4MG7m8KcFX0/mu0d0ncwjCnIE2u0qXBtxsDmv30esukq3TvK08Tvvqg5qPzaVZLrHUSEDWFmdI2AZrKaGCnhgpDj0UJP+PUwhsGIg/DXIZJlwln8HUhdfaktcVEKfAUb3Ji8JoQHgjmckDkwqDjTZXmCY0Ujj5nUbqFs+qxV3vufEeFH1OrRYGi+rY0WIp1xp+0HM2EnihINdgrcA9rp9dLbUw== 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 AS8PR07MB8069.eurprd07.prod.outlook.com (2603:10a6:20b:358::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 12:25:02 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.7633.018; Thu, 30 May 2024 12:25:02 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 4/8] pci: declare structures and IOMMU operation for PRI Thread-Topic: [PATCH v1 4/8] pci: declare structures and IOMMU operation for PRI Thread-Index: AQHasoxlVf0NBxjHCEirwX3kIlKGLA== Date: Thu, 30 May 2024 12:25:02 +0000 Message-ID: <20240530122439.42888-5-clement.mathieu--drif@eviden.com> References: <20240530122439.42888-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240530122439.42888-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_|AS8PR07MB8069:EE_ x-ms-office365-filtering-correlation-id: 7315b40e-060a-47c3-68a6-08dc80a387aa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|1800799015|366007|38070700009; x-microsoft-antispam-message-info: =?utf-8?q?g47j7CM6e/F6woJe5Rsv8N3ZnPKzKL0?= =?utf-8?q?gn/EL8E5PffBbs+vmCYOxvcQgUoIpDZvMZz0Tu5PeJF+L8GizS5CPZixKxCut7u+9?= =?utf-8?q?7bqhFI1k4ZP9rN017QvTgk/JBU9VJQOdj8K4ULpyEJOIKJ7mk0A/+wK4I2S/qyv7s?= =?utf-8?q?PwKUsPPwtgdxS05+cy5/4DOgoo4Cnt0r6MhOvs7isJHxlSsSIhJZ3P0AdW/pzrir6?= =?utf-8?q?ohW8trVB9pmXHh/Auv+m/5AqX3MoNYoYm6LcGkKE9+SXJcEKwviC7y3BK0F3ZrGT7?= =?utf-8?q?fvJbAFZRef2DFA0Vbqhksnmbu43yMCmiIOTgoSNPXcd63HgJLoFvVM34H3NMuqyAt?= =?utf-8?q?umvbH9e6wwdrncYLOxjraxPXWxqBarV8GPiy495wlW6K8a28Au1Y+PxsNmafr9T8L?= =?utf-8?q?+8KwBX6xYnX4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zpA8VyKyNxBXUv3muatw=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)(1800799015)(366007)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?GFnN39kBy6khIPngaSKKZ6Te2UrG?= =?utf-8?q?7LB+/MSPgcwuBn/fq9hDNWsv9GELDQp+ejOpELyKv53mQnHaMWFUrClgGbAeer+Gz?= =?utf-8?q?l7I4Yvi2ZldD6JMabyC0taj/0n1L1aYPvQYb0K6zrGn3jxdx9bTiur3SMymfO5BbY?= =?utf-8?q?GhDW1xP/WUbTgqs+7M8Ys56bwlR/dIHneD31CY1+eLBP3NX7VslwYRLCsyIlLpdNK?= =?utf-8?q?4O9BN6xKJ4LvGtSuWBKrnu9uloPuP08bdLONL2FvMGlQPpTVbuitK9Oc4DwB+X9xV?= =?utf-8?q?MmvEC+2rXYJf3lRaPUTtuZBg2yFeFPXTCQw0F6aQCW1tK00jYhqQmbmgM+Zc/ZT2S?= =?utf-8?q?fFY875hd5w9jZm7Dic9Eae6Ws1+YV4NOop2kW5n/AmvlvMSIWjTDPF2YkwwCtmCtf?= =?utf-8?q?EfeTDI40LGpCJGS6nOnfsLWeMqOMT1uy1ZvE7cYPOlgol+3tLkWb1Y9pZ7YG2hPT0?= =?utf-8?q?Q1nGQpVCMHAt5t3WOghHtM7wkskFdXeodmIUBFSjXYjGGdLKw67eD41aUCLHcrmor?= =?utf-8?q?Y2Z0MhoTgR4fzZXiP0gVsK0VznVPBdtIcfyZBoiFOf0WP7GE7nhb7N83JAsLRBsTk?= =?utf-8?q?m4C+LF7xl2PNfRPiFgdC7W/DykG/QBtS5T7oYlDkoER3QJFy1PKhvt62AbYG7AMZf?= =?utf-8?q?kcHf7vKt5oDOM1y3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4myTGvBvn9PnhfDYk7hh+W/nE=3D?= Content-ID: <12F47AA919D68C4A975B8AC8ED64B813@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: 7315b40e-060a-47c3-68a6-08dc80a387aa X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:02.3514 (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: 2sKdgkHIq/Oj2xnmZGZhvAZ4BhvFWJ/FrfloMWA/BRjnYjd/9a8rPu36VFZz2+axHSN6RWnEprH5xdXrGKykIW8YmNf/Gdz4zIJYh8fNuj5/xhh450F9zivum8ztnrE+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 The API deliberately designed to be similar to the ATS one. We define a struct that stores a function pointer to the device's callback. Registering and unregistering a notifier is done using a pair of functions that will be added in a future commit of this series. An IOMMU can support PRI by implementing the iommu_pri_request_page operation declared in IOMMUMemoryRegionClass. Signed-off-by: Clément Mathieu--Drif --- include/exec/memory.h | 30 ++++++++++++++++++++++++++++++ include/hw/pci/pci_bus.h | 1 + 2 files changed, 31 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 0ced7c33b1..f4780d3920 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -218,6 +218,25 @@ typedef struct IOMMUTLBEvent { IOMMUTLBEntry entry; } IOMMUTLBEvent; +/* Page Request Interface */ +#define IOMMU_PRI_RESP_CODE_SUCCESS(val) (!(val)) +#define IOMMU_PRI_RESP_CODE_INVALID_REQUEST(val) ((val) == 0x1u) +#define IOMMU_PRI_RESP_CODE_FAILURE(val) ((val) & 0xeu) + +typedef struct IOMMUPRIResponse { + uint8_t response_code; + uint16_t prgi; +} IOMMUPRIResponse; + +struct IOMMUPRINotifier; + +typedef void (*IOMMUPRINotify)(struct IOMMUPRINotifier *notifier, + IOMMUPRIResponse *response); + +typedef struct IOMMUPRINotifier { + IOMMUPRINotify notify; +} IOMMUPRINotifier; + /* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ #define RAM_PREALLOC (1 << 0) @@ -589,6 +608,16 @@ struct IOMMUMemoryRegionClass { IOMMUTLBEntry *result, size_t result_length, uint32_t *err_count); + + /** + * @iommu_pri_request_page: + * This method must be implemented if the IOMMU has PRI enabled + * + * @see pci_pri_request_page_pasid + */ + int (*iommu_pri_request_page)(IOMMUMemoryRegion *iommu, hwaddr addr, + bool lpig, uint16_t prgi, bool is_read, + bool is_write, bool exec_req, bool priv_req); }; typedef struct RamDiscardListener RamDiscardListener; @@ -878,6 +907,7 @@ struct IOMMUMemoryRegion { QLIST_HEAD(, IOMMUNotifier) iommu_notify; IOMMUNotifierFlag iommu_notify_flags; + IOMMUPRINotifier *pri_notifier; }; #define IOMMU_NOTIFIER_FOREACH(n, mr) \ diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 2261312546..eaa777fde4 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -29,6 +29,7 @@ enum PCIBusFlags { }; #define PCI_NO_PASID UINT32_MAX +#define PCI_PRI_PRGI_MASK 0x1ffU struct PCIBus { BusState qbus;