From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Stewart Hildebrand <stewart.hildebrand@amd.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Oleksandr Andrushchenko" <Oleksandr_Andrushchenko@epam.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"George Dunlap" <george.dunlap@citrix.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Paul Durrant" <paul@xen.org>
Subject: Re: [PATCH v7 01/12] vpci: introduce per-domain lock to protect vpci structure
Date: Thu, 22 Jun 2023 21:18:35 +0000 [thread overview]
Message-ID: <87bkh7nql1.fsf@epam.com> (raw)
In-Reply-To: <6418b3bf-5b7e-3c12-52d6-534bf791617a@amd.com>
Hi Stewart,
Stewart Hildebrand <stewart.hildebrand@amd.com> writes:
> On 6/13/23 06:32, Volodymyr Babchuk wrote:
>
> ...
>
>> diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
>> index 652807a4a4..1270174e78 100644
>> --- a/xen/drivers/vpci/vpci.c
>> +++ b/xen/drivers/vpci/vpci.c
>> @@ -38,20 +38,32 @@ extern vpci_register_init_t *const __end_vpci_array[];
>>
>> void vpci_remove_device(struct pci_dev *pdev)
>> {
>> - if ( !has_vpci(pdev->domain) || !pdev->vpci )
>> + struct vpci *vpci;
>> +
>> + if ( !has_vpci(pdev->domain) )
>> return;
>>
>> - spin_lock(&pdev->vpci->lock);
>> + write_lock(&pdev->domain->vpci_rwlock);
>> + if ( !pdev->vpci )
>> + {
>> + write_unlock(&pdev->domain->vpci_rwlock);
>> + return;
>> + }
>> +
>> + vpci = pdev->vpci;
>> + pdev->vpci = NULL;
>
> Here we set pdev->vpci to NULL, yet there are still a few uses
> remaining after this in vpci_remove_device. I suspect they were missed
> during a s/pdev->vpci/vpci/ search and replace.
>
Yes, you are right. Thank you, I'll fix this in the next version.
>> + write_unlock(&pdev->domain->vpci_rwlock);
>> +
>> while ( !list_empty(&pdev->vpci->handlers) )
>
> pdev->vpci dereferenced here
>
>> {
>> - struct vpci_register *r = list_first_entry(&pdev->vpci->handlers,
>> + struct vpci_register *r = list_first_entry(&vpci->handlers,
>> struct vpci_register,
>> node);
>>
>> list_del(&r->node);
>> xfree(r);
>> }
>> - spin_unlock(&pdev->vpci->lock);
>> +
>> if ( pdev->vpci->msix )
>
> pdev->vpci dereferenced here
>
>> {
>> unsigned int i;
>> @@ -61,29 +73,33 @@ void vpci_remove_device(struct pci_dev *pdev)
>> if ( pdev->vpci->msix->table[i] )
>
> pdev->vpci dereferenced here, and two more above not shown in the diff context
>
>> iounmap(pdev->vpci->msix->table[i]);
>
> pdev->vpci dereferenced here
>
>> }
>> - xfree(pdev->vpci->msix);
>> - xfree(pdev->vpci->msi);
>> - xfree(pdev->vpci);
>> - pdev->vpci = NULL;
>> + xfree(vpci->msix);
>> + xfree(vpci->msi);
>> + xfree(vpci);
>> }
--
WBR, Volodymyr
next prev parent reply other threads:[~2023-06-22 21:19 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 10:32 [PATCH v7 00/12] PCI devices passthrough on Arm, part 3 Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 01/12] vpci: introduce per-domain lock to protect vpci structure Volodymyr Babchuk
2023-06-16 16:30 ` Roger Pau Monné
2023-06-21 22:07 ` Volodymyr Babchuk
2023-06-22 8:15 ` Roger Pau Monné
2023-06-22 21:17 ` Volodymyr Babchuk
2023-06-23 8:50 ` Roger Pau Monné
2023-06-23 9:26 ` Volodymyr Babchuk
2023-06-23 17:09 ` Jan Beulich
2023-07-04 21:03 ` Volodymyr Babchuk
2023-07-05 7:11 ` Jan Beulich
2023-07-05 8:59 ` Roger Pau Monné
2023-07-05 9:13 ` Jan Beulich
2023-07-07 2:02 ` Volodymyr Babchuk
2023-07-07 6:32 ` Jan Beulich
2023-07-09 22:41 ` Volodymyr Babchuk
2023-07-10 6:20 ` Jan Beulich
2023-06-20 20:17 ` Stewart Hildebrand
2023-06-22 21:18 ` Volodymyr Babchuk [this message]
2023-06-13 10:32 ` [PATCH v7 04/12] vpci/header: implement guest BAR register handlers Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 02/12] vpci: restrict unhandled read/write operations for guests Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 03/12] vpci: add hooks for PCI device assign/de-assign Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 06/12] vpci/header: handle p2m range sets per BAR Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 07/12] vpci/header: program p2m with guest BAR view Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 05/12] rangeset: add RANGESETF_no_print flag Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 08/12] vpci/header: emulate PCI_COMMAND register for guests Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 10/12] vpci: add initial support for virtual PCI bus topology Volodymyr Babchuk
2023-06-21 12:06 ` Jan Beulich
2023-07-07 16:45 ` Oleksandr Tyshchenko
2023-06-13 10:32 ` [PATCH v7 09/12] vpci/header: reset the command register when adding devices Volodymyr Babchuk
2023-06-13 10:32 ` [PATCH v7 11/12] xen/arm: translate virtual PCI bus topology for guests Volodymyr Babchuk
2023-06-21 12:01 ` Jan Beulich
2023-06-13 10:32 ` [PATCH v7 12/12] xen/arm: account IO handlers for emulated PCI MSI-X Volodymyr Babchuk
2023-06-15 2:01 ` [PATCH v7 00/12] PCI devices passthrough on Arm, part 3 Stewart Hildebrand
2023-06-15 9:39 ` Volodymyr Babchuk
2023-06-15 12:16 ` Jan Beulich
2023-06-21 22:11 ` Volodymyr Babchuk
2023-06-22 7:48 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkh7nql1.fsf@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=Oleksandr_Andrushchenko@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=stewart.hildebrand@amd.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.