From patchwork Mon Jun 3 05:59:45 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: 13683268 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 0C72BC25B75 for ; Mon, 3 Jun 2024 06:01:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sE0jq-0006qg-Cn; Mon, 03 Jun 2024 02:00:10 -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 1sE0jh-0006kN-UY for qemu-devel@nongnu.org; Mon, 03 Jun 2024 02:00:03 -0400 Received: from smarthost4.eviden.com ([80.78.11.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sE0je-00070x-OD for qemu-devel@nongnu.org; Mon, 03 Jun 2024 02:00:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717394399; x=1748930399; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=z8u53u+CM2INsVXAc6uqK70A1lJTTUSaPFDUaxCmfhk=; b=g9fpAuXoAxWCy1NVp5fCKf2z+y3GsWmx9mg7eSW0QQD1nd6mXm21L72C QxxGYMLO62akBsTb8Mr3WH1ObxJtVVpX8gJQ1x7hNpm2fuT9xU5iPlt/N 2kb/P90aakL+SgUySWPwyZSrlXmFFFsDAPyQQ+aWe2jcIVH2/go6ZdUTM sdLmZsZvqB7D1jQTp3hAhQvV39R/HawZ8In5O/dW/GVAjGYSzW6RxiCka vewnM8p0LGPAdOGyl+0IAqY+hEcMmu2/tbd/qiUGzUL+rzg/83QF0iFIl yollvV4LDvpEjRVAfT4Av2Ph3GtSE/KeW05unRj7QwJhoMkL4kFdNYsy1 g==; X-IronPort-AV: E=Sophos;i="6.08,210,1712613600"; d="scan'208";a="13815878" X-MGA-submission: MDHwQ4j8y9Ip9XSWWpuGa0SkPI1EdSKoxqsbLI2eUzJ38Uw+V6k2EfE5DYgS5oQOA2boD4dHhUHMSc2Z5lJuzP7ibA+PU7HF5Pe5MgojuH0EKzb0NOYTjQuktgKru8+ZqTbf2eAhsvdhctqBdOO/89kRlQ77HA6oHrKQl9R2PkK8jA== Received: from mail-he1eur01lp2050.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.50]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 07:59:49 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVz1ZUJsVDTgJb+QflYCPvtVEIslS52AJ/YwESMKac8lK2W2PSe0ygkU1yKDCF0J6N/Nggv60v3Bi6nVFudSGbWGguboHQsCibdHGfqwLzoaNYwNNpMzsjDiYgqCrLTwatjM/AkQTraM6jEyJLIRfjL4jgBl1vEYinNs5w8U9B7X85CAq2ExZkt+z7FXF5kRkcZ4Enf/1gzd99zFcvM7zPhAvr1lGahhpltVgVcYQ4TMbTxWOKHMwGghd1prOknrvUlbzwZmPsV7BAnXKLNfyzY8gJ1DhOOnjEqngVBHoYNJbN9hp0N0KEtNmrIAhcEZ8/t1elpIyVm6XgdVB3PNJQ== 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=z8u53u+CM2INsVXAc6uqK70A1lJTTUSaPFDUaxCmfhk=; b=UkoRDhx3bYCk6Bsds7HUsaIkbTFv3FLDrGuO5Yt1kdI8Ee+V0sOm74ptTMld1w++QBoMzkkRdI/FOnA0jYTQ5WadkHoye3l08gEm+BX3zvp67SiKW5XYn6vZkpKoZvxFbdImUZrKcCFsOQkal1VhJXPzUE23Ih4dquWRJS5Z63cfVkDMIP6foy4dWnr9SbhZVvQIpAt3KF/nwPkHwgmH8n+3NWyFpYAIV6Wp/NvR1yizJMagquRWhe5g6SyAxjh1G6i1szgBoGx5w52JwYOzxL5lIq4KoszZvKijiGYh9EUM6sPEbPJoxsS9tV4iBeIxFAzTcFKReLfI+yrmv95WqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z8u53u+CM2INsVXAc6uqK70A1lJTTUSaPFDUaxCmfhk=; b=Khu4QM2bAp/tJNcIXJJYQrGrJ8677kXM4nsgvJSUGruJFnEeK/vRjiciiBQZxU8VOksCwY0XJOJ/rF11yxYDKDOQah6SsUKeGuon56IVYRBFevGU7DlKC2YWSEJ8/5MoCcC59IkJZ0IfYWoD7f6/ylOu3mljvdqAUWt5I5aQAU16L2yJ8U5uETiZH2noxj1HcL+6Vo1n8/r7DFTflTmi/1oOwN9VPx9duxbMxDnxgWTO5cNFRb9A2w/ZopCA0ARWDZjldTrog+HEOzv8nrNv3Wg2PRtNaVC1CBKg2SIL8XFMvx7JopT+jQZ3/UHDiMZrZPJRtNsjOcCwWatxa87OQA== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6238.eurprd07.prod.outlook.com (2603:10a6:800:136::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 05:59:45 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.7633.021; Mon, 3 Jun 2024 05:59:45 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd v5 07/22] pcie: helper functions to check if PASID and ATS are enabled Thread-Topic: [PATCH ats_vtd v5 07/22] pcie: helper functions to check if PASID and ATS are enabled Thread-Index: AQHatXs7XMyQi9yUpEaND2cFURryiw== Date: Mon, 3 Jun 2024 05:59:45 +0000 Message-ID: <20240603055917.18735-8-clement.mathieu--drif@eviden.com> References: <20240603055917.18735-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240603055917.18735-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_|VI1PR07MB6238:EE_ x-ms-office365-filtering-correlation-id: 1dbe1e5c-04bd-4ad1-7b8b-08dc83925e75 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|366007|1800799015|38070700009; x-microsoft-antispam-message-info: =?utf-8?q?44acz55QDtVakBFyEDdm56LdJdP0O32?= =?utf-8?q?4nNautOBocGr0bkUXGcDCtVlsDfw2X4sfUaOpFmn9bjj87kOUXDMJdT0ECgOP+vPB?= =?utf-8?q?LhODV7W2Qd0TD3lvclWHDjdLTdY/GokoWrPNNzcxsh+diO38meDTekNQwMj0VZ4d9?= =?utf-8?q?myQ7VDd+gvxJXa8m28/tgJBJ1paY4tnD2x0MwQuuVzZsWnpESqrt9kQnWn11Qrmjc?= =?utf-8?q?LQa6DKTp+p2EtnmtQaPZ5LI3CWusxUP8bopi8JeftjpZBePENL8fn67i/1Tqdeb4E?= =?utf-8?q?fIHFVb76Q8vhCOhH2v8rWL9632J0w25khLE+DFMO5r0Ds2g6frJrywex4E7U72b1B?= =?utf-8?q?rxb2dSP5HjlC8ZoF4MDX8u6KnI7s0IrvZtOZQc2kNpB4gSPt8JgTYzHxz32KyeT0f?= =?utf-8?q?nm+sPw+B1H4M5gii93tX6iCIv43sLUuSTwtpoKageJAerrsUpx8ptDap7UZRmZcZ+?= =?utf-8?q?4EBXxRTdcFO+BbLzlAcgbqSJNk1aw5wSu7EQ2dQgnu3BGninGCsql5KElORm42p5y?= =?utf-8?q?6lg9rM637RIV/bYlvIHqjNECDYsBUaRKTri5AdIDEl1SbAKgt9ZHWYj7q3mNsvCyE?= =?utf-8?q?eHKSJg1s6wALm3AV8v/m5hB08xkxgJtybho0wWs49YJH0pXVPrtBs3QyRbCS97zJu?= =?utf-8?q?Lu26NiYbnQfFRHJW4yRg3bCctaiABJeU9j8SauxOJkQcAEke0u4N+lgJPAe5BgBNo?= =?utf-8?q?Iea7l59bdHvbP4kSDqj90E6NM2/TPEggMaX8ogwilS6VlPWgA+XlArqC5kIprCckn?= =?utf-8?q?qT2uJU2eZTJv/zZpDeGjNVaw6ludJnt6QRVAoLMP702KINpi2SN2VK/Ng4XIhrmO/?= =?utf-8?q?wtdMdboQqzNToHPxyp+Xi3qT8l1bM7R5UH8Ur7YsrceUuYCtrxWZRyLQ9iwRuTkM1?= =?utf-8?q?QXiX1H2acoQecbmLgiVVQ3SWcrTN2zntHWnmqbkqkadu/E4zl29a0NizS58C0xs54?= =?utf-8?q?jACfKQZ33g0FlphmgohL3F7Fr/7317zlbS+1Mw4rbqizvBO29jkK1uV8tmFhDxZgs?= =?utf-8?q?RPFJ+LCehaENEfRiI6h3HKBYL+jD6Zjj7Xy8LibGxE0M1tBp++6UV779eWwAPK4Eh?= =?utf-8?q?8aOa+RQ2UcMpsRRqZgeXHDcX0mpWwD8y9rzqsE16nKT+EL9SWoCNTEAhruK3rJwnZ?= =?utf-8?q?MUhX9sPogWftB6p+FS44TWI1mNaH8CJ5J9FAkVGZIDucgI07i4I7vRKrk619mjpHl?= =?utf-8?q?7HntdLXaJ4Cofg9ioTiR7yQToMrrf5LE3vxFPdeD81/qyS/IWzEHBTIxHD1GwFzZV?= =?utf-8?q?uBeiFUUtAVijrb5G19bw8bnGs1UFKtnhTng=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?+AmlinVtSv0i81NUtLY9K7zd19OE?= =?utf-8?q?Uio+RhKDynBIYxQsW5DzLBED5NUQbq0yhXlnlBirnsB9DGnDhIkwG483rqDInziec?= =?utf-8?q?N5imMEklNWoGN2r4kNAQKood68KBiOw/u+RS83/+PmUnPql2JliruMSr3HTAc0Fiy?= =?utf-8?q?rePyRnwloSFrvWeAM0fROuwM6kFHgCcEEbzmDKK87zapPy4QW6JPbNC5pS3prk7/7?= =?utf-8?q?N1faN8XRY2a01ybr+wLuHS1NynR7nrLhxa+ktX9gaS6C0bg2ggM0hgNV6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P2J+cN?= =?utf-8?q?u6f1qCbmsPrhmzc6hLtMKnrJXd/m/ZAkQKqqmU9cv6nkvmw7y0XQysL5R8QwkGB5O?= =?utf-8?q?nSLY9h6K5srJqVEA/7jJNZ2qsBzJMAfbKJTf9+Kg6PZz6iuiHjq1bztZgfh+vWUEf?= =?utf-8?q?65kwoZtWECu0ELZV9otaF8fp7BkQ4i6v76ob9af8STBFSnaX+v+mDcHIsGhhBjnO0?= =?utf-8?q?hfT1Hi4tA2XlBbrM+JB0MXiL+SZbVff8uxZFScGBGQmBDJgLub/g+H7EXjFC9I0Jk?= =?utf-8?q?kK0IDXDVSr2GVzuVWXUvZxARwGl+HiPRC1wJUi68QTjfmXjA5LrnyqFMUKlNGivim?= =?utf-8?q?cByEY5QTRw49vXQIg8CC3hz6RqhbRYKzXEgXhsRDVA1xnsfMegt79TZB3VK11gXmz?= =?utf-8?q?OjfeB7cU0e+K6EbhMuSVgUdtN0OXq9/K7hUxJ7oR91HGmqdK9XTZyJ0=3D?= Content-ID: <0206B37C22524C4BBD30D199EB16BFB3@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: 1dbe1e5c-04bd-4ad1-7b8b-08dc83925e75 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jun 2024 05:59:45.2601 (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: 8VlLlXh6xznQ//jOvLLW1NwqJzkzYoiCgvYrmQzVJ9WHBtFT/W20zjJmxAdPjvhnEqrFVdnyObhDi/dPi58ccPUO4Xywe9ID+5mF+Jm5w3rb5HSBcqChoggRcYC11lVY X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6238 Received-SPF: pass client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 From: Clément Mathieu--Drif ats_enabled and pasid_enabled check whether the capabilities are present or not. If so, we read the configuration space to get the status of the feature (enabled or not). Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 18 ++++++++++++++++++ include/hw/pci/pcie.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index d6a052b616..4efd84fed5 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1201,3 +1201,21 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, dev->exp.pasid_cap = offset; } + +bool pcie_pasid_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.pasid_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.pasid_cap + PCI_PASID_CTRL) & + PCI_PASID_CTRL_ENABLE) != 0; +} + +bool pcie_ats_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.ats_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.ats_cap + PCI_ATS_CTRL) & + PCI_ATS_CTRL_ENABLE) != 0; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b870958c99..0c127b29dc 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -154,4 +154,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, bool exec_perm, bool priv_mod); + +bool pcie_pasid_enabled(const PCIDevice *dev); +bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */