[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 02/11] vpci: cancel pending map/unmap on vpci removal
- To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 19 Nov 2021 14:00:57 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=aoXtEWcat3ZJ0NsTKaaM5NBTp3WHS2TcIAermQB/Scw=; b=buGnLYl14sd0pBwkt07vsJBxXa/1Ojzy1jjOij/TdDr3iGiKfbpWNRDmcjeqtgcxj+EfScliCIvMprW6TMJLsnHdJk8VVejtd11FJuRcRR88WyUJWR3qp8ENQxZMfp8JR8BZeqfyuyRtQbFCZvPax02AotYdEqxhPAJexxudEQRqGpHFe/OnLndPraNnResBA0pJMILiZk+3cxi0YP+eC2wZr6p8jGFAyVoIcw/EkiiA9hHOJXwosbyd/ePb2Gl5qf/FSlJ9ldVuYRcUP0cBZkFjnLUZVedFtpZKuyc65JjMW2SonVxIuhIXUH6sAxuJ1ewzSjx+nzigoSW7Hbvgfw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JD3jLjNp/E2LiIGIQOd5XcRPs7aqtyXcgiqTr1AO6zqdP8dNHm2O6snUxZmY2zia+5RXkSUOhrb1tqstayspYQRC1fJjamwHuwqqCGZGusZr0nSkrTbfnichoMtX5gIkrtZKnPy037wm1gyxRakhcsMiJNIwLlXbYJ/Eg0fd2UCTEx8KLOHm3yUWVDtDZeSchc2dvEl9eXbjBJjcCSjkXIMKxS5wJg4l7msb8TBytOCGW1dYuz/F7hRgx9nWnFTa4/IQZxTjd6mu72UZVzt0HfL4z5cUKvrd+HOYgKojTe/c4gmlhinDXiERljHZXGaM8lrcvFDCg5QKko5G1VB7NA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- 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>
- Delivery-date: Fri, 19 Nov 2021 13:01:57 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 19.11.2021 13:34, Oleksandr Andrushchenko wrote:
> Possible locking and other work needed:
> =======================================
>
> 1. pcidevs_{lock|unlock} is too heavy and is per-host
> 2. pdev->vpci->lock cannot be used as vpci is freed by vpci_remove_device
> 3. We may want a dedicated per-domain rw lock to be implemented:
>
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 28146ee404e6..ebf071893b21 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -444,6 +444,7 @@ struct domain
>
> #ifdef CONFIG_HAS_PCI
> struct list_head pdev_list;
> + rwlock_t vpci_rwlock;
> + bool vpci_terminating; <- atomic?
> #endif
> then vpci_remove_device is a writer (cold path) and vpci_process_pending and
> vpci_mmio_{read|write} are readers (hot path).
Right - you need such a lock for other purposes anyway, as per the
discussion with Julien.
> do_physdev_op(PHYSDEVOP_pci_device_remove) will need
> hypercall_create_continuation
> to be implemented, so when re-start removal if need be:
>
> vpci_remove_device()
> {
> d->vpci_terminating = true;
> remove vPCI register handlers <- this will cut off PCI_COMMAND emulation
> among others
> if ( !write_trylock(d->vpci_rwlock) )
> return -ERESTART;
> xfree(pdev->vpci);
> pdev->vpci = NULL;
> }
>
> Then this d->vpci_rwlock becomes a dedicated vpci per-domain lock for
> other operations which may require it, e.g. virtual bus topology can
> use it when assigning vSBDF etc.
>
> 4. vpci_remove_device needs to be removed from vpci_process_pending
> and do nothing for Dom0 and crash DomU otherwise:
Why is this? I'm not outright opposed, but I don't immediately see why
trying to remove the problematic device wouldn't be a reasonable course
of action anymore. vpci_remove_device() may need to become more careful
as to not crashing, though.
Jan
|