diff mbox

[PULL,07/13] msix: fix msix_vector_masked

Message ID 1455868726-26350-8-git-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin Feb. 19, 2016, 8 a.m. UTC
commit 428c3ece97179557f2753071fb0ca97a03437267 ("fix MSI injection on Xen")
inadvertently enabled the xen-specific logic unconditionally.
Limit it to only when xen is enabled.
Additionally, msix data should be read with pci_get_log
since the format is pci little-endian.

Reported-by: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/msix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Stabellini Feb. 19, 2016, 12:18 p.m. UTC | #1
On Fri, 19 Feb 2016, Michael S. Tsirkin wrote:
> commit 428c3ece97179557f2753071fb0ca97a03437267 ("fix MSI injection on Xen")
> inadvertently enabled the xen-specific logic unconditionally.
> Limit it to only when xen is enabled.
> Additionally, msix data should be read with pci_get_log
> since the format is pci little-endian.
> 
> Reported-by: "Daniel P. Berrange" <berrange@redhat.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

the follow up patch is missing from the pull request:

http://marc.info/?l=xen-devel&m=145553838801725&w=2


>  hw/pci/msix.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> index eb4ef11..537fdba 100644
> --- a/hw/pci/msix.c
> +++ b/hw/pci/msix.c
> @@ -80,10 +80,10 @@ static void msix_clr_pending(PCIDevice *dev, int vector)
>  static bool msix_vector_masked(PCIDevice *dev, unsigned int vector, bool fmask)
>  {
>      unsigned offset = vector * PCI_MSIX_ENTRY_SIZE;
> -    uint32_t *data = (uint32_t *)&dev->msix_table[offset + PCI_MSIX_ENTRY_DATA];
> +    uint8_t *data = &dev->msix_table[offset + PCI_MSIX_ENTRY_DATA];
>      /* MSIs on Xen can be remapped into pirqs. In those cases, masking
>       * and unmasking go through the PV evtchn path. */
> -    if (xen_is_pirq_msi(*data)) {
> +    if (xen_enabled() && xen_is_pirq_msi(pci_get_long(data))) {
>          return false;
>      }
>      return fmask || dev->msix_table[offset + PCI_MSIX_ENTRY_VECTOR_CTRL] &
> -- 
> MST
>
Peter Maydell Feb. 19, 2016, 12:20 p.m. UTC | #2
On 19 February 2016 at 12:18, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Fri, 19 Feb 2016, Michael S. Tsirkin wrote:
>> commit 428c3ece97179557f2753071fb0ca97a03437267 ("fix MSI injection on Xen")
>> inadvertently enabled the xen-specific logic unconditionally.
>> Limit it to only when xen is enabled.
>> Additionally, msix data should be read with pci_get_log
>> since the format is pci little-endian.
>>
>> Reported-by: "Daniel P. Berrange" <berrange@redhat.com>
>> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> the follow up patch is missing from the pull request:
>
> http://marc.info/?l=xen-devel&m=145553838801725&w=2

does this mean I should prefer not to apply the pull, or can
that patch be committed later ?

thanks
-- PMM
Stefano Stabellini Feb. 19, 2016, 12:29 p.m. UTC | #3
On Fri, 19 Feb 2016, Peter Maydell wrote:
> On 19 February 2016 at 12:18, Stefano Stabellini
> <stefano.stabellini@eu.citrix.com> wrote:
> > On Fri, 19 Feb 2016, Michael S. Tsirkin wrote:
> >> commit 428c3ece97179557f2753071fb0ca97a03437267 ("fix MSI injection on Xen")
> >> inadvertently enabled the xen-specific logic unconditionally.
> >> Limit it to only when xen is enabled.
> >> Additionally, msix data should be read with pci_get_log
> >> since the format is pci little-endian.
> >>
> >> Reported-by: "Daniel P. Berrange" <berrange@redhat.com>
> >> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> >> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >
> > the follow up patch is missing from the pull request:
> >
> > http://marc.info/?l=xen-devel&m=145553838801725&w=2
> 
> does this mean I should prefer not to apply the pull, or can
> that patch be committed later ?
 
I would have preferred the two patches to go in together, but I wouldn't
want to delay Michael's fix. If he is not around to respin the pull
request today, I'd say go ahead and commit it anyway.
diff mbox

Patch

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index eb4ef11..537fdba 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -80,10 +80,10 @@  static void msix_clr_pending(PCIDevice *dev, int vector)
 static bool msix_vector_masked(PCIDevice *dev, unsigned int vector, bool fmask)
 {
     unsigned offset = vector * PCI_MSIX_ENTRY_SIZE;
-    uint32_t *data = (uint32_t *)&dev->msix_table[offset + PCI_MSIX_ENTRY_DATA];
+    uint8_t *data = &dev->msix_table[offset + PCI_MSIX_ENTRY_DATA];
     /* MSIs on Xen can be remapped into pirqs. In those cases, masking
      * and unmasking go through the PV evtchn path. */
-    if (xen_is_pirq_msi(*data)) {
+    if (xen_enabled() && xen_is_pirq_msi(pci_get_long(data))) {
         return false;
     }
     return fmask || dev->msix_table[offset + PCI_MSIX_ENTRY_VECTOR_CTRL] &