| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
 Re: [PATCH v6 03/13] vpci: move lock outside of struct vpci
 
To: Jan Beulich <jbeulich@xxxxxxxx>From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>Date: Mon, 7 Feb 2022 12:57:00 +0000Accept-language: en-USArc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=noneArc-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=CtWl24wVUiCAmPhliY2OEMQ2kE9TkCcumqYM9tE56sw=; b=SiHspuD/BFJvoEIX95QdqQxykB+Ww9BFCO51o1WQG9oxH8Pv9QP6sTFG/iZQwbSC4QJxYy7HF3o5A+0EP4MjHO+hUiXLivaF5sATgxII+NnVQ7aI4q1Tsn/31XILhOZIo5HyB5rsQasiFFogsCPOsy8cUNCzSa5QrHOEfa3FIxwwS32Yw6WvPydcOHDzYFaTPvTtIXvB2TMKIl0JC10pLxgoXFzBKWlKtxmavcvgv0IJKnetPBUsSChuzXVSl5+KQ01HexVkK1kwryD2r2rcZ9+E7JQ3EPpCIf3fDz4I6IaTNkKw7uhbzNAfH5Nm4NMoFiB4hAHXVP+85dtlNk6Inw==Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CqJeWZVxv5dR2UW5/WswZ3tikfXRTbnVYm5VYXzY5K1qgjwmCesitapFUabDsg3CRgETCvehYuOR1RGxYhyvLDM793Y+KmQa4c2Pitg4NcqjC6LoVm7gaPaezsbR4v/FAW/ev9EAk6FsNUFG4JzIYmhfw0PQvUMAJ4ZDrNWRs/uY9Gt48JWGbGgobXIYrCijdAdRJr5YRgPvAMOb3qRozdUSg167ruJDyB2IRhCFl43a+VRf+U83Dqg+s5xVFN7jJqmezMtkIPSOhWO6u5w3Nd4mNgnPq8PD9xFDpfXcuk/VbX4m0rS6E2cMmgiEZXLkWAFG+o0yRRnE0+X5WReAhg==Cc: "julien@xxxxxxx" <julien@xxxxxxx>,        "sstabellini@xxxxxxxxxx"	<sstabellini@xxxxxxxxxx>,        Oleksandr Tyshchenko	<Oleksandr_Tyshchenko@xxxxxxxx>,        Volodymyr Babchuk	<Volodymyr_Babchuk@xxxxxxxx>,        Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>,        "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>,        "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>,        "paul@xxxxxxx"	<paul@xxxxxxx>,        Bertrand Marquis <bertrand.marquis@xxxxxxx>,        Rahul Singh	<rahul.singh@xxxxxxx>,        "xen-devel@xxxxxxxxxxxxxxxxxxxx"	<xen-devel@xxxxxxxxxxxxxxxxxxxx>,        Roger Pau Monné	<roger.pau@xxxxxxxxxx>,        Oleksandr Andrushchenko	<Oleksandr_Andrushchenko@xxxxxxxx>Delivery-date: Mon, 07 Feb 2022 12:57:13 +0000List-id: Xen developer discussion <xen-devel.lists.xenproject.org>Thread-index:  AQHYGZFc/MnzQOjwVEeBBUHLSW0md6yDBUkAgAASSACAAATYAIAAD/WAgAAKNgCAAAbfgIAABnuAgAAQvgCAAAMCAIAAAY4AgAADxICAABrnAIAABAgAgAR3CoCAABgPAIAABjkAThread-topic: [PATCH v6 03/13] vpci: move lock outside of struct vpci 
 
On 07.02.22 14:34, Jan Beulich wrote:
> On 07.02.2022 12:08, Oleksandr Andrushchenko wrote:
>> 1. vpci_{read|write} are not protected with pcidevs_lock and can run in
>> parallel with pci_remove_device which can remove pdev after vpci_{read|write}
>> acquired the pdev pointer. This may lead to a fail due to pdev dereference.
>>
>> So, to protect pdev dereference vpci_{read|write} must also use pdevs_lock.
> I think this is not the only place where there is a theoretical race
> against pci_remove_device().
Not at all, that was just to demonstrate one of the possible sources of races.
>   I would recommend to separate the
> overall situation with pcidevs_lock from the issue here.
Do you agree that there is already an issue with that? In the currently 
existing code?
>   I don't view
> it as an option to acquire pcidevs_lock in vpci_{read,write}().
Yes, that would hurt too much, I agree. But this needs to be solved
>   If
> anything, we need proper refcounting of PCI devices (at which point
> likely a number of lock uses can go away).
It seems so. Then not only pdev's need refcounting, but pdev->vpci as well
What's your view on how can we achieve both goals?
pdev and pdev->vpci and locking/refcounting
This is really crucial for all the code for PCI passthrough on Arm because
without this ground work done we can't accept all the patches which rely
on this: vPCI changes, MSI/MSI-X etc.
>
> Jan
>
Thank you,
Oleksandr
 |