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

[RFC PATCH v4 5/6] xen/vpci: support ro mask


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Mon, 28 Aug 2023 13:56:53 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=dU/f6BYM+t+yAh1uQ1Cq9rU23TlKf83Tj/wjom6+IVU=; b=jaoompQuoo7wzvnNfndd0zsZJZu7DkQk/iSOc3CNauejuUQC4Eh3TCBl81X2c6U1dOy1CSWiBV5nk2dN+gbW/qvlMrPdRm1PbgAFJL8lLrvZyEp5KH6Nh2FHgNPLSwR6jQ0R4BUN8tyip4sNhYxFu53fddv4+LGSvaEnd6jwgIRIxNEAlXTiRnBtHhqrF9UxRm59uL9HQPvVL4rUiOlry0dRasf+TmzOVNarE2HnFBLc/0SwRrTK66meq0d0jrhbt9vVPWNQ7weF9YBSjYFcN1LSpYXf2wXGoS1XPXTQWfQZx7dzC9UoozMOR8QwfdQDWSin6PGa04hFSrdq3N2JKQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPHH0+u5014acUuC1706UsAUtoAetJ4rPxNach1h23NS91Dq7/TMuEc0VXdgshXD7hhHRsxIX/0Ut4Rap8s5WVWGa1WvHirn4M4lLQLwTFmfWH9WBBLD8JEXXey5XgYK4/FMZLBmqwIeFDvZRsuUH5lmgDMivKiBdAaiwLlHB0YA/hCKrN+mweaVIcaL3Es/TFw8nahWAwK+h8dsGZ67+8pxEurws4yc3ZlnTqXTaklM5fZbmZOZwOSSl0RotQFHHxQ6LQgWLTZnKZJ3hSXDkedTbr/s0UshQ5I9+TwPaNaUBEFmfTnBGMWQn2pd2KT7iDX4eAohSMU9P3r0dvvn4w==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 28 Aug 2023 18:02:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add support for a read-only bit mask for vPCI register handlers.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
v3->v4:
* new patch

RFC: It seemed like a low-hanging fruit to add support for ro mask. Let me know
     what you think, and I could squash it into the status handler patch for the
     next version of the series.
---
 xen/drivers/vpci/header.c |  4 ++--
 xen/drivers/vpci/vpci.c   | 15 ++++++++++-----
 xen/include/xen/vpci.h    |  5 +++--
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index dc8c6a66770b..4a4dbb69ab1c 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -556,8 +556,8 @@ static int cf_check init_bars(struct pci_dev *pdev)
     if ( rc )
         return rc;
 
-    rc = vpci_add_rw1c_register(pdev->vpci, status_read, vpci_hw_write16,
-                                PCI_STATUS, 2, header, 0xF900);
+    rc = vpci_add_register_mask(pdev->vpci, status_read, vpci_hw_write16,
+                                PCI_STATUS, 2, header, 0x06F8, 0xF900);
     if ( rc )
         return rc;
 
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 8b26870a8a2b..2a67cc516626 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -29,6 +29,7 @@ struct vpci_register {
     unsigned int offset;
     void *private;
     struct list_head node;
+    uint32_t ro_mask;
     uint32_t rw1c_mask;
 };
 
@@ -154,7 +155,8 @@ void cf_check vpci_hw_write16(
 
 static int add_register(struct vpci *vpci, vpci_read_t *read_handler,
                         vpci_write_t *write_handler, unsigned int offset,
-                        unsigned int size, void *data, uint32_t rw1c_mask)
+                        unsigned int size, void *data, uint32_t ro_mask,
+                        uint32_t rw1c_mask)
 {
     struct list_head *prev;
     struct vpci_register *r;
@@ -174,6 +176,7 @@ static int add_register(struct vpci *vpci, vpci_read_t 
*read_handler,
     r->size = size;
     r->offset = offset;
     r->private = data;
+    r->ro_mask = ro_mask;
     r->rw1c_mask = rw1c_mask;
 
     spin_lock(&vpci->lock);
@@ -206,15 +209,16 @@ int vpci_add_register(struct vpci *vpci, vpci_read_t 
*read_handler,
                       unsigned int size, void *data)
 {
     return add_register(vpci, read_handler, write_handler, offset, size, data,
-                        0);
+                        0, 0);
 }
 
-int vpci_add_rw1c_register(struct vpci *vpci, vpci_read_t *read_handler,
+int vpci_add_register_mask(struct vpci *vpci, vpci_read_t *read_handler,
                            vpci_write_t *write_handler, unsigned int offset,
-                           unsigned int size, void *data, uint32_t rw1c_mask)
+                           unsigned int size, void *data, uint32_t ro_mask,
+                           uint32_t rw1c_mask)
 {
     return add_register(vpci, read_handler, write_handler, offset, size, data,
-                        rw1c_mask);
+                        ro_mask, rw1c_mask);
 }
 
 int vpci_remove_register(struct vpci *vpci, unsigned int offset,
@@ -447,6 +451,7 @@ static void vpci_write_helper(const struct pci_dev *pdev,
         data = merge_result(val, data, size, offset);
     }
 
+    data &= ~r->ro_mask;
     r->write(pdev, r->offset, data & (0xffffffffU >> (32 - 8 * r->size)),
              r->private);
 }
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 51b1b06c2c71..b0636182d91e 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -37,11 +37,12 @@ int __must_check vpci_add_register(struct vpci *vpci,
                                    vpci_write_t *write_handler,
                                    unsigned int offset, unsigned int size,
                                    void *data);
-int __must_check vpci_add_rw1c_register(struct vpci *vpci,
+int __must_check vpci_add_register_mask(struct vpci *vpci,
                                         vpci_read_t *read_handler,
                                         vpci_write_t *write_handler,
                                         unsigned int offset, unsigned int size,
-                                        void *data, uint32_t rw1c_mask);
+                                        void *data, uint32_t ro_mask,
+                                        uint32_t rw1c_mask);
 int __must_check vpci_remove_register(struct vpci *vpci, unsigned int offset,
                                       unsigned int size);
 
-- 
2.42.0




 


Rackspace

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