Skip to contentSkip to conversation

fix XSA-46 regression with xend/xm

PATCH In review Jan Beulich 5 participants 13 messages May 21, 2013 – May 24, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix XSA-46 regression with xend/xm

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

tools/libxc/xc_physdev.c +1 -1
@@ -49,7 +49,7 @@ int xc_physdev_map_pirq(xc_interface *xc
     map.domid = domid;
     map.type = MAP_PIRQ_TYPE_GSI;
     map.index = index;
-    map.pirq = *pirq;
+    map.pirq = *pirq < 0 ? index : *pirq;
 
     rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
 
tools/python/xen/xend/server/pciif.py +1 -1
@@ -340,7 +340,7 @@ class PciController(DevController):
                 raise VmError(('pci: failed to configure I/O memory on device '+
                             '%s - errno=%d')%(dev.name,rc))
 
-        if not self.vm.info.is_hvm() and dev.irq:
+        if dev.irq > 0:
             rc = xc.physdev_map_pirq(domid = fe_domid,
                                    index = dev.irq,
                                    pirq  = dev.irq)

fix XSA-46 regression with xend/xm

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

tools/libxc/xc_physdev.c +1 -1
@@ -49,7 +49,7 @@ int xc_physdev_map_pirq(xc_interface *xc
     map.domid = domid;
     map.type = MAP_PIRQ_TYPE_GSI;
     map.index = index;
-    map.pirq = *pirq;
+    map.pirq = *pirq < 0 ? index : *pirq;
 
     rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
 
tools/python/xen/xend/server/pciif.py +1 -1
@@ -340,7 +340,7 @@ class PciController(DevController):
                 raise VmError(('pci: failed to configure I/O memory on device '+
                             '%s - errno=%d')%(dev.name,rc))
 
-        if not self.vm.info.is_hvm() and dev.irq:
+        if dev.irq > 0:
             rc = xc.physdev_map_pirq(domid = fe_domid,
                                    index = dev.irq,
                                    pirq  = dev.irq)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Quoted 8 lines

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

In both cases tested with xend rather than xl or both?

Quoted 25 lines
tools/libxc/xc_physdev.c +1 -1
@@ -49,7 +49,7 @@ int xc_physdev_map_pirq(xc_interface *xc
     map.domid = domid;
     map.type = MAP_PIRQ_TYPE_GSI;
     map.index = index;
-    map.pirq = *pirq;
+    map.pirq = *pirq < 0 ? index : *pirq;
 
     rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
 
tools/python/xen/xend/server/pciif.py +1 -1
@@ -340,7 +340,7 @@ class PciController(DevController):
                 raise VmError(('pci: failed to configure I/O memory on device '+
                             '%s - errno=%d')%(dev.name,rc))
 
-        if not self.vm.info.is_hvm() and dev.irq:
+        if dev.irq > 0:
             rc = xc.physdev_map_pirq(domid = fe_domid,
                                    index = dev.irq,
                                    pirq  = dev.irq)
#2 lore raw
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 5 lines
Quoted 3 lines

In both cases tested with xend rather than xl or both?

My tests were done using xm only. I never tried xl so don't know if it was affected in the first place. I will try xl tonight to verify that it works.

Gordan

#3 lore raw
In reply to Ian Campbell
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 5 lines
Quoted 3 lines

In both cases tested with xend rather than xl or both?

Both of them run xend only afaik.

Quoted 28 lines
Quoted 14 lines
tools/libxc/xc_physdev.c +1 -1
@@ -49,7 +49,7 @@ int xc_physdev_map_pirq(xc_interface *xc
     map.domid = domid;
     map.type = MAP_PIRQ_TYPE_GSI;
     map.index = index;
-    map.pirq = *pirq;
+    map.pirq = *pirq < 0 ? index : *pirq;
 
     rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
 

tools/python/xen/xend/server/pciif.py class PciController(DevController): · line 340

Quoted 1 line
tools/python/xen/xend/server/pciif.py +0 -0
@@ -340,7 +340,7 @@ class PciController(DevController):
                 raise VmError(('pci: failed to configure I/O memory on 

device '+

Quoted 10 lines
tools/python/xen/xend/server/pciif.py +1 -1
                             '%s - errno=%d')%(dev.name,rc))
 
-        if not self.vm.info.is_hvm() and dev.irq:
+        if dev.irq > 0:
             rc = xc.physdev_map_pirq(domid = fe_domid,
                                    index = dev.irq,
                                    pirq  = dev.irq)
#4 lore raw
In reply to Ian Campbell
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 5 lines
Quoted 3 lines

In both cases tested with xend rather than xl or both?

I can confirm that my VMs start fine with xl with this patch applied.

Gordan

#5 lore raw
Quoted 33 lines · Gordan Bobic
Quoted 32 lines · Ian Campbell
Quoted 28 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 4 lines
Quoted 1 line

In both cases tested with xend rather than xl or both?

I can confirm that my VMs start fine with xl with this patch applied.

...and they are HVM guests with devices passed through?

-George

#6 lore raw
Quoted 34 lines · George Dunlap
Quoted 33 lines · Gordan Bobic
Quoted 32 lines · Ian Campbell
Quoted 28 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

In both cases tested with xend rather than xl or both?

I can confirm that my VMs start fine with xl with this patch applied.

...and they are HVM guests with devices passed through?

Yes, HVM guests with PCI passthrough NIC, VGA passthrough, and USB passthrough.

Gordan

#7 lore raw
Quoted 38 lines · Gordan Bobic
Quoted 37 lines · George Dunlap
Quoted 36 lines · Gordan Bobic
Quoted 33 lines · Ian Campbell
Quoted 20 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Quoted 8 lines

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

In both cases tested with xend rather than xl or both?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I can confirm that my VMs start fine with xl with this patch applied.

...and they are HVM guests with devices passed through?

Yes, HVM guests with PCI passthrough NIC, VGA passthrough, and USB passthrough.

Great, thanks! I'll check this off my list.

-George

Reviewed-by on v1 1/1
#8 lore raw
In reply to Jan Beulich
Quoted 19 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Quoted 8 lines

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 26 lines
tools/libxc/xc_physdev.c +1 -1
@@ -49,7 +49,7 @@ int xc_physdev_map_pirq(xc_interface *xc
     map.domid = domid;
     map.type = MAP_PIRQ_TYPE_GSI;
     map.index = index;
-    map.pirq = *pirq;
+    map.pirq = *pirq < 0 ? index : *pirq;
 
     rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
 
tools/python/xen/xend/server/pciif.py +1 -1
@@ -340,7 +340,7 @@ class PciController(DevController):
                 raise VmError(('pci: failed to configure I/O memory on device '+
                             '%s - errno=%d')%(dev.name,rc))
 
-        if not self.vm.info.is_hvm() and dev.irq:
+        if dev.irq > 0:
             rc = xc.physdev_map_pirq(domid = fe_domid,
                                    index = dev.irq,
                                    pirq  = dev.irq)
#9 lore raw
In reply to Jan Beulich
Quoted 19 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Quoted 8 lines

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

I think to get a release ack, someone will need to commit to testing it with xl for 4.3.

-George

#10 lore raw
Quoted 26 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 6 lines
Quoted 3 lines

I think to get a release ack, someone will need to commit to testing it with xl for 4.3.

It is pretty obvious (see the description) that xl is unaffected.

Jan

#11 lore raw
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I think to get a release ack, someone will need to commit to testing it with xl for 4.3.

It is pretty obvious (see the description) that xl is unaffected.

It's pretty obvious that you think so, but it's my job to be skeptical. :-) If both xend and xl assume a 1:1 model, and this patch changes things for xend, why is it not possible for this to have an effect on xl? You have a guess, but it's marked "afaict".

In any case it should be pretty straightforward to have done. We could even check it in and just put a release blocker, "Someone tests pass-through with xl" to make sure we don't forget it.

-George

#12 lore raw
Quoted 37 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 24 lines · Jan Beulich

The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests.

This in turn exposes, however, an inconsistency between xend and qemu:
The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model).

Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow).

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I think to get a release ack, someone will need to commit to testing it with xl for 4.3.

It is pretty obvious (see the description) that xl is unaffected.

Quoted 8 lines

It's pretty obvious that you think so, but it's my job to be skeptical. :-) If both xend and xl assume a 1:1 model, and this patch changes things for xend, why is it not possible for this to have an effect on xl? You have a guess, but it's marked "afaict".

In any case it should be pretty straightforward to have done. We could even check it in and just put a release blocker, "Someone tests pass-through with xl" to make sure we don't forget it.

Please do so then, because I had committed it already before you even raised your concern (on the basis of it being a bug fix).

Jan