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

[PATCH 0/4] Yet another pci/vpci locking re-work



From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

Hello, all!

This is a yet another attempt to re-work the existing pci/vpci locking
scheme towards vPCI is going to be used for guests.
For more details on the previous attempts and their flaws please see [1], [2].

This work is based on the idea that it is possible to extend the
existing locking scheme by additionally providing a global read/write lock:

This way most of the code continues to use pcidevs_{lock|unlock}, so
only minor changes are required which do not lead to functional changes
seen by the users: these become readers with respect to the new rwlock
and they acquire _pcidevs_lock as before.

As to the writers (those which can add/remove pci devices and their
respective pdev) we need to make them use the new rwlock in write mode.
For that we introduce pcidevs_write_{un}lock helpers.

Those users, which do not add/remove pdevs and are only interested in
pdev->vpci or simple pdev's list traversal, will use
pcidevs_read_{lock|unlock} which only acquires the rwlock in read mode
without acquiring _pcidevs_lock. This is to make sure there is no
unnecessary contention for the later. For the cases when it is required
to make sure that no other CPU can access critical sections under the
read lock (modify_bars for example) it is possible to upgrade it to a
normal pcidevs_lock due to both read lock and _pcidevs_lock allow
recursion.

The series was tested on:
 - x86 PVH Dom0 and doesn't break it.
 - x86 HVM with PCI passthrough to DomU and doesn't break it.

Thank you,
Oleksandr

[1] 
https://lore.kernel.org/xen-devel/20180717094830.54806-2-roger.pau@xxxxxxxxxx/
[2] https://lore.kernel.org/all/20220204063459.680961-4-andr2000@xxxxxxxxx/

Oleksandr Andrushchenko (4):
  pci: add rwlock to pcidevs_lock machinery
  vpci: restrict unhandled read/write operations for guests
  vpci: use pcidevs locking to protect MMIO handlers
  vpci: resolve possible clash while removing BAR overlaps

 xen/arch/x86/hvm/vmsi.c       | 24 +++++++++++--
 xen/drivers/passthrough/pci.c | 65 +++++++++++++++++++++++++++++------
 xen/drivers/vpci/header.c     | 30 ++++++++++++++--
 xen/drivers/vpci/msi.c        | 21 +++++++----
 xen/drivers/vpci/msix.c       | 55 +++++++++++++++++++++++++----
 xen/drivers/vpci/vpci.c       | 34 +++++++++++++++---
 xen/include/xen/pci.h         |  9 +++++
 xen/include/xen/vpci.h        |  2 +-
 8 files changed, 205 insertions(+), 35 deletions(-)

-- 
2.25.1




 


Rackspace

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