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

Re: vpci: Need for vpci_cancel_pending


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 28 Oct 2021 12:30:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=tUCZ0gn6lGYZuz7TP2vGZsgRF18FCCsnQd/3UBtBTP0=; b=KzHsB6oUh9XKH8oC/avAzmkPFY4b+7huVNVlD3ZrQy1s/eo99m/xa/y6zIH7tMNfe5YOqFPZiC0MPB8fAtWuLoocaDbrOuBi39gB+BXZT2py/hLYJVi2fQ89an6Hi+JFeONXgEyvHOkEyt9TUXIbeNeliYgaotgROLol9Th0aq2nZXUI5u93EM7DO849jL5WUKJDLEgNE4sXdAVBtntCqQNdQikpO6TkciykD4OEbMTmroukjpNYPTg81RC76PZuff+id0WE/Rg4SOqPBp6HRSrW8u9Hh/9oaN4cyv3nmmBxCZt65kH3VDTy/O3DZ3iov+rtN18gK2WEwOGfPMnCVQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gfuvGISKDoj74pcblbNB01BCgZXDuid2yHlErL6pMH8lk3v0tLA8/rpp05jPVbnXPoMwRZOzA6HmoHex7uRzgw73aUZwNSlXPlUgMR7Nwo8ql1wmS1o6GHZ5Nj2z6ymuztt5RldLAvng7PRoGT3d5FXlnZnK9kCsUReE+oMlq3I/066Juk3T4CcuJ8MAKvbk8WI+n1WHwnt6PrPwqPMpv9LNAj4QUU/hxVWMoJ4JXv7geRzBmGLi9UQ7t97cRafl0JXLHVujEacibbTiQTwk7LWQa9V//iAuyVWaB3b96tGVH79b71+ep/bdVdKTUWoapjO4xaPng7Uz1gsjUHaqKA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 28 Oct 2021 10:30:52 +0000
  • Ironport-data: A9a23:xaJvQqvPFIP6Jq88jP4SErtT8efnVLBZMUV32f8akzHdYApBsoF/q tZmKTiPOPiMamDyf9x/OYmzpEgCusfVydQwGgdlpCozFXgX+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cw24jhWmthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NplmqaOZxotPLf3hrpNA0RlOBFDL7NF9+qSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY254WTK6GO ZNxhTxHNhbZP0JsIHUrLakFvsP0t3jDQmwCpwfAzUYwyzeKl1EguFT3C/LFd9rPSchLk0Kwo mPd43+/EhwcLMaYyzeO7jSrnOCntQT/VYEJHbu07MlDhlGJ23cTAx0bU1i8ifShg0v4UNVaQ 3H44QJ38/J0rhbyCICgAVvo+xZooyLwRfJ/KdMU9QWP0JHKvVbJW1UvfgNTdt8p4ZpeqSMR6 neFmNbgBDpKubKTSG6A+rr8kQ5eKRT5PkdZOndaFVptD83L5dhp1Eq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kDksH46GL0hAe9KGi8zAlZrgbxJDLxk76DOWhTftzLLhCRCX0joXTjsKmN4ZgC T4uj28wp/mn+Cwyxfa2WOWx5NKmOH5wt8GIMCXkMAaJhjllw7tToV8XL+puiwzvYiUmRsXue iJhy1lE9V46nvXcG3wiRzx2zP42DJr0HPmwU/wuwqrneXJABYBT+ZRj4NQdRXUr2A6ustn7a 5N12WF87JKEBLphk3Glpn1fiAvsnDxjWspkOYVgXAae5AZcqVtoYsW+14QOIscHRj99JssHI BVfY/hDc5tABCnhk3izytSKITGZAV3Iv7GeDlMhiWt6UkXoJgjpHFogPD2nR87heQAotd/lq P5259T5cNzp/ktHNVA7dc6MLiK41P2MGfx2UKpUBza/fI8SjnwQ6Ce2sRA2AjtQu1P8KcP
  • Ironport-sdr: F11yVwODpKW/9692EmFKjf4ho1p+xQ6+i9F9z9lIN/hZ7qLXL8knQbpp4ZrWAa6g3IVplBCQGJ FSaRgdVFKWsm7jVWmPa7Dv9DXZBjTTbqC+P39rUHED6iPoARJj/4k3HKi5JQjEmosnEQkAO7zN 5/Z6S9XksSJIueDMw3WPPxaTXY12F6Qwf0SMp15v9jIWwtwT4nC/FoKu9t2VFHscdGLwv7KwNb j2WRZnknY9UutsQaD3rwqgthyQUBt+Jg+dkEZV8yXoSe4N2wu877KR/mmYmFW7KtZCGQjhyYAr 9yiMpwjN1HdjZVuag2NhkHSS
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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?

Thanks, Roger.



 


Rackspace

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