Skip to contentSkip to conversation

Cleanups + various fixes due to libxl ABI + more logging on errors.

PATCH Superseded Konrad Rzeszutek Wilk 2 participants 17 messages Jul 2, 2015 – Jul 17, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cleanups + various fixes due to libxl ABI + more logging on errors.

Hey!

since RFC [https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg07326.html]
- Added Acks
- Followed 'xen: Print and use errno where applicable.' suggestion by Stefano and added a wrapper.

As I am in the process of syncing the 'dev.config' and Xen's internal cache of the PCI config space I noticed that some oddities in the code and figured that having them in would be easier for me (so I don't have to handle 20 odd patches).

Stefano, patches 1-3 are unchanged since the RFC posting (well, they have the Ack tag added). Patch:

[PATCH v1 4/6] xen: use errno instead of rc for xc_domain_add_to_physmap

uses the new wrapper you suggested.

The last two patches are new and I missed them the first time I posted:
[PATCH v1 5/6] xen/pt/msi: Add the register value when printing [PATCH v1 6/6] xen/pt: Use XEN_PT_LOG properly to guard against

In short, please review #4,#5, and #6.

 hw/xen/xen_pt.c             |  6 +++---
 hw/xen/xen_pt.h             |  1 -
 hw/xen/xen_pt_config_init.c |  8 ++++----
 hw/xen/xen_pt_msi.c         |  2 +-
 include/hw/xen/xen_common.h | 22 ++++++++++++++++++++++
 xen-hvm.c                   |  4 ++--
 6 files changed, 32 insertions(+), 11 deletions(-)

Konrad Rzeszutek Wilk (6):
xen/pt: Update comments with proper function name.
xen/pt: Make xen_pt_msi_set_enable static
xen/pt: xen_host_pci_config_read returns -errno, not -1 on failure
xen: use errno instead of rc for xc_domain_add_to_physmap xen/pt/msi: Add the register value when printing logging and error messages xen/pt: Use XEN_PT_LOG properly to guard against compiler warnings.

#1 lore raw

PATCH 1/6 xen/pt: Update comments with proper function name.

It has changed but the comments still refer to the old names.

---
 hw/xen/xen_pt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/xen/xen_pt.c +2 -2
index ed5fcae..706e3d9 100644
@@ -378,7 +378,7 @@ static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
         }
     }
 
-    /* need to shift back before passing them to xen_host_pci_device */
+    /* need to shift back before passing them to xen_host_pci_set_block. */
     val >>= (addr & 3) << 3;
 
     memory_region_transaction_commit();
@@ -406,7 +406,7 @@ out:
                                     (uint8_t *)&val + index, len);
 
         if (rc < 0) {
-            XEN_PT_ERR(d, "pci_write_block failed. return value: %d.\n", rc);
+            XEN_PT_ERR(d, "xen_host_pci_set_block failed. return value: %d.\n", rc);
         }
     }
 }
Signature · 1 line
2.1.0
#2 lore raw

PATCH 1/6 xen/pt: Update comments with proper function name.

In reply to Konrad Rzeszutek Wilk

It has changed but the comments still refer to the old names.

---
 hw/xen/xen_pt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/xen/xen_pt.c +2 -2
index ed5fcae..706e3d9 100644
@@ -378,7 +378,7 @@ static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
         }
     }
 
-    /* need to shift back before passing them to xen_host_pci_device */
+    /* need to shift back before passing them to xen_host_pci_set_block. */
     val >>= (addr & 3) << 3;
 
     memory_region_transaction_commit();
@@ -406,7 +406,7 @@ out:
                                     (uint8_t *)&val + index, len);
 
         if (rc < 0) {
-            XEN_PT_ERR(d, "pci_write_block failed. return value: %d.\n", rc);
+            XEN_PT_ERR(d, "xen_host_pci_set_block failed. return value: %d.\n", rc);
         }
     }
 }
Signature · 1 line
2.1.0
#3 lore raw

PATCH 2/6 xen/pt: Make xen_pt_msi_set_enable static

In reply to Konrad Rzeszutek Wilk

As we do not use it outside our code.

---
 hw/xen/xen_pt.h     | 1 -
 hw/xen/xen_pt_msi.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
hw/xen/xen_pt.h +0 -1
index 393f36c..09358b1 100644
@@ -289,7 +289,6 @@ static inline uint8_t xen_pt_pci_intx(XenPCIPassthroughState *s)
 }
 
 /* MSI/MSI-X */
-int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool en);
 int xen_pt_msi_setup(XenPCIPassthroughState *s);
 int xen_pt_msi_update(XenPCIPassthroughState *d);
 void xen_pt_msi_disable(XenPCIPassthroughState *s);
hw/xen/xen_pt_msi.c +1 -1
index 263e051..5822df5 100644
@@ -220,7 +220,7 @@ static int msi_msix_disable(XenPCIPassthroughState *s,
  * MSI virtualization functions
  */
 
-int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool enable)
+static int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool enable)
 {
     XEN_PT_LOG(&s->dev, "%s MSI.\n", enable ? "enabling" : "disabling");
 
Signature · 1 line
2.1.0
#4 lore raw

PATCH 2/6 xen/pt: Make xen_pt_msi_set_enable static

In reply to Konrad Rzeszutek Wilk

As we do not use it outside our code.

---
 hw/xen/xen_pt.h     | 1 -
 hw/xen/xen_pt_msi.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
hw/xen/xen_pt.h +0 -1
index 393f36c..09358b1 100644
@@ -289,7 +289,6 @@ static inline uint8_t xen_pt_pci_intx(XenPCIPassthroughState *s)
 }
 
 /* MSI/MSI-X */
-int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool en);
 int xen_pt_msi_setup(XenPCIPassthroughState *s);
 int xen_pt_msi_update(XenPCIPassthroughState *d);
 void xen_pt_msi_disable(XenPCIPassthroughState *s);
hw/xen/xen_pt_msi.c +1 -1
index 263e051..5822df5 100644
@@ -220,7 +220,7 @@ static int msi_msix_disable(XenPCIPassthroughState *s,
  * MSI virtualization functions
  */
 
-int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool enable)
+static int xen_pt_msi_set_enable(XenPCIPassthroughState *s, bool enable)
 {
     XEN_PT_LOG(&s->dev, "%s MSI.\n", enable ? "enabling" : "disabling");
 
Signature · 1 line
2.1.0
#5 lore raw

PATCH 3/6 xen/pt: xen_host_pci_config_read returns -errno, not -1 on failure

In reply to Konrad Rzeszutek Wilk

However the init routines assume that on errors the return code is -1 (as the libxc API is) - while those xen_host_* routines follow another paradigm - negative errno on return, 0 on success.

---
 hw/xen/xen_pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen_pt.c +1 -1
index 706e3d9..ea1ceda 100644
@@ -716,7 +716,7 @@ static int xen_pt_initfn(PCIDevice *d)
 
     /* Initialize virtualized PCI configuration (Extended 256 Bytes) */
     if (xen_host_pci_get_block(&s->real_device, 0, d->config,
-                               PCI_CONFIG_SPACE_SIZE) == -1) {
+                               PCI_CONFIG_SPACE_SIZE) < 0) {
         xen_host_pci_device_put(&s->real_device);
         return -1;
     }
Signature · 1 line
2.1.0
#6 lore raw

PATCH 3/6 xen/pt: xen_host_pci_config_read returns -errno, not -1 on failure

In reply to Konrad Rzeszutek Wilk

However the init routines assume that on errors the return code is -1 (as the libxc API is) - while those xen_host_* routines follow another paradigm - negative errno on return, 0 on success.

---
 hw/xen/xen_pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen_pt.c +1 -1
index 706e3d9..ea1ceda 100644
@@ -716,7 +716,7 @@ static int xen_pt_initfn(PCIDevice *d)
 
     /* Initialize virtualized PCI configuration (Extended 256 Bytes) */
     if (xen_host_pci_get_block(&s->real_device, 0, d->config,
-                               PCI_CONFIG_SPACE_SIZE) == -1) {
+                               PCI_CONFIG_SPACE_SIZE) < 0) {
         xen_host_pci_device_put(&s->real_device);
         return -1;
     }
Signature · 1 line
2.1.0
#7 lore raw

PATCH 4/6 xen: use errno instead of rc for xc_domain_add_to_physmap

In reply to Konrad Rzeszutek Wilk

In Xen 4.6 commit cd2f100f0f61b3f333d52d1737dd73f02daee592 "libxc: Fix do_memory_op to return negative value on errors" made the libxc API less odd-ball: On errors, return value is -1 and error code is in errno. On success the return value is either 0 or an positive value.

Since we could be running with an old toolstack in which the Exx value is in rc or the newer, we add an wrapper around the xc_domain_add_to_physmap (called xen_xc_domain_add_to_physmap) which will always return the EXX.

---
 include/hw/xen/xen_common.h | 22 ++++++++++++++++++++++
 xen-hvm.c                   |  4 ++--
 2 files changed, 24 insertions(+), 2 deletions(-)
include/hw/xen/xen_common.h +22 -0
index 38f29fb..fc66c3c 100644
@@ -407,4 +407,26 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 460
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    return xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+}
+#else
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    /* In Xen 4.6 rc is -1 and errno contains the error value. */
+    int rc = xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+    if (rc == -1)
+        return errno;
+    return rc;
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
xen-hvm.c +2 -2
index 0408462..fae2d22 100644
@@ -345,7 +345,7 @@ go_physmap:
         unsigned long idx = pfn + i;
         xen_pfn_t gpfn = start_gpfn + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
@@ -422,7 +422,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         xen_pfn_t idx = start_addr + i;
         xen_pfn_t gpfn = phys_offset + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
Signature · 1 line
2.1.0
Reviewed-by on v1 4/6
#8 lore raw

Re: [PATCH v1 4/6] xen: use errno instead of rc for xc_domain_add_to_physmap

Quoted 23 lines · Konrad Rzeszutek Wilk

In Xen 4.6 commit cd2f100f0f61b3f333d52d1737dd73f02daee592 "libxc: Fix do_memory_op to return negative value on errors" made the libxc API less odd-ball: On errors, return value is -1 and error code is in errno. On success the return value is either 0 or an positive value.

Since we could be running with an old toolstack in which the Exx value is in rc or the newer, we add an wrapper around the xc_domain_add_to_physmap (called xen_xc_domain_add_to_physmap) which will always return the EXX.

---
 include/hw/xen/xen_common.h | 22 ++++++++++++++++++++++
 xen-hvm.c                   |  4 ++--
 2 files changed, 24 insertions(+), 2 deletions(-)
include/hw/xen/xen_common.h +0 -0
index 38f29fb..fc66c3c 100644

include/hw/xen/xen_common.h static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, · line 410

Quoted 4 lines
include/hw/xen/xen_common.h +1 -0
@@ -407,4 +407,26 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 460

This patch is fine as is and you can add my

however there is no code to detect 460 at the moment, see configure:1844. We need one more test case in the configure script to detect 4.6.

Quoted 47 lines
include/hw/xen/xen_common.h +21 -0
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    return xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+}
+#else
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    /* In Xen 4.6 rc is -1 and errno contains the error value. */
+    int rc = xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+    if (rc == -1)
+        return errno;
+    return rc;
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
xen-hvm.c +2 -2
index 0408462..fae2d22 100644
@@ -345,7 +345,7 @@ go_physmap:
         unsigned long idx = pfn + i;
         xen_pfn_t gpfn = start_gpfn + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
@@ -422,7 +422,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         xen_pfn_t idx = start_addr + i;
         xen_pfn_t gpfn = phys_offset + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
Signature · 1 line
2.1.0
Reviewed-by on v1 4/6
#9 lore raw

Re: [Qemu-devel] [PATCH v1 4/6] xen: use errno instead of rc for xc_domain_add_to_physmap

In reply to Konrad Rzeszutek Wilk
Quoted 23 lines · Konrad Rzeszutek Wilk

In Xen 4.6 commit cd2f100f0f61b3f333d52d1737dd73f02daee592 "libxc: Fix do_memory_op to return negative value on errors" made the libxc API less odd-ball: On errors, return value is -1 and error code is in errno. On success the return value is either 0 or an positive value.

Since we could be running with an old toolstack in which the Exx value is in rc or the newer, we add an wrapper around the xc_domain_add_to_physmap (called xen_xc_domain_add_to_physmap) which will always return the EXX.

---
 include/hw/xen/xen_common.h | 22 ++++++++++++++++++++++
 xen-hvm.c                   |  4 ++--
 2 files changed, 24 insertions(+), 2 deletions(-)
include/hw/xen/xen_common.h +0 -0
index 38f29fb..fc66c3c 100644

include/hw/xen/xen_common.h static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom, · line 410

Quoted 4 lines
include/hw/xen/xen_common.h +1 -0
@@ -407,4 +407,26 @@ static inline int xen_set_ioreq_server_state(XenXC xc, domid_t dom,
 
 #endif
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 460

This patch is fine as is and you can add my

however there is no code to detect 460 at the moment, see configure:1844. We need one more test case in the configure script to detect 4.6.

Quoted 47 lines
include/hw/xen/xen_common.h +21 -0
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    return xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+}
+#else
+static inline int xen_xc_domain_add_to_physmap(XenXC xch, uint32_t domid,
+                                               unsigned int space,
+                                               unsigned long idx,
+                                               xen_pfn_t gpfn)
+{
+    /* In Xen 4.6 rc is -1 and errno contains the error value. */
+    int rc = xc_domain_add_to_physmap(xch, domid, space, idx, gpfn);
+    if (rc == -1)
+        return errno;
+    return rc;
+}
+#endif
+
 #endif /* QEMU_HW_XEN_COMMON_H */
xen-hvm.c +2 -2
index 0408462..fae2d22 100644
@@ -345,7 +345,7 @@ go_physmap:
         unsigned long idx = pfn + i;
         xen_pfn_t gpfn = start_gpfn + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
@@ -422,7 +422,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         xen_pfn_t idx = start_addr + i;
         xen_pfn_t gpfn = phys_offset + i;
 
-        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
+        rc = xen_xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
                     PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
Signature · 1 line
2.1.0
#10 lore raw

PATCH 5/6 xen/pt/msi: Add the register value when printing logging and error messages

In reply to Konrad Rzeszutek Wilk

We would like to know what the MSI register value is to help in troubleshooting in the field. As such modify the logging logic to include such details in xen_pt_msgctrl_reg_write.

---
 hw/xen/xen_pt_config_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_pt_config_init.c +3 -3
index dd37be3..462e1b9 100644
@@ -1086,7 +1086,7 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
         /* setup MSI pirq for the first time */
         if (!msi->initialized) {
             /* Init physical one */
-            XEN_PT_LOG(&s->dev, "setup MSI\n");
+            XEN_PT_LOG(&s->dev, "setup MSI (register: %x).\n", *val);
             if (xen_pt_msi_setup(s)) {
                 /* We do not broadcast the error to the framework code, so
                  * that MSI errors are contained in MSI emulation code and
@@ -1094,12 +1094,12 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
                  * Guest MSI would be actually not working.
                  */
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not map MSI.\n");
+                XEN_PT_WARN(&s->dev, "Can not map MSI (register: %x)!\n", *val);
                 return 0;
             }
             if (xen_pt_msi_update(s)) {
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not bind MSI\n");
+                XEN_PT_WARN(&s->dev, "Can not bind MSI (register: %x)!\n", *val);
                 return 0;
             }
             msi->initialized = true;
Signature · 1 line
2.1.0
#11 lore raw

PATCH 5/6 xen/pt/msi: Add the register value when printing logging and error messages

In reply to Konrad Rzeszutek Wilk

We would like to know what the MSI register value is to help in troubleshooting in the field. As such modify the logging logic to include such details in xen_pt_msgctrl_reg_write.

---
 hw/xen/xen_pt_config_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_pt_config_init.c +3 -3
index dd37be3..462e1b9 100644
@@ -1086,7 +1086,7 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
         /* setup MSI pirq for the first time */
         if (!msi->initialized) {
             /* Init physical one */
-            XEN_PT_LOG(&s->dev, "setup MSI\n");
+            XEN_PT_LOG(&s->dev, "setup MSI (register: %x).\n", *val);
             if (xen_pt_msi_setup(s)) {
                 /* We do not broadcast the error to the framework code, so
                  * that MSI errors are contained in MSI emulation code and
@@ -1094,12 +1094,12 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
                  * Guest MSI would be actually not working.
                  */
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not map MSI.\n");
+                XEN_PT_WARN(&s->dev, "Can not map MSI (register: %x)!\n", *val);
                 return 0;
             }
             if (xen_pt_msi_update(s)) {
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not bind MSI\n");
+                XEN_PT_WARN(&s->dev, "Can not bind MSI (register: %x)!\n", *val);
                 return 0;
             }
             msi->initialized = true;
Signature · 1 line
2.1.0
Reviewed-by on v1 5/6
#12 lore raw

Re: [PATCH v1 5/6] xen/pt/msi: Add the register value when printing logging and error messages

Quoted 5 lines · Konrad Rzeszutek Wilk

We would like to know what the MSI register value is to help in troubleshooting in the field. As such modify the logging logic to include such details in xen_pt_msgctrl_reg_write.

Quoted 34 lines
 hw/xen/xen_pt_config_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_pt_config_init.c +3 -3
index dd37be3..462e1b9 100644
@@ -1086,7 +1086,7 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
         /* setup MSI pirq for the first time */
         if (!msi->initialized) {
             /* Init physical one */
-            XEN_PT_LOG(&s->dev, "setup MSI\n");
+            XEN_PT_LOG(&s->dev, "setup MSI (register: %x).\n", *val);
             if (xen_pt_msi_setup(s)) {
                 /* We do not broadcast the error to the framework code, so
                  * that MSI errors are contained in MSI emulation code and
@@ -1094,12 +1094,12 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
                  * Guest MSI would be actually not working.
                  */
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not map MSI.\n");
+                XEN_PT_WARN(&s->dev, "Can not map MSI (register: %x)!\n", *val);
                 return 0;
             }
             if (xen_pt_msi_update(s)) {
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not bind MSI\n");
+                XEN_PT_WARN(&s->dev, "Can not bind MSI (register: %x)!\n", *val);
                 return 0;
             }
             msi->initialized = true;
Signature · 1 line
2.1.0
Reviewed-by on v1 5/6
#13 lore raw

Re: [Qemu-devel] [PATCH v1 5/6] xen/pt/msi: Add the register value when printing logging and error messages

In reply to Konrad Rzeszutek Wilk
Quoted 5 lines · Konrad Rzeszutek Wilk

We would like to know what the MSI register value is to help in troubleshooting in the field. As such modify the logging logic to include such details in xen_pt_msgctrl_reg_write.

Quoted 34 lines
 hw/xen/xen_pt_config_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_pt_config_init.c +3 -3
index dd37be3..462e1b9 100644
@@ -1086,7 +1086,7 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
         /* setup MSI pirq for the first time */
         if (!msi->initialized) {
             /* Init physical one */
-            XEN_PT_LOG(&s->dev, "setup MSI\n");
+            XEN_PT_LOG(&s->dev, "setup MSI (register: %x).\n", *val);
             if (xen_pt_msi_setup(s)) {
                 /* We do not broadcast the error to the framework code, so
                  * that MSI errors are contained in MSI emulation code and
@@ -1094,12 +1094,12 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
                  * Guest MSI would be actually not working.
                  */
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not map MSI.\n");
+                XEN_PT_WARN(&s->dev, "Can not map MSI (register: %x)!\n", *val);
                 return 0;
             }
             if (xen_pt_msi_update(s)) {
                 *val &= ~PCI_MSI_FLAGS_ENABLE;
-                XEN_PT_WARN(&s->dev, "Can not bind MSI\n");
+                XEN_PT_WARN(&s->dev, "Can not bind MSI (register: %x)!\n", *val);
                 return 0;
             }
             msi->initialized = true;
Signature · 1 line
2.1.0
#14 lore raw

PATCH 6/6 xen/pt: Use XEN_PT_LOG properly to guard against compiler warnings.

In reply to Konrad Rzeszutek Wilk

If XEN_PT_LOGGING_ENABLED is enabled the XEN_PT_LOG macros start using the first argument. Which means if within the function there is only one user of the argument ('d') and XEN_PT_LOGGING_ENABLED is not set, we get compiler warnings. This is not the case now but with the "xen/pt: Use xen_host_pci_get_[byte|word] instead of dev.config" we will hit - so this sync up the function to the rest of them.

---
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen_pt_config_init.c +1 -1
index 462e1b9..21d4938 100644
@@ -1418,7 +1418,7 @@ static int xen_pt_msixctrl_reg_init(XenPCIPassthroughState *s,
     reg_field = pci_get_word(d->config + real_offset);
 
     if (reg_field & PCI_MSIX_FLAGS_ENABLE) {
-        XEN_PT_LOG(d, "MSIX already enabled, disabling it first\n");
+        XEN_PT_LOG(&s->dev, "MSIX already enabled, disabling it first\n");
         xen_host_pci_set_word(&s->real_device, real_offset,
                               reg_field & ~PCI_MSIX_FLAGS_ENABLE);
     }
Signature · 1 line
2.1.0
Reviewed-by on v1 6/6
#15 lore raw

Re: [PATCH v1 6/6] xen/pt: Use XEN_PT_LOG properly to guard against compiler warnings.

Quoted 8 lines · Konrad Rzeszutek Wilk

If XEN_PT_LOGGING_ENABLED is enabled the XEN_PT_LOG macros start using the first argument. Which means if within the function there is only one user of the argument ('d') and XEN_PT_LOGGING_ENABLED is not set, we get compiler warnings. This is not the case now but with the "xen/pt: Use xen_host_pci_get_[byte|word] instead of dev.config" we will hit - so this sync up the function to the rest of them.

Quoted 19 lines
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen_pt_config_init.c +1 -1
index 462e1b9..21d4938 100644
@@ -1418,7 +1418,7 @@ static int xen_pt_msixctrl_reg_init(XenPCIPassthroughState *s,
     reg_field = pci_get_word(d->config + real_offset);
 
     if (reg_field & PCI_MSIX_FLAGS_ENABLE) {
-        XEN_PT_LOG(d, "MSIX already enabled, disabling it first\n");
+        XEN_PT_LOG(&s->dev, "MSIX already enabled, disabling it first\n");
         xen_host_pci_set_word(&s->real_device, real_offset,
                               reg_field & ~PCI_MSIX_FLAGS_ENABLE);
     }
Signature · 1 line
2.1.0
Reviewed-by on v1 6/6
#16 lore raw

Re: [Qemu-devel] [PATCH v1 6/6] xen/pt: Use XEN_PT_LOG properly to guard against compiler warnings.

In reply to Konrad Rzeszutek Wilk
Quoted 8 lines · Konrad Rzeszutek Wilk

If XEN_PT_LOGGING_ENABLED is enabled the XEN_PT_LOG macros start using the first argument. Which means if within the function there is only one user of the argument ('d') and XEN_PT_LOGGING_ENABLED is not set, we get compiler warnings. This is not the case now but with the "xen/pt: Use xen_host_pci_get_[byte|word] instead of dev.config" we will hit - so this sync up the function to the rest of them.

Quoted 19 lines
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen_pt_config_init.c +1 -1
index 462e1b9..21d4938 100644
@@ -1418,7 +1418,7 @@ static int xen_pt_msixctrl_reg_init(XenPCIPassthroughState *s,
     reg_field = pci_get_word(d->config + real_offset);
 
     if (reg_field & PCI_MSIX_FLAGS_ENABLE) {
-        XEN_PT_LOG(d, "MSIX already enabled, disabling it first\n");
+        XEN_PT_LOG(&s->dev, "MSIX already enabled, disabling it first\n");
         xen_host_pci_set_word(&s->real_device, real_offset,
                               reg_field & ~PCI_MSIX_FLAGS_ENABLE);
     }
Signature · 1 line
2.1.0