From patchwork Mon Jul 18 21:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12921788 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 EBB7ACCA485 for ; Mon, 18 Jul 2022 21:16:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.370125.601804 (Exim 4.92) (envelope-from ) id 1oDY5v-0004kX-Bg; Mon, 18 Jul 2022 21:15:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 370125.601804; Mon, 18 Jul 2022 21:15:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDY5v-0004kH-6J; Mon, 18 Jul 2022 21:15:59 +0000 Received: by outflank-mailman (input) for mailman id 370125; Mon, 18 Jul 2022 21:15:58 +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 1oDY5t-00043p-P7 for xen-devel@lists.xenproject.org; Mon, 18 Jul 2022 21:15:58 +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 cfd31e8d-06de-11ed-bd2d-47488cf2e6aa; Mon, 18 Jul 2022 23:15:56 +0200 (CEST) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26IImA9R005163; Mon, 18 Jul 2022 21:15:46 GMT Received: from eur03-ve1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2051.outbound.protection.outlook.com [104.47.9.51]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3hcrm7v72d-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Jul 2022 21:15:45 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by VI1PR03MB6288.eurprd03.prod.outlook.com (2603:10a6:800:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Mon, 18 Jul 2022 21:15:42 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488%7]) with mapi id 15.20.5417.035; Mon, 18 Jul 2022 21:15:42 +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: cfd31e8d-06de-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CWeE+wJYWJJrwDHWsMt0I0M6DEXNVrWCgbCZUPtc2jIcH7M9kDuPs4JMi3+R++xIlnT211ZBwGYC7ggerZr2CRR2fnY7iAXlm+uizigD3MANCalXGo53W2cVN/lP/uYCFXVZeNtCUPgc3dtDtQYA6hgDx/XxgwZtkr8PdChfcWoe7Bdb/Mx45ao1frW53lGukUeP4XujT5IwulzQUzXOKEsF7M1c3JgsZC0HFL8E7qjTnYJWEOD/nlqxrViiZDOguiG+tu2Y7ANgNrN+LAFNcbKRF5bpte0uWa0lGzcokVpWkOho2URIU/1fubRjvyASHJCW8xM2h4uNLXTVJqjgCQ== 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=mrfxkv03rMCDP4WEfyDsnkkchTYLXSytKn95yOOQFFk=; b=AUBOxrV1zCTx1FZZ+uFs1RMb6gZ2CA7fzYn0OaON6ixOHTn96+/jCKCr3d6w9Wq6tJYz6mxDxgtzyuHVtmsqezayucPKN48CkKDt+iON5ppzZaZ7P1cMlyPa5FOnYsFRqdoaTBAMvXyrkB1pzmA6NB9C82o4wVe7yDIyJlRq5uPt1o3+NpJzDOh/4m10UZIjwqlwyASIMKRAOXwasu71Ov004haKaNgHbBZhIoKiphcVSShtGgM3ztOc2zoWK/C5wie0AYQUI3/QJEkeKOWLd1aqJcBk9fbnFfneMIWBaA7KLjv7cNNI0qr5CWGKdNOlR1Z7y9Vz7nNVjJlfQwv/uw== 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=mrfxkv03rMCDP4WEfyDsnkkchTYLXSytKn95yOOQFFk=; b=GiznS+bq9UmTyCb/84UqC7dVFvyhh8Jdsa81hYsIpiHQs3MOtUerHwZtDl9Avrxzf1XiT8WaYTHxr19al1lnNUgjH28gdab2OuQOwcAeG1041g3hg9SZ7vxQo6wwvGf7zkFmsO9He/f761gyrdKo04lEwX1jZbaeAa7HzGxEBbPuwSq6A/CZAZ3oR1fJHagb5WOpa3xGp5k1hg7p5CgZjwm2gfxkD1EHIJBQ6jRzLCxjWjG/N8FgGEcN09igRcIr7Fns02lNFC3ohMuXQr/P970rcwQE62vHTjzhqi4psantt6RzJ8EmsQ5EArKDQmNY9zwMWsAkU3jDt2pHVHviRg== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Oleksandr Andrushchenko , Jan Beulich , Andrew Cooper , =?iso-8859-1?q?Roger_Pau_Monn=E9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Paul Durrant , Volodymyr Babchuk Subject: [PATCH v2 1/4] pci: add rwlock to pcidevs_lock machinery Thread-Topic: [PATCH v2 1/4] pci: add rwlock to pcidevs_lock machinery Thread-Index: AQHYmuuJlTOCfCU2VEeylMdGd6xTkw== Date: Mon, 18 Jul 2022 21:15:42 +0000 Message-ID: <20220718211521.664729-2-volodymyr_babchuk@epam.com> References: <20220718211521.664729-1-volodymyr_babchuk@epam.com> In-Reply-To: <20220718211521.664729-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.36.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9a871693-0bba-4246-9dd2-08da6902ac02 x-ms-traffictypediagnostic: VI1PR03MB6288:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wpmVIOdDNmSMgAqWHfBSsR9o2XTEriWwO6FVHDMcUKiJuHX3zDk3kmliSYz0LfpeAo9ZOc38CssGN31eLTd0UQyEAhrTjuSigTkj+ackrJSUh8/6/5KJwdHbwMK5P/36pZFLrdWUs8e4GJGdc7G1xGHLGp7PN/kVSkGR2rFC8AMLvvTj/WDE5HrspwroWyXgiX4Emu1pJzEosaDr587qfXvfSxKJpv1AyIYv05Xgyq2gRo92t3yK6jhSrScQCCzWm954dXFn0bTlavn96ETewhRKi3R5JzmHuXfxmZ2TcM4OC6hJi99sICK/WnFDjJLr3h3I+umuUq6ZORsrxfS7HfXMS9eZ5AzZ4U3osdXj2F/1W8O6R+ITtfRO5xqRN8EnhpgTbOEvFFtTy51PYgURpngk2tVE8N1PT7lUn+AvsBYn6171wMe+h9oAkfEQW+let2BLB/fb9WgZNWvmvnCKcyS47iZm8cmPWTotXWza33bQggLLbqYGwA7vH7i4c7OATwiKfn0DM+HYvCQGM1MjisWKR+LY3BqVy9K2LWtHXdKuZ21dAXUpV+GrqQBUCBnQYzWt50B6PgFjreltrqCQbbkyZsRZKbu5//QNSgXFgKCHm6l+EZneWUGA2TEi95CoroTKXs7AB3oTMdSyv/iZuEYyPxCAgAhgPOr9dtJsh20NZNBal+ru7sthQktLre3X6RHXhc8CrJX+LvLa2n3P7uWf5qRR38f5c6ccyFQqQFZcy0u+LEw1i4y9Daoq8Cjf51B9UeI7gLDLTq9R5RteS+z7VmRlGvTkMl8NCDw2HtV/A1ComHnZat5Ic19KrOYI7eX4nvsE2HMCtzweLsCUAg== 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:(13230016)(4636009)(396003)(136003)(346002)(39860400002)(366004)(376002)(2906002)(5660300002)(8936002)(36756003)(186003)(4326008)(86362001)(91956017)(64756008)(66946007)(66556008)(8676002)(66446008)(66476007)(76116006)(122000001)(6506007)(478600001)(316002)(2616005)(6512007)(6916009)(26005)(107886003)(54906003)(6486002)(55236004)(1076003)(41300700001)(38070700005)(30864003)(83380400001)(38100700002)(71200400001)(309714004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?C7YAgEgWd29Bn7l9BkWaPKq?= =?iso-8859-1?q?wzZxjOJTknjR6aNkIFqKiDPtVhVXeihDT+w7O8fZuG1flrcii9XbePGPvjL5?= =?iso-8859-1?q?MFxxvVzBz8g6mXJ8zqgYHcAxF4k7CwhJxwJTqhmj+GnBq/Lxs9c7M/0mlNER?= =?iso-8859-1?q?t2KL1Vw9aE3AXq3vPOSrO+FcZ+KuNN0zVxBPl0MzE7VwcY0OQ0TThjShqdl1?= =?iso-8859-1?q?/62Qzo5lPdYzglwvBSMMFIHnQieaV9mvBAbcbH9J9xZ0ULs+SrjLTajRBW9g?= =?iso-8859-1?q?NbG5geg7SSP2H42pn+i1+0TkIEIDYkiMGsl03Yyse88FJR4xjQnWA3+wWTKr?= =?iso-8859-1?q?Jax+bGF5YT3MydMM1CQeLpi1jLHTlno4EMZ9iF6u4/tUqZ8fJl9RER6D2xBG?= =?iso-8859-1?q?NOYgTRUBEPI/lNxme8ZP89n12FJgWSC7xR21bdoJdZ9BvRGl8V4Sgera4rS5?= =?iso-8859-1?q?Y7hnSA4A+RRuOlNY3UEDee+BWI5iuC3dqWpuqkw5lydsX03dUbaBM2GKDHHU?= =?iso-8859-1?q?3PMMTHJG3QdM2wpSKPpzdy2b/aaPDExZy9CRRAYwcyNFVm6OCAIKRToLZ+MS?= =?iso-8859-1?q?AKvRJxNicoTumcTVB1+4FDyl2N35G5bxTly94JeX2We+k6GCmhoTVmr/Ehtz?= =?iso-8859-1?q?vQ/J3nsVKEjR3PgF0MafoX2KsLtbgIAdWc87qJWtPGoACFs7OlLCWJCZ9i3D?= =?iso-8859-1?q?vQRYCbn9Yi0X5tUbK8GXJR7TIUKd+e2TLxi5kvp2HCLB45WyzpTDX3gQ+84U?= =?iso-8859-1?q?Qs1Mo8ob4CY6i/J730Gg4kDLPkPiil1UQaO7Y03XqTjPOL/YT5JaFcSTMwU9?= =?iso-8859-1?q?JygtFVXzkb9vD+N3QtEjv16i/XyOt4bt6C/y2asTB2IviQiSM8Y5XNArK2IJ?= =?iso-8859-1?q?wv4Y/bNRyp85Lrpzd3qBtUZMfEh4Fu+j4Jg6qLyxkJftEXEeVt3ypwJ2DPnT?= =?iso-8859-1?q?CoIRDKo8Wdbw6SFFzyZyA2OepRJxF4UcD9owUkr2wdMAUOGaPjQ6insD+yDu?= =?iso-8859-1?q?tQR7hHYL8QghFOkwmmqlvOEY5iENQlcgqVrUEM9YANLScYInbiAjuhTP3Ovc?= =?iso-8859-1?q?kLRF1P/h2rD4dZfeQ8JAiRT+RVSP2dgNU9JSRCe8DSKDxW8NeSx0tRbB/g2e?= =?iso-8859-1?q?Cm9V61FVyJQSurizwZEbMT5PWXug5z+DLWmzhaA5YKTRJ1DiUeJcAnYCuPxW?= =?iso-8859-1?q?ov/c2+ef2hwu87mmFVhft7+BtfRR8y6d8l5yAUK8nHEAI/WQ7FSEj5/RN0Om?= =?iso-8859-1?q?5ZsLIORpMyjNiW2KOV27K8lbUj5XcI/hfBZ+wu3iZIUUdTUmmea+T6tNQ8Mt?= =?iso-8859-1?q?0U6KUMSAhHaeY+QMgYfJIr7OpWJx0/AV4EuETgzoZ1+e8eUDCyuKbrApTXYe?= =?iso-8859-1?q?XYjxcIFetNHZvGK020YRy6jCgHqSw0i8AsyCrmHLoHOdBzCtwqzDa9vBqaPQ?= =?iso-8859-1?q?WyrUfQMnp4kwLjmTV9t+28MPmOtoJakLYugnwRMIDI9hL+ZmxylJlaNzolwt?= =?iso-8859-1?q?DSGKzbHB7NZvrlTZNxa7zVgA+1omEqkorkHQlQzzwO2WdX3WlOfEFAgqoIF4?= =?iso-8859-1?q?DY15OTOYnEhg32RXrzYS4GeoRYSLPEygthU9mtGGis/BrZw6j3CbRuJGKAaz?= =?iso-8859-1?q?8cbler5oGmvDYxf1h1f6H8cA5znpAku8vAAHXzg=3D=3D?= 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: 9a871693-0bba-4246-9dd2-08da6902ac02 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2022 21:15:42.2581 (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: l9XW/h6+XsKHYBkSpQeMJ4bE7wercW/YB7tkhVo24AUPSGhaX5WkbEvowUfEI2OQfw117QAu6zCgj3VE2vwIWJ+hXy7i/yKVFhuPrHn8+WU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6288 X-Proofpoint-GUID: xxKPsVfYVFEv_UacRVeoyWL-kt6yti-L X-Proofpoint-ORIG-GUID: xxKPsVfYVFEv_UacRVeoyWL-kt6yti-L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-18_20,2022-07-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207180089 From: Oleksandr Andrushchenko Currently pcidevs lock is a global recursive spinlock which is fine for the existing use cases. It is used to both protect pdev instances themselves from being removed while in use and to make sure the update of the relevant pdev properties is synchronized. Moving towards vPCI is used for guests this becomes problematic in terms of lock contention. For example, during vpci_{read|write} the access to pdev must be protected to prevent pdev disappearing under our feet. This needs to be done with the help of pcidevs_{lock|unlock}. On the other hand it is highly undesirable to lock all other pdev accesses which only use pdevs in read mode, e.g. those which do not remove or add pdevs. For the above reasons introduce a read/write lock which will help preventing locking contentions between pdev readers and writers. This read/write lock replaces current recursive spinlock. By default all existing code uses pcidevs_lock() which takes write lock. This ensures that all existing locking logic stays the same. To justify this change, replace locks in (V)MSI code with read locks. This code is a perfect target, as (V)MSI code only requires that pdevs will not disappear during handling, while (V)MSI state is protected by own locks. This is in preparation for vPCI to be used for guests. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Volodymyr Babchuk --- Since v1: - user per CPU variable to track recursive readers and writers - use read locks in vmsi code --- xen/arch/x86/hvm/vmsi.c | 22 ++++++------ xen/arch/x86/irq.c | 8 ++--- xen/arch/x86/msi.c | 16 ++++----- xen/drivers/passthrough/pci.c | 65 +++++++++++++++++++++++++++++++---- xen/include/xen/pci.h | 10 +++++- 5 files changed, 91 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index d4a8c953e2..c1ede676d0 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -466,7 +466,7 @@ int msixtbl_pt_register(struct domain *d, struct pirq *pirq, uint64_t gtable) struct msixtbl_entry *entry, *new_entry; int r = -EINVAL; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); ASSERT(spin_is_locked(&d->event_lock)); if ( !msixtbl_initialised(d) ) @@ -536,7 +536,7 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq) struct pci_dev *pdev; struct msixtbl_entry *entry; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); ASSERT(spin_is_locked(&d->event_lock)); if ( !msixtbl_initialised(d) ) @@ -682,7 +682,7 @@ static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data, { unsigned int i; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); if ( (address & MSI_ADDR_BASE_MASK) != MSI_ADDR_HEADER ) { @@ -724,7 +724,7 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev) ASSERT(msi->arch.pirq != INVALID_PIRQ); - pcidevs_lock(); + pcidevs_read_lock(); for ( i = 0; i < msi->vectors && msi->arch.bound; i++ ) { struct xen_domctl_bind_pt_irq unbind = { @@ -743,7 +743,7 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev) msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address, msi->vectors, msi->arch.pirq, msi->mask); - pcidevs_unlock(); + pcidevs_read_unlock(); } static int vpci_msi_enable(const struct pci_dev *pdev, unsigned int nr, @@ -783,10 +783,10 @@ int vpci_msi_arch_enable(struct vpci_msi *msi, const struct pci_dev *pdev, return rc; msi->arch.pirq = rc; - pcidevs_lock(); + pcidevs_read_lock(); msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address, vectors, msi->arch.pirq, msi->mask); - pcidevs_unlock(); + pcidevs_read_unlock(); return 0; } @@ -798,7 +798,7 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq, ASSERT(pirq != INVALID_PIRQ); - pcidevs_lock(); + pcidevs_read_lock(); for ( i = 0; i < nr && bound; i++ ) { struct xen_domctl_bind_pt_irq bind = { @@ -814,7 +814,7 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq, spin_lock(&pdev->domain->event_lock); unmap_domain_pirq(pdev->domain, pirq); spin_unlock(&pdev->domain->event_lock); - pcidevs_unlock(); + pcidevs_read_unlock(); } void vpci_msi_arch_disable(struct vpci_msi *msi, const struct pci_dev *pdev) @@ -861,7 +861,7 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry, entry->arch.pirq = rc; - pcidevs_lock(); + pcidevs_read_lock(); rc = vpci_msi_update(pdev, entry->data, entry->addr, 1, entry->arch.pirq, entry->masked); if ( rc ) @@ -869,7 +869,7 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry, vpci_msi_disable(pdev, entry->arch.pirq, 1, false); entry->arch.pirq = INVALID_PIRQ; } - pcidevs_unlock(); + pcidevs_read_unlock(); return rc; } diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index de30ee7779..7b4832ffb1 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -2156,7 +2156,7 @@ int map_domain_pirq( struct pci_dev *pdev; unsigned int nr = 0; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); ret = -ENODEV; if ( !cpu_has_apic ) @@ -2313,7 +2313,7 @@ int unmap_domain_pirq(struct domain *d, int pirq) if ( (pirq < 0) || (pirq >= d->nr_pirqs) ) return -EINVAL; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); ASSERT(spin_is_locked(&d->event_lock)); info = pirq_info(d, pirq); @@ -2907,7 +2907,7 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p, msi->irq = irq; - pcidevs_lock(); + pcidevs_read_lock(); /* Verify or get pirq. */ spin_lock(&d->event_lock); pirq = allocate_pirq(d, index, *pirq_p, irq, type, &msi->entry_nr); @@ -2923,7 +2923,7 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p, done: spin_unlock(&d->event_lock); - pcidevs_unlock(); + pcidevs_read_unlock(); if ( ret ) { switch ( type ) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index 6be81e6c3b..6ce7b5523a 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -613,7 +613,7 @@ static int msi_capability_init(struct pci_dev *dev, u8 slot = PCI_SLOT(dev->devfn); u8 func = PCI_FUNC(dev->devfn); - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); pos = pci_find_cap_offset(seg, bus, slot, func, PCI_CAP_ID_MSI); if ( !pos ) return -ENODEV; @@ -782,7 +782,7 @@ static int msix_capability_init(struct pci_dev *dev, if ( !pos ) return -ENODEV; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); control = pci_conf_read16(dev->sbdf, msix_control_reg(pos)); /* @@ -999,7 +999,7 @@ static int __pci_enable_msi(struct msi_info *msi, struct msi_desc **desc) struct pci_dev *pdev; struct msi_desc *old_desc; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); pdev = pci_get_pdev(msi->seg, msi->bus, msi->devfn); if ( !pdev ) return -ENODEV; @@ -1054,7 +1054,7 @@ static int __pci_enable_msix(struct msi_info *msi, struct msi_desc **desc) struct pci_dev *pdev; struct msi_desc *old_desc; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); pdev = pci_get_pdev(msi->seg, msi->bus, msi->devfn); if ( !pdev || !pdev->msix ) return -ENODEV; @@ -1145,7 +1145,7 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool off) if ( !use_msi ) return 0; - pcidevs_lock(); + pcidevs_read_lock(); pdev = pci_get_pdev(seg, bus, devfn); if ( !pdev ) rc = -ENODEV; @@ -1158,7 +1158,7 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool off) } else rc = msix_capability_init(pdev, NULL, NULL); - pcidevs_unlock(); + pcidevs_read_unlock(); return rc; } @@ -1169,7 +1169,7 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool off) */ int pci_enable_msi(struct msi_info *msi, struct msi_desc **desc) { - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); if ( !use_msi ) return -EPERM; @@ -1305,7 +1305,7 @@ int pci_restore_msi_state(struct pci_dev *pdev) unsigned int type = 0, pos = 0; u16 control = 0; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); if ( !use_msi ) return -EOPNOTSUPP; diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 938821e593..f93922acc8 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -50,21 +50,74 @@ struct pci_seg { } bus2bridge[MAX_BUSES]; }; -static spinlock_t _pcidevs_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_RWLOCK(_pcidevs_rwlock); +static DEFINE_PER_CPU(unsigned int, pcidevs_read_cnt); +static DEFINE_PER_CPU(unsigned int, pcidevs_write_cnt); void pcidevs_lock(void) { - spin_lock_recursive(&_pcidevs_lock); + pcidevs_write_lock(); } void pcidevs_unlock(void) { - spin_unlock_recursive(&_pcidevs_lock); + pcidevs_write_unlock(); } -bool_t pcidevs_locked(void) +bool pcidevs_locked(void) { - return !!spin_is_locked(&_pcidevs_lock); + return pcidevs_write_locked(); +} + +void pcidevs_read_lock(void) +{ + if ( this_cpu(pcidevs_read_cnt)++ == 0 ) + read_lock(&_pcidevs_rwlock); +} + +int pcidevs_read_trylock(void) +{ + int ret = 1; + + if ( this_cpu(pcidevs_read_cnt) == 0 ) + ret = read_trylock(&_pcidevs_rwlock); + if ( ret ) + this_cpu(pcidevs_read_cnt)++; + + return ret; +} + +void pcidevs_read_unlock(void) +{ + ASSERT(this_cpu(pcidevs_read_cnt)); + + if ( --this_cpu(pcidevs_read_cnt) == 0 ) + read_unlock(&_pcidevs_rwlock); +} + +bool pcidevs_read_locked(void) +{ + /* Write lock implies read lock */ + return this_cpu(pcidevs_read_cnt) || this_cpu(pcidevs_write_cnt); +} + +void pcidevs_write_lock(void) +{ + if ( this_cpu(pcidevs_write_cnt)++ == 0 ) + write_lock(&_pcidevs_rwlock); +} + +void pcidevs_write_unlock(void) +{ + ASSERT(this_cpu(pcidevs_write_cnt)); + + if ( --this_cpu(pcidevs_write_cnt) == 0 ) + write_unlock(&_pcidevs_rwlock); +} + +bool pcidevs_write_locked(void) +{ + return rw_is_write_locked(&_pcidevs_rwlock); } static struct radix_tree_root pci_segments; @@ -581,7 +634,7 @@ struct pci_dev *pci_get_pdev(int seg, int bus, int devfn) struct pci_seg *pseg = get_pseg(seg); struct pci_dev *pdev = NULL; - ASSERT(pcidevs_locked()); + ASSERT(pcidevs_read_locked()); ASSERT(seg != -1 || bus == -1); ASSERT(bus != -1 || devfn == -1); diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index f34368643c..052b2ddf9f 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -158,7 +158,15 @@ struct pci_dev { void pcidevs_lock(void); void pcidevs_unlock(void); -bool_t __must_check pcidevs_locked(void); +bool __must_check pcidevs_locked(void); + +void pcidevs_read_lock(void); +void pcidevs_read_unlock(void); +bool __must_check pcidevs_read_locked(void); + +void pcidevs_write_lock(void); +void pcidevs_write_unlock(void); +bool __must_check pcidevs_write_locked(void); bool_t pci_known_segment(u16 seg); bool_t pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func); From patchwork Mon Jul 18 21:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12921787 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 C35F5CCA479 for ; Mon, 18 Jul 2022 21:16:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.370121.601771 (Exim 4.92) (envelope-from ) id 1oDY5q-0003xh-Al; Mon, 18 Jul 2022 21:15:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 370121.601771; Mon, 18 Jul 2022 21:15:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDY5q-0003xa-6k; Mon, 18 Jul 2022 21:15:54 +0000 Received: by outflank-mailman (input) for mailman id 370121; Mon, 18 Jul 2022 21:15:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDY5o-0003xU-UL for xen-devel@lists.xenproject.org; Mon, 18 Jul 2022 21:15:53 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cc83e0d7-06de-11ed-924f-1f966e50362f; Mon, 18 Jul 2022 23:15:51 +0200 (CEST) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26IImA9Q005163; Mon, 18 Jul 2022 21:15:45 GMT Received: from eur03-ve1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2051.outbound.protection.outlook.com [104.47.9.51]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3hcrm7v72d-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Jul 2022 21:15:45 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by VI1PR03MB6288.eurprd03.prod.outlook.com (2603:10a6:800:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Mon, 18 Jul 2022 21:15:42 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488%7]) with mapi id 15.20.5417.035; Mon, 18 Jul 2022 21:15:42 +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: cc83e0d7-06de-11ed-924f-1f966e50362f ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lOBvARjaHrV3kFe71EpnIPF63BTk02OQMSqRhEm/9mhND9KUnKZVyLrDfe+Qx48F53fZVI7qWgVjW6kEHLKalHeqhsWoSzWBQh3zoYBbXNBtjmV08r8TuII4DA/bLOM7J5ahL7SwNdOCmP1DLv8AUtPSF/0NH6SBY3wkoK/h3WhWiFBQ0B6kCoA6NcFPs41Ig02J7d+A64sqEoKdjI13zn0UXm516VNKsRttcaxV09bfNfhU3aOxJsRdfeBEE0MI1J4E9c0PAOq8EhPUExXhRZclXXDZzo2aVdzGSh5woMBCaA6bIHvHRfF0lIOj0QFY0xguM4w/K7tCFleGPYLAFA== 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=T4aVJIa9/bhaGhacjrCd+o+XlsceCPV6UM3umTjKOTc=; b=n8qkOFGJQmMVVy6/LZvbhb0O+57XTg7pVSb57KZJWjUAJEUViTphNQpaAdw/y7iMqYR7U1fDtTEBi8fxB4zDF5REXYReMoIIu1OiDgjwInmXYM7gJ6RWpYRR3U2Cx3UqEiSUlAYSslEzRXuoogQHs9ON1hweC0MtyE0C7yc2xrA9JGHFWf/WqbIl9E0+N2rYO8ZvcczDrly8foiO65IQFHoXRYPgPmX10X+ThKHKUuaagKXqbbA9DVj6JbHDqisObYcXBphNwXXlyneNLlGuzciIXAEeXrCOQCqzPqCAmPJ/cMTf2lqa02knDcMlfCH7+/W2I5eR11kkZOxLXkSSBA== 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=T4aVJIa9/bhaGhacjrCd+o+XlsceCPV6UM3umTjKOTc=; b=pLuqQgdYNZhHAHmIRlXCWNS3CQQBS5nHJxJz1tEUUk603gilKpLuCU4/X89r2H790gU+kBNmV72+OgNgfxo+vXFPJIZDFF5v2aAw/BffzXDgb/FR90iPUlJI+w9JVdVvCmPKfviNiTKi2+5ZUO9KqVRrCPANGR733SJ4fqr1rrao+pY21paHEcloIE7X70hZPVkL9EgArIcePZsMAnnmRDc2wp3OhgHeBJYv+21EfIIBu31lFgNR7+w3LnqQ2CArVWdL+HQeLd1I0biTuUUm7FM7anHkHkuDNXAgq69OCD1G7mpd0jYIeY9PVGyAus5vjfeh+SMhZ8pOGpN++XVWGQ== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Oleksandr Andrushchenko , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Subject: [PATCH v2 2/4] vpci: restrict unhandled read/write operations for guests Thread-Topic: [PATCH v2 2/4] vpci: restrict unhandled read/write operations for guests Thread-Index: AQHYmuuJ9rK3Yz1P9ESDEYkc1v52zw== Date: Mon, 18 Jul 2022 21:15:42 +0000 Message-ID: <20220718211521.664729-3-volodymyr_babchuk@epam.com> References: <20220718211521.664729-1-volodymyr_babchuk@epam.com> In-Reply-To: <20220718211521.664729-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.36.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c438cfa-7cae-43d5-c2c9-08da6902ac28 x-ms-traffictypediagnostic: VI1PR03MB6288:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0aRk/lKutfhDcHfnwhIMWg7jFqWqRhnFnjh8ea1V//kZgSesLkPYXPaAFBeqH+NreOmciL1gjH0ImHZ1LgssGVeBbAVL/hJj/20H0JHtxf1SZMXFOFMiysF3EU3CiPWLuZs5uyZjSINvDMylanO2z2zdHcNBAWvdnV1CR96Npwi3zYwZsVgmwD/OIJ9+8+KwCrtCYeSgy/xMjPHAooGiXUTedAr53LmuMGoEWyJ38/VzS0wUEdFPEoiho7VazuRQ6u3Q2gpVANGREsWdYF4e5JlW26IEttNoE4bMTQaaY47Q6unhWhZP6oBjekNnZCQN4RTCxMBqOkkR0ReMpzsvAiMXXtTIo5BOISzzla8V1Qt2vWL3i/0KcCZo5nDxnY9NgRKEXZmjZdrsii6e7jwrrdgXkaigF91CSG+SwaD70ZGCDkQuhvzE/PTKs9BYbTF7wVPYsr1iHw0328JX5bfqzO5enEZhzcRojU+bZgsT+UGnxXEHSxsPApMIa5t37LPxyjY1fJzEzf6xhFXGjbtA2urf9BXqgeHReaMo8aWcofgr8U/uMqp8mhDjtlwA4k7ZIqJlWZZYWw5v17qfKpOFBNq2IUwhXu50DLCikY18JFXjXeXEmhsRYzOTzS2RvY+JACw57YWJZnPxiI0hbEY+RGJ6dAV5wS5sUnH/bK6Z10x/aNjepzmwCs7gALZQumpawLGfMZadooQ5fkRET1IbkVErf8at6t+aSwTYMBCMdscbB3H69/zmNgHcVye9/LTY+VXQQhBYQZdihs9Owrb1s0TsUUeIN1KMdWrtoloYHFzzu+IJUrjj9/z2IO4E2bDL 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:(13230016)(4636009)(396003)(136003)(346002)(39860400002)(366004)(376002)(2906002)(5660300002)(8936002)(36756003)(186003)(4326008)(86362001)(91956017)(64756008)(66946007)(66556008)(8676002)(66446008)(66476007)(76116006)(122000001)(6506007)(478600001)(316002)(2616005)(6512007)(6916009)(26005)(54906003)(6486002)(55236004)(1076003)(41300700001)(38070700005)(83380400001)(38100700002)(71200400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?EZMDCXNj5d2pPOlvkbC/bJB67wOI?= =?utf-8?q?m6IEnPiiV3Ut3Zu6FN/kyuHEuppS+3eOoDcOnyldBB1GhrKJY/vnbYPbm96HkY65C?= =?utf-8?q?OP+yELuaH2XTLM8RuuHG7JcJXiALsTg+CiN/mzJ+fiUfRcW7TKBNC5mQSnrM8KYoH?= =?utf-8?q?3AoA3I64uj1QIqb5uLkT8ikJP9zn5Dj67Flg5zvfDkv3392NIePaM/at4ToiMrAAE?= =?utf-8?q?dN1z4HJDuvTxZ8+0IWd/IVme11n5lGicpTf3KcNO/aOEBNpp3HYKjdPjBVVXPSWp4?= =?utf-8?q?r90lzr7JVOtr8zk4fkkPeQDcfFkq85CxfjJqyyZFgxsoG0XNf5o5a3oS6Mt1IQfwk?= =?utf-8?q?MipPvAzhgnZv1Ut8kMgo9ilZtJrWRCD5FmqBG52ZjglTUtXEernfBKsg2/7ORUTMg?= =?utf-8?q?I4yd4mfBdzkIXwhZI5X941PRWFYkPbzfIhb8Jb7Br8ORFsg+4/4BvFuB4GgpkKyLT?= =?utf-8?q?NuWlzFdLCkwwwrPY+moncCm8xU4VcEkAdbCGkhBCoRkBYAubEEyr3JB43zTp1r1Xu?= =?utf-8?q?Sz7gx+TdRT0RQC7RPm157Xa6ErvhM510+1CPcO6BMnLpRmKUdaUx9eP6035Vl0giQ?= =?utf-8?q?j+DK6BU/30YM6p0T2aU1G35V8Irr2TkXnpCgC3eUIw8MJs5rbRgIoQRALvAx1PRA7?= =?utf-8?q?eXKfDTbRcHmFbH5B/Lkl5MaUVRzRrQgrk8Jzo8cDWX/0b6jJqSDIBu9AlqDqEcnRY?= =?utf-8?q?hx2202v9xMjl29ChsQ9NQ1KdEv0mitccOXhJ6VSKkLuAmomIgLJn0wa4ve8BPwbQX?= =?utf-8?q?9/8kl6hdnLCJJQZl9SE/w1F7BtG1dwmI+pll4wsVtxKB6ul+QNTW3lR4Eu91G0rDJ?= =?utf-8?q?NnbkeiEvReUe2Pi0t9eQ2fEs68kwtRXaJGAxTvfUETtXi4ZlTkxNigHUNn7+jssYd?= =?utf-8?q?HNdCOGV5tKfyOA9UHpZVeb1Ry7bmMVjwLc72MK7blG/JvO7Hdm2KzvfD27k66ZANx?= =?utf-8?q?9rCW4Mzh9dHL26h3EVqWeegBSbaNLQXl16g+S1q9OFWinb0Q+W4BxkYtc5OkKq3Ia?= =?utf-8?q?Xc/oIsgDwq+aoZiBsYDSay235bUE8224A9UH5jsROz7R82JMUtkjRMw7/w6jk/hRR?= =?utf-8?q?NjtBHCJaxfvzLKwypoTw+DfRevknB/SBX2ckMWivhQ9dUjct0YXI5cEk+gZW6LcuU?= =?utf-8?q?LMoOhnhG+Kihg+JiV+CQA+3Wy2W3P6j5b2ky7WjuWn+FJitvBYr/z1P7m+e9qwXaG?= =?utf-8?q?hD64h5SkFCvGFPiBg3A5fkFF0BWl1gRWyDFT2yWK0R4KNiv3NxS2/x3p5FFQVjxOs?= =?utf-8?q?JiU1luN633BYDZl+hm1RjYJyoEnwoBQ2A6wtGOfAkSbU3ZkS53y8W5fZnBwhI0c91?= =?utf-8?q?1G6KPpEtlpcFKhKsvN1b+7lsnN1dwTszNWhg56zCwiplVLmdKeDkuCRjTULVpOh2U?= =?utf-8?q?bEP+wDTbO8D9gWsJ2F0Egx4+jceYyRPkqLmlDVTtgYTOSQuqQYdSS9x/pOKHo5A1x?= =?utf-8?q?TuNTDWd9SRWzYIA+NvBlEn5tV3TpTEpS3OdEmsX3hF2wkbjzn0YiuzoGgz4ZnLMs+?= =?utf-8?q?vn88dElOuTK8HP4xZxh/lFOphju6bX+nuA=3D=3D?= Content-ID: <1D95F0D67B20544C809C0743122493D2@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: 7c438cfa-7cae-43d5-c2c9-08da6902ac28 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2022 21:15:42.4925 (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: N04M2wFrNwB4re/zwa2o9dMddffbO+wlqVD1+mOHiqUwdTrhK7RtLS1z5KJp8UGlfi15Ib+Ve6tUZkJaE206t4KHIsO75qXdfDqgMkadR2Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6288 X-Proofpoint-GUID: zhFlXhG--pwUbkfipFwlwnGzJ__2JklR X-Proofpoint-ORIG-GUID: zhFlXhG--pwUbkfipFwlwnGzJ__2JklR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-18_20,2022-07-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207180089 From: Oleksandr Andrushchenko A guest would be able to read and write those registers which are not emulated and have no respective vPCI handlers, so it will be possible for it to access the hardware directly. In order to prevent a guest from reads and writes from/to the unhandled registers make sure only hardware domain can access the hardware directly and restrict guests from doing so. Suggested-by: Roger Pau Monné Signed-off-by: Oleksandr Andrushchenko --- Since v6: - do not use is_hwdom parameter for vpci_{read|write}_hw and use current->domain internally - update commit message New in v6 Moved into another series --- xen/drivers/vpci/vpci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 9fb3c05b2b..c7a40a2f41 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -215,6 +215,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, { uint32_t data; + /* Guest domains are not allowed to read real hardware. */ + if ( !is_hardware_domain(current->domain) ) + return ~(uint32_t)0; + switch ( size ) { case 4: @@ -255,9 +259,13 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, return data; } -static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, - uint32_t data) +static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, + unsigned int size, uint32_t data) { + /* Guest domains are not allowed to write real hardware. */ + if ( !is_hardware_domain(current->domain) ) + return; + switch ( size ) { case 4: From patchwork Mon Jul 18 21:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12921785 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 87251C433EF for ; Mon, 18 Jul 2022 21:16:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.370126.601810 (Exim 4.92) (envelope-from ) id 1oDY5v-0004p4-Lb; Mon, 18 Jul 2022 21:15:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 370126.601810; Mon, 18 Jul 2022 21:15:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDY5v-0004oL-Gv; Mon, 18 Jul 2022 21:15:59 +0000 Received: by outflank-mailman (input) for mailman id 370126; Mon, 18 Jul 2022 21:15:58 +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 1oDY5u-00043p-L5 for xen-devel@lists.xenproject.org; Mon, 18 Jul 2022 21:15:58 +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 d0366d87-06de-11ed-bd2d-47488cf2e6aa; Mon, 18 Jul 2022 23:15:57 +0200 (CEST) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26IImA9T005163; Mon, 18 Jul 2022 21:15:47 GMT Received: from eur03-ve1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2051.outbound.protection.outlook.com [104.47.9.51]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3hcrm7v72d-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Jul 2022 21:15:47 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by VI1PR03MB6288.eurprd03.prod.outlook.com (2603:10a6:800:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Mon, 18 Jul 2022 21:15:42 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488%7]) with mapi id 15.20.5417.035; Mon, 18 Jul 2022 21:15:42 +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: d0366d87-06de-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fnHiF3xqr0l7KB1cozyYzFptAwsSkKHK5kZHVvJlsRV57uV4DLvpkbI5QTwYqp7QfqhJeUEeqUfSdVX+oeAo3SmB1ZNqsklehINn51dBJTnkNVQuBr3m1Mk9sFxQwb+SRthGfLMCj0PEqTRCEAcl9HCUEVYNNl49AZsFg76RrXG9XZsceXOs3ndKI8DjBQHW8zFN6+LgzrUTgfmcrC+ZADVJ/orT8tQshcgycVuF5h7m2zw4jbYIhYL+/LfHjYM8/B6lPFXtjbpPikiyySwNGcyTzvAEK0mkkIMpWC1lxj9xoCx0WmRYl0fzEjv5BiZ04QG7Y92VVKP/UNDx6VKGBA== 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=51uIUXejlp+stzTIoouwR0IIpUJyhvl7006kWAxwFuA=; b=B1ropvomBBjZOxibwUE6C6140HbQu5bCYX04YOgBMeDgKf9HKLirQMO3sB1bAubjl82Vwtzoada+1mHfTHOPhot3w3LynO7vRFF8rOwXFwzecKZrAua63gYQ3kZV0CYZrR4slNA4Ol/8Xt1108bU4aKy5m2r3LIrRGj7b1oXMqz6uL2Z6Ge3Ni65adXO6ne71fRDBzHEn2qsIG9Zb5sZ3j8FCes71hkkk/Nybvy1EyTTjOd0rIaL/Cf6Z4yJiWOMdpXza9tOlIagDz28R08oN0e9Fker/MWu6ZsjvGKKsKnA8l1PCvyB+VwSpPHUCos9FJUU24W4R7ITGKx59oS+LQ== 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=51uIUXejlp+stzTIoouwR0IIpUJyhvl7006kWAxwFuA=; b=mFNZm90s75AAP+RPh1NlQ7a5VcL64OhwoOzNMmVUjyFIuHY1NtAvsAPEYBefAz9nlcy10WZMKGo4CPBuBqWy5e9FfP5BEnQJ+88HnE8PcPBqRUMkmH1HO2Ij7UJAR7uLLDM+8bLm7vtnEevgMjc0JLUAPGazXvH+NQxObfzV3tWp4kT/YtO5yZnsXIhc0RWPPKyKJSe51c9KdfK1ywTIiPjdPhKfSgEKlxUwi9gYremadqqIek5Onh8DoYZ4wAykE8TOEcPdKMvcwSXuk1Bc5c3xKlKgOujReng+mM6CEFeAgdFWkASHk+ifuOb99/yuZNqYXfohdhQRpOFo6JiWEQ== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Oleksandr Andrushchenko , Jan Beulich , Andrew Cooper , =?iso-8859-1?q?Roger_Pau_Monn=E9?= , Wei Liu , George Dunlap , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Subject: [PATCH v2 3/4] vpci: use pcidevs locking to protect MMIO handlers Thread-Topic: [PATCH v2 3/4] vpci: use pcidevs locking to protect MMIO handlers Thread-Index: AQHYmuuJA1lWCBgnj0iqi/IOtvD1PA== Date: Mon, 18 Jul 2022 21:15:42 +0000 Message-ID: <20220718211521.664729-4-volodymyr_babchuk@epam.com> References: <20220718211521.664729-1-volodymyr_babchuk@epam.com> In-Reply-To: <20220718211521.664729-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.36.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 34069ad9-9f6e-407a-ac59-08da6902ac53 x-ms-traffictypediagnostic: VI1PR03MB6288:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: c3xyq5Nx1U+m5MHuIrZ25mx7wNPx+WeGtDmIssKabcrgWhpEI6vwoLZWrTpn4oyVR0Gux/eolqf6cg07QDI3OSop48VZJPeEB58MeEdNETQ8n2MXb5624WlYJ7jHp/CS9zNqd2eU2I3s+Aesle3hEZMKqoeRW2Ns9Z9QtndTIzOxr7BA38sh6HkQZBZQaVPFwjzdqTEHU8YgggrkDCng12I2J5GQyPodV74nOYgjL9skm/XKby5nG8WMBHXUsPYz8s1U8FwEzwL/vemvfqEsbvSg38gwjAF0fs0A2qMOrxGN+zykdPVD5HMSkDUhfnKgP2VjTHWvzyFqAmat1sT22f+nJHCIha3W9MFLehuZUW7WNMow9Xx7Xs46bE/+ZDHqgvGztig9YXhq9SR+TFq1i5v/uf9877vu6jIikH5S+D1jajp5eoeNrSHYD4Pt+Aqs9m96qIa5D9+zHHY92WIk9pRTQmbZZUuvcyiFc6DpGF7osdmXDB3rVPX/2tn0KxNO1dPSIrHqNH663NwR6ERVn3WVAzfuRlorVFrqZHDf1lATUj7ahTrGagA17jhV7KXfY4fb/mlfslcoYgwNz8mXA5uq39V5qzxajfZCb/ZI+nc1+mIn2Wy4URwHrspA/rYXc4XIufprS5arLpu+74XYrz3WVToA7spCsPgdRVu02ic48nGrfQhOwByUtWCf7flMKVepzyAHu+YyZy0l3KBOOcH/OFm/6e5UejSPoWUf2ZyjaQOgjzTseB83IyAFxuM1CNJvxxETaoaPrzibR4GKSDmBxENIE01QUvvO6f0u5ZwPlq2+RwwY2Rj0Hz78URMg6+2AXyfW3Js10iIWNMKBjA== 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:(13230016)(4636009)(396003)(136003)(346002)(39860400002)(366004)(376002)(2906002)(5660300002)(8936002)(36756003)(186003)(4326008)(86362001)(91956017)(64756008)(66946007)(66556008)(8676002)(66446008)(66476007)(76116006)(122000001)(6506007)(478600001)(316002)(2616005)(6512007)(6916009)(26005)(107886003)(54906003)(6486002)(55236004)(1076003)(41300700001)(38070700005)(30864003)(83380400001)(38100700002)(71200400001)(309714004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?f8TdYz0CSYwwzu6pGaumKlr?= =?iso-8859-1?q?Lp1jRvmzf/2p2T+rZQQ+uS+1Cl2LFg7Ok4x+rYyV1xqxg8x8Pgk724RCPILF?= =?iso-8859-1?q?4rUw55VJABrH0ZwGU7jnaaWDzxqBWuZhCJGkWcTILFUw+muBSy0xSBAb6FaS?= =?iso-8859-1?q?Xt2enSYZsc8/4HseIHujm+nBeU0w3n/XViss9RoUJ5B511jylfgcy93ezbb+?= =?iso-8859-1?q?xsF5FmVfv732166O98gwHs/lxlowL8t0odY3/lA09Ph7/q1gug8pg6aQxu4+?= =?iso-8859-1?q?Vpl/XiXMMW+P+m8ckY+5kAxDZnzwZg205XM0HNUHFs+fcMnr0Ined1f6rKHr?= =?iso-8859-1?q?lUqTyd1ICJNDk4u3FChZyBAWNjgo+vi0UjNVjqS2PxJ/OarrIFZoiyuSqgqh?= =?iso-8859-1?q?RJvgULJ1Cjzpnc6JSDZimBs/P0p+TjkFZwdxEtp4KwTVv4F9vpNTMV1HWFSi?= =?iso-8859-1?q?8L3bvqwK67+uuGDx8hwEimGj88Hv4S6nKoT3Tup1CvZfqJ3DE27ma2Ua1m7d?= =?iso-8859-1?q?/avcXAuW9N86lgsEDNuBPVVduVmk/PkosgVXb314Grn52FHkg1PRF7PfQiy8?= =?iso-8859-1?q?/+ARYQ5vSwn7RppqbJU97WmUc3IBr0znJbti1Yar/4etvjGipoMRiH6oWRnY?= =?iso-8859-1?q?X85H937FIjrPi7nPjfLFtUbxO8g/N6WSqeHLUy3sXFT8dPs3j+G3RdFJYRi+?= =?iso-8859-1?q?dNerJY6UzwYMfwPQ79QZz5j7SReuLZJ8Z2bEmmnbtbz8IkhTQiXcs61OOUfB?= =?iso-8859-1?q?8pTSIjomXQkLxAZYbuY6X47sifKxsB5TunnKqKI1BC7J5SJ5EM1jNDu57Ah8?= =?iso-8859-1?q?0c2Hxk6qjfOPdiN8sCC76I4/3uGk4n0AYK5UOBRNxlEaIqBDM3fFGwR+eblu?= =?iso-8859-1?q?MmTm2dYCqlbnxPkEYTV9Po6d9PvgddL2TIHLazH1ikSML/ClYZjQznT9+/Bo?= =?iso-8859-1?q?l9jARJalNGBXD8dKZJMUcVWzkToUBTdi8outmhuV/WXKVhvIf8DAwU5zDmQd?= =?iso-8859-1?q?5LlQGxpka0y1q//CbapZQXRiazXuotQgst0Y5tM9c9CZQvO5l4B0jjWXjFVE?= =?iso-8859-1?q?RgEve8W2D2w7buGITuGk9gXqbDWc7wQroSIj+vv4qEabg90jUhsRxacOUYHN?= =?iso-8859-1?q?YSuKUHdo8VzlcG35zrqL0TfgAi7/Ci50G6pBDRr/P8PXMChkf99y6QdaXJ+T?= =?iso-8859-1?q?uIPFYT6HicqoCgrZ0QQYl4zR9F7amWDuXmA4z5HEZhWOiR1abJHrD1Zcup/H?= =?iso-8859-1?q?2pujRccUi/C6kyGXUiQv1BLo0HmgJ/eggImNUd+f2o5PU1MGgZ5+zE2Q0L85?= =?iso-8859-1?q?3PZdBNjAuvjknGc01Y0LhvQhIa5i8NC30LijuSjrB1Yb4SkMvcNVSDPocG2I?= =?iso-8859-1?q?bhNOC+KyuSa8+N+kd9r95VEIOQbzhswvaBTfbtc1VBw+08B0YVf4J0wA6I5b?= =?iso-8859-1?q?S5rTHHJMCTzriEABOKbEhAVy/45fbx3tA0vJYEwKjID9pF6o7wqzTNb0nUz3?= =?iso-8859-1?q?D9jf721S36Ki69ZBTvHtvuDR02fTW7UcPAOrIaZRWfB6ZhuzWK8obtpB041t?= =?iso-8859-1?q?VPQgIcPqI4TyRd4jg4Nw9f5PunbrcBmPyOO7NiqysZjoCy3sepBFlzK/JSKY?= =?iso-8859-1?q?oT7kiSkzJOA5PcDjkQ15M7r4rTxXHueIr4e8qfA=3D=3D?= 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: 34069ad9-9f6e-407a-ac59-08da6902ac53 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2022 21:15:42.7893 (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: yEJI410boRtbdSdqHfzpNCr79plULzdsebkneEC2l5Xbr3Cn3kaBEm8AN4rqFt+WLGG3XnlStnmRf1sQ10yHZ6NX/m1nJLGElLvEf9VhFvg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6288 X-Proofpoint-GUID: z2sEGbcbuvCAHsJY7GH6nIJoabdoNh6i X-Proofpoint-ORIG-GUID: z2sEGbcbuvCAHsJY7GH6nIJoabdoNh6i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-18_20,2022-07-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207180089 From: Oleksandr Andrushchenko vPCI MMIO handlers are accessing pdevs without protecting this access with pcidevs_{lock|unlock}. This is not a problem as of now as these are only used by Dom0. But, towards vPCI is used also for guests, we need to properly protect pdev and pdev->vpci from being removed while still in use. For that use pcidevs_read_{un}lock helpers. This patch adds ASSERTs in the code to check that the rwlock is taken and in appropriate mode. Some of such checks require changes to the initialization of local variables which may be accessed before the ASSERT checks the locking. For example see init_bars and mask_write. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Volodymyr Babchuk --- Since v1: - move pcidevs_read_{lock|unlock} into patch 1 --- xen/arch/x86/hvm/vmsi.c | 24 ++++++++++++++--- xen/drivers/vpci/header.c | 24 +++++++++++++++-- xen/drivers/vpci/msi.c | 21 ++++++++++----- xen/drivers/vpci/msix.c | 55 ++++++++++++++++++++++++++++++++++----- xen/drivers/vpci/vpci.c | 16 +++++++++--- xen/include/xen/pci.h | 1 + xen/include/xen/vpci.h | 2 +- 7 files changed, 121 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index c1ede676d0..3f250f81a4 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -891,10 +891,16 @@ void vpci_msix_arch_init_entry(struct vpci_msix_entry *entry) entry->arch.pirq = INVALID_PIRQ; } -int vpci_msix_arch_print(const struct vpci_msix *msix) +int vpci_msix_arch_print(const struct domain *d, const struct vpci_msix *msix) { unsigned int i; + /* + * FIXME: this is not immediately correct, as the lock can be grabbed + * by a different CPU. But this is better then nothing. + */ + ASSERT(pcidevs_read_locked()); + for ( i = 0; i < msix->max_entries; i++ ) { const struct vpci_msix_entry *entry = &msix->entries[i]; @@ -911,11 +917,23 @@ int vpci_msix_arch_print(const struct vpci_msix *msix) if ( i && !(i % 64) ) { struct pci_dev *pdev = msix->pdev; + pci_sbdf_t sbdf = pdev->sbdf; spin_unlock(&msix->pdev->vpci->lock); + pcidevs_read_unlock(); + + /* NB: we still hold rcu_read_lock(&domlist_read_lock); here. */ process_pending_softirqs(); - /* NB: we assume that pdev cannot go away for an alive domain. */ - if ( !pdev->vpci || !spin_trylock(&pdev->vpci->lock) ) + + if ( !pcidevs_read_trylock() ) + return -EBUSY; + pdev = pci_get_pdev_by_domain(d, sbdf.seg, sbdf.bus, sbdf.devfn); + /* + * FIXME: we may find a re-allocated pdev's copy here. + * Even occupying the same address as before. Do our best. + */ + if ( !pdev || (pdev != msix->pdev) || !pdev->vpci || + !spin_trylock(&pdev->vpci->lock) ) return -EBUSY; if ( pdev->vpci->msix != msix ) { diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index a1c928a0d2..e0461b1139 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -142,16 +142,19 @@ bool vpci_process_pending(struct vcpu *v) if ( rc == -ERESTART ) return true; + pcidevs_read_lock(); spin_lock(&v->vpci.pdev->vpci->lock); /* Disable memory decoding unconditionally on failure. */ modify_decoding(v->vpci.pdev, rc ? v->vpci.cmd & ~PCI_COMMAND_MEMORY : v->vpci.cmd, !rc && v->vpci.rom_only); spin_unlock(&v->vpci.pdev->vpci->lock); + pcidevs_read_unlock(); rangeset_destroy(v->vpci.mem); v->vpci.mem = NULL; if ( rc ) + { /* * FIXME: in case of failure remove the device from the domain. * Note that there might still be leftover mappings. While this is @@ -159,7 +162,10 @@ bool vpci_process_pending(struct vcpu *v) * killed in order to avoid leaking stale p2m mappings on * failure. */ + pcidevs_write_lock(); vpci_remove_device(v->vpci.pdev); + pcidevs_write_unlock(); + } } return false; @@ -172,7 +178,16 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev, int rc; while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == -ERESTART ) + { + /* + * It's safe to drop and re-acquire the lock in this context + * without risking pdev disappearing because devices cannot be + * removed until the initial domain has been started. + */ + pcidevs_write_unlock(); process_pending_softirqs(); + pcidevs_write_lock(); + } rangeset_destroy(mem); if ( !rc ) modify_decoding(pdev, cmd, false); @@ -450,10 +465,15 @@ static int cf_check init_bars(struct pci_dev *pdev) uint16_t cmd; uint64_t addr, size; unsigned int i, num_bars, rom_reg; - struct vpci_header *header = &pdev->vpci->header; - struct vpci_bar *bars = header->bars; + struct vpci_header *header; + struct vpci_bar *bars; int rc; + ASSERT(pcidevs_write_locked()); + + header = &pdev->vpci->header; + bars = header->bars; + switch ( pci_conf_read8(pdev->sbdf, PCI_HEADER_TYPE) & 0x7f ) { case PCI_HEADER_TYPE_NORMAL: diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c index 8f2b59e61a..d864f740cf 100644 --- a/xen/drivers/vpci/msi.c +++ b/xen/drivers/vpci/msi.c @@ -184,12 +184,17 @@ static void cf_check mask_write( static int cf_check init_msi(struct pci_dev *pdev) { - uint8_t slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn); - unsigned int pos = pci_find_cap_offset(pdev->seg, pdev->bus, slot, func, - PCI_CAP_ID_MSI); + uint8_t slot, func; + unsigned int pos; uint16_t control; int ret; + ASSERT(pcidevs_write_locked()); + + slot = PCI_SLOT(pdev->devfn); + func = PCI_FUNC(pdev->devfn); + pos = pci_find_cap_offset(pdev->seg, pdev->bus, slot, func, PCI_CAP_ID_MSI); + if ( !pos ) return 0; @@ -277,6 +282,9 @@ void vpci_dump_msi(void) printk("vPCI MSI/MSI-X d%d\n", d->domain_id); + if ( !pcidevs_read_trylock() ) + continue; + for_each_pdev ( d, pdev ) { const struct vpci_msi *msi; @@ -310,7 +318,7 @@ void vpci_dump_msi(void) printk(" entries: %u maskall: %d enabled: %d\n", msix->max_entries, msix->masked, msix->enabled); - rc = vpci_msix_arch_print(msix); + rc = vpci_msix_arch_print(d, msix); if ( rc ) { /* @@ -318,12 +326,13 @@ void vpci_dump_msi(void) * holding the lock. */ printk("unable to print all MSI-X entries: %d\n", rc); - process_pending_softirqs(); - continue; + goto pdev_done; } } spin_unlock(&pdev->vpci->lock); + pdev_done: + pcidevs_read_unlock(); process_pending_softirqs(); } } diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c index bea0cc7aed..35cc9280f4 100644 --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -144,9 +144,13 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr) list_for_each_entry ( msix, &d->arch.hvm.msix_tables, next ) { - const struct vpci_bar *bars = msix->pdev->vpci->header.bars; + const struct vpci_bar *bars; unsigned int i; + if ( !msix->pdev->vpci ) + continue; + + bars = msix->pdev->vpci->header.bars; for ( i = 0; i < ARRAY_SIZE(msix->tables); i++ ) if ( bars[msix->tables[i] & PCI_MSIX_BIRMASK].enabled && VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, i) ) @@ -158,7 +162,13 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr) static int cf_check msix_accept(struct vcpu *v, unsigned long addr) { - return !!msix_find(v->domain, addr); + int rc; + + pcidevs_read_lock(); + rc = !!msix_find(v->domain, addr); + pcidevs_read_unlock(); + + return rc; } static bool access_allowed(const struct pci_dev *pdev, unsigned long addr, @@ -218,17 +228,26 @@ static int cf_check msix_read( struct vcpu *v, unsigned long addr, unsigned int len, unsigned long *data) { const struct domain *d = v->domain; - struct vpci_msix *msix = msix_find(d, addr); + struct vpci_msix *msix; const struct vpci_msix_entry *entry; unsigned int offset; *data = ~0ul; + pcidevs_read_lock(); + + msix = msix_find(d, addr); if ( !msix ) + { + pcidevs_read_unlock(); return X86EMUL_RETRY; + } if ( !access_allowed(msix->pdev, addr, len) ) + { + pcidevs_read_unlock(); return X86EMUL_OKAY; + } if ( VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, VPCI_MSIX_PBA) ) { @@ -299,6 +318,7 @@ static int cf_check msix_read( break; } spin_unlock(&msix->pdev->vpci->lock); + pcidevs_read_unlock(); return X86EMUL_OKAY; } @@ -307,15 +327,24 @@ static int cf_check msix_write( struct vcpu *v, unsigned long addr, unsigned int len, unsigned long data) { const struct domain *d = v->domain; - struct vpci_msix *msix = msix_find(d, addr); + struct vpci_msix *msix; struct vpci_msix_entry *entry; unsigned int offset; + pcidevs_read_lock(); + + msix = msix_find(d, addr); if ( !msix ) + { + pcidevs_read_unlock(); return X86EMUL_RETRY; + } if ( !access_allowed(msix->pdev, addr, len) ) + { + pcidevs_read_unlock(); return X86EMUL_OKAY; + } if ( VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, VPCI_MSIX_PBA) ) { @@ -351,6 +380,7 @@ static int cf_check msix_write( break; } + pcidevs_read_unlock(); return X86EMUL_OKAY; } @@ -428,6 +458,7 @@ static int cf_check msix_write( break; } spin_unlock(&msix->pdev->vpci->lock); + pcidevs_read_unlock(); return X86EMUL_OKAY; } @@ -440,9 +471,13 @@ static const struct hvm_mmio_ops vpci_msix_table_ops = { int vpci_make_msix_hole(const struct pci_dev *pdev) { - struct domain *d = pdev->domain; + struct domain *d; unsigned int i; + ASSERT(pcidevs_read_locked()); + + d = pdev->domain; + if ( !pdev->vpci->msix ) return 0; @@ -487,13 +522,19 @@ int vpci_make_msix_hole(const struct pci_dev *pdev) static int cf_check init_msix(struct pci_dev *pdev) { - struct domain *d = pdev->domain; - uint8_t slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn); + struct domain *d; + uint8_t slot, func; unsigned int msix_offset, i, max_entries; uint16_t control; struct vpci_msix *msix; int rc; + ASSERT(pcidevs_write_locked()); + + d = pdev->domain; + slot = PCI_SLOT(pdev->devfn); + func = PCI_FUNC(pdev->devfn); + msix_offset = pci_find_cap_offset(pdev->seg, pdev->bus, slot, func, PCI_CAP_ID_MSIX); if ( !msix_offset ) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index c7a40a2f41..1559763479 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -37,7 +37,9 @@ extern vpci_register_init_t *const __end_vpci_array[]; void vpci_remove_device(struct pci_dev *pdev) { - if ( !has_vpci(pdev->domain) ) + ASSERT(pcidevs_write_locked()); + + if ( !has_vpci(pdev->domain) || !pdev->vpci ) return; spin_lock(&pdev->vpci->lock); @@ -332,10 +334,14 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size) return data; } + pcidevs_read_lock(); /* Find the PCI dev matching the address. */ pdev = pci_get_pdev_by_domain(d, sbdf.seg, sbdf.bus, sbdf.devfn); - if ( !pdev ) + if ( !pdev || (pdev && !pdev->vpci) ) + { + pcidevs_read_unlock(); return vpci_read_hw(sbdf, reg, size); + } spin_lock(&pdev->vpci->lock); @@ -381,6 +387,7 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size) ASSERT(data_offset < size); } spin_unlock(&pdev->vpci->lock); + pcidevs_read_unlock(); if ( data_offset < size ) { @@ -443,9 +450,11 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, * Find the PCI dev matching the address. * Passthrough everything that's not trapped. */ + pcidevs_read_lock(); pdev = pci_get_pdev_by_domain(d, sbdf.seg, sbdf.bus, sbdf.devfn); - if ( !pdev ) + if ( !pdev || (pdev && !pdev->vpci) ) { + pcidevs_read_unlock(); vpci_write_hw(sbdf, reg, size, data); return; } @@ -486,6 +495,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, ASSERT(data_offset < size); } spin_unlock(&pdev->vpci->lock); + pcidevs_read_unlock(); if ( data_offset < size ) /* Tailing gap, write the remaining. */ diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 052b2ddf9f..c974ebdc94 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -161,6 +161,7 @@ void pcidevs_unlock(void); bool __must_check pcidevs_locked(void); void pcidevs_read_lock(void); +int pcidevs_read_trylock(void); void pcidevs_read_unlock(void); bool __must_check pcidevs_read_locked(void); diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 67c9a0c631..7ab39839ff 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -175,7 +175,7 @@ int __must_check vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry, int __must_check vpci_msix_arch_disable_entry(struct vpci_msix_entry *entry, const struct pci_dev *pdev); void vpci_msix_arch_init_entry(struct vpci_msix_entry *entry); -int vpci_msix_arch_print(const struct vpci_msix *msix); +int vpci_msix_arch_print(const struct domain *d, const struct vpci_msix *msix); /* * Helper functions to fetch MSIX related data. They are used by both the From patchwork Mon Jul 18 21:15:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 12921784 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 BBE09C43334 for ; Mon, 18 Jul 2022 21:16:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.370122.601782 (Exim 4.92) (envelope-from ) id 1oDY5s-0004DG-Hn; Mon, 18 Jul 2022 21:15:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 370122.601782; Mon, 18 Jul 2022 21:15:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oDY5s-0004D9-Ex; Mon, 18 Jul 2022 21:15:56 +0000 Received: by outflank-mailman (input) for mailman id 370122; Mon, 18 Jul 2022 21:15:55 +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 1oDY5q-00043p-WC for xen-devel@lists.xenproject.org; Mon, 18 Jul 2022 21:15:55 +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 cd82502e-06de-11ed-bd2d-47488cf2e6aa; Mon, 18 Jul 2022 23:15:53 +0200 (CEST) Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26IImA9S005163; Mon, 18 Jul 2022 21:15:46 GMT Received: from eur03-ve1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2051.outbound.protection.outlook.com [104.47.9.51]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3hcrm7v72d-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Jul 2022 21:15:46 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by VI1PR03MB6288.eurprd03.prod.outlook.com (2603:10a6:800:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Mon, 18 Jul 2022 21:15:43 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::3db3:dad:7bd7:4488%7]) with mapi id 15.20.5417.035; Mon, 18 Jul 2022 21:15:43 +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: cd82502e-06de-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hJG1DGNKi9gfpF8N52wXZBhhGY05kaI7qCegqq3FsOo+4fX2622YUdbd0M4OvqEFr2teKJyVGLoRWim9kDKopmNEqDSbnOwzHm208QAMpZ7hyVtsS/6yPfEjq5l5lHt8MgnDAQ/65R2pnjrSPod9M735RXz6qgc5w2Gv0TBItunyT536cuRN5LHHBVlb3QxMi0wrRWED4IZ/toarO9YTindgefNXIM4sMi0d62C6Ye/6Nq+RY8/FBSig929HvS3xuHQeE9NTSh6lMbCZWyi2AftmnZFjEMTb6RLyah7ZLROHLfbZAUSmBjntW/xxvHLxTYhFsWzwCLq5GyK3lfGaYQ== 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=ksdanVPgWNjcEsmDWclgKo/WTZPT/811BmuA9N3cIiA=; b=cgCvelgaB24g4mDSKCvZBy22/GyMf+Wfr0bMEytInxrTK0LFsoezjff2OrwRCFhWLHvavSyJ95bsD2v4fWtqIwNo5m/j4bRlodC5QZgnTrXrJ2EA4yiSXuahQAtLlA6cGCYw5Efuc7p5ZcXUUj7piJEVs1q/BGMxp9Jsz5+KCzufySfN/IodOBgKZZPQLYs0AasIzHzgp0cRxxBaUFXSl7wxfU363gi1QYrO1cGN3T3zV9KRqm9t5IQ9t1CN983WQrUW+Q7WLrCyWqRNf1F94LNReA01SyGroctezJgkPAaMVC7wO9qMx75gAqees8VL2yrI+grb3f4XiJb0GaQbVQ== 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=ksdanVPgWNjcEsmDWclgKo/WTZPT/811BmuA9N3cIiA=; b=HSHBprWcvOvJ47W6C0lBrTpdIkkJdm26woGD9bmN+V6SQJQPwN8gXcbJws5djKolitb3myJOzIc9dvaVG+/r/W+ZdP86PKOTpR/jAMHLO7Gw85QAFYy9z8NIOTMUSf4XOCOfXDRzP/eDi1Z23BGYHCJY1zcFSESu5dRijeWYk5V9X5ttaTO+1YX92YDrRIZlYi5xwxJPepMNCuPE2ZYJFi1O6pkYygrHpSVgmHuEL2eOzA2Z4Mm9nHvLs+oPfF6olWhbdlGNc627jf0H1dsSv1qLklZP52bDbHfPHMGVdH3m0GhchY8Aaqi3VccnVnIogrUs7y8B2FnAoLjDfiCSkg== From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" CC: Volodymyr Babchuk , =?iso-8859-1?q?Roger_Pau?= =?iso-8859-1?q?_Monn=E9?= Subject: [PATCH v2 4/4] vpci: include xen/vmap.h to fix build on ARM Thread-Topic: [PATCH v2 4/4] vpci: include xen/vmap.h to fix build on ARM Thread-Index: AQHYmuuJ09LC1x/2uEWs942YY/fNVA== Date: Mon, 18 Jul 2022 21:15:43 +0000 Message-ID: <20220718211521.664729-5-volodymyr_babchuk@epam.com> References: <20220718211521.664729-1-volodymyr_babchuk@epam.com> In-Reply-To: <20220718211521.664729-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.36.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6b6ad0bd-8b6f-4062-f850-08da6902ac80 x-ms-traffictypediagnostic: VI1PR03MB6288:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wkk1l0uiIodJdZSFcOiVERfckDFR8Yr7VSL7MQLmrMwutCMorXqL/FDEo2tqgmFFGDbDnCvHwm8JrdVqF8qYNXrTwPjFRJPuUaef9puETzrcheQr5WSDtNyTvu5JpnPN6bWsG0VMd9ar2RUpftENUSRKfWtFSM0py5aa3mgWLQPitXJOYKCfpgahfXE6QEnhT0DgCUtW2hBoWklKjQA6FJ9JanwMPdx5mVHFkYV/vUnOFP70q9yVNHIbpJ0ZGzl0ckSVdPVmQdJjreGQQ9J1whxaUrD+VQCP47KR/YzfR4xsRGeNFp2VS4x4To766mpN8tOZz5dfwrGk4gmglatme3oRz0p08dddEOGAoSztgNjPZMoeeCYtfaap5rOJwjYOdePO74HttHUAbcoLvs4cTVW8XaI287AaxMFy+G5sV+JgyJ4jLCNeG/kR93LGIwXdKMqb6GvEiiCpyId6v6LKkco+YnYn/h1F5gWczSxq1owMlFgqh/nVIgJ1XM60MzMpvgL9JhtdW9heq3Duv0UHQPHz7Arz5ybnbhy0dQIZEDfGQ/0AdbhDbb+se5dg0is+L8svGks/jVCmd8VT1BVnVgwOvIf9L0M9eadBaFJVRiKdgc1eZhQavpbEDH1dmZoRBzOgST431ZeElwzopavmWyyoPKptt+cfYtLqpU0PlDn8ft58ZXgsipietxCXPaorxw6tUFpgctGARaKsP3Y4rLBHheguTiq155ntPZI68ggCkMqQdv0dd7P1qvWoPbTGdQ2/a6C0BThfCF7Lz64hPhV+M6HCnMgNd5q6GMc/qGol+yLEPT2ib4Z8e8pyMazm 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:(13230016)(4636009)(396003)(136003)(346002)(39860400002)(366004)(376002)(2906002)(5660300002)(8936002)(36756003)(186003)(4326008)(4744005)(86362001)(91956017)(64756008)(66946007)(66556008)(8676002)(66446008)(66476007)(76116006)(122000001)(6506007)(478600001)(316002)(2616005)(6512007)(6916009)(26005)(54906003)(6486002)(55236004)(1076003)(41300700001)(38070700005)(83380400001)(38100700002)(71200400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?4Svz0KfunChTd57mLSFOpDK?= =?iso-8859-1?q?d5yMV9+ZRNItyhJLxVpGCrlUMjKXHieZWf0/1AUWtBlUTEfi9Stn3v8K7tKw?= =?iso-8859-1?q?c5aF0P6P2A9UjdGjQOEfxykEicGyxI7d2tOIx/tzAk08ursWR0Zt2UFAmjDV?= =?iso-8859-1?q?9OR2uU8p5g6iEpmAU5idVVSHlD/7e31jkWP+vPKJFZ3tM0FlxQbivzbdQi6E?= =?iso-8859-1?q?RKOHRubU1tzx41yw0EFQWAvzyWQHn0xAsattOk3MlpDo1ZRBWrcYqfgS4987?= =?iso-8859-1?q?bhWXDKdbNHLO3ZIEkRol1vk5/+56FkaGTbrz0vHAfliGkIDTcoE5MFGTz3uK?= =?iso-8859-1?q?xQLbudxQhHolSusuihXxjQtmAn06B6fow/r8ziWsI9BAdG0HvMQv8Scz017y?= =?iso-8859-1?q?BXw/p2zunM+4JPUEJhIVVoo45YmYy0GFMVkz8fumuGjIBqvTFExPGS+MW3hY?= =?iso-8859-1?q?y+Jp4rb3unNCQAscObZ8/NlFJKTn0Gu4hvgQb+kiCY2W7T18+RX804IgeYdi?= =?iso-8859-1?q?bbWkoLfeiNA9DffECni8KDKQFNRg2QGijWUV+EY2o9r/S2baT+N9ZyPluNgm?= =?iso-8859-1?q?psjvmWKUmeIvdlYH9oUz/N2HoYAzy/zhZX/mKiN+iJ1IK7aqJROxfcxRLqkA?= =?iso-8859-1?q?yodMWeAb8ioYjqvV/zsXWBSaTke7JKDgoSpbYyKeY9oAHpUWbos6Igwf5plE?= =?iso-8859-1?q?Sv3EOuUjwFC9r/V7DR49HSlBeuhlTzI/e6JEvRMd4W+WJyAI3f8gVRT39+KT?= =?iso-8859-1?q?COatJA+lsz0+KzVKe+E+4OuoEC2EFjdssRGBGAmxsymJ/76KMxjNsHsQx7LX?= =?iso-8859-1?q?ecqG2QssofCR8QkxscTK5+sboYNbaw1aKSaD3HwF7Tx9BTUp/w53nEoaq3rg?= =?iso-8859-1?q?1HfdYjKwvWdZp3SBk7b39Ff8rtuHdjLVF4wvdXUB3iOotRX0vK24NEUjzycv?= =?iso-8859-1?q?/nxxTz3HLXnwScczXy4kagNUF8BB4kbZepV2Xc/sVoeAtxWZBHUYPtSq7MsE?= =?iso-8859-1?q?DgWERq/4e8XAn2bBaq5bxOVrgSqO9GBXODG9dokbl/T13tMd8Sppm/llgqt5?= =?iso-8859-1?q?2HJWE19rIPYAGk1eG3H4gk38F6b0KB8+h7Jh3xBpCiS9AoEB0gxi9OD8zRMK?= =?iso-8859-1?q?7GkQQ+pnezSqSHNM+zdmxzx5rSj0g23z3s5PvyL2thzdAuxjoP9bkuwTXuNu?= =?iso-8859-1?q?UElNiylpS+bcDfmjFkOaUeC7p61AWJKtvKFeFi7wcE8vO05V+sGalRL/X3a2?= =?iso-8859-1?q?YdIg5CKhO170bPe48FDcWYXZTXTL/sPKcMZ06QoMEeGiFQTuAE9pApzyzaJ2?= =?iso-8859-1?q?ZSe37FlDJvRixeTbAYZSnswZR9m9oc8TFODinBVnaee0MT4fFNJQlhdAHGT2?= =?iso-8859-1?q?zi2dS+y3JiwsAJQrOTE+HOHHFqS1KxAAwzEvANdrYwaDgt6W7Wxxx8wd1iq0?= =?iso-8859-1?q?C8DHVABnB7jLE53RR5OCWoVOXqjMDA3w2Gft6V2Z2QDKO1DGAtyjRT3paZsi?= =?iso-8859-1?q?n2h4xSYQanXk86MMtRlpIw7QGy8EniE9sPVTacGxaTeZ6Gc3nx8IR3Mvwq7I?= =?iso-8859-1?q?RDA/jzV9VDERjln6NyYEctnevDUfqXKRwLRE3H0QJzNJFk48sieUo9J4DS6R?= =?iso-8859-1?q?dJxRIVRtsj2J/C8N8PGYSLIRyaRE3VUamyLOuhA=3D=3D?= 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: 6b6ad0bd-8b6f-4062-f850-08da6902ac80 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2022 21:15:43.0705 (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: m5Y/+4oGldBqyz6pxv1P4ShlkkJHqCi4tvgK2Y/HMUi9wdBgX0HbqZOD/ZyVSsIkPgJkj39I+WiPO+sxHvM50y8gwEYhxbuCEhi6QqHrt4Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6288 X-Proofpoint-GUID: 8Kx16ohB7z4_SSKC517HlrJP1tRIWTjY X-Proofpoint-ORIG-GUID: 8Kx16ohB7z4_SSKC517HlrJP1tRIWTjY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-18_20,2022-07-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 mlxlogscore=962 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207180089 Patch b4f211606011 ("vpci/msix: fix PBA accesses") introduced call to iounmap(), but not added corresponding include. Fixes: b4f211606011 ("vpci/msix: fix PBA accesses") Signed-off-by: Volodymyr Babchuk Acked-by: Jan Beulich Reviewed-by: Roger Pau Monné --- xen/drivers/vpci/vpci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 1559763479..674c9b347d 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -19,6 +19,7 @@ #include #include +#include /* Internal struct to store the emulated PCI registers. */ struct vpci_register {