From patchwork Tue Mar 14 20:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 13175006 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 AC5C5C74A44 for ; Tue, 14 Mar 2023 20:57:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.509842.786441 (Exim 4.92) (envelope-from ) id 1pcBhw-0003tI-MV; Tue, 14 Mar 2023 20:57:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 509842.786441; Tue, 14 Mar 2023 20:57:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcBhw-0003tB-Ja; Tue, 14 Mar 2023 20:57:20 +0000 Received: by outflank-mailman (input) for mailman id 509842; Tue, 14 Mar 2023 20:57:19 +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 1pcBhu-0001PG-Vn for xen-devel@lists.xenproject.org; Tue, 14 Mar 2023 20:57:19 +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 ce07fcaa-c2aa-11ed-87f5-c1b5be75604c; Tue, 14 Mar 2023 21:57:18 +0100 (CET) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32EKchDk017378; Tue, 14 Mar 2023 20:56:33 GMT Received: from eur05-vi1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3pb0520156-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Mar 2023 20:56:32 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by PAXPR03MB7967.eurprd03.prod.outlook.com (2603:10a6:102:21a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Tue, 14 Mar 2023 20:56:30 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::967e:573a:15a9:176e]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::967e:573a:15a9:176e%4]) with mapi id 15.20.6178.026; Tue, 14 Mar 2023 20:56:29 +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: ce07fcaa-c2aa-11ed-87f5-c1b5be75604c ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KC+QS4Tfda97B5JX5EyOp/DUgDilagBhIOp5xaWdvjEVRg7xemXl3oNNm4hmu0io7UjGL6hwYKF+WmND86C4g2H8d9TGBkpJx1bjHTgDFCC+zWckTpqKbuvIXoCOhplU3FSy0KXoxg6D1CDFiB3PkWtrKbXXn0t57GKKEddq2Yb1emTY1rDiaPjW6MhWRNnNEYA4+zBo4+uhx4ziqiMEdufRkZtWidjC5Yhdxsw9Dxf4H95mYcefEP1nuRlE1ObWbhyFE0nH/bQLdUl8XbdtEAi86tRIhvgT57hHXjKjSprKGNINIv4Ob16aARFiAfEtNqn5ErIUP9U2cbPtyRB4ww== 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=gCGo2K1yWc3whjLYAbvm4bc/nJTzqYRDNubeotfQN6s=; b=MI1rx/kclSuQB+UaRc5zLWXcXzjNvBEmoyXgEr0PeEC7g5hKHZbfiodoDHpieb+dSyVzZ6f6HdgNAuWyMyG4CT/sFXyxBKTF7Xr0lk0Fb2/s2EaZk9rOWUpwM1goBzcIbnsUIgK5p8ZmN5o5K4NYZMLENJwNhOI9Xga59polvluZIF+uVDMxG0XVjBEsczigp/BADEUV0l6vRDjd2nLmD9m0Ii2HES+a/alKXcgm4Uc8EoykOe6hIpUOf4Q2JvsG2iDED939DhbVNrJCln+rEWLuVCvR07DywzuZrkiEIfZAfSHnb8PSr6Iy3ETn5WIgYg9/1OytkZAICOT07af+YQ== 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=gCGo2K1yWc3whjLYAbvm4bc/nJTzqYRDNubeotfQN6s=; b=hWjPEDEQsz9ii/GhH+wpZq5pzG2701hsi6TzRswTwSGEzAfPNaOe/d+Jui108MjiX11pBEnFV8mda9iMzwPG+uDijjffQpeLFrwte3+98bBLIcowF9rs3mJg2Ue6mI7RKyku6QwwAyp2JLToji6VfApSg1RCFDr3yQhrkOcNsm+rf2aTaqmSpcMtkPkudXC9kY3PLoBCPjvKXJxUfNuhIM21m5uIQcTyfQy/uyPV/oeFj1/OuIJ1AJPjC6k+BxNh5gzRx/uE+yJyaJ0U+1y+qtVdORcuY9cqtMhCWFMnhyvto4r1ge6S3PqByKjcfozKRxNawLyBzp+QM0SksRjAYA== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Paul Durrant , Kevin Tian Subject: [PATCH v3 0/6] vpci: first series in preparation for vpci on ARM Thread-Topic: [PATCH v3 0/6] vpci: first series in preparation for vpci on ARM Thread-Index: AQHZVrdy6rMOYMwx706MoeCGqRZxrA== Date: Tue, 14 Mar 2023 20:56:28 +0000 Message-ID: <20230314205612.3703668-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.39.2 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|PAXPR03MB7967:EE_ x-ms-office365-filtering-correlation-id: b6afa6e5-5d50-4ef7-c676-08db24ce954f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: brxRUYPHkt48aBdvEtqOltztUmC5Pgz/QY8CriXE+BckuqYthMYcvmIOEqPXPwrs+eHzohkQYt44x/FojH/4hkaJM3soy1phpT+XfYYQxzBsGZlZNPsqwEy2LB6gCBTrh/UI4Aay9EoLh8xHFxZfl2QNd0hrBRWOw0hGB2IKKmQkI8nxJGbm0mxXZpBMVq/IqxNxI1PbqlWctTjrG5AdmF51QzNjvU7HJVzZm7fq3O43hd6yB+I1NBNew8OC6v9lgRpSRQ3BjOE3umwkNpe2iSUiGAclwx/QJTP31IkYdm1xcCtMvVrnd9LP53yNOHhZFRIsNXerS/IuwiA6Ae/ZwwOHfvA9L1nEX16fG3xzNk2xo22Ee9KK+uLpidWwhLX0OIHK08CW9r5y0N1ozWKB304m9FBWsusd1qGHgeDt0Ps2UOtndoo1dMW2qPeOaH8tj5n6D5gmkRh5vtHxrWkfIqeZ1nneIq7VnQRNXp63a5JWQkzQfHz/8JkLyt0OhPIMMgtpNgMyfHIW7hgFS4llWUgYeCmGVHATbPbVCD8XB8ZhQxbwJApARCRriAgD/4XAiG+R5shVym5Ehj/NHNWZCQDEfeqod3GpVR+tA0LSbndIDvh92CY+qUCVlQrpu69d4C5kxPklShZYYmYG9/Ilu4vibKCzSuKqyc6mDwelOhgYUVb05aZ7hbfSrVMPG5n8cm3eGHJYjWjdd/sqLftR3A== 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:(13230025)(4636009)(376002)(346002)(136003)(366004)(396003)(39860400002)(451199018)(54906003)(316002)(86362001)(36756003)(38070700005)(38100700002)(478600001)(122000001)(55236004)(83380400001)(6512007)(6506007)(2616005)(1076003)(186003)(26005)(7416002)(5660300002)(6486002)(91956017)(41300700001)(6916009)(71200400001)(76116006)(64756008)(8936002)(8676002)(2906002)(66556008)(66476007)(66946007)(66446008)(4326008);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?QlblVywenbSvypuaPzbcjNFguQBb?= =?utf-8?q?Ms3uUKnT7CryHlJRAt8vV/byUr4LHByitjvSWj1GpdYSfPllredBS5l8oxLLe/r9y?= =?utf-8?q?o/Zi8uBOwD2LnDD+Wd28k5Xdhbhj3g6/pz0urqgwLOYKk5fGI+QOlXhDAbJ6IkeYV?= =?utf-8?q?e+M5TxfUBJycN/e4uUkhyZMXHqaiewJXoqLJ7oB52RMwdkk2dsy06o540p+NNBsvv?= =?utf-8?q?N39iE2HxEjpbrnVHsNpTw/Znad8PCz4SjSYQNNmb3VK2UQ6/dgUohZKcpog5QoVxC?= =?utf-8?q?WCXYPWolVnTxmvXIzXM7T09taBXf7M084KdTyRfD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fdstYn2jd0k8Ud9gS5U968u/?= =?utf-8?q?jAI8jcKDqLjFysz6VE+OVupVDNuAvmKOAiUCfsj0g0CZb9YOVEKqiw3XulKCQ2mMF?= =?utf-8?q?hB6gUBsKzc6ofSrFkX+AB3qMJAUjV0apRkbB/zdDXkJj3M2Cy8T06SpUL5Dupjjlc?= =?utf-8?q?RMSYTcSRyiCoIKQaiJzHIjZxMBlZu6/s2oS71707jYmHN06tGTOvPUBr9FQDuy0Ph?= =?utf-8?q?8D25BroMO2jjQws3IEehPYmAXwqLIjIdN1Q4AceZxwlZ335UIIPd/m/tOOOWQ6AAA?= =?utf-8?q?s+ZEZ793ZNYgbGa9832SltPF2Y1Dg0XYCsWWqB+XWe9YRZ1IkMTMBPxts2XXbiesp?= =?utf-8?q?ijxm7lRbdeCZc9AoUrrtCDIR0NyKACnz4A=3D=3D?= Content-ID: <1ABC6007A1120C41AAE42EC995A6DEDF@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: b6afa6e5-5d50-4ef7-c676-08db24ce954f X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2023 20:56:28.9640 (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: o45o97pj783TykNVoDdyRyOZ85iS/7bPq8S/x4GWgBAswcZEAqlPwnH4PyY8kTg65crELVzZuBKmLeaFNEL8jSFutqGmveHZDxGkJZtTWJU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7967 X-Proofpoint-ORIG-GUID: nNE1jLtMnASfCT5Vw66q0yNeR9m3LNI_ X-Proofpoint-GUID: nNE1jLtMnASfCT5Vw66q0yNeR9m3LNI_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-14_14,2023-03-14_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=385 priorityscore=1501 suspectscore=0 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303140168 This patch set is spiritual successor of "[PATCH v2 0/4] vpci: first series in preparation for vpci on ARM". But most of the contents was reworked. Main aim of those patches is to allow vPCI MMIO handlers to work with DomUs, not only with Dom0. To do this, we need protect pdev from being removed while still in use. Jan suggested to use reference counting for this. So this series include patches from other series ("[RFC] Rework PCI locking") that implement reference counting for pdevs. With reference counting implemented, it would be possible to make further rework of PCI locking. Oleksandr Andrushchenko (1): vpci: restrict unhandled read/write operations for guests Volodymyr Babchuk (5): xen: add reference counter support xen: pci: introduce reference counting for pdev vpci: crash domain if we wasn't able to (un) map vPCI regions vpci: use reference counter to protect vpci state xen: pci: print reference counter when dumping pci_devs xen/arch/x86/hvm/vmsi.c | 2 +- xen/arch/x86/irq.c | 4 + xen/arch/x86/msi.c | 44 ++++++- xen/arch/x86/pci.c | 3 + xen/arch/x86/physdev.c | 17 ++- xen/common/sysctl.c | 7 +- xen/drivers/passthrough/amd/iommu_init.c | 12 +- xen/drivers/passthrough/amd/iommu_map.c | 6 +- xen/drivers/passthrough/pci.c | 141 +++++++++++++++-------- xen/drivers/passthrough/vtd/quirks.c | 2 + xen/drivers/video/vga.c | 7 +- xen/drivers/vpci/header.c | 11 +- xen/drivers/vpci/vpci.c | 31 ++++- xen/include/xen/pci.h | 18 +++ xen/include/xen/refcnt.h | 59 ++++++++++ 15 files changed, 293 insertions(+), 71 deletions(-) create mode 100644 xen/include/xen/refcnt.h