From patchwork Thu May 30 12:25:00 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: 13680332 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 4B2DBC25B74 for ; Thu, 30 May 2024 12:25:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqG-0006yU-N1; Thu, 30 May 2024 08:25:13 -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 1sCeqD-0006xk-4x for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:09 -0400 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 1sCeq8-00060c-PE for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071905; x=1748607905; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=HVKnFkrmgwdohMnHQE5psyw3hmzpcGX7tSLYpwPUtPg=; b=IPtAJfAiloqZRDL0Dy5gUXGbReO3RZOtZIsZEuNqacmtxkoxITrEDO0T LZS4yp1UqZEwhdH36a4k/vKXSvDHd8iSgJHO3vUn6wqhq8qyX3VF4NQMh VtPnXjgKUvSfp+i+Hn8FuB7ezTCtbTdK7Y/8K6ATDysU+gon1luuOEtED r8C1K4wT7ftHefjLVcG2T/irTvuQPIk+SLK62iN9yHB6m4/16eZDtx8q7 mhpayNNwXi+QPJO8rYwA2bQAUKw49yPeJvCrqbVnv6lWYzcesbibvFfMp fFJuCULyAqcao1n6hQoVuf0O8kDYoMweby4V78X2ideDDlZbW/jrOfF2i g==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581111" X-MGA-submission: MDFFSogs6Qum6mvTEluzHApt1FNFthsGIzL8llpUFVpVjQavGTWsX3RY2poZj8ZPMel7HwgxJ05pGO5OxNPkj8ZZS5nPhniYw1F8q5Yp+Zy2VStRcmnbVkodNi5VaZ02+HvnKZXY4VgRKL/cvljPZHOXMlSYfYcXOZ8KUss0/sfWAQ== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:01 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KGi56cIw2J080kev3LMaMS2BMTPZPpxNzpgU/4zSvl/CRFrqP21dxvFe+hVywsWawUhfQ0YC81XB921dRAAmMwJtkrVZu//Fh8nS/c9EuRpfEOS5hWXRrxI3KG7SEKp9t+itYMLcVuhzudKBRdt4XAe8cS2x5QUbYRt7UemKMOz5OiJ/s//jRH7AcakXjfHuaGCyrml5lJQjCge+wKTvIcdjGRH3aceN860w/AiTpria3UBWvHZW7TvUjKb3UGqqUdtEVnRAj0emMcc5lhvniInnVDLVCVfnorJ+t9+oRT+GT623YUoyKhDnqfg1ATMNTpzQJolnoAURRMwooThyOw== 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=HVKnFkrmgwdohMnHQE5psyw3hmzpcGX7tSLYpwPUtPg=; b=SM3mtnpdwd1yjqAcl5Ccbhs67otKF29h6f5tmQ7s6FD3+qiPa6XNANFUs4C4u+WoWTmgmsmmqI0zTGszJircYNISODxZwK15aQlauIG6UhMHsiWiVeBIU9vlyDbAeYrnmYpXMtdx2CSv8PmuNsP3+GDTTaTqhTfHZ9mhMQJP8yE93eHyGwCmUv1vK1dfcNP04PTmBUCpfEmZdndgYexub6wgVSsy8qeYDmFVo732pRxO11XiWq2saF2/lEXc4UFI8PrQl0PUGgZ7CbNhJfiNr5HtWXM7vUw6G+GFB29fVmTfAfQKnBKFXqKg1Cz+q9Amv0SDit5GpBNOyn85pNdhAg== 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:00 +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:00 +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 1/8] pcie: add a helper to declare the PRI capability for a pcie device Thread-Topic: [PATCH v1 1/8] pcie: add a helper to declare the PRI capability for a pcie device Thread-Index: AQHasoxj3XXMvKtwP02RxAFJg4tHdg== Date: Thu, 30 May 2024 12:25:00 +0000 Message-ID: <20240530122439.42888-2-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: 2bd6d0bf-546e-464c-1d36-08dc80a38653 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?DiewgTZ0B0CSFa/Oj+sdibjjegMC8BC?= =?utf-8?q?A8MbPmFs0n675oSE42LCsLGZuircJoyMbxTOQBHl//4X1Jyj/hI7pAGUXGYZS10LC?= =?utf-8?q?vcAqO3wEyKTFmACNCjyhHr4EP8Ng9Iie0+Pa4hB07coUIHceyDmc3OTvH7hLwNQfd?= =?utf-8?q?x9XVWwzGlnXQzVxzP/a4LSi7LIIFNfPFQYomu2olvTPuFTBIGn9fpDHam1r8ugekE?= =?utf-8?q?MTHzBV5kVPrKjaNoA/aWXuGix7ZQ/ZnPtwpTeBhz5wuxAajIQDdBOhCu8tIdENacq?= =?utf-8?q?j/SPjDWFKSoU04EgIOIwcEna+4l3PTKR37k5b5tCxBZQyWgCR5uzZxLK+dwJNVxkD?= =?utf-8?q?A+JFCfI4tclRycgDt34i/81XO7rUdQ88/ro6Q2DuiuEMUlhbIGoQDF6ipWFy6j8pL?= =?utf-8?q?jHwZtoXlzEHGmHMqb7izKq/2RQECj/tTrrWg/oiMed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-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?yjsRIpCiDAJW1uoAvrazHkGFBany?= =?utf-8?q?1tPbeNOJcIqJlspWVlG2MTIn+3z3tPo0opspm3QxFSFonxkbkRv0fPRuC22YmVn2l?= =?utf-8?q?+u/1RIRTibAe1rPoj79Y3yyG5YIghWXHxGVL1Bh684CFdR7mLgMytitGOWX3XnlMI?= =?utf-8?q?LMH5UMdn50ANxARee7/XOPvNsAQ3ET8znPNlA9Di6aa86XWpkwBJhP0wzxMGnXiNB?= =?utf-8?q?Kft6uCbhBPl+Jd5HtKyTpU5zVmm6K4feNZve8rCXdZULnF+SwDBKB1RG2wm3xHjsq?= =?utf-8?q?wm1hnjkKslf6Njs2FAiy2PXnxu/3OVDYzG7edmAzM8S3iRrzks0Y3ds7ofdOtvxWR?= =?utf-8?q?au9b0IteE98zuUByt9VDmCe90VlawQH4P9YjyIa/fIsjXV+aJMYLKtFvcT7oUBySF?= =?utf-8?q?4gEfdtmk+4GxFoGAk+K5XKuw9Aax3rPHgPsFLAp4oLMDuAOjIRVtHZje4VDLV9DJi?= =?utf-8?q?RuW+M01VSoGoFDi/0h/Y/BlWOSO7Yt3zRCvnDKbUE0DX5tGPevVJ2jBbPN+sJQXpf?= =?utf-8?q?dfKDISnPL/M9lYbGHTdKEFdR9unuxXghzvr+SbQz1qiTEyak2Y2XI+dJYzZ3DY6xI?= =?utf-8?q?C1EpEZP4LzCQhnlCwezJvWDpaeGc+dWehqlJ0lPMo0SoK1qXM9TpnSUiCV4wuHUPo?= =?utf-8?q?15KCmVVldag5lO0zA17xw51BUGtmjV9qfPPIUdurN10gEwOsp8FaO76B0qA/5HTj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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: 2bd6d0bf-546e-464c-1d36-08dc80a38653 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:00.0946 (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: PK3jXAXn42tHcufiEVyrGDZSBvkzF+2+X9y50/g0auETSNQXv1FKLYV4jYBJwKFyLTV+CT4gE2ZdGV+Rs5KqTq1cXsRyRp5WPnHFw/2qgP3HsaUnmg75Gb/nByHqCIrr X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, 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 pri configuration offset is also stored into the PCIExpressDevice to make it easier to get the PRI status register Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 25 +++++++++++++++++++++++++ include/hw/pci/pcie.h | 5 ++++- include/hw/pci/pcie_regs.h | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 4efd84fed5..053bca6949 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1202,6 +1202,31 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, dev->exp.pasid_cap = offset; } +/* PRI */ +void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, + bool prg_response_pasid_req) +{ + static const uint16_t control_reg_rw_mask = 0x3; + static const uint16_t status_reg_rw1_mask = 0x3; + static const uint32_t pr_alloc_reg_rw_mask = 0xffffffff; + + uint16_t status_reg = prg_response_pasid_req ? PCI_PRI_STATUS_PASID : 0; + status_reg |= PCI_PRI_STATUS_STOPPED; /* Stopped by default */ + + pcie_add_capability(dev, PCI_EXT_CAP_ID_PRI, PCI_PRI_VER, offset, + PCI_EXT_CAP_PRI_SIZEOF); + /* Disabled by default */ + + pci_set_word(dev->config + offset + PCI_PRI_STATUS, status_reg); + pci_set_long(dev->config + offset + PCI_PRI_MAX_REQ, outstanding_pr_cap); + + pci_set_word(dev->wmask + offset + PCI_PRI_CTRL, control_reg_rw_mask); + pci_set_word(dev->w1cmask + offset + PCI_PRI_STATUS, status_reg_rw1_mask); + pci_set_long(dev->wmask + offset + PCI_PRI_ALLOC_REQ, pr_alloc_reg_rw_mask); + + dev->exp.pri_cap = offset; +} + bool pcie_pasid_enabled(const PCIDevice *dev) { if (!pci_is_express(dev) || !dev->exp.pasid_cap) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 0c127b29dc..198d6da817 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -72,9 +72,10 @@ struct PCIExpressDevice { uint16_t aer_cap; PCIEAERLog aer_log; - /* Offset of ATS and PASID capabilities in config space */ + /* Offset of ATS, PRI and PASID capabilities in config space */ uint16_t ats_cap; uint16_t pasid_cap; + uint16_t pri_cap; /* ACS */ uint16_t acs_cap; @@ -154,6 +155,8 @@ 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); +void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, + bool prg_response_pasid_req); bool pcie_pasid_enabled(const PCIDevice *dev); bool pcie_ats_enabled(const PCIDevice *dev); diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h index 0a86598f80..bb8791d1b3 100644 --- a/include/hw/pci/pcie_regs.h +++ b/include/hw/pci/pcie_regs.h @@ -89,6 +89,10 @@ typedef enum PCIExpLinkWidth { /* PASID */ #define PCI_PASID_VER 1 #define PCI_EXT_CAP_PASID_MAX_WIDTH 20 + +/* PRI */ +#define PCI_PRI_VER 1 + /* AER */ #define PCI_ERR_VER 2 #define PCI_ERR_SIZEOF 0x48 From patchwork Thu May 30 12:25:00 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: 13680333 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 F2355C25B74 for ; Thu, 30 May 2024 12:26:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqS-000798-G2; Thu, 30 May 2024 08:25:24 -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 1sCeqR-00078N-Dv for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:23 -0400 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 1sCeqB-0006Bm-DU for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071907; x=1748607907; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=tCBCyA3QC3xUDKpKmhu7uFqyaQRiN7sbA9LPX/ickcQ=; b=jGZtNmrpk2W7yawblOYzWUa7xq32pT8JyLK7sHOj+jeeXhd04gAk79Gn J9vIJ5vFcoXQGJYRMcqHFOufkx4Y+TTyub37qCyblOwRtCy/k6A+Vvief EqBBV1aMBum5wt2AsP8Scok9XHiQNNf9xdGnB5bBHACJudcsfiTL2mwui m+LiyVDWml3NyuwU1H2d8oinbyo0EQCY77NMO1HsK0v5faWrcop2EWGiP ZAnpymuoka3hV/+0GpzuxZMwN7+MS2p3iLJ37eUmj/qkG3jL0HpEuzM10 KosgzzbsCSwvNUlQQeNpUaBrslP1V19WO360W7rgjMDceWHYt6aVDfvvM A==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581113" X-MGA-submission: MDEmsCtzrkQ3an1DIC4XTmJRGd2v9fmMbMkrAmu7zCjTwJvzQOFKqKw0Wa6croVj5nujNjkqSpzkKRvD93hvknunVtas7+zhSyJMr5GVs4Kzk4C/lUYVMu+fDA8UzIn3LSiM1g8mqjPh8EF76z2AaAz81o+hfLyFZIUHVnZC9wvcTw== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:01 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YX5Lbg5jQavsx0vGtIwvNSvbLY09T5ec0oezCG5qGhdGPWfEAuDx7hhT6KHhT1zTdPt9yZzgywhmVbmXm6kmc7vax3fvUCQjC6akoPiPRebwOjqC+E50kUbFBxVqtso/lp/38llnPYirNYxhMHdLYGHnoLWifl3E15P1ho8KnEDQDLFZyf3j1N993+IG2LFZ8Tizc0ekOY569uAiVBRsPt8syzOa//0nuROCCqbaTUVLEWugob54xtl3ufROu6A/X7Jlqn/ZDfTbB7xxRp/Byh6xqdBijMhqOWQO1olZem7ig5D8ybaivqmgCQQ9o0rHlbCTPLM+jOmpPsCptGMmqw== 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=tCBCyA3QC3xUDKpKmhu7uFqyaQRiN7sbA9LPX/ickcQ=; b=MKouLe79O9V83CjdxMRQpaG0zIgkko8wYsFtP9pjdtl0EkrcdWFp1rj6Vy/8dgy8S7/hm85rnpt98kdRRQcw5ZOlhOiQBucshA5CJTzaY0sNDeNIYCVDRhjq6yapOX/20WfZDQcPKf0ncwCNGWB0GfX4IwQ3WyQkCWH3AhOR2AhYACPhpP5Tq80Spn0TDr6JAgVfOpcFPr5a1/YxIFk52FdXX2VFjefJ5nC/asP3XPwzXyFDS1dmVt+as3JgSk+N3uAF4YmWAOFJS2WkBiIvp2TYdvsC1+nL4A2qVwzdQAFAj8zWuLE75/n5HBggvujGpkOUeqoA9t5KwizTBE4W/w== 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:00 +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:00 +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 2/8] pcie: helper functions to check to check if PRI is enabled Thread-Topic: [PATCH v1 2/8] pcie: helper functions to check to check if PRI is enabled Thread-Index: AQHasoxkPVm+Hva2J0qbK0L/RbRYyg== Date: Thu, 30 May 2024 12:25:00 +0000 Message-ID: <20240530122439.42888-3-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: f6d05f19-6b2e-4424-14bf-08dc80a386cf 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?OoweBFWEvqDB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4lbQVHPDo7amF/IuoAhO3OskV?= =?utf-8?q?gXcZbU03x5wNWXdQUBp3uoSjKGUs5Mj5amsc9yc93NAZuquxZKXfjLp4GMrRdG9b/?= =?utf-8?q?NnYNV1x+8OwDT2mQs5SsHfLTNudruGcCLoFkXd5Y5k4p2cATOvOF7aX8XlYq1CPSa?= =?utf-8?q?YoosTv2ZIXjB9+8NZs0q+BZGF5/Yeg0dSZjgvTSjlW23BoGXKiXYS27GRNR7qU24/?= =?utf-8?q?FcabYLrsXmPnRJyTzKkyMVVz+f34AhPEzmroMM/QUg18TaoV2cmc9d6jFwCn5cDWl?= =?utf-8?q?a0PQL4tBi7GzTYcYodEWj3WsGYEFOuwx18H72Zrghr0tE/luZGplgEKGTo8XKc/gv?= =?utf-8?q?FCwo1gBiMNPfTg/yUIKbTnT27FT4lusVidEkevLw1VyUXILKVZTkElqKNT2GAlCxk?= =?utf-8?q?zxfj26+KRYKp6k0dhQcSrh22QSKyxQFNu7Q=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?MeV1uq7WensnmoKm5IAdzmNmtE5E?= =?utf-8?q?0lgum82Mf+68wko8MDupmVVIdnUF/yI9FxreEg4D/theIjC72McrxQK2ahFT7CNn7?= =?utf-8?q?AKzxWia1fStMRp0ok4oGMsUrImt8vkVwTmGFr1WGO8jIAvQqxcgqUKToNBq7hDlDC?= =?utf-8?q?H55gykx6mtA/lMVRgAmWeofBDguUZog/a/ssZ1uXSwUmT1rF1MaPpM5oos+TbH0Dz?= =?utf-8?q?++slibuf2cXN96+3zJA/0jnRHj4eVhnIh4ddHfGfTEgAeieqa9+LGbRXz4xEpxfzu?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lt7HbitFF1Y6p75D/3bWu0wGYQDqw4WjEASCdito9f67M+lHnpjqeOFLhl1qiEw2R?= =?utf-8?q?/+aUwnbrcNcjS52tN2fBBZRxp2wwWiB0UiNIWQN2B2zIVAJ82TiO7bIsL2sIlDfCD?= =?utf-8?q?rgN6cHsFtPlJaVK1ZXSfl6P49kGfFCivEKzhXW1jkv7NBX/1OI3NdXeI4WwrVAnjm?= =?utf-8?q?5lhQseTnp0HZPJXBdUS4+OyPPHAcnCGOo0onw1rdDuEc+t+8IZ54cs4IythrDO5d6?= =?utf-8?q?wrocqFkkQwETXkKm6glZmqUXk91F9EJt3EQqy0nzH936klx7QY24wnJk6pzsF51oL?= =?utf-8?q?v6AX/E58WZptqa60pkTQZdmAN8t0lccLs8vgbate+pPnuKv2qZxgcmRFOAyGpi6po?= =?utf-8?q?g+N+6Dw72hxIZGRJv3yezRoTAE3MK9/qARsy4yjgpAQr83qfl5liVNI=3D?= Content-ID: <35438FC9CF2B344E9BD802F41DF4AC96@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: f6d05f19-6b2e-4424-14bf-08dc80a386cf X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:00.9136 (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: WNhv5rNTny6DvUouGbTvPczPnbH964czV+yfGLwMqtb8t9xEeilxM/hqUcrK/fgGgrzXb87lH3MWvj/GJarOGywzYj4Y/6FqFa1zctqCLX7D2ry0JcsLp9HbQEC4VX4Q X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 Received-SPF: pass client-ip=80.78.11.84; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost3.eviden.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 pri_enabled can be used to check whether the capability is present and enabled on a PCIe device Signed-off-by: Clément 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 053bca6949..3fb6588c31 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1227,6 +1227,15 @@ void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, dev->exp.pri_cap = offset; } +bool pcie_pri_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.pri_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.pri_cap + PCI_PRI_CTRL) & + PCI_PRI_CTRL_ENABLE) != 0; +} + bool pcie_pasid_enabled(const PCIDevice *dev) { if (!pci_is_express(dev) || !dev->exp.pasid_cap) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 198d6da817..b976fd739a 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,6 +158,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, bool prg_response_pasid_req); +bool pcie_pri_enabled(const PCIDevice *dev); bool pcie_pasid_enabled(const PCIDevice *dev); bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */ From patchwork Thu May 30 12:25:01 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: 13680331 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 AD093C27C43 for ; Thu, 30 May 2024 12:25:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqL-00071i-1x; Thu, 30 May 2024 08:25:17 -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 1sCeqJ-0006zN-II for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:15 -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 1sCeqB-0006BP-BU for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071907; x=1748607907; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=IlN3tIaCmeHp1OLg27eH0h46h/eGp9wjTvAZbRgPYyU=; b=oSptrorolwoGgTek8BKuvxdfc0IKJs0X0r+cKi4/LPBVHmqobDEOGu+c IvzgM27U68P+ayiBAJ83qFdwz2dweohdl8wmG6lJmubXTu0GM5kxUCsqU NoTkIZL9QEPWwOXnUCSf2gkqS6uHP+pnsemP6FAlFmv2IlUJ5PYcORqvs b72+XY3QMUFS2YDu5fHWkH+sqMdpAY/AAsGk8FKGkyR/LQP3Wc+WJTt+E hTJi8NI+Sey37wm+PLJuFKHmXabbS4ujOIueko0htvIAxBRPIr8uurpW7 iMnV/3Yay+ttHkhLPZdp1Faovo/Qf14gcWp48nE/T7pKG9eW5ag7ePEwK w==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13582414" X-MGA-submission: MDGZrnJxGg9FrzMmr/4ToYpPJ800IPLC9OwFGM5b5D2xkM/tDW+tFDbdHbBwIZOaXrkla6g3UuN84/y3UkLwR1EBoVHxVPxtSIhdxQd3SKsxyesNqyJeLD1aj4lAO+3Z/R/+jWolV6/P81XEr5cL+DzwKmKgSlZfRYEdibkJegKyow== 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:02 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k97Fdj1nldz6lM+86aln4rgLSWK2boOUtVVBwl9dm+JJxAJOTGfvvgxKaOZSBFgFrSjUBGGno+D7MHvWWqOD+1y+QhB+Pgryarq+1bQg1zyf5sSmOgl1jF/632ipoRbZrSuaavaaOZBE2e5pTPCUJ0SO62fXlt2olLmsgHwopDxzQqxBxzXPU6Dmnp+irELYie+Us6U2av1VD9MMg7K8s475v4pHf1nwbOsgf4oOvjRL0V0W3k24Rh035WwNKsqTMIyKd/IYNlbG6SRmqYys9I0FJRA0h8WVXNUdTGQ6cClh1o5ybneatAejd/2xr0f4fNYTT59CEJjo/vD88be8dA== 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=IlN3tIaCmeHp1OLg27eH0h46h/eGp9wjTvAZbRgPYyU=; b=bF7+4g2jjcHfbuOdm42/K92dJrwf285oKDUzjnP6L3XwzEllvYEKNbMiy/kBKDib0fdQY9Yytq/kP+aDPDu66d73vuFt1GRPCVHLs/YWqtamkeVLsWHW+KPWKFNzKfV+sp/2X1gpcXmSNfZ7SdD2kbV7OxkKSJ9Q9NgNwZWcWoEzYhjC2nCvmTEks0VRimVJDqB4WNOJ73RqBBt0SupVtvNc23yQClSZYSDYzwrPsGO/KofpL79swd9kQ+y08+lGsfD4B+R8e/Yb/rFxOsK/n09cpJU+EjGAo1GpTjJQjqzeU07XFkwHo+nzRBbNz2KqODTpMVglx1r9hiTU1Igatw== 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:01 +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:01 +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 3/8] pcie: add a way to get the outstanding page request allocation (pri) from the config space. Thread-Topic: [PATCH v1 3/8] pcie: add a way to get the outstanding page request allocation (pri) from the config space. Thread-Index: AQHasoxkx17E2CeSRk6sKhg4F2Rw/Q== Date: Thu, 30 May 2024 12:25:01 +0000 Message-ID: <20240530122439.42888-4-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: 61f153da-5b18-4385-ef44-08dc80a38738 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?UfbTOvkUlCmIPAGC83gK6t9DtP9FSxw?= =?utf-8?q?nqsnPlcDHlYUu8ICe7e4Ex9gBFd6k4kVRBNaNyAQFWZQtezWn1vAtRQh8uL/XNZXf?= =?utf-8?q?npfrZvekULYOYkTc8OmUZqk/DWtbJ1JPNFw+ktxyzOWfCBjXidmeTVNSYudVw8m7E?= =?utf-8?q?dXvGf/kwGLrpC2We7ywxRqjxDsWLXa3vggli7SMrm6L3xc2SDC3YgdK//N9zlIPIs?= =?utf-8?q?t54IM54jKCy/HfHtJClx46hK/C1gs9JbpOpaNUlox3g9zTk84dfph1TKurN0mg4z/?= =?utf-8?q?vc5hMKJFC9VOVZmVpms6OXS2LWOz7EoABhXxbGyOGPEtbGEHFzaUteXcy0Gu8QWy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?ADSqImpLVQ9sIF+aLkIAPRj7SQ/LMPxmOCQdM7bxVVu/Qc0fvU0GKkdJvf96WVOot?= =?utf-8?q?DzfJSKRZKH/kbgcBMhz7lqqQi2ymtZSQ7CA=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?b/p0ytNFnnbOtXP2wLLTPVC08HoS?= =?utf-8?q?PNojFhzpHbimDb2CNp2b3CGBonEViPxTsYA394iPvwEtX+2zW4hbZiTIoQRA16dOS?= =?utf-8?q?eRYceekrO3JMaJuL+dTG02S4Nte6Oti362l87+RVy8qBf+2cgTNjKiezMxYncgTw+?= =?utf-8?q?QpSydwNCc79+wOu6yepgip+XWbWr8qispt9sVhfCPjWmbZKU1G4pgGe+fcikJl/sV?= =?utf-8?q?wWZg3YT8Y9nESl7aJ83CIA6kDP6TCuvOyV5ryb5lV9xffVA075WDWrF/fM12dKutj?= =?utf-8?q?JSVtw+69+f1z4XppwcAeLwhQUNQK3lSgkv0kTzcS1mTJWguXFQfhuDZlZyofu2xU/?= =?utf-8?q?u6qiDEJ/t4VHP/tEhOrWnNha1iBH4smyyD2wOgfvF54m/5B2Rc72j0apYA2ia1CAI?= =?utf-8?q?oyDsn3FY4V2nBj2jAUl4WaxN0lJtoRqpZNoOHQqHy2eTjWl3HG4VV5ShSsEQOukEo?= =?utf-8?q?qaAgaZTZNKoVvcirX80JvAFNdDMt7TdAeC9qqmBYNe6dpBBY3eCPrDrNVa0XyBsRt?= =?utf-8?q?Ky7foSNPPUwsvBeep2p3WOiL4gNHudX/bwBSmPjiXunDCETgQdFwJHqzmsnngmaKI?= =?utf-8?q?xwU5gB94MAl5O+NL318zM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kjkGfpnsWqo42gZMO3H4bE8n7pueXyNk7HM?= =?utf-8?q?vWsZrX+ZnjbMZFJlvBcNXFkSv+/J1u9buGKtkzkupWOzHNr94UMP2Bs=3D?= Content-ID: <146F358A85B7294D98209D060FF9792C@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: 61f153da-5b18-4385-ef44-08dc80a38738 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:01.5987 (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: 0tmMSh24gP8rnsG51pEQvtowUUiq4IR4W+ZS6DWNyvLcdM8iAMwiw6iI5X4Lu2F93j1Q/ZwDplW6HdRzHBvZ5NACq9GqQAaKRh10RT5gY7V/HbmDqp2Gky9FmbADJkEL 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 8 ++++++++ include/hw/pci/pcie.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 3fb6588c31..d11b11fc34 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1227,6 +1227,14 @@ void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, dev->exp.pri_cap = offset; } +uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev) +{ + if (!pcie_pri_enabled(dev)) { + return 0; + } + return pci_get_long(dev->config + dev->exp.pri_cap + PCI_PRI_ALLOC_REQ); +} + bool pcie_pri_enabled(const PCIDevice *dev) { if (!pci_is_express(dev) || !dev->exp.pri_cap) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b976fd739a..7eb448148b 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,6 +158,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap, bool prg_response_pasid_req); +uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev); bool pcie_pri_enabled(const PCIDevice *dev); bool pcie_pasid_enabled(const PCIDevice *dev); bool pcie_ats_enabled(const PCIDevice *dev); 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?+8KwBX6xYnX4ZBL8D2KBtosSxMRF6CJu+QvJnUmhF96UKtmnL/onxQKhI1GI+fumi?= =?utf-8?q?W0z1lifbaFwG8OjGudSljv6U7nFVrBlxwD8b451nZUt7Q2I+ji5Ce1IPw99CnBRLN?= =?utf-8?q?L8IVrNnNcGxAcsOKcvdWG/scI5zi7wEPqYAgf0/SU7g8s1UWb/rc6+7L4CFmk+AAr?= =?utf-8?q?mRGT824QnB/vXxraiCV9FL725l/LtRkSeV2KFrB4ial9ouW6Fbz5fnU7GolTzCsjn?= =?utf-8?q?tVXf/TIWNU8kQu3PGArQBBP9kuC9YFY4n7fxEZS/LIRGZ1oSsrwlELwTHmR4IVocJ?= =?utf-8?q?5vBBUdfp07dclZWqabcHGywHoZV2lJ6JwVKGIoH7Hf33TCzRjqBk8tir7BgyhgEx+?= =?utf-8?q?LJZLrM+Sn3HqAYBcn3Q+h3KfnAcj4OSUhc4KEbYT2KtQqnWLAbQF7UnfJFe7XSfOY?= =?utf-8?q?qHyFnkdngnkUb9AWJ2LOLFuQcmMjeGqxF95HwC8DcpfoVAS9hyA5KbcB3RITGzclr?= =?utf-8?q?3x4oe43i5NzeQcegdGbjg+PDjaV49HqoGr5Y/XQRf2Or/gouK6LoVvl0Kk6xN65tO?= =?utf-8?q?dXSWTCYnKqvbhNX0jmDDbRQuGc6vhKMomJfr73HgfcjXmtod78RLbDIXkuisSweNi?= =?utf-8?q?jfQrMZOVVzDUdGSPVEbr+wR8jfZP3kgyjOcOY2imqXKgY139MzI9/H1aDIc/p4crC?= =?utf-8?q?TOlzZfCp03jAg7gDhH6k6wZroL9PSv8U71Mxf8Nj2p/sILGgAn8GPZQ6EV2k3Cep2?= =?utf-8?q?DGC/+97y9GihEYpRqgmG6Bm1YKDAxaxdOn+qg6olGr5BcfQYV22qEd6VOvAfcj61E?= =?utf-8?q?XZGYk1HG7yVVAeohQTbudM/ul53Sw1E9wt294lj7ONeEDgOBaY5xuHn+rNhVTXPEo?= =?utf-8?q?FiQfuZYNy10/3xHzpA8VyKyNxBXUv3muatw=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+ejOpEL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4VRCzSPU2m0xDJmLMYC5Dsn0EBwcbqrk7j?= =?utf-8?q?9kcp9N4ZXwwf1GbdkBk0pQZUZSEseT9BVrfxYafEqWfY2YI1WP2KPiGfrC63LyILk?= =?utf-8?q?HQm95znagbWbk+IWkN9girbw5ia5gdomkt0p9dh9W0IrJBOz7jvEtRsF8NOgQBLIK?= =?utf-8?q?R183zuw5f1vsbEeZMCwGMw262U5oRuVbhSYgf8j0v4melPwsaBSqTWVgFMPHwYmmg?= =?utf-8?q?UNEnf7nemOkVHcebOYUxIncFYRri2E+qREZoizC7klWUKGcmNq4G5lyDoQDnRU02q?= =?utf-8?q?GtOFzD8uVsvYFaPFNvQ2GjPjjePU4jM7sQL4V5yrNShXo7qmUg7LqCuzLK8GvRRbp?= =?utf-8?q?XuOqsv/r+H/RnB+35+QHJz+jJfw2lmU5+sfnawu3s+quwaSxkGoyCGbW8Reu9sE47?= =?utf-8?q?om9g58WpFn2ZcD/8wtpYqmv0yZqbTzSUl+YIPW5AqY/z2eDGDMNH9t45tLHei2754?= =?utf-8?q?7Pl4mwFOq9Vw/hZFqT5qMjdfM4fUs0TT6Zs0M5Zskx3PrgQd28pO0yRgasHTauesX?= =?utf-8?q?nvQz+wRrewlb1aoSI+TWdeBWYU9uzSjHT5MCjbQGdx6sFcosfMB30uUaXqJSoTxsg?= =?utf-8?q?nANXUS0fL07/CHzTgwLG6NY37mG0mh4myTGvBvn9PnhfDYk7hh+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; From patchwork Thu May 30 12:25:03 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: 13680348 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 64E51C25B74 for ; Thu, 30 May 2024 12:26:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqO-00073o-9B; Thu, 30 May 2024 08:25:20 -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 1sCeqL-00072p-RF for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:17 -0400 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 1sCeqH-00060c-3F for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071913; x=1748607913; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=/KNC9YlY5dCStxnGJESvt06kpnylow9D0BXt0DFqGPc=; b=mCM2Vo+EUPllv77ox8NlC06wXaoor4vRDaUk+Nfjd5LB+z87JmeiKN9+ V0kE2GCncucyVkIxFArzapp/IXDQGG6/ZcOgvBxIGhZfcndoY265uANCk JVal2dBhIvivfCYEtxiEIBA+r8L83YnUpxg5KdY5MReokz8qhAP4tb5G7 g+hjvukmJTR6uWksHeul/jagT/7yL4copq7MrQL4ro/JD0vlk521D2Y0U DIJgjPPVkCsC94Uz5jZsCQMDOIWHdiRUcA14knUn7SRimq6zQp1Cl9abP l0VVxAKGEsRYa2oCzRCegS2KgtdB/EM+pPr8ehEOY3/tt9VwUuSzxIFxO g==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581115" X-MGA-submission: MDGjkgWSbnOmxXEr9n3nj4xnTvOvTz++DNMLrrI2i7mIkF19EKy9SLv2BwvdW78SzO1Q/OmMHDlY8tnoy9HcXJtZTXXyoIoZJfSnNyKgWyaP24k4gtU8YXIvqY06EaOZKFiTWLQ+XLxohd0xrgclD/pBb389T5wCGSkdqdynGg7kNA== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:04 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZ5p3tfQWys1jZkUX7RRszpJE4NXAcG4I/Yo9V4exvzk45RDIcCkOSwOQ09sAYbnuBxJ3+P/kapwMt3IK8LreGMd73pP0Wc9ZJLnyAVdSQsXUinO2gJQZePyuPtXkikY5DmenoTVFNg9Kut3qxVzielCyvMJWp15s7TnG1MKH8VoPNR57wHxAHTjCCn0Bt/6cVPp0YIBmTSegEzbXu89ZSP5iAw6ab3vA9JISXjRW/xBkJvyFSdF2eXP49wdU5X8xjsx4J3P5sXgXjFTEZvi2XVmDN8b2KHl7+zBpxNpl8PBtjAbiMKrPkEgMVOlv8nM3xlujnA0FxoKuZ8/gykatQ== 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=/KNC9YlY5dCStxnGJESvt06kpnylow9D0BXt0DFqGPc=; b=fxKdN0N1/EisrjBTWI8XLjXttiGH0fdlUW4quCNNiL4/okzn4hHe0wZQQVj5vujuRFaPRtrmk6pfV/dNqbbzOy4jo30XKsL7tF6A1Y6+m+XqLMEFBGvqjIx+MJRTIXR2KVRjN6gG+vOGtJ+l3RpNNk7a45dvu0/+DyxVL2PX3Ox7Q2krsw2kwzdHxO6vOdJZW2t7AY4gPO17WzaACjSlPx/4XJrYMzoG3z+oxdGzIeVdaWAd6fNHdJ2/bfIMFCggkHGj5z1d4Kcg+mm1O1+5+MIi9/EXrvWBEhN1LTlPwC0v9ZyqE4aFtDyzc83w9n6IUiawgnpC+ex2S7xkp1M+pQ== 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:03 +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:03 +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 5/8] pci: add a PCI-level API for PRI Thread-Topic: [PATCH v1 5/8] pci: add a PCI-level API for PRI Thread-Index: AQHasoxlDbCdNhpNy0WmSlq+hx398A== Date: Thu, 30 May 2024 12:25:03 +0000 Message-ID: <20240530122439.42888-6-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: 020b8aaa-8221-451e-cc68-08dc80a38828 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?3RXjLkjDIxd0yBSV0FsUe0s/ga6hR+j?= =?utf-8?q?R0q5oJEUuZkxK3iDLKAuHYi260mwOSPkP9OW1BdXXN9MtUDEUU7SvuEf00kIujUGD?= =?utf-8?q?qak3x0BfFj6HJoxF+veaL+FA9iolJgwwkD9SUEP0CfmHPQDMKfwKcQurXrIEl4uIn?= =?utf-8?q?tl8pssG2luHJ6KBn0XkSa32NEtpb3n/iUCjWihs5e+VQOVEzktS9yeOeo//V8UmGf?= =?utf-8?q?DllDEXG87OUAcuyRruglrTc0rW4qoCZsEcpopTKyhg7aoqiFyeniNeKGDdso5mwwt?= =?utf-8?q?TaFz31ua9NIMgO8wOr9MKrdyh/gA5VyUVute+sS1Ifk3S6DfH/0AMpabpw3dGRHab?= =?utf-8?q?Lo3dYa8V5Dmq/W2fyvoZWgXtub6b+SJkbwZ3OEMiUSPUvV4iKtH9PgjaJyJHExdQ+?= =?utf-8?q?Xg8QygERXoyUDPs/Q43AcIE4slx9PpA0GuijB3Rql7OVDDz5xk38Wb2VQrNFAUiNj?= =?utf-8?q?CqjrfyDnVLVabwPtpK3al88kmQ6nnmDSqA8YQy/Udtqz7z+TuzM2nNLyn521yz6DY?= =?utf-8?q?2ukZOnVhvZXx8PALplPVZtNgX3xTIUuG7jsAJ3XzJfFvJFnPv6IeqFfwXAZ30mQm4?= =?utf-8?q?DjUZucd3LJB3Yya5hZ2PS4dMg9l4xJrtQT5llFrjLBCZmk8kadGuDHesQWNN2qoir?= =?utf-8?q?CaaEI1A3pcgHGda1rQ2essLpvPs6DN6/jLXhHYBzM+NOeRehG+NktAOFj1SxuKYts?= =?utf-8?q?lU+ZtyK9J1Gxe3x1N7yoybW9RhUuum5aZZ8IBkiHp8G2rkYyOdOroQZmbu+QvHUSO?= =?utf-8?q?ovgdPWrGuAbj0ehYfncdEfTqsR5taUCIVlKWlUb6NZRnpYgE56oZmozQmREYyp3YT?= =?utf-8?q?irU9BgfYAr/lowcaJ8IEPiiD1qi4itFq1Im7oO4pD5bQ77cHgY9/FqcwUWGeeqzoL?= =?utf-8?q?Su9eXp0VjM568IBprW+JDexS9X/kQaiaPXxhs1/V8qITAHwAFm8agr37kdJJd8Hxw?= =?utf-8?q?cPZ/1Z+EK66tRLQvo7A81AMBYgKUGTLDK++rjMseE4xyNb9+uRgPNHqscv1p2BbtS?= =?utf-8?q?zLNs942TLJ6PyR+k3Aj5BeoHX329NkUSOVcpnfIPMAziMYiKumUczpmYrX6mgahAd?= =?utf-8?q?4HDJ7fflnvmrgF8tg032gjApb/HfagP0ohYl1P4jFjcsFnWnMAr8xLetvZ4jf242Z?= =?utf-8?q?uzOttLCKauTbdcrNgy/bCWOmYfzf0qjY7GKtrTRYdwz2HfB2zAx2G9ElSUgIIMlcM?= =?utf-8?q?vuNxMCVvJ06WFt5zEwg94K5nyetQYRXDllRMdoFU66GbTItNE8JVfH+Kd1GL8kyoA?= =?utf-8?q?RA0T+vjjK/cnuV3CAAPA6+vHicSPlXHZMTg=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?RQMmiXJRAPJGw6Bxb7M95Qppy5VJ?= =?utf-8?q?/Rqpo+2X3vUlmKO0IRbMeZL8vv7YV3Yybypt070Y7qyzBhBBnsSvclfM0XjE15Tcp?= =?utf-8?q?TmLubfowHhupf5Po94KnqZsfxvpwqGDDmz63BEtvoo+OQV23R3GC1UXiM48gjjU9x?= =?utf-8?q?h8EMFTfawp7QtQqPt+A91DjFmRn1qj5TObLTdby4FHQvRjejp+UtHpPeuVtK9Iz5L?= =?utf-8?q?ym5zNQV4TsciAvtJmJlZ/YbbZdjFbMUWWA9bhGz4bteqjOE7HrshmRjBLOPvlAdFy?= =?utf-8?q?NV7BtRwJ+ApZ2wTJfs9NT1MdCSSTAhTPPnibicslWpTpe4D/I/7cGk1GU5Epd0jqN?= =?utf-8?q?V9PoaRvgHUZDsFxxn6V32hce0zBj7BvvqhiQ72ZrGaBR7m/wd/UF+Mw04UUzewCoU?= =?utf-8?q?JatKYFW72AulGPMjjwW+P7a779ABmGIto0WCZp+th64yA08vaH87y1yjn0CfVvs6X?= =?utf-8?q?9DJbQKmTcQda2v2MCTuYATj2EV2FJ7iQbu5H0Znmdt5pajaQ6ftbLxRHMIICzrTJA?= =?utf-8?q?4vXysCbi73AOMTfVMazfjDD5zRv/OT4vNSp/s3nrcZKb8Up0hytKH5QcoHyG+wCCy?= =?utf-8?q?bQ33xCl05EdfPsDQWS06ZppDXKJyXpnDWCTdEo+wWl2kpe5A59WMzq1KQMLqYUBzv?= =?utf-8?q?1ykJiTOCAMkT51+9CE0/I0A/+uEUm3mji0w+PHNlXEKTXFDoxhzdp/YWvHJyCPWaT?= =?utf-8?q?RYgCWKpybPnJ8jSAQxsmjj4mFJ6G/9vqhR6d1Xls14Q9zs8J2WtMJujSzmfR7TNRH?= =?utf-8?q?tbTSLMV37cUtXDYbru1vAcxZD/eyp3c9C5YnYovhQoR478XVqkBMO5OInWg4ztqZN?= =?utf-8?q?zJiFkmvUtSPTf9fHCBtmKfD5YPxRRODXCd/mpsTja6KrXWK1rHAHW8IlYe67qwPGE?= =?utf-8?q?gBOCAn6dfdPx+NtO1roqTt3gc1uRSwsMjyYBA/6eKToIa5PJEtxpTREneK+fGy8bS?= =?utf-8?q?mzb1fDiyTr6RkmW1zcwVBWoA2oYyS6J4gxabuwYXYBAZEK6e89iawCpo53TsUglB9?= =?utf-8?q?lixyjjrT5vWGQnbQCvJu6wB9WSsfOXtVFWQCH6IdEXvRH5THYdMAL8Z8LG+TEiqY0?= =?utf-8?q?xpNkP8zImZ0Hzq6WdJ+HkXwQP2heu9WJl8QFZl6k2ftavWMnwpdJjktlz4/eZJfO3?= =?utf-8?q?uTBq5o/XB215lC0DkPcrbMTDaS93NIeMHPaiKWnGoJDzH9GW6p4/3OHRLlJwZebEH?= =?utf-8?q?Zkt7X30FemDqAkBv6UOQqnqmN4L4TMmw09oNAg/PJxt7TmwdFtDR4zAZeeF+Q4hi4?= =?utf-8?q?Z1bGzV/ZPmZV21w1+VTljWDuvehJo90Lv9eO3LNnVv+3DbbyyGzOo5pIXw8kt75c+?= =?utf-8?q?DFWHnTx8nsQRvNxKE+w0TD+NJ7WRSHbu1g+rxjjZCC/moF4R3XWsuWrXqJA54e/b6?= =?utf-8?q?asM8wUgUKJSPd+EFiqF3+QAZrtXYVzdMfh5c4XvE5TSkU1+DDRUYfnNIRSchuFITF?= =?utf-8?q?B+ePolBPeJ+uANwo8piy6ITgeIZjpwMxHExUIRL6EoxHSCAk8l3X9Ks5ZmeRnytvU?= =?utf-8?q?CfExd4ygmuaEs+gbV+KMIXfg+kb7WylNgpYTkJ1YD/BahaGzev5ELEA=3D?= Content-ID: <8281B5836E2F704D91A22E38E442386F@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: 020b8aaa-8221-451e-cc68-08dc80a38828 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:03.1956 (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: VOeU5bDG+bE7EsRvy3pmnDMZZ3/dPVBLT1u+uxXBzVzlegbseBDmfORYnXRcS7EsjSH/UiNizpKl1rDRBF97EPbdFjj2zW4qgU3ZHk/WDmVQnGOCE8rqOnWt8Jcxzi+P X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, 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 A device can send a PRI request to the IOMMU using pci_pri_request_page_pasid. The PRI response is sent back using the notifier managed with pci_pri_register_notifier and pci_pri_unregister_notifier. Signed-off-by: Clément Mathieu--Drif --- hw/pci/pci.c | 37 ++++++++++++++++++++++++++++++++ include/exec/memory.h | 35 +++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 45 +++++++++++++++++++++++++++++++++++++++ system/memory.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 10b0708130..dd854fc18f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2833,6 +2833,43 @@ void pci_device_unset_iommu_device(PCIDevice *dev) } } +int pci_pri_request_page_pasid(PCIDevice *dev, uint32_t pasid, bool priv_req, + bool exec_req, hwaddr addr, bool lpig, + uint16_t prgi, bool is_read, bool is_write) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr || !pcie_pri_enabled(dev)) { + return -EPERM; + } + return memory_region_iommu_pri_request_page(iommu_mr, priv_req, exec_req, + addr, lpig, prgi, is_read, + is_write); +} + +int pci_pri_register_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUPRINotifier *notifier) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr || !pcie_pri_enabled(dev)) { + return -EPERM; + } + return memory_region_register_iommu_pri_notifier(MEMORY_REGION(iommu_mr), + notifier); +} + +int pci_pri_unregister_notifier(PCIDevice *dev, uint32_t pasid) +{ + IOMMUMemoryRegion *iommu_mr = pci_device_iommu_memory_region_pasid(dev, + pasid); + if (!iommu_mr || !pcie_pri_enabled(dev)) { + return -EPERM; + } + memory_region_unregister_iommu_pri_notifier(MEMORY_REGION(iommu_mr)); + return 0; +} + 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, diff --git a/include/exec/memory.h b/include/exec/memory.h index f4780d3920..71bdd7e64d 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1870,6 +1870,16 @@ void memory_region_notify_iommu(IOMMUMemoryRegion *iommu_mr, int iommu_idx, IOMMUTLBEvent event); +/** + * Notify the device attached to a memory region by calling the PRI + * callback (if exists) + * + * @iommu_mr: the region in which the PRI request has been performed + * @response: the response to be forwarded to the device + */ +void memory_region_notify_pri_iommu(IOMMUMemoryRegion *iommu_mr, + IOMMUPRIResponse *response); + /** * memory_region_notify_iommu_one: notify a change in an IOMMU translation * entry to a single notifier @@ -1944,6 +1954,31 @@ ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, size_t result_length, uint32_t *err_count); +/** + * Register a PRI callback in an IOMMU memory region + * + * Return 0 if the notifier has been installed, + * error code otherwise. + * An error occurs when the region already has a + * callback configured. + * + * @mr: the target iommu memory region + * @n: the notifier to be installed + */ +int memory_region_register_iommu_pri_notifier(MemoryRegion *mr, + IOMMUPRINotifier *n); + +/** + * Unregister a PRI callback from an IOMMU memory region + * + * @mr: the target iommu memory region + */ +void memory_region_unregister_iommu_pri_notifier(MemoryRegion *mr); + +int memory_region_iommu_pri_request_page(IOMMUMemoryRegion *iommu_mr, + bool priv_req, bool exec_req, + hwaddr addr, bool lpig, uint16_t prgi, + bool is_read, bool is_write); /** * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is * defined on the IOMMU. diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8adba6af97..76a6031d8d 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -473,6 +473,51 @@ bool pci_iommu_init_iotlb_notifier(PCIDevice *dev, uint32_t pasid, IOMMUNotifier *n, IOMMUNotify fn, void* opaque); +/** + * Perform a PRI request + * + * This function is intended to be used by PCIe devices using SVM + * + * Return 0 if the PRI request has been sent to the guest OS, + * an error code otherwise + * + * @dev: the PRI 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: untranslated address of the requested page + * @lpig: last page in group + * @prgi: page request group index + * @is_read: request read access + * @is_write: request write access + */ +int pci_pri_request_page_pasid(PCIDevice *dev, uint32_t pasid, bool priv_req, + bool exec_req, hwaddr addr, bool lpig, + uint16_t prgi, bool is_read, bool is_write); + +/** + * Register a PRI callback for a given address space + * + * Return 0 on success, an error code otherwise + * + * @dev: the PRI-capable PCI device + * @pasid: the pasid of the address space to install the callback in + * @notifier: the notifier to register + */ +int pci_pri_register_notifier(PCIDevice *dev, uint32_t pasid, + IOMMUPRINotifier *notifier); + +/** + * Unregister a PRI callback from a given address space identified + * by a pasid. + * + * Return 0 if the callback has been unregistered, an error code otherwise + * + * @dev: the PRI-capable PCI device + * @pasid: the pasid of the address space to remove the callback from + */ +int pci_pri_unregister_notifier(PCIDevice *dev, uint32_t pasid); + /** * pci_ats_request_translation_pasid: perform an ATS request * diff --git a/system/memory.c b/system/memory.c index d9d66ae2e1..105c02b686 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1765,6 +1765,7 @@ void memory_region_init_iommu(void *_iommu_mr, mr->terminates = true; /* then re-forwards */ QLIST_INIT(&iommu_mr->iommu_notify); iommu_mr->iommu_notify_flags = IOMMU_NOTIFIER_NONE; + iommu_mr->pri_notifier = NULL; } static void memory_region_finalize(Object *obj) @@ -2025,6 +2026,45 @@ ssize_t memory_region_iommu_ats_request_translation(IOMMUMemoryRegion *iommu_mr, result_length, err_count); } +int memory_region_register_iommu_pri_notifier(MemoryRegion *mr, + IOMMUPRINotifier *n) +{ + IOMMUMemoryRegion *iommu_mr; + if (mr->alias) { + return memory_region_register_iommu_pri_notifier(mr->alias, n); + } + iommu_mr = IOMMU_MEMORY_REGION(mr); + if (iommu_mr->pri_notifier) { + return -EBUSY; + } + iommu_mr->pri_notifier = n; + return 0; +} + +void memory_region_unregister_iommu_pri_notifier(MemoryRegion *mr) +{ + IOMMUMemoryRegion *iommu_mr; + if (mr->alias) { + memory_region_unregister_iommu_pri_notifier(mr->alias); + return; + } + iommu_mr = IOMMU_MEMORY_REGION(mr); + iommu_mr->pri_notifier = NULL; +} + +int memory_region_iommu_pri_request_page(IOMMUMemoryRegion *iommu_mr, + bool priv_req, bool exec_req, + hwaddr addr, bool lpig, uint16_t prgi, + bool is_read, bool is_write) +{ + IOMMUMemoryRegionClass *imrc = memory_region_get_iommu_class_nocheck(iommu_mr); + if (!imrc->iommu_pri_request_page) { + return -ENODEV; + } + return imrc->iommu_pri_request_page(iommu_mr, addr, lpig, prgi, is_read, + is_write, exec_req, priv_req); +} + void memory_region_notify_iommu_one(IOMMUNotifier *notifier, IOMMUTLBEvent *event) { @@ -2085,6 +2125,15 @@ void memory_region_notify_iommu(IOMMUMemoryRegion *iommu_mr, } } +void memory_region_notify_pri_iommu(IOMMUMemoryRegion *iommu_mr, + IOMMUPRIResponse *response) +{ + assert(memory_region_is_iommu(MEMORY_REGION(iommu_mr))); + if (iommu_mr->pri_notifier) { + iommu_mr->pri_notifier->notify(iommu_mr->pri_notifier, response); + } +} + int memory_region_iommu_get_attr(IOMMUMemoryRegion *iommu_mr, enum IOMMUMemoryRegionAttr attr, void *data) From patchwork Thu May 30 12:25:03 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: 13680336 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 D4A67C25B74 for ; Thu, 30 May 2024 12:26:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqM-00073O-HE; Thu, 30 May 2024 08:25:18 -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 1sCeqK-00071g-V0 for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:16 -0400 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 1sCeqF-0006CX-Mo for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071911; x=1748607911; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=/9deiCr5zfRae8uKC+gcrmZtUgeFngGPj+Ci4oAplW0=; b=uHZEXPA3fTawgpFko+hD1nVh93fG/aYysdCgtBUor97IUHHliwBt28bx PHjuobzM9Jji6eLHnk/QS0adlplgG/vw7d0+YD/zT+4qhkqPNnY10oDAy XExPQItjloOLJY9IlpC0OwTm6W1rPCcZvQu7OjGFtYg4wDgSKPCMDqItk duG3YUzcUCLtNz/5mEFcCE0Q5xc6hwrDQmqppxhVMYVz1wHA9t1I0zU8T T4DQY7pWCNdKZBCEe5UZTE3ILRvLoPap3rQ1JIs1kWwVaL4+33KrgzvQJ Dcazw391w9U9bNf3YxDzuzRAaoff2psKeON7pyEk7v4KHfzTbOmodX5OY A==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581117" X-MGA-submission: MDFPc2Uw4XwEguz5Cogvjh6ocKJxlqnIxpyBmpBHb5w2ZCEwHYNlCyVyKsp/WInwN4PXG6Xy38PcGaxmEjmo9Gy4JBE+gnPBGVhjXkNEk9H6bf7fRoaqE+FoHN7jfOYvB/YqyvX5vW1TRHObsH80qEVYapT2nZX1GhV8q2ySuSEQlg== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:06 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xjqqkyfpv2P987VXZxxalWOJJbElnjkfhhHFySOkCgTXaQUghIhy0nFhaysm4LJO+JdhEB5hbLhe4p/5ze3b20QQSUt0lU78BkgFoYpopBkAD/jweA2fTj/xzwdBLkVVi2/pP73dyFQXHw+PFQUH7r5S5BQ9tU97XUcEq3fkcTkWdvBnGUCSdzeFpvGQ2Azt2TviRd/cuq1lkMY16yr1hwrfjUE4zbMN2eooV50FQ/Jw7+oNbvkI6KlGbYTQSonOZCTTwC4Rf/xm8NaGWzIWKHJ07tGdlIuIjXt/NPJ3AvI/7U6D7fERMi37f2Q1E8EsNQfR+4LuugzKjl52uwm8xg== 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=/9deiCr5zfRae8uKC+gcrmZtUgeFngGPj+Ci4oAplW0=; b=CERh5oqm+o1+YnVKEOz9UQCqe+OzRwfAM0Zdbq0I55f3LJNNbKC0K/kzV9KvDaxr6i5LshrzTaM65SxI/uBPw4xRENqjv9RJBu7mk3cvxWMEzkESEJNZcY8p0QJDTTaXA+TS5H9nW+BrezSbySr7De2Aj+i1M7QG0a4iyW/rvSBdsyLaUHUDHy/FcZdWgtqjW1RpMT9oA+OVbk+kkYZlQRRD/cawxBbZs0f/jvuabDDRQWBZN4JxI4JRMlgL6kKPc8c8W5dvcTcWcMfHDt5Z/8xlYKMWEAxVy+ej+a+fyhx6S0YJkjpolMAmNk3j06/ti+BsQ3pcOAopeHXFgKZoCw== 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:04 +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:03 +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 6/8] intel_iommu: declare PRI constants and structures Thread-Topic: [PATCH v1 6/8] intel_iommu: declare PRI constants and structures Thread-Index: AQHasoxm243WHLgbkk2BAL0jzD3XeA== Date: Thu, 30 May 2024 12:25:03 +0000 Message-ID: <20240530122439.42888-7-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: 461e6470-3af9-4a5c-4178-08dc80a3889b 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?Bkomr+JfSaGR1AZEI+khG/XBocoEBix?= =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?q?tI9DTtPzjdgLY6xkHWbyUIqCYSlWtf5VWJ344k/cHsGcnJ+WWb+1iybHLuDrgAo1x?= =?utf-8?q?mc56NpVk/k9ahvPhs+ZbJ6N9rtxJZown44DxdU3wMWXCu/H7XBit0D5/SkbppfLw2?= =?utf-8?q?JjCYV+TXlhxeYGWim/gRgKniw69yWM94BVBiBCBzIyLJuWM4AlGGP/+wEeiwini9V?= =?utf-8?q?4d7l2zi8ml8odrjSpU4UauMNAOBWJztoMEJ/v1AmqIK4eE7PD4ehKzg1W69Nv7+Ux?= =?utf-8?q?A3yNA9wMOdtKfmrJdZOXFAhERM8KF3DeI2qGx5LWaWeXhQSAzWf5zY7lEH7ZrgX3X?= =?utf-8?q?3oQ+Llq3uQmqkXU0h5LhDBh7hrBCUojOrA/RmM7/wdqpo3MA4wTZ7RZtAKKN9/gtf?= =?utf-8?q?55WI1/D6xKjn6HcCn53ZrOnIBUlIsjEnJbA=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?mMy/TrF+gCFlF7YXu0Shewt0JtXp?= =?utf-8?q?bbXIHkmbAMaoWFMiHR768wayQXYQaq9y3XpKzw+rjcCBbRRoANDecAWFhEjoP/jC4?= =?utf-8?q?HrKhdg0DPtQuQMdpAaEy2pqt2XNCRp/3twsRDZlLFOeOPKFfaj4oNizfrCnoxkLQp?= =?utf-8?q?S4iYt2PYtYLgHFuVfsPrv6aQ9L/XC+pCvzsUwSCQjYEQBLFDgh9C+h59xCbPQr/q7?= =?utf-8?q?AbCTaADDeDCYDwFVnfj0n5STaKcAXVXp2ekN09yJTu/cvRcoPFOxX6fBGZiAxQJku?= =?utf-8?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?q?b4btzoPORsrSJXlMmKL9jCqCgCjFPlkXIBVH/EB+HmZK8Gh9lY4sZWpYzvxnDM3YW?= =?utf-8?q?oJBtq+8dxBon01HtWM+FO8aRW9FUalombnf4JHZwDO7mIapo9CgH9jOUW0gBXogCi?= =?utf-8?q?NfNj9zK1EejGigYod5/1JP3HHUZxv3WAFu7xYqO7nIrvIXVmDVl0hg3bmU7pwY0mY?= =?utf-8?q?RzNC3yfd+FL76p9h9E9ZZEPRshHZG1J3R0z4zo2vcAeoYHumLkrTBNHbEXxRzRfto?= =?utf-8?q?sfJ0LqWPdzCxhbrImth+5deS3YJpWb1vRV5DHhRjEdWxSxr25AhVmmCTiOI7WvDpH?= =?utf-8?q?hd9cH9xZSlQF+eWOmLl+N10YxYN4ulwymRDPbjkUEqjG/JasozZ0T3w/yDLcDDyEz?= =?utf-8?q?5U6u2jx0zvm8ZDavYxAi/WCk5lq4zF3DtlR7ZwaUymm2LJcPhtdbHNs=3D?= Content-ID: <49D715EDC1D20447B486473CB1621A62@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: 461e6470-3af9-4a5c-4178-08dc80a3889b X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:03.9573 (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: rbE4hOAaWS5jtO/lDj3wHq4f314Crrq5vKEFlzEXWFkZSRRZkqrS/5HLwrU7TIeMzU7kt6Prde9+GfbwEPvr6x9DXbBVN21c7Dv58r9UJcVzpMXu6d1TkRafmeWqhyEv X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, 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 Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu_internal.h | 52 +++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 461158f588..9e01251335 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -191,6 +191,7 @@ #define VTD_ECAP_EIM (1ULL << 4) #define VTD_ECAP_PT (1ULL << 6) #define VTD_ECAP_SC (1ULL << 7) +#define VTD_ECAP_PRS (1ULL << 29) #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_NEST (1ULL << 26) #define VTD_ECAP_SRS (1ULL << 31) @@ -373,6 +374,18 @@ union VTDInvDesc { }; typedef union VTDInvDesc VTDInvDesc; +/* Page Request Descriptor */ +union VTDPRDesc { + struct { + uint64_t lo; + uint64_t hi; + }; + struct { + uint64_t val[4]; + }; +}; +typedef union VTDPRDesc VTDPRDesc; + /* Masks for struct VTDInvDesc */ #define VTD_INV_DESC_TYPE 0xf #define VTD_INV_DESC_CC 0x1 /* Context-cache Invalidate Desc */ @@ -384,6 +397,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_PIOTLB 0x6 /* PASID-IOTLB Invalidate Desc */ #define VTD_INV_DESC_PC 0x7 /* PASID-cache Invalidate Desc */ #define VTD_INV_DESC_DEV_PIOTLB 0x8 /* PASID-based-DIOTLB inv_desc*/ +#define VTD_INV_DESC_PGRESP 0x9 /* Page Group Response Desc */ #define VTD_INV_DESC_NONE 0 /* Not an Invalidate Descriptor */ /* Masks for Invalidation Wait Descriptor*/ @@ -425,7 +439,16 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_SIZE(val) ((val) & 0x1) #define VTD_INV_DESC_DEVICE_IOTLB_SID(val) (((val) >> 32) & 0xFFFFULL) #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL -#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 +#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8ULL + +/* Mask for Page Group Response Descriptor */ +#define VTD_INV_DESC_PGRESP_RSVD_HI 0xfffffffffffff003ULL +#define VTD_INV_DESC_PGRESP_RSVD_LO 0xfff0000000000fe0ULL +#define VTD_INV_DESC_PGRESP_PP(val) ((val >> 4) & 0x1ULL) +#define VTD_INV_DESC_PGRESP_RC(val) ((val >> 12) & 0xfULL) +#define VTD_INV_DESC_PGRESP_RID(val) ((val >> 16) & 0xffffULL) +#define VTD_INV_DESC_PGRESP_PASID(val) ((val >> 32) & 0xfffffULL) +#define VTD_INV_DESC_PGRESP_PRGI(val) ((val >> 3) & 0x1ffULL) /* Mask for PASID Device IOTLB Invalidate Descriptor */ #define VTD_INV_DESC_PASID_DEVICE_IOTLB_ADDR(val) ((val) & \ @@ -545,6 +568,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_SM_CONTEXT_ENTRY_RID2PASID_MASK 0xfffff #define VTD_SM_CONTEXT_ENTRY_RSVD_VAL0(aw) (0x1e0ULL | ~VTD_HAW_MASK(aw)) #define VTD_SM_CONTEXT_ENTRY_RSVD_VAL1 0xffffffffffe00000ULL +#define VTD_SM_CONTEXT_ENTRY_PRE 0x10ULL typedef struct VTDPASIDCacheEntry { struct VTDPASIDEntry pasid_entry; @@ -700,4 +724,30 @@ typedef struct VTDHostIOMMUDevice { uint32_t errata; QLIST_ENTRY(VTDHostIOMMUDevice) next; } VTDHostIOMMUDevice; + +/* Page Request Descriptor */ +/* For the low 64-bit of 128-bit */ +#define VTD_PRD_TYPE (1ULL) +#define VTD_PRD_PP(val) ((val & 1ULL) << 8) +#define VTD_PRD_RID(val) ((val & 0xffffULL) << 16) +#define VTD_PRD_PASID(val) ((val & 0xfffffULL) << 32) +#define VTD_PRD_EXR(val) ((val & 1ULL) << 52) +#define VTD_PRD_PMR(val) ((val & 1ULL) << 53) +/* For the high 64-bit of 128-bit */ +#define VTD_PRD_RDR(val) (val & 1ULL) +#define VTD_PRD_WRR(val) ((val & 1ULL) << 1) +#define VTD_PRD_LPIG(val) ((val & 1ULL) << 2) +#define VTD_PRD_PRGI(val) ((val & 0x1ffULL) << 3) +#define VTD_PRD_ADDR(val) (val & 0xfffffffffffff000ULL) + +/* Page Request Queue constants */ +#define VTD_PQA_ENTRY_SIZE 32 /* Size of an entry in bytes */ +/* Page Request Queue masks */ +#define VTD_PQA_ADDR 0xfffffffffffff000ULL /* PR queue address */ +#define VTD_PQA_SIZE 0x7ULL /* PR queue size */ +#define VTD_PR_STATUS_PPR 1UL /* Pending page request */ +#define VTD_PR_STATUS_PRO 2UL /* Page request overflow */ +#define VTD_PR_PECTL_IP 0X40000000UL /* PR control interrup pending */ +#define VTD_PR_PECTL_IM 0X80000000UL /* PR control interrup mask */ + #endif From patchwork Thu May 30 12:25:04 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: 13680334 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 10802C27C44 for ; Thu, 30 May 2024 12:26:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqV-0007B9-Tt; Thu, 30 May 2024 08:25:27 -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 1sCeqT-0007A1-HQ for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:25 -0400 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 1sCeqL-0006CX-NS for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071917; x=1748607917; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=gNcnDcGIoZWQA9eLeBSUZ/Vwq52+cEGSr0++VuU4HGY=; b=NvPHhUI98IcVg9jRFHyjewbdI4UCY23/SE2PRTVOe1DtFeuDTvuLaCIA ssJ7pmHv8lCCyrAVrikTwyTplDnqerTDK2IcUmyS5Irtlf6SHMZokV72Q +9iKNI+lANvbQwFPveyKLbVq4dFQbDtn/Ku07BBMLMr07q+bAHrmsLKIw pvtvZO+uxO4yqvuw/Zs6Cuci5BBP0v0CavVIPL5pzFSZ8QU2fb1ZA3wjj 4NQfylvYSaWW6+jygDWAd5vcwztMPNuo/tVGTI9d5tqa/GuPGmHzMR5xL IMrNIrvZB9ajD1xseDbEMAZIb5oHdh80YI343UdF6qAlKirAEBbg4w9Ig w==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581119" X-MGA-submission: MDF4KhjoaBdeXoFC9wYhCZomhS3YUDLBt13KxfZglEb/hg5xub+MbtBduFheZ1WFo0FpXxlU2OW62RyLnfTLpAkkR0aQwgsZK1X3LfR6OOLYEYILERmAfYRAu7atFZE/O4NcIJKhszAg0vJkbgwKBAGGBUOZCEN9DyEWaQC6lmv6WA== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:07 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDSxqvdkkXdHWK6Zo4j1n7Md3MandHRELijm/aJl5eQ3AWERO812K/9EODCDdXgQo46PgFXOQ7Lln720t2rJ/K8MaRUG5Do0iFudcr3MqdaqGxQrQokSQzbUlL9PIf2d4pYYlVhpgmVHYjOuGEPePKAHXVrWuwn6JNJyfiQJt9ROX6O31K3TQixxrzc7dsGnU/UNS9xyisgd8vnM9XSPLv+XroIDR5RVMTJcIJYbOx17MxYCIGhIABmHlnfvSofXsvXICZUSJyQTBXaFtcsukLWmBX6pyaVfHUpHrV2m40yZryH1ugN11y0FWN7/RO4m8WjZdTDCejLhObjh9j1P4g== 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=gNcnDcGIoZWQA9eLeBSUZ/Vwq52+cEGSr0++VuU4HGY=; b=McFNQ8ppIVc7QGmF2WNgnNlqOYMhWBjySvqpmJ39m7cFpk3IP85rK/zlOf8n6WFrigqaLDKgod1Pgw8JRxs3Fm7g4zPw2EJe/EqZBxZ65DFo7yfchbzZSxyy4m/IulQqzQOXY1qNM2QmjXcX413xDJocg8jc1JUdnpU3pm2AgIj/JG2Dq538s+1OWAmCazGb+qBpeHVKgM61FCfT30bcpb/Ih3y92OaudpcqoNTJ20XWT9j+AMWtJ9nyeTQ1C5LzRSU8iw+JBQv+bTF4dfFqgEfJD5Ygty8l2vLqWFpjVY9FAMjGUTVfiRAM6oRqd7jqI83gh4Ts6mVU7tl9dqjKkA== 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:05 +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:04 +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 7/8] intel_iommu: declare registers for PRI Thread-Topic: [PATCH v1 7/8] intel_iommu: declare registers for PRI Thread-Index: AQHasoxmdbGUniy0gkq3Lt1n7bIUGA== Date: Thu, 30 May 2024 12:25:04 +0000 Message-ID: <20240530122439.42888-8-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: 4a1a30c3-77ab-48b5-390b-08dc80a38917 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?54IyMS81BXXSaIcltn0YSnCAjvKYWkR?= =?utf-8?q?DprsxRH7mMtUSDhtyuzKFsKAHMEDIYF8tSj2+XCfLSwZlpad1PhFVSaI7vj5dSpjU?= =?utf-8?q?0XJB6A7gb1TcyD9fImTlXZpGJl1/WmCgf+g3OwboRIMp+xosxi+JxbvcQW/1C482X?= =?utf-8?q?adqMzSMpWt4QsiGpQKvkEWaI5NhEWjmuzNzIFU1GG/y0UzGEN4hJpGvAHHeU8gzFm?= =?utf-8?q?yoqq1aVla6EgzpU7HEFM4H9dyCuYhycsjWMBAMs4I1X2hzYTHHBIhQsdrbPVb9uw4?= =?utf-8?q?RjRctnf7rwghmV7j1JmZa68SCc+rIp2GOC9flmG8JW7WUUOhis2kWtf/le93RsO6U?= =?utf-8?q?zB5bIvn5O2LgwNhf9Gv5bkI3jVtXaAve1xEXzbufV72vXPfPit3W4tTIGiGcVjsp7?= =?utf-8?q?gYhfXMxCGgabShuwyWn4ZR/3FkKXEqlvj+MsyxktGk4x95fxYjUvCgOFXvIx0ruVo?= =?utf-8?q?huv39Dd7n5ueJI33rYRgDHo8TAW8yNvcWt+bx+xDnqkmjueIJNdFawk76F3+36kmL?= =?utf-8?q?5B6x0LgTZnaEpp/ISpNWHQOloEEIhdT0e8Ifw6w4e1x9npXvOF99BGkt4Ri3iFSX/?= =?utf-8?q?HMBSTZ5I9T/gZo5YHs4fJeh7FxfWLmO/njcgByZ3cLQPn2mkAh0vRPxr8dDAbwJJU?= =?utf-8?q?QANJ10k87NU7y4LAbPPjAmiENkbuTyCGoNV4piZarDPG2k8SDk+XWqRhxTEUjYKE/?= =?utf-8?q?U4557f9B0qgZEY1X9hjpEbqQzKmUSfsewoG1Wy5RuMkYxhnfToIMWuqt38whgfYwc?= =?utf-8?q?o3oX/C3yIecdEXBYfT1REM6tHbRwUIFmdWOgyjduCYRkv1jfVoFvpuhEyoFI/XhaB?= =?utf-8?q?7eD4HePlGTFMnTGtafugB2AUYNJh4rRj8CxlVc0S/YlkVx2c4hZ4tR9Cye+wLfUf1?= =?utf-8?q?o6vn4m20Uc5t7m1XYzcBQX/9ET5hwyKzZDBW4qMm4qdDYXzhfQ+DotofKKXq7vV/W?= =?utf-8?q?ktvkXfqYLG48aJxuYPpnASRpJdzPGP239S4wxUHBQqVv+IUs/AAoGdhntauR6/zq9?= =?utf-8?q?k9kDHMufcJtEOWmjngagA6RtJ5ogFBjg2iVGFDFYUfr85vzCGXgFgAOMFSvcKFvo0?= =?utf-8?q?+ebkBKODd/Dp19B5KJiS16mYsT5tJyiT1NaI5bHLrI+KD9jekgZ1M6+RJ8UmU/8ee?= =?utf-8?q?OMt0/9HXuoFr0+4gYC/8ah2tvbltorUb2yLQYO7j9Nwdsirg8e4yRd3GDQocIrsLv?= =?utf-8?q?5szP8xLfA5ADyaUsUfE/Exi7K9IcicYxHYvfoU11PALJzXkaB5E+3vluKVE9+YOvL?= =?utf-8?q?RpevFWZ2vR7GY/r2j/+6AqYrAiN0gxwo16g=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?3X/PmZjzvn+1A+BrH84KIvwVfk1f?= =?utf-8?q?5Hrs0FrvgtO5VnYnjaQujzpUvFsXQYjx6i29sqNqI5wCGbrAZhJM81WyDs7hLZrKY?= =?utf-8?q?Bw2ERjMf4mRh5bX+mwcM+8n4ZwoKDAwXUTfxnXxHxVBjoWEYmp2enDGFa/+BMIQNZ?= =?utf-8?q?8WU6ib8r5WtHGtYm7mQuTDbImXkJITmFUJdpZb4/tLiXfKyBCglc5ZiUGeA5j5hbh?= =?utf-8?q?rZoHXCLsPqd4Iql6g/pLBhw9b/rqLQl2aGhJ9hstRhddymW9g5+AgLEtziQvEkumW?= =?utf-8?q?Yb+ZNNa3Z/cuFS4F8vULgk6mSMHGYKn7lSdikVhUTj4Ms9Gyk3ppJJOuhm7gt7Rz+?= =?utf-8?q?jQCGWe7KPlS1veiQT7iruCEu32fm5zeN7a1GUAEiT+mem0I6/SfhrmoUOse2BlKa3?= =?utf-8?q?lIDyoEMC/wf5kdYirJ0Dgg9RAf9Njgk7ThqjYV6s6ZeSN/D1YKczWZySgsEqbkSxe?= =?utf-8?q?iMUqPJ5HsjjhgdshV32ubTeM9IM0THJGwEb6qTullA4SxkcFmU3KnDmkIJIEUG2xR?= =?utf-8?q?C+PtKWop1X7qcl7MqwXPCFJovYIsylz0NMb5aOsKL/yA4oiw2gd6OB2IJyoPua1Do?= =?utf-8?q?vWUVhcMWvmYaDf9CqZaBSwfWo07B3+Dzw6S3yfFfG0WEpAaJPSfDAAjdkYj1CR3G6?= =?utf-8?q?eKYe4wu1NnUHW15g9PvfGihLe9gsKsVd0ZIp/eHFYriaOUhjMhB26vMGWujpX+AQG?= =?utf-8?q?EeXd2Q8L2a6jmnBgF2JSOp15ybypCPzE8FDvvzgXwmaE3hRBeQF5DwRd2gPCHWe4P?= =?utf-8?q?aRwv6d2bYXShNcj3ZoNTSesIsLi5UYCM8PGJpPgTYVUteNbP0LJ/wldu9CsP0PrCF?= =?utf-8?q?iPC5HTN9inbTWWytCg/I/HEhZKPjaCIGDb2jztOKODrz2gO3Kki4xjLf2qYaPAM7h?= =?utf-8?q?CWja6vKF9M1XJCzkvdz+M5mkHMUAeNA1fxX0Mq6EVxihInKkC1qrjN6W2nsTHtlI3?= =?utf-8?q?h6TNL5fmrCiT4jfIb++XT0NRTE+O6FvvmY0fzQL8is6QC0X4g1+4vaH9+X4+dj3lm?= =?utf-8?q?PIt6QbhEWdaKraf9fyCOB9324H8b8F3oeqsbmiEjeJLmNojSZe1MQcP1qYBK66hPx?= =?utf-8?q?CVkay3KdTSjNH9k9vDBtG6R+9EckqbvdujKWNzMuoQp7u/IE7tMXCw0B5NKboL/K9?= =?utf-8?q?iNey7icVhRFiT52FZ0m3OAphwcRzGblUCIoLLyXm0V+e7QTj3YelBv1XmFVCmrBc1?= =?utf-8?q?/CmQPfWv0YBGKH64i2kfDA0qRjdy2BAX3MbhduO0UH0dA8u58fZZ/t/t44B3p7CWg?= =?utf-8?q?mLNb1g9g5A3/Y8bvdvW+2Jjog72wn7L/aopiXR5XsBvGJY7RusBLGf2jGmvdON2h+?= =?utf-8?q?SEyjuXmBpNHziSlQVHkp9sqPLOr3MOT47JhxuUGZLOZkB+cQW2xzJFl0SqlCi86T+?= =?utf-8?q?PFDURB4OWXeEG4Z8ShxGaDabCuuGgZvTkjeA2TzRlHwNcNRbJcWxJVMk/7cYe+bMF?= =?utf-8?q?WFhdIxwkPgynufK1f864JIv2+GMJZlyX83d5elrQryUithSW0L+GAsOWqv/WCGGqz?= =?utf-8?q?MlpGbcYsJ4jdQrUf+kd/ekHPAbkDMi4aEnx7nvPr2TgXjhgP+Et5wDo=3D?= Content-ID: <8DE45F1EC0C64749B7B52C214DF0DA8E@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: 4a1a30c3-77ab-48b5-390b-08dc80a38917 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:04.7705 (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: 26RHbAEA0TfJ4IZEoo7AgrHDH5TV3QPWxB/8ffxbQn+tH51HZ6//uC234UbPkhurmFdrkddHgr+uNvyUoHH0JNggvi3qzkDpTshuKk1Hrc2g0OMZjej43PiVfZX2nnqV X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, 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 Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2e78ebe6d2..899655928d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4609,6 +4609,27 @@ static void vtd_handle_iectl_write(IntelIOMMUState *s) } } +static void vtd_handle_prs_write(IntelIOMMUState *s) +{ + uint32_t prs = vtd_get_long_raw(s, DMAR_PRS_REG); + if (!(prs & VTD_PR_STATUS_PPR) && !(prs & VTD_PR_STATUS_PRO)) { + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + } +} + +static void vtd_handle_pectl_write(IntelIOMMUState *s) +{ + uint32_t pectl = vtd_get_long_raw(s, DMAR_PECTL_REG); + if ((pectl & VTD_PR_PECTL_IP) && !(pectl & VTD_PR_PECTL_IM)) { + /* + * If IP field was 1 when software clears the IM field, + * the interrupt is generated along with clearing the IP field. + */ + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); + } +} + static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) { IntelIOMMUState *s = opaque; @@ -4649,6 +4670,17 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) val = s->iq >> 32; break; + /* Page Request Event Address Register */ + case DMAR_PEADDR_REG: + assert(size == 4); + val = vtd_get_long_raw(s, DMAR_PEADDR_REG); + break; + + case DMAR_PEUADDR_REG: + assert(size == 4); + val = vtd_get_long_raw(s, DMAR_PEUADDR_REG); + break; + default: if (size == 4) { val = vtd_get_long(s, addr); @@ -4712,6 +4744,17 @@ static void vtd_mem_write(void *opaque, hwaddr addr, vtd_handle_iotlb_write(s); break; + /* Page Request Event Address Register */ + case DMAR_PEADDR_REG: + assert(size == 4); + vtd_set_long(s, addr, val); + break; + + case DMAR_PEUADDR_REG: + assert(size == 4); + vtd_set_long(s, addr, val); + break; + /* Invalidate Address Register, 64-bit */ case DMAR_IVA_REG: if (size == 4) { @@ -4892,6 +4935,18 @@ static void vtd_mem_write(void *opaque, hwaddr addr, vtd_set_long(s, addr, val); break; + case DMAR_PRS_REG: + assert(size == 4); + vtd_set_long(s, addr, val); + vtd_handle_prs_write(s); + break; + + case DMAR_PECTL_REG: + assert(size == 4); + vtd_set_long(s, addr, val); + vtd_handle_pectl_write(s); + break; + default: if (size == 4) { vtd_set_long(s, addr, val); @@ -5957,6 +6012,18 @@ static void vtd_init(IntelIOMMUState *s) * Interrupt remapping registers. */ vtd_define_quad(s, DMAR_IRTA_REG, 0, 0xfffffffffffff80fULL, 0); + + /* Page request registers */ + if (s->ecap & VTD_ECAP_PRS) { + vtd_define_quad(s, DMAR_PQH_REG, 0, 0x7ffe0ULL, 0); + vtd_define_quad(s, DMAR_PQT_REG, 0, 0x7ffe0ULL, 0); + vtd_define_quad(s, DMAR_PQA_REG, 0, 0xfffffffffffff007ULL, 0); + vtd_define_long(s, DMAR_PRS_REG, 0, 0, 0x3UL); + vtd_define_long(s, DMAR_PECTL_REG, 0, 0x80000000UL, 0); + vtd_define_long(s, DMAR_PEDATA_REG, 0, 0xffffUL, 0); + vtd_define_long(s, DMAR_PEADDR_REG, 0, 0xfffffffcUL, 0); + vtd_define_long(s, DMAR_PEUADDR_REG, 0, 0xffffffffUL, 0); + } } /* Should not reset address_spaces when reset because devices will still use From patchwork Thu May 30 12:25:05 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: 13680347 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 0DBF6C25B74 for ; Thu, 30 May 2024 12:26:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCeqT-0007A4-NL; Thu, 30 May 2024 08:25:25 -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 1sCeqS-000790-8E for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:24 -0400 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 1sCeqM-00060c-6L for qemu-devel@nongnu.org; Thu, 30 May 2024 08:25:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717071918; x=1748607918; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=CnU3SpW1Pg/uaqz3Nb+Z7ZxPd3dpDERhJY1nEyqHUdg=; b=V8nypa8DLdl+nUOWhNs5uzYU0IjELAhT/L5RkjWb6JtsLXEK+LYNnw5e NMJfEU85WDT5450QHQ1yGCcU49YIprwf6DozVf/RtGidZKlBzO14aYnsv IePN/vJ+ZGm52fVUMzdxCRh0PxNqYoRe+4afIptw2ndX0mJAIL4gboBsz YbcLoc4O0QXtp+Z3tOqILg1cPRLY/ySUXklMXWoiwWrfqGreI2A/8gYcJ oApJu9y9LpFUF3qJk80LLJSnAm5VlGC/Fm2GK6WYMipnhmly4MQE6HAWl D2xL9of1lz7IkGobA/XYsgN9GYkLpIZU7/jGVzhlPBN56gNvMunO6N0h6 w==; X-IronPort-AV: E=Sophos;i="6.08,201,1712613600"; d="scan'208";a="13581120" X-MGA-submission: MDHEHRsmBaEq/NMQWL2y7WEHsttL+uVL2ecyUtNn0v5geSW7PdqRxFZO6/FlEW8UMnlJCdYy6lIfBsb/v3m8yu7wPnDxx7Q9KJ0TsxALpvCRsy9x25n+SQDUu4D2+uYpebm+cAhAX+BUaNlIhqlNDKeWUXroymd6SRSdvhAZndC3Mw== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost3.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 14:25:07 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ev+uBjl88jPHGzJhZJqhuvgACC1Q4pRZAtcynRmXNR5hmcngbh2eALLkRCA0skm5YR+4G8fdY3StUtto7WhhtIGJy5eF7rXBgjF6eUtjBnyazuYOJLI9BiV8tRSuB1hq/PdmqVAiXr8KBI68SHqPEZAlIEvaMDyqyuJQ2DnyZ2rabKE8cMwNapppb4kxION6r+olg/7xluTqSQkqTiD8PpqhY7BcPFjAMRWfORup7NnMqpYdwSuuqYgguRDxzxtDZlYE1ABwsbohpc7Skv8l7qwQVHDZahuDH0Du9cNpvldfOvrQ8c8ggU+xy+pPGW/ecldARIBJaj8xu9Lw4NfPWw== 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=CnU3SpW1Pg/uaqz3Nb+Z7ZxPd3dpDERhJY1nEyqHUdg=; b=XWJSfjv7mcjgG7bxkg/lgCikXdZyXYTZO0r7nqH82wUSBJPQPGWla/WpMXqQ4gyHmR2Bb2Kdr0I7iSDVabarmee/iMkB9+XrdfZ+xX7NPmTAV7MoIttvtAjOqMhmnrSRpRWaX7fZxqKGGAazDPcuufaFlcBPPtJGeb+AHnuWQWsqccw042raYzPrlnAcD46+HhpJ0WitDyxyVmGV24toac7XNZGcIL4Yz+rR8U7ME6XJdjuzIPWvIF6eUIQAcfqQZT6ArYs+7B65/Te23YNqU4lIqsUxSMsk/iFBR+l14CRU8SvqlwR3sYRgYiyI9Y+k3P4YnA5F/EKHWshj0+7AeA== 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:05 +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:05 +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 8/8] intel_iommu: add PRI operations support Thread-Topic: [PATCH v1 8/8] intel_iommu: add PRI operations support Thread-Index: AQHasoxnvtS4ZcFnKU+EJPIjk9nm7Q== Date: Thu, 30 May 2024 12:25:05 +0000 Message-ID: <20240530122439.42888-9-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: f11a3497-5307-4362-440e-08dc80a389a2 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?QlygnngDMMfIokMLgenuIo2yiRpqia3?= =?utf-8?q?0osaRtgroNrbBaZCVGsSRvkaQoucsOeROzSRvuAXo5tZY5itQbUc+usKo6qpyZ+mZ?= =?utf-8?q?wC7MCLzwxRE3fyFTXLHL4mbiJ36geb4kcLyZsbCyB5zAqGnPyltZgmckwHCL5pOg2?= =?utf-8?q?j42Robs6jra/NzJi4D5i1Uq6QHr5qdturyufwxyFx6pvZu16XnP0Z4LJ8KyJl8Ngb?= =?utf-8?q?3SLM0893u/tDA+l/hc53WoR1GebfE04jcXI7ESPblW3Zzh2ZGJjdICy0KmUh+yoM7?= =?utf-8?q?8phuQFpujaSXlFG8gDICEkpLVdXtperhWJJlhB53sJuHS2rj75iYl0d3L8lYwiuTp?= =?utf-8?q?0Si5Aiud9SdyFVutqcDO95Di4XH95ZeuLEI3RXMos9RBI9W7dPhz96jDjHerKSNCJ?= =?utf-8?q?svaX5Uo2gpAj+1BSlpYTny4UWKWXsJLeLmXCy8qaWdIqc7lYcfcEN7HjIsaOF3zb0?= =?utf-8?q?w5QusQ9BKZPGzF1CGUoUGDNG2wGjTbSlwtpiMRPJjRUf6x2VE3sOAD8sZFOKVLA84?= =?utf-8?q?Qx9/4p1nGBCUUWxJDHGI215W5ovaBDXu9jA83WdTazKPWJ7tJ89+IWLcLm9wan0Qf?= =?utf-8?q?JcmnSMyBdpU0nnnMmQ19MXm5rT+O4CI9cq3Oh+IhmOoWsc3cCiKg0usvP9oWFmXqr?= =?utf-8?q?aHMvrBWKcZ7weHidAKYNKgJX/0zOasRyImifRE0y08CHdh5EatDUf6L16xz2QEFl9?= =?utf-8?q?wfAiIOXXa9NfJA/seReai3F/7ntCJhVVbLPe7YmlPLW7u49wC3Aq5oEar2xuAD3a+?= =?utf-8?q?vYyUt0QUgy1nBOKCTS/kOH7fdVr+7ffhpObREwEivg/6TuqB9lWGahbmpcKpKDfAw?= =?utf-8?q?81907SKoVGADWgUEVsHgT9qCVfkBaiiIyoaJP9BUMHlNDq4zXP4s7geHZBx84+vJW?= =?utf-8?q?aI+9Bw23g8HiY/8ll3j6l5R7+LZRG46YYqtuxaJgjS1pfIMtZomy1wja4MkAfNkT6?= =?utf-8?q?zfiIj8ZU0/mGfFoQ2ac6XW6OMR//GsFmHoeoynSFuTPNVQn60bScb85/423a2knS5?= =?utf-8?q?SNNGSeg+H+H4zJl1C4JKwt11MEHYrDSZBG+Epni39WtNJTDekgNCAweFfRTd1fFZk?= =?utf-8?q?fKe7G7rMUWZkWKqkhTCgyVrOGpAlkSwGMrUVILgnvr0P59uTu3YGXJqSw2i+cmmRe?= =?utf-8?q?4PM/v/BJIzaUmvF08kg+xAcix7BtF/R93B4a1NnCwCCj1e0FYvzIJG9kkNSr4OuFR?= =?utf-8?q?UQlYrFrNRvxpp4M8090Fd7KttnB873nwnEnokRPmswX0f0EtuHB6IQqpTh9GdHooS?= =?utf-8?q?XfXd29/VzZYMsn2+2vvvwoQrl6GQwFhb8og=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?5HQKJvJzVPxeF+EEE5nlLuuQP1Of?= =?utf-8?q?rnzEdF7dI3UvoffCnX6B4SbXzocZBz33OBqa/ksgokoVrVH3mGuBMgXFMC5fhtn0D?= =?utf-8?q?Fgu9L+gAnJWXSOwiU0hlChpiR4K1utZ/AcF4FA9DfpA+n5uXh6cTsJcg9AoA0zlnn?= =?utf-8?q?wXxKP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?n10piBQTbczq8IUVlkTFNuaAshhoO1M0jbYTMoVAlddNMaVoF7LDRRe8eznONErQ8?= =?utf-8?q?eV52PsglAXL+Qg+JMfv+DzYwHCFdOw+CjA5qre4CK6IfRhT5wgUd5JdQ84i8HLmvd?= =?utf-8?q?XqtzanlbqTqup6YpD6NtXPjrZYBagNZAkok2TboZLUS0aKBxzFlK0YCwE7wKCQYwV?= =?utf-8?q?7xBW+NKlGMOfveCV1i39AxePpymRMQ2PpJYFYQXRSXe+2ruytiMX8V86lyJliorso?= =?utf-8?q?JKlg0NUkn0V2nCgfXnldYfV3bIb4+JBqhPMLe5gGmExpKFu4fVQ4FTzPTJMEiu8Kx?= =?utf-8?q?/slTsFcOl2mGO5vMt4mS3RjChFJ5t/wqds4jQjJjLxcorCi4NbI3a4SabKR5YXFjl?= =?utf-8?q?pn494d81VY7iOYwbzOBdXl146xt4zI9zEzRXrtK024HF+MsJpaZMWd0NwBoXlRvG1?= =?utf-8?q?qsCUa+0/wAMkmEsMr/25nfZOFYmHqDSoA1EFrATzXGEofABloNcZ9Bp4kuBEYCrpO?= =?utf-8?q?vDH/vzegSsGxUsTtXC5L6MQwKhoTyCPV4dAY3F+C/NV8PydlDuoHEuc=3D?= Content-ID: 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: f11a3497-5307-4362-440e-08dc80a389a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2024 12:25:05.5130 (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: qONImZXfcqXBG1QfKsI0wRX5jAdTdqoBArvgPYW6Kwv7ylL1O9rUQMbb3q9HByMwmjZVtWUOGHujUSh3mq9IYzIK3rlTDFL8XB6G2JVwTRH/AHMwyE0to5CFE3xVZxy+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8069 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, 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 Implement the iommu_pri_request_page IOMMU operation and the behavior when receiving a page group response descriptor Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 235 +++++++++++++++++++++++++++++++++ hw/i386/intel_iommu_internal.h | 2 + 2 files changed, 237 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 899655928d..dcc92aae58 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -51,6 +51,8 @@ ((ce)->val[1] & VTD_SM_CONTEXT_ENTRY_RID2PASID_MASK) #define VTD_CE_GET_PASID_DIR_TABLE(ce) \ ((ce)->val[0] & VTD_PASID_DIR_BASE_ADDR_MASK) +#define VTD_CE_GET_PRE(ce) \ + ((ce)->val[0] & VTD_SM_CONTEXT_ENTRY_PRE) /* pe operations */ #define VTD_PE_GET_TYPE(pe) ((pe)->val[0] & VTD_SM_PASID_ENTRY_PGTT) @@ -1922,6 +1924,7 @@ static const bool vtd_qualified_faults[] = { [VTD_FR_PASID_ENTRY_P] = true, [VTD_FR_PASID_TABLE_ENTRY_INV] = true, [VTD_FR_SM_INTERRUPT_ADDR] = true, + [VTD_FR_SM_PRE_ABS] = true, [VTD_FR_FS_NON_CANONICAL] = true, [VTD_FR_FS_BIT_UPDATE_FAILED] = true, [VTD_FR_MAX] = false, @@ -4379,6 +4382,45 @@ static bool vtd_process_device_piotlb_desc(IntelIOMMUState *s, return true; } +static bool vtd_process_page_group_response_desc(IntelIOMMUState *s, + VTDInvDesc *inv_desc) +{ + VTDAddressSpace *vtd_dev_as; + + if ((inv_desc->lo & VTD_INV_DESC_PGRESP_RSVD_LO) || + (inv_desc->hi & VTD_INV_DESC_PGRESP_RSVD_HI)) { + error_report_once("%s: invalid page group response desc: hi=%"PRIx64 + ", lo=%"PRIx64" (reserved nonzero)", __func__, + inv_desc->hi, inv_desc->lo); + return false; + } + + bool pasid_present = VTD_INV_DESC_PGRESP_PP(inv_desc->lo); + uint8_t response_code = VTD_INV_DESC_PGRESP_RC(inv_desc->lo); + uint16_t rid = VTD_INV_DESC_PGRESP_RID(inv_desc->lo); + uint32_t pasid = VTD_INV_DESC_PGRESP_PASID(inv_desc->lo); + uint16_t prgi = VTD_INV_DESC_PGRESP_PRGI(inv_desc->hi); + + if (!pasid_present) { + error_report_once("Page group response without PASID is" + "not supported yet"); + return false; + } + + vtd_dev_as = vtd_get_as_by_sid_and_pasid(s, rid, pasid); + if (!vtd_dev_as) { + return true; + } + + IOMMUPRIResponse response = { + .prgi = prgi, + .response_code = response_code + }; + memory_region_notify_pri_iommu(&vtd_dev_as->iommu, &response); + + return true; +} + static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) { @@ -4486,6 +4528,13 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) } break; + case VTD_INV_DESC_PGRESP: + trace_vtd_inv_desc("page group response", inv_desc.hi, inv_desc.lo); + if (!vtd_process_page_group_response_desc(s, &inv_desc)) { + return false; + } + break; + default: error_report_once("%s: invalid inv desc: hi=%"PRIx64", lo=%"PRIx64 " (unknown type)", __func__, inv_desc.hi, @@ -6138,6 +6187,191 @@ static uint64_t vtd_get_min_page_size(IOMMUMemoryRegion *iommu) return VTD_PAGE_SIZE; } +/* 11.4.11.3 : The number of entries in the page request queue is 2^(PQS + 7) */ +static inline uint64_t vtd_prq_size(IntelIOMMUState *s) +{ + return 1ULL << ((vtd_get_quad(s, DMAR_PQA_REG) & VTD_PQA_SIZE) + 7); +} + +/** + * Return true if the bit is accessible and correctly set, false otherwise + */ +static bool vtd_check_pre_bit(VTDAddressSpace *vtd_as, hwaddr addr, + uint16_t sid, bool is_write) +{ + int ret; + IntelIOMMUState *s = vtd_as->iommu_state; + uint8_t bus_n = pci_bus_num(vtd_as->bus); + VTDContextEntry ce; + bool is_fpd_set = false; + + ret = vtd_dev_to_context_entry(s, bus_n, vtd_as->devfn, &ce); + + if (ret) { + goto error_report; + } + + if (!VTD_CE_GET_PRE(&ce)) { + ret = -VTD_FR_SM_PRE_ABS; + goto error_get_fpd_and_report; + } + + return true; + +error_get_fpd_and_report: + /* Try to get fpd (may not work but we are already on an error path) */ + is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD; + vtd_ce_get_pasid_fpd(s, &ce, &is_fpd_set, vtd_as->pasid); +error_report: + vtd_report_fault(s, -ret, is_fpd_set, sid, addr, is_write, + vtd_as->pasid != PCI_NO_PASID, vtd_as->pasid); + return false; +} + +/* Logic described in section 7.5 */ +static void vtd_generate_page_request_event(IntelIOMMUState *s, + uint32_t old_pr_status) +{ + uint32_t current_pectl = vtd_get_long(s, DMAR_PECTL_REG); + /* + * Hardware evaluates PPR and PRO fields in the Page Request Status Register + * and if any of them is set, Page Request Event is not generated + */ + if (old_pr_status & (VTD_PR_STATUS_PRO | VTD_PR_STATUS_PPR)) { + return; + } + + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, 0, VTD_PR_PECTL_IP); + if (!(current_pectl & VTD_PR_PECTL_IM)) { + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); + } +} + +/* When calling this function, we known that we are in scalable mode */ +static int vtd_pri_perform_implicit_invalidation(VTDAddressSpace *vtd_as, + hwaddr addr) +{ + IntelIOMMUState *s = vtd_as->iommu_state; + VTDContextEntry ce; + VTDPASIDEntry pe; + uint16_t pgtt; + uint16_t domain_id; + int ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), + vtd_as->devfn, &ce); + if (ret) { + return -EINVAL; + } + ret = vtd_ce_get_rid2pasid_entry(s, &ce, &pe, vtd_as->pasid); + if (ret) { + return -EINVAL; + } + pgtt = VTD_PE_GET_TYPE(&pe); + domain_id = VTD_SM_PASID_ENTRY_DID(pe.val[1]); + ret = 0; + switch (pgtt) { + case VTD_SM_PASID_ENTRY_FLT: + vtd_piotlb_page_invalidate(s, domain_id, vtd_as->pasid, addr, 0, false); + break; + /* Room for other pgtt values */ + default: + error_report_once("Translation type not supported yet : %d", pgtt); + ret = -EINVAL; + break; + } + + return ret; +} + +/* Page Request Descriptor : 7.4.1.1 */ +static int vtd_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) +{ + VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu); + IntelIOMMUState *s = vtd_as->iommu_state; + uint64_t queue_addr_reg = vtd_get_quad(s, DMAR_PQA_REG); + uint64_t queue_tail_offset_reg = vtd_get_quad(s, DMAR_PQT_REG); + uint64_t new_queue_tail_offset = ( + (queue_tail_offset_reg + VTD_PQA_ENTRY_SIZE) % + (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); + uint64_t queue_head_offset_reg = vtd_get_quad(s, DMAR_PQH_REG); + hwaddr queue_tail = (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_offset_reg; + uint32_t old_pr_status = vtd_get_long(s, DMAR_PRS_REG); + uint16_t sid = PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn); + VTDPRDesc desc; + + if (!(s->ecap & VTD_ECAP_PRS)) { + return -EPERM; + } + + /* + * No need to check if scalable mode is enabled as we already known that + * VTD_ECAP_PRS is set (see vtd_decide_config) + */ + + /* We do not support PRI without PASID */ + if (vtd_as->pasid == PCI_NO_PASID) { + return -EPERM; + } + if (exec_req && !is_read) { + return -EINVAL; + } + + /* Check PRE bit in the scalable mode context entry */ + if (!vtd_check_pre_bit(vtd_as, addr, sid, is_write)) { + return -EPERM; + } + + if (old_pr_status & VTD_PR_STATUS_PRO) { + /* + * No action is taken by hardware to report a fault + * or generate an event + */ + return -ENOSPC; + } + + /* Check for overflow */ + if (new_queue_tail_offset == queue_head_offset_reg) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); + vtd_generate_page_request_event(s, old_pr_status); + return -ENOSPC; + } + + if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { + return -EINVAL; + } + + desc.lo = VTD_PRD_TYPE | VTD_PRD_PP(true) | VTD_PRD_RID(sid) | + VTD_PRD_PASID(vtd_as->pasid) | VTD_PRD_PMR(priv_req); + desc.hi = VTD_PRD_RDR(is_read) | VTD_PRD_WRR(is_write) | + VTD_PRD_LPIG(lpig) | VTD_PRD_PRGI(prgi) | VTD_PRD_ADDR(addr); + + desc.lo = cpu_to_le64(desc.lo); + desc.hi = cpu_to_le64(desc.hi); + if (dma_memory_write(&address_space_memory, queue_tail, &desc, sizeof(desc), + MEMTXATTRS_UNSPECIFIED)) { + error_report_once("IO error, the PQ tail cannot be updated"); + return -EIO; + } + + /* increment the tail register and set the pending request bit */ + vtd_set_quad(s, DMAR_PQT_REG, new_queue_tail_offset); + /* + * read status again so that the kernel does not miss a request. + * in some cases, we can trigger an unecessary interrupt but this strategy + * drastically improves performance as we don't need to take a lock. + */ + old_pr_status = vtd_get_long(s, DMAR_PRS_REG); + if (!(old_pr_status & VTD_PR_STATUS_PPR)) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PPR); + vtd_generate_page_request_event(s, old_pr_status); + } + + return 0; +} + static PCIIOMMUOps vtd_iommu_ops = { .get_address_space = vtd_host_dma_iommu, .get_address_space_pasid = vtd_host_dma_iommu_pasid, @@ -6346,6 +6580,7 @@ static void vtd_iommu_memory_region_class_init(ObjectClass *klass, 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; + imrc->iommu_pri_request_page = vtd_iommu_pri_request_page; } 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 9e01251335..b2314c6a95 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -319,6 +319,8 @@ typedef enum VTDFaultReason { * request while disabled */ VTD_FR_IR_SID_ERR = 0x26, /* Invalid Source-ID */ + VTD_FR_SM_PRE_ABS = 0x47, /* SCT.8 : PRE bit in a present SM CE is 0 */ + VTD_FR_RTADDR_INV_TTM = 0x31, /* Invalid TTM in RTADDR */ /* PASID directory entry access failure */ VTD_FR_PASID_DIR_ACCESS_ERR = 0x50,