From patchwork Thu Jul 20 00:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13319652 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 79C67C001DC for ; Thu, 20 Jul 2023 00:32:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.566253.884828 (Exim 4.92) (envelope-from ) id 1qMHb0-0001JW-Kq; Thu, 20 Jul 2023 00:32:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 566253.884828; Thu, 20 Jul 2023 00:32:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMHb0-0001JP-GJ; Thu, 20 Jul 2023 00:32:42 +0000 Received: by outflank-mailman (input) for mailman id 566253; Thu, 20 Jul 2023 00:32:40 +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 1qMHay-0001JI-MS for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 00:32:40 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ed4632e2-2694-11ee-b23a-6b7b168915f2; Thu, 20 Jul 2023 02:32:38 +0200 (CEST) Received: from pps.filterd (m0174678.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36JMeiB4017190 for ; Thu, 20 Jul 2023 00:32:37 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2057.outbound.protection.outlook.com [104.47.13.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3rxgyx9k43-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Jul 2023 00:32:36 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by AS8PR03MB7783.eurprd03.prod.outlook.com (2603:10a6:20b:407::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Thu, 20 Jul 2023 00:32:31 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::68d2:d90f:ac32:7c85]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::68d2:d90f:ac32:7c85%3]) with mapi id 15.20.6588.035; Thu, 20 Jul 2023 00:32:30 +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: ed4632e2-2694-11ee-b23a-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbF0bKnUtZ9ymR4HbSCROfRaaceHqpUNQBH26ssCKQDdJXaQ2tdz4BCa5cvjXfM+2CXyKx5X3M0ZraS5S2oDx+b085zBUffS9YMef3DZocfgryG9Y12hW20xhfnoKTK42HkUCosQ7zFUV5R5gW6VkB/B/74dee2pwziiVl6eKa/LoCXdnsOtrsEMnh61BlCpGhFStB/yPwSqCLbgeKPyVuBJfkDJA1KhzDV0WfbrMtgx0FF4z9lBEdVHekZOky2dN5cdPFtDZlwNMcmEQkGhcKWLAzG6WN9FXLwqczOJIiw5nQsOqNePn7htz6GJoBAsd8Co6fJ2kkBPj5javY1ydw== 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=JeowWcWPtPbWi0eZ5zqE5dIolWtWXr+/pLHrvWgkYIw=; b=EzPRdT+/Lh86sZc6Eq2rPy90VHag5ZaZm2CTy2jcQ5KGL4eXtRdcKge/fjv8qydsBLcQ4vLG7AC8F4ZN58v+B8jva+6dTpJ06coJeQrn9EAi7g7i0JWdt9l5uZ5k9WeLFWex/MFfJgRjXZKF70ACcFCro5HFRY11wWIjOeh21JJhgdxgR2Aw/aBGHI3s+MVZA/0LAJW4S7i8Sccq991JY48V2C8LCj58M+2IsJcPPc4EkXRvboOd6vTk5pf8F+5QBVMu1gGyjjgMdATiviWXaAsfiLnGG1eSjRQM/sQcvBzkf0GbS8iS9JEtC7g+/M/5Q6J2R58A/QFjdGXGAz1Mkw== 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=JeowWcWPtPbWi0eZ5zqE5dIolWtWXr+/pLHrvWgkYIw=; b=Ms3+PTMXxzhiQ/YLHmQS9srZJWqfcr7ksM0HqUTk/6gulYAN7WipaptW414VCQXyyTVAyPIQwgDK/S0IUutNtLLTOXo+NVIQ4dMA0sh2Kt7AjyS7z+SHRMO3dpIRozhKv+zmhTqq8D975MwzT44a36cqphgm4m2qbr7ao6nX0oGcPlAyJCTgiOSoTtD7tYo1+QnSpKUCW7vyMqMtrO6gZrcHKDViKqnANvCwH8LZzpiPVj8uTVlzICCMfgQ3YITVRL4+7Aj++d1wBAFkwpK6nfW+iVEg0DE7e5x9hrTPHPCrhXIu+D53LJM9EE7zefXsVvqc3IBG2fJy0Igd7++A0w== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk Subject: [PATCH v8 00/13] PCI devices passthrough on Arm, part 3 Thread-Topic: [PATCH v8 00/13] PCI devices passthrough on Arm, part 3 Thread-Index: AQHZuqGqn2EU3dWVak6ca3YhrfMkhg== Date: Thu, 20 Jul 2023 00:32:30 +0000 Message-ID: <20230720003205.1828537-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.41.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|AS8PR03MB7783:EE_ x-ms-office365-filtering-correlation-id: 321a223e-27e2-4bf1-f2db-08db88b8cd7f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 43cJlLMRYqHQR/vpUCi5bRyjhiJgd8a6GBG7gCxq+dCimBww/k91Ufjdbtk0YK7SpttfdwO/il0ESazyVhhXBoqafqa4/EowJG6ppWxO/25tHst30F3A36tWZKP+WPex4dVEym9zaKYcN2uSeFMNLg2Qnv3wo1LQnOa8QwLJ2B9PsxqR1YrGO/4k4J4oRE/WRtTYOQEWEBMABRnJfn5DLM1Lvk5yWIbsFfTg9Ke1ZHTHTISSiyY52rYsrBRz9FXLKTD+54PloHLwva0h05+nuuYVOMTOi+cI7xGwReWkaqlcvIy7ElCt5PM2JU/MO2bIbDS1p8BteLvsA2uerVd2Q2mgtYb4iJy6c7oDnXIdQiV4FzaP2jokPusuxCP1QGhzcgqQJ3TlN+Ur2Wyf/duuMPUGQTU8Aa9FWhTkM79C9ySAi64WkkL+C2jtf5yphceXlEWSytkDUFvX1+pWOo7hg31BiXQuXOqW02tgSo9iVZKQ6Ix+UBvaZD3Jc0gpNhnYKC8haSkUXpAaMxyK7ht3mYaD6pEKt10nEnHmlXjJ4R0v/oMLJjIH4QEq08Q4lIhiQO28vI98WyvpCqtJA6iiOPTJFOOBXpR04ZvBxIpm+ZSQcc+iXcdjjViNmGPxrJv2 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:(13230028)(4636009)(136003)(39860400002)(346002)(366004)(396003)(376002)(451199021)(55236004)(26005)(1076003)(6506007)(41300700001)(316002)(83380400001)(2616005)(107886003)(186003)(6512007)(6486002)(122000001)(478600001)(66946007)(71200400001)(4326008)(64756008)(38070700005)(66556008)(76116006)(66476007)(91956017)(6916009)(38100700002)(86362001)(5660300002)(66446008)(8936002)(8676002)(36756003)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?k+V0f/x7UZ4idZsVYg4bWGgvzhXv?= =?utf-8?q?pXcKpw9OkbNTT6U7CVkQlD/PNzjLPScnTUWmJYcI5c0RxWtD3dn2RaVGwbQFWWxyv?= =?utf-8?q?wGsDlPiR6iNQA3L43IYLhHj/evYnx2CqWVQIZ3aT9O72VxiJP/WRIJlbyqVeMEpz+?= =?utf-8?q?G5xy0Z3KWiocgsQmFZ7cLoXOfrGGVWei8bAHec/MogWB3+iT9u6tUbO++/+x2HBkG?= =?utf-8?q?ksx/a0PTHhnttjzY060veTRi0FYy/Uhzn2M0SS2zGPVuS8LIAgOSUnd9wW9mGKsiR?= =?utf-8?q?AksQ9+DsccrRCenhivRRC+dl6uPYHlh0Me3XgPWVfQZY4zfX1ozUMcMhc2RDOA4WW?= =?utf-8?q?OTOVMXzTVEnVRCiOTwLK0egJO3L+HX5FqPadHlYxbDVN2AyOizfjE2uYBASccnC26?= =?utf-8?q?6z2f+Z58zhQPDKbBcLEwFjOXu0Xb57rd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jLEQX36sFIa9AM3xVqyp?= =?utf-8?q?XY46WTM6Z2dnMG4LRJQ4hb2bgf/qtpR6cSf/I/czFZbwYJ2yF2oxyL+0X6oncR0o1?= =?utf-8?q?ap1WTSwK0AcD3It4m0sYs/jUSRAdssgDzyLG9aU3VwyYnFMKvtGxGQsbpymFGFR3H?= =?utf-8?q?S6bqeTIHx3X6rLn3xBt4lmqba369h+hWwcwU8JewQIG/gKUMMuPL/AzuAoe6j2nnA?= =?utf-8?q?i9HePqDY0TeUDa0OTl0DoGjnGruk5ukADg=3D=3D?= Content-ID: <50EB4D64EAA452418832C6EE22A4DF46@eurprd03.prod.outlook.com> 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: 321a223e-27e2-4bf1-f2db-08db88b8cd7f X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 00:32:30.5997 (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: FrdkSzRQzh6L9oB1hJZivGbsRzSzmSgnVS6JZ//0Iqw3xO1k2ehiDACqUNCGBrcsHBDy3IaBsji9rU8ZrVNX3lJJx8MZ4oLy3PCKoGuOxLw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7783 X-Proofpoint-ORIG-GUID: IPVgSiLDSK0xNEr2y08kqCCSqaArlJCI X-Proofpoint-GUID: IPVgSiLDSK0xNEr2y08kqCCSqaArlJCI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-19_16,2023-07-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 mlxlogscore=726 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307200002 Hello, This is next version of vPCI rework. Aim of this series is to prepare ground for introducing PCI support on ARM platform. 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. Apart from locking scheme rework, there are less major fixes in some patches, based on the review comments. Oleksandr Andrushchenko (12): 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/header: reset the command register when adding devices 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 Volodymyr Babchuk (1): pci: introduce per-domain PCI rwlock xen/arch/arm/vpci.c | 61 ++- xen/arch/x86/hvm/vmsi.c | 4 + xen/common/domain.c | 1 + xen/common/rangeset.c | 5 +- xen/drivers/Kconfig | 4 + xen/drivers/passthrough/amd/pci_amd_iommu.c | 9 +- xen/drivers/passthrough/pci.c | 96 ++++- xen/drivers/passthrough/vtd/iommu.c | 9 +- xen/drivers/vpci/header.c | 453 ++++++++++++++++---- xen/drivers/vpci/msi.c | 18 +- xen/drivers/vpci/msix.c | 56 ++- xen/drivers/vpci/vpci.c | 176 +++++++- xen/include/xen/pci.h | 1 + xen/include/xen/rangeset.h | 5 +- xen/include/xen/sched.h | 9 + xen/include/xen/vpci.h | 42 +- 16 files changed, 828 insertions(+), 121 deletions(-)