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

[PATCH v3 5/6] vpci: use reference counter to protect vpci state


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 14 Mar 2023 20:56:30 +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=DQPuJAI8PAXGvKTZe3ed59NbyldzeM5G1uslGFxDTuU=; b=O1qk2JsQoh7mjTZ+X7BQTKpKfycIQNoy/qfeAPHRBWWoUEBENrzfUYpLgud8zrzt8esGhlM1N/AZKw0mrje+RHHGuxkA02iSJ3gvZQUWigx7rhV+poWegVnN5zafMg00UFpZZEIac1CGKK25PhX9FVucBfAgXMAk3JNR4pGyRWzwgLLMs1DkMoqHsNpdN5R7RKyCWw31uXd0qu1/mV6EFk/0KzVSZpG4ewsKo/+P7YSzokr9vgPYZAjvVQttaXa1Ni+ZJS+qp8tAYXmbSu+ZNzJ3MHs62tXb13ZmtQ/plssIfx6t2zl3MW3HTOsoCvTYphrize6/VwGdwkv2l3RXkQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A75yNUZY7TFYc8MqS2xbkx9820TE4p03QsYhwvDwJceTcShrdZv7AK+0gzdqetMeJXNGRTfTDiWcJqWx9wCklXHTEWMIVACcFVeRq5TM1Lcns9hl5y83t9eDB06AUghwi/ll4Um7AIZbgTeD/hhtDy8NezgFnLVYgsGsVA84XR89eCYXm6uRp1ooKF3RaIAOxMjq5NiJLRXlbb9ZLQbHlrqmCCLPQuBZ6dTk7qMCaOhyVP0sF+emBSzumhKuNQ7JgRXSFZRmC0wswS/HXjfdcT+Auh85ehXwRSdLX6XbyK5txtINdPv6JC+w6YxT0BTdcuyiI+ISCqZaRwlk8WTfkg==
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Tue, 14 Mar 2023 20:57:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZVrdzxSa6ccK6DkSWhcHx4QyzSw==
  • Thread-topic: [PATCH v3 5/6] vpci: use reference counter to protect vpci state

vPCI MMIO handlers are accessing pdevs without protecting this
access with pcidevs_{lock|unlock}. This is not a problem as of now
as these are only used by Dom0. But, towards vPCI is used also for
guests, we need to properly protect pdev and pdev->vpci from being
removed while still in use.

For that use pdev reference counting.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>

---

v3:
 - Moved from another patch series
---
 xen/drivers/vpci/vpci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 199ff55672..005f38dc77 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -62,6 +62,7 @@ void vpci_remove_device(struct pci_dev *pdev)
     xfree(pdev->vpci->msi);
     xfree(pdev->vpci);
     pdev->vpci = NULL;
+    pcidev_put(pdev);
 }
 
 int vpci_add_handlers(struct pci_dev *pdev)
@@ -72,6 +73,8 @@ int vpci_add_handlers(struct pci_dev *pdev)
     if ( !has_vpci(pdev->domain) )
         return 0;
 
+    pcidev_get(pdev);
+
     /* We should not get here twice for the same device. */
     ASSERT(!pdev->vpci);
 
-- 
2.39.2



 


Rackspace

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