qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption
@ 2014-08-13  7:20 Alexey Kardashevskiy
  2014-08-26  7:07 ` Alexey Kardashevskiy
  2014-08-27 11:00 ` Alexander Graf
  0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2014-08-13  7:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf

When disabling MSI/MSIX via "ibm,change-msi" RTAS call, no check was made
if MSI or MSIX is actually supported and the MSI message was reset
unconditionally. If this happened on a device which does not support MSI
(but does support MSIX, otherwise "ibm,change-msi" would not be called),
this device would have PCIDevice::msi_cap field (MSI capability offset)
set to zero and writing a vector would actually clear PCI status.

This clears MSI message only if MSI or MSIX is present on a device.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/ppc/spapr_pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index d1f4c86..c0e703f 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -263,7 +263,6 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     unsigned int irq, max_irqs = 0, num = 0;
     sPAPRPHBState *phb = NULL;
     PCIDevice *pdev = NULL;
-    bool msix = false;
     spapr_pci_msi *msi;
     int *config_addr_key;
 
@@ -301,7 +300,12 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
         }
 
         xics_free(spapr->icp, msi->first_irq, msi->num);
-        spapr_msi_setmsg(pdev, 0, msix, 0, num);
+        if (msi_present(pdev)) {
+            spapr_msi_setmsg(pdev, 0, false, 0, num);
+        }
+        if (msix_present(pdev)) {
+            spapr_msi_setmsg(pdev, 0, true, 0, num);
+        }
         g_hash_table_remove(phb->msi, &config_addr);
 
         trace_spapr_pci_msi("Released MSIs", config_addr);
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption
  2014-08-13  7:20 [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption Alexey Kardashevskiy
@ 2014-08-26  7:07 ` Alexey Kardashevskiy
  2014-08-27 11:00 ` Alexander Graf
  1 sibling, 0 replies; 3+ messages in thread
From: Alexey Kardashevskiy @ 2014-08-26  7:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, Alexander Graf

On 08/13/2014 05:20 PM, Alexey Kardashevskiy wrote:
> When disabling MSI/MSIX via "ibm,change-msi" RTAS call, no check was made
> if MSI or MSIX is actually supported and the MSI message was reset
> unconditionally. If this happened on a device which does not support MSI
> (but does support MSIX, otherwise "ibm,change-msi" would not be called),
> this device would have PCIDevice::msi_cap field (MSI capability offset)
> set to zero and writing a vector would actually clear PCI status.
> 
> This clears MSI message only if MSI or MSIX is present on a device.

Ping?


> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  hw/ppc/spapr_pci.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index d1f4c86..c0e703f 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -263,7 +263,6 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>      unsigned int irq, max_irqs = 0, num = 0;
>      sPAPRPHBState *phb = NULL;
>      PCIDevice *pdev = NULL;
> -    bool msix = false;
>      spapr_pci_msi *msi;
>      int *config_addr_key;
>  
> @@ -301,7 +300,12 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>          }
>  
>          xics_free(spapr->icp, msi->first_irq, msi->num);
> -        spapr_msi_setmsg(pdev, 0, msix, 0, num);
> +        if (msi_present(pdev)) {
> +            spapr_msi_setmsg(pdev, 0, false, 0, num);
> +        }
> +        if (msix_present(pdev)) {
> +            spapr_msi_setmsg(pdev, 0, true, 0, num);
> +        }
>          g_hash_table_remove(phb->msi, &config_addr);
>  
>          trace_spapr_pci_msi("Released MSIs", config_addr);
> 


-- 
Alexey

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption
  2014-08-13  7:20 [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption Alexey Kardashevskiy
  2014-08-26  7:07 ` Alexey Kardashevskiy
@ 2014-08-27 11:00 ` Alexander Graf
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2014-08-27 11:00 UTC (permalink / raw)
  To: Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc



On 13.08.14 09:20, Alexey Kardashevskiy wrote:
> When disabling MSI/MSIX via "ibm,change-msi" RTAS call, no check was made
> if MSI or MSIX is actually supported and the MSI message was reset
> unconditionally. If this happened on a device which does not support MSI
> (but does support MSIX, otherwise "ibm,change-msi" would not be called),
> this device would have PCIDevice::msi_cap field (MSI capability offset)
> set to zero and writing a vector would actually clear PCI status.
> 
> This clears MSI message only if MSI or MSIX is present on a device.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Thanks, applied to ppc-next.


Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-27 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-13  7:20 [Qemu-devel] [PATCH] spapr_pci: Fix config space corruption Alexey Kardashevskiy
2014-08-26  7:07 ` Alexey Kardashevskiy
2014-08-27 11:00 ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).