xen/pciback: Make missing GSI non-fatal
Subsystems (2)
PATCH 1/1 xen/pciback: Make missing GSI non-fatal
A PCI may not have a legacy IRQ. In that case, do not fail assigning to the pciback stub. Instead just skip xen_pvh_setup_gsi().
This will leave psdev->gsi == -1. In that case, when reading the value via IOCTL_PRIVCMD_PCIDEV_GET_GSI, return -ENOENT. Userspace can used this to distinquish from other errors.
--- drivers/xen/acpi.c | 4 ++-- drivers/xen/xen-pciback/pci_stub.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/xen/acpi.c +2 -2
@@ -101,7 +101,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, pin = dev->pin;if (!pin) -return -EINVAL ; +return -ENOENT ; entry =acpi_pci_irq_lookup (dev, pin);if (entry) {
@@ -116,7 +116,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, gsi =-1 ;if (gsi <0 ) -return -EINVAL ; +return -ENOENT ; *gsi_out = gsi; *trigger_out = trigger;
drivers/xen/xen-pciback/pci_stub.c +10 -7
@@ -240,6 +240,9 @@ static int pcistub_get_gsi_from_sbdf(unsigned int sbdf)if (!psdev)return -ENODEV ; +if (psdev->gsi ==-1 ) +return -ENOENT ; + return psdev->gsi; }#endif
@@ -475,14 +478,14 @@ static int pcistub_init_device(struct pcistub_device *psdev)#ifdef CONFIG_XEN_ACPI if (xen_initial_domain () &&xen_pvh_domain ()) { err =xen_acpi_get_gsi_info (dev, &gsi, &trigger, &polarity); -if (err) { -dev_err (&dev->dev,"Fail to get gsi info!\n" ); - goto config_release; +if (err && err != -ENOENT ) { +dev_err (&dev->dev,"Failed to get gsi info! %d\n" , err); + }else if (!err) { + err =xen_pvh_setup_gsi (gsi, trigger, polarity); +if (err) + goto config_release; + psdev->gsi = gsi; } - err =xen_pvh_setup_gsi (gsi, trigger, polarity); -if (err) - goto config_release; - psdev->gsi = gsi; }#endif
Signature · 1 line
2.34.1
Quoted 52 lines · Jason Andryuk
A PCI may not have a legacy IRQ. In that case, do not fail assigning to the pciback stub. Instead just skip
xen_pvh_setup_gsi().This will leave
psdev->gsi== -1. In that case, when reading the value viaIOCTL_PRIVCMD_PCIDEV_GET_GSI, return-ENOENT. Userspace can used this to distinquish from other errors.Fixes b166b8ab4189 ("xen/pvh: Setup gsi for passthrough device")Signed-off-by Jason Andryuk <[email protected]>--- drivers/xen/acpi.c | 4 ++-- drivers/xen/xen-pciback/pci_stub.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-)drivers/xen/acpi.c +2
-2@@ -101,7 +101,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, pin = dev->pin;if (!pin) -return -EINVAL ; +return -ENOENT ; entry =acpi_pci_irq_lookup (dev, pin);if (entry) {@@ -116,7 +116,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, gsi =-1 ;if (gsi <0 ) -return -EINVAL ; +return -ENOENT ; *gsi_out = gsi; *trigger_out = trigger;drivers/xen/xen-pciback/pci_stub.c +3
-0@@ -240,6 +240,9 @@ static int pcistub_get_gsi_from_sbdf(unsigned int sbdf)if (!psdev)return -ENODEV ; +if (psdev->gsi ==-1 ) +return -ENOENT ; + return psdev->gsi; }#endif
drivers/xen/xen-pciback/pci_stub.c static int pcistub_init_device(struct pcistub_device *psdev) · line 482
Quoted 8 lines
drivers/xen/xen-pciback/pci_stub.c +2
-3@@ -475,14 +478,14 @@ static int pcistub_init_device(struct pcistub_device *psdev)#ifdef CONFIG_XEN_ACPI if (xen_initial_domain () &&xen_pvh_domain ()) { err =xen_acpi_get_gsi_info (dev, &gsi, &trigger, &polarity); -if (err) { -dev_err (&dev->dev,"Fail to get gsi info!\n" ); - goto config_release; +if (err && err != -ENOENT ) { +dev_err (&dev->dev,"Failed to get gsi info! %d\n" , err);
I think here needs " goto config_release;" since it is not ENOENT error.
Quoted 13 lines
drivers/xen/xen-pciback/pci_stub.c +5
-4+ } else if (!err) { + err =xen_pvh_setup_gsi (gsi, trigger, polarity); +if (err) + goto config_release; + psdev->gsi = gsi; } - err =xen_pvh_setup_gsi (gsi, trigger, polarity); -if (err) - goto config_release; - psdev->gsi = gsi; }#endif
Signature · 2 lines
Best regards, Jiqian Chen.
Quoted 11 lines · Jiqian
drivers/xen/xen-pciback/pci_stub.c static int pcistub_init_device(struct pcistub_device *psdev) · line 482
Quoted 9 lines · Jason Andryuk
drivers/xen/xen-pciback/pci_stub.c +2
-3@@ -475,14 +478,14 @@ static int pcistub_init_device(struct pcistub_device *psdev)#ifdef CONFIG_XEN_ACPI if (xen_initial_domain () &&xen_pvh_domain ()) { err =xen_acpi_get_gsi_info (dev, &gsi, &trigger, &polarity); -if (err) { -dev_err (&dev->dev,"Fail to get gsi info!\n" ); - goto config_release; +if (err && err != -ENOENT ) { +dev_err (&dev->dev,"Failed to get gsi info! %d\n" , err);I think here needs " goto
config_release;" since it is not ENOENT error.
Yes, thank you for catching that.
Regards,
Jason
Quoted 1 line · Jason Andryuk
A PCI may not have a legacy IRQ. In that case, do not fail assigning
Nit: Missing "device".
Quoted 4 lines
to the pciback stub. Instead just skip
xen_pvh_setup_gsi().This will leave
psdev->gsi== -1. In that case, when reading the value viaIOCTL_PRIVCMD_PCIDEV_GET_GSI, return-ENOENT. Userspace can used
Nit: "use".
Quoted 1 line
this to distinquish from other errors.
Nit: "distinguish".
drivers/xen/acpi.c int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 107
Quoted 11 lines
drivers/xen/acpi.c +1
-1@@ -101,7 +101,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, pin = dev->pin;if (!pin) -return -EINVAL ; +return -ENOENT ; entry =acpi_pci_irq_lookup (dev, pin);if (entry) {
While I can understand this change, ...
drivers/xen/acpi.c int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 122
Quoted 9 lines
drivers/xen/acpi.c +1
-1@@ -116,7 +116,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, gsi =-1 ;if (gsi <0 ) -return -EINVAL ; +return -ENOENT ; *gsi_out = gsi; *trigger_out = trigger;
... I'd expect this needs to keep using an error code other than ENOENT. Aiui this path means the device has a pin-based interrupt, just that it's not configured correctly. In which case we'd better not allow the device to be handed to a guest. Unless there's logic in place (somewhere) to make sure it then would get to see a device without pin-based interrupt.
drivers/xen/xen-pciback/pci_stub.c static int pcistub_get_gsi_from_sbdf(unsigned int sbdf) · line 244
Quoted 8 lines
drivers/xen/xen-pciback/pci_stub.c +2
-0@@ -240,6 +240,9 @@ static int pcistub_get_gsi_from_sbdf(unsigned int sbdf)if (!psdev)return -ENODEV ; +if (psdev->gsi ==-1 ) +return -ENOENT ;
This may, aiui, mean either of the two situations above. They would then need distinguishing, too, if user space is intended to derive decisions from the error code it gets.
Jan
Quoted 23 lines · Jan Beulich
drivers/xen/acpi.c int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 107
Quoted 11 lines · Jason Andryuk
drivers/xen/acpi.c +1
-1@@ -101,7 +101,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, pin = dev->pin;if (!pin) -return -EINVAL ; +return -ENOENT ; entry =acpi_pci_irq_lookup (dev, pin);if (entry) {While I can understand this change, ...
Quoted 7 lines
drivers/xen/acpi.c +1
-1@@ -116,7 +116,7 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev, gsi =-1 ;if (gsi <0 ) -return -EINVAL ; +return -ENOENT ;
Quoted 8 lines
drivers/xen/acpi.c int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 122
Quoted 2 lines
drivers/xen/acpi.c +0
-0*gsi_out = gsi; *trigger_out = trigger;... I'd expect this needs to keep using an error code other than ENOENT. Aiui this path means the device has a pin-based interrupt, just that it's not configured correctly. In which case we'd better not allow the device to be handed to a guest. Unless there's logic in place (somewhere) to make sure it then would get to see a device without pin-based interrupt.
This is actually the case that fails for me.
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
Interrupt: pin A routed to IRQ -2147483648
Interrupt Pin is 0x01, and Interrupt Line is 0xff
I'll have to check the existing code to see what it does.
Also, thanks for catching the commit message typos.
Regards,
Jason