From patchwork Thu Oct 12 22:09:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13419845 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 411ABCDB482 for ; Thu, 12 Oct 2023 22:09:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.616072.957849 (Exim 4.92) (envelope-from ) id 1qr3s7-0002wU-J9; Thu, 12 Oct 2023 22:09:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 616072.957849; Thu, 12 Oct 2023 22:09:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qr3s7-0002vD-C8; Thu, 12 Oct 2023 22:09:35 +0000 Received: by outflank-mailman (input) for mailman id 616072; Thu, 12 Oct 2023 22:09:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qr3s6-00016v-1s for xen-devel@lists.xenproject.org; Thu, 12 Oct 2023 22:09:34 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0568c859-694c-11ee-98d4-6d05b1d4d9a1; Fri, 13 Oct 2023 00:09:33 +0200 (CEST) Received: from pps.filterd (m0174682.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39CKqml2008371; Thu, 12 Oct 2023 22:09:18 GMT Received: from eur01-db5-obe.outbound.protection.outlook.com (mail-db5eur01lp2050.outbound.protection.outlook.com [104.47.2.50]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3tpr7cr8dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Oct 2023 22:09:17 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DBAPR03MB6376.eurprd03.prod.outlook.com (2603:10a6:10:193::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Thu, 12 Oct 2023 22:09:14 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::f606:63f7:5875:6076]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::f606:63f7:5875:6076%4]) with mapi id 15.20.6863.043; Thu, 12 Oct 2023 22:09:14 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0568c859-694c-11ee-98d4-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJar0ktDK0Zr4Nusawcylt9N5IgEcz1ZPFFgTVOBLSeNsi5RVFls2X+Rr5TskutmMBKsTf/h1LfFmF61hxWsY4cAMniwEz8563BWIqZZOCcfLSc33/iphWVOcmOaEkXJL4uqHdhPkROV23ty11f+UR8nG56I+AecIyg7Es2FiDHJD7V12bqWEj4Jng3SKKdzfpVvv4Xoe03QYovQzehbH8PY6tAKKMS5PNEXiHtpaOl+d0K4u6NOuqsZr99028tWWU1eTJ8VXbsJW9xW3gDvR2oN5LOweo2pka2d54VDyN1UVBh5zQF0zMtXgvY6fkgFqDS8wtVcxrY849SqR9VGKQ== 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=fhXyJHYlAPTYayr221weXq+AyrDZqJ1ahzFObJgSnxk=; b=Iq0ZmxRYu9RtIp1K79RvDKisYb+MygeuuZRx7yayXOCFqfPv+uN/yvyj0vjSPEdODnK22LWHRv+f9hHrMThf5Zo3SBeE+yF0/8CbmyJFwsS44Gr+UZUYV2jB7yFR150P79kF6731+tHoMaxJFqsT13+ZpWKZMo0l3k0RYWPj8ttfAQYuOvrvgPZ4hkPDfopgnONlxha0rAoVMA5MAnwjhuH7BWraqi1JYuoXA0H15ZvzLGQ9ZxQyF/CBC7HfXmRxPFT47jvIX4PgX71HXzOAtv0YukEAq55fsHO5lz0ImuEfy5Kq3kGBtyWYCpk4UxcqJTcfpDMxxcZwrFMvCxSfSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fhXyJHYlAPTYayr221weXq+AyrDZqJ1ahzFObJgSnxk=; b=NWn3q7iUmybgUn2r0ktUns/JLOooMu4GZnKx8g/OL/bxip0VZujOQxJ7VBOqkXFeW1aHmqIqKWPshppzJyAtjfT9LDYrFHY7H/Qm04QRfOj5oYNde478fAYEPfLpNBmfnK1jMKx/7yvpT4G3IUq2sJr9zEkKEwkbjVqz+wcKmNvyirSCC/l7/npQ3o9xHgeriieifrQD0j1k8i00lHygK3n9UElTsUYjCwFvFakU6OlGwbxuGhFg4TmrewGskgDk19lYXkiLaVmta7q5A7YfjsbfR3xJ1FtEQc7qoLn/yB/H5zWSaczn/sj3CBwCc07f6pA1EZwIPXR+yPmPeIFRiw== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Stewart Hildebrand , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Paul Durrant , Kevin Tian , Jun Nakajima , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v10 00/17] PCI devices passthrough on Arm, part 3 Thread-Topic: [PATCH v10 00/17] PCI devices passthrough on Arm, part 3 Thread-Index: AQHZ/Vi800FGBIOTr0uxo4jqDLR7uA== Date: Thu, 12 Oct 2023 22:09:14 +0000 Message-ID: <20231012220854.2736994-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DBAPR03MB6376:EE_ x-ms-office365-filtering-correlation-id: 2790b472-fa02-4918-8ab2-08dbcb6fdeca x-ld-processed: b41b72d0-4e9f-4c26-8a69-f949f367c91d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YoXTJlnmejxo++8LZP4k0hzc/kpXn5KoJCMFdXaYIAlToBUz/Y89eBjzv0bD06h+bhqPJqHhtR1cSTj6gwJTfcD+ysGfQNqZZaLlnyFCK0pDmOf7pMhbkh+WntxZX1eR71jsK+lMUpZsicKSf5mfBN8tnZha0jJwzy5ikJCnpT181mtmXCkg+jb+iOnHbkMe3wpY/tidL1ueUyaSCI9ITvzZi5ql7z/zsN1cdp61ucrYRic3p9RBPUX85AAy1sBsKPRzR3Wsq/wV1qq9ljtPznjd4+kVreTBM7n/6xew0e4miePMpPimgY4QJCNl7GpN9A0EL12wlBnmWE/wQv1t4GMibT153T4hVvVwPSHMNGWfOCDpn5so8rd9gX27OwZL7Aas6WkTBevVecfXi/AtkhRmkXGmNcKLl8W1BR+oyOiLaqJfhixiP3JB+JSWSpRsUuuTxn6Bo56PXSbxwuuezWYnnicS0Iv4q6VPyAMGU249n6gG/ERpiIP7leObP9eJwX+9SaPu7n3GaOgrAV95BdUEmYgXAfxqTtmqpASJcrmcsude1I2iKwlDECyVY+k1SrBbPVv+BKrAyKflqZ/Dh2SjkJwH1/1G1DyeOI6TJwRRQiT5WwkwrxQw5ze3l0o9 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(396003)(346002)(366004)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(107886003)(2616005)(71200400001)(26005)(6512007)(6506007)(55236004)(36756003)(86362001)(38100700002)(38070700005)(122000001)(1076003)(83380400001)(7416002)(91956017)(41300700001)(64756008)(316002)(76116006)(54906003)(66946007)(66446008)(6916009)(66556008)(66476007)(2906002)(8936002)(5660300002)(8676002)(4326008)(6486002)(478600001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?hr4j37UOfHbOiAfSN9d6+NHuzIY5?= =?utf-8?q?vi4Xhq2aWt0hwVMkQayRAtdTdvHNyhIqfiVpvlNuv++HunQklRE4p02CJ6DMffc1u?= =?utf-8?q?xmqYAOIUz/Gtmfp0HQdyceTEqTFotsiU4nuTXDRvBYfyXCfxAVFiAa7ro0JcUUFVd?= =?utf-8?q?ShjpHgYHP5eZggfXeAGY7Q8bFkFX+Vk/UdvAcE9I54vlQ0vF+jS/7+4OLHSym03He?= =?utf-8?q?8Ssrh5uaixOhPtXbSoTyuSVUWADD8SCu4p308ZBsgLG09O8ogD4QgpaFVhXZhGdTX?= =?utf-8?q?r2xWDlKrv90rZKokeY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GNp3/Uxy0TsX+oHpobNtAvXnkewmlsZOTdZZzZt?= =?utf-8?q?AHXYpLGfDBCvCbaizJbfE4/Sb7tvnOnIgSLOUiuzksRusj4/CNO1dJ6EYAquwnjDQ?= =?utf-8?q?6xpLd1gTRt67o2BJahz8E9NHlpOowjD/YdbTIvfHk8JAozGDdZj5wweKqgHjYN1Pm?= =?utf-8?q?nRBz6Xrxm7S7X1y/9TlYS7fKTrm3ZBhsLFcQxbnVdwmUyR8lpbMum9lPI1GrktFWI?= =?utf-8?q?Sj8v52vlE6KgGjjyBLw/ZtRwATyVCRe2Axc5mnHbfbuFKXPjyNQFkB8cypLOh8R+r?= =?utf-8?q?Wd2EmlNbxmWEXCq13UVVfAVdphhwub3btvhoUF+651F5w3e7mlR/2IRq9JcEw/iAM?= =?utf-8?q?krMn4Act/mrsfIpiY5yfYxryg+p3tSUcyw=3D=3D?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2790b472-fa02-4918-8ab2-08dbcb6fdeca X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2023 22:09:14.2177 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8wpWODMTcvSaWDI0ayhJ/5PGYnAWJtENFEk7kXaGF/zsgOYo/ZzSIZ2E4/aE/tHCQGh0mrh3QxjRV6QGs6p3/CP+3fxqcwJKJjwW1rMnR2c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR03MB6376 X-Proofpoint-GUID: pYxa6fu9qz-NA_deBcOPhgRr-52qJx6J X-Proofpoint-ORIG-GUID: pYxa6fu9qz-NA_deBcOPhgRr-52qJx6J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-12_14,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 clxscore=1011 malwarescore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310120186 Hello all, This is next version of vPCI rework. Aim of this series is to prepare ground for introducing PCI support on ARM platform. in v10: - Removed patch ("xen/arm: vpci: check guest range"), proper fix for the issue is part of ("vpci/header: emulate PCI_COMMAND register for guests") - Removed patch ("pci/header: reset the command register when adding devices") - Added patch ("rangeset: add rangeset_empty() function") because this function is needed in ("vpci/header: handle p2m range sets per BAR") - Added ("vpci/header: handle p2m range sets per BAR") which addressed an issue discovered by Andrii Chepurnyi during virtio integration - Added ("pci: msi: pass pdev to pci_enable_msi() function"), which is prereq for ("pci: introduce per-domain PCI rwlock") - Fixed "Since v9/v8/... " comments in changelogs to reduce confusion. I left "Since" entries for older versions, because they were added by original author of the patches. in v9: v9 includes addressed commentes from a previous one. Also it introduces a couple patches from Stewart. This patches are related to vPCI use on ARM. Patch "vpci/header: rework exit path in init_bars" was factored-out from "vpci/header: handle p2m range sets per BAR". in v8: The biggest change from previous, mistakenly named, v7 series is how locking is implemented. Instead of d->vpci_rwlock we introduce d->pci_lock which has broader scope, as it protects not only domain's vpci state, but domain's list of PCI devices as well. As we discussed in IRC with Roger, it is not feasible to rework all the existing code to use the new lock right away. It was agreed that any write access to d->pdev_list will be protected by **both** d->pci_lock in write mode and pcidevs_lock(). Read access on other hand should be protected by either d->pci_lock in read mode or pcidevs_lock(). It is expected that existing code will use pcidevs_lock() and new users will use new rw lock. Of course, this does not mean that new users shall not use pcidevs_lock() when it is appropriate. Changes from previous versions are described in each separate patch. Oleksandr Andrushchenko (11): vpci: use per-domain PCI lock to protect vpci structure vpci: restrict unhandled read/write operations for guests vpci: add hooks for PCI device assign/de-assign vpci/header: implement guest BAR register handlers rangeset: add RANGESETF_no_print flag vpci/header: handle p2m range sets per BAR vpci/header: program p2m with guest BAR view vpci/header: emulate PCI_COMMAND register for guests vpci: add initial support for virtual PCI bus topology xen/arm: translate virtual PCI bus topology for guests xen/arm: account IO handlers for emulated PCI MSI-X Stewart Hildebrand (1): xen/arm: vpci: permit access to guest vpci space Volodymyr Babchuk (5): pci: msi: pass pdev to pci_enable_msi() function pci: introduce per-domain PCI rwlock vpci/header: rework exit path in init_bars rangeset: add rangeset_empty() function arm/vpci: honor access size when returning an error xen/arch/arm/vpci.c | 78 +++- xen/arch/x86/hvm/vmsi.c | 26 +- xen/arch/x86/hvm/vmx/vmx.c | 2 - xen/arch/x86/include/asm/irq.h | 3 +- xen/arch/x86/include/asm/msi.h | 3 +- xen/arch/x86/irq.c | 14 +- xen/arch/x86/msi.c | 25 +- xen/arch/x86/physdev.c | 2 +- xen/common/domain.c | 5 +- xen/common/rangeset.c | 14 +- xen/drivers/Kconfig | 4 + xen/drivers/char/ns16550.c | 4 +- xen/drivers/passthrough/amd/pci_amd_iommu.c | 9 +- xen/drivers/passthrough/pci.c | 94 +++- xen/drivers/passthrough/vtd/iommu.c | 9 +- xen/drivers/vpci/header.c | 482 +++++++++++++++----- xen/drivers/vpci/msi.c | 34 +- xen/drivers/vpci/msix.c | 56 ++- xen/drivers/vpci/vpci.c | 157 ++++++- xen/include/xen/rangeset.h | 8 +- xen/include/xen/sched.h | 9 + xen/include/xen/vpci.h | 42 +- 22 files changed, 875 insertions(+), 205 deletions(-)