[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vpci: Need for vpci_cancel_pending


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Thu, 28 Oct 2021 10:32:17 +0000
  • Accept-language: en-US
  • 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
  • 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=nl6HudNpHslqI/UiWj1QV4BZrWsOMpJYIAhOf971FEE=; b=hpuIjmxpf01DfWqEB49YtJWOQjkolx4hcq9tzb51ucTWmcNpx7sDYeGMc7PIXPXjNyutBEaM5RrPGIzVcnAE70IUDYk8VimzEnhwjdrEIpMlog179yoXvtKqiGwX99Xf+HRBTcLoVwQ2LSzJKkMEkjuvWvq/ZINUcpTo0//GmtMUP9zQyKWcmbbalI3RjYphuPe6Tzb/gkcMDDGc8RUeHfHa9NSFFT8E2R1YTmmxdOWPrVPo3eqVDY9rirgdiTi76rjzjalhan1+OL2ya5P1sDc8MbHWFWcHcm4aNVVFYZq48VbwtW1Q7pBbtbkCCw1cUbPGqajM1qdHbK+fY+6nmA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OR1wLKc8IXuIjkO2Gh8DhmkSGH05YktTVrv4Y7DPgG69o7ZcjphcVnXG0JphTjJ4HGT3gKYdiyNZVGnMk9UZ3h1GzNFKQ/yV9fkPeUiM0IxSIBNAP5mMT75sdb79y+sY/F7WzePDu/irpaHqtnP5l3qcTeuggOZbvBsGHsSueHB+HGZfskwVOSvt8fpxV62YWxJnEW3BJtHfz59sEZ0HK8gUw43wWtffej5QJIK8pIkjCs0Q+QWv0h78UvjE3ptVIPB61n+5Qk9RCh2n8p6krUX0QEOlBHaRKvRAkS9ZD18J1SX4iEFfM9XttFuw9qLp5m2Y10QpQ+QAPYo1/E6DDA==
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 28 Oct 2021 10:32:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXy+MtilSp1e2bsUu2TEgvHf6jsavoMiQAgAACRgCAAAFoAIAAAJCA
  • Thread-topic: vpci: Need for vpci_cancel_pending


On 28.10.21 13:30, Roger Pau Monné wrote:
> On Thu, Oct 28, 2021 at 10:25:28AM +0000, Oleksandr Andrushchenko wrote:
>>
>> On 28.10.21 13:17, Roger Pau Monné wrote:
>>> On Thu, Oct 28, 2021 at 10:04:20AM +0000, Oleksandr Andrushchenko wrote:
>>>> Hi, all!
>>>>
>>>> While working on PCI passthrough on Arm I stepped onto a crash
>>>> with the following call chain:
>>>>
>>>> pci_physdev_op
>>>>      pci_add_device
>>>>          init_bars -> modify_bars -> defer_map -> 
>>>> raise_softirq(SCHEDULE_SOFTIRQ)
>>>>      iommu_add_device <- FAILS
>>>>      vpci_remove_device -> xfree(pdev->vpci)
>>>>
>>>> Then:
>>>> leave_hypervisor_to_guest
>>>>      vpci_process_pending: v->vpci.mem != NULL; v->vpci.pdev->vpci == NULL
>>>>
>>>> Which results in the crash below:
>>>>
>>>> (XEN) Data Abort Trap. Syndrome=0x6
>>>> (XEN) Walking Hypervisor VA 0x10 on CPU0 via TTBR 0x00000000481dd000
>>>> (XEN) 0TH[0x0] = 0x00000000481dcf7f
>>>> (XEN) 1ST[0x0] = 0x00000000481d9f7f
>>>> (XEN) 2ND[0x0] = 0x0000000000000000
>>>> (XEN) CPU0: Unexpected Trap: Data Abort
>>>> ...
>>>> (XEN) Xen call trace:
>>>> (XEN)    [<00000000002246d8>] _spin_lock+0x40/0xa4 (PC)
>>>> (XEN)    [<00000000002246c0>] _spin_lock+0x28/0xa4 (LR)
>>>> (XEN)    [<000000000024f6d0>] vpci_process_pending+0x78/0x128
>>>> (XEN)    [<000000000027f7e8>] leave_hypervisor_to_guest+0x50/0xcc
>>>> (XEN)    [<0000000000269c5c>] entry.o#guest_sync_slowpath+0xa8/0xd4
>>>>
>>>> So, it seems that if pci_add_device fails and calls vpci_remove_device
>>>> the later needs to cancel any pending work.
>>> Indeed, you will need to check that v->vpci.pdev == pdev before
>>> canceling the pending work though, or else you could be canceling
>>> pending work from a different device.
>> How about:
>>
>> void vpci_cancel_pending(struct pci_dev *pdev)
>> {
>>       struct vcpu *v = current;
>>
>>       if ( v->vpci.mem && v->vpci.pdev == pdev)
>>       {
>>           rangeset_destroy(v->vpci.mem);
>>           v->vpci.mem = NULL;
>>       }
>> }
>>
>> This will effectively prevent the pending work from running
> Can't you just place this in vpci_remove_device?
>
> Or is there a need to cancel pending work without removing the device?
@@ -149,8 +149,7 @@ bool vpci_process_pending(struct vcpu *v)
                          !rc && v->vpci.rom_only);
          spin_unlock(&v->vpci.pdev->vpci->lock);

-        rangeset_destroy(v->vpci.mem);
-        v->vpci.mem = NULL;
+        vpci_cancel_pending(v->vpci.pdev);

So, we can re-use it and do not copy paste the same
>
> Thanks, Roger.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.