From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX93e-0008Ee-94 for qemu-devel@nongnu.org; Mon, 07 Apr 2014 08:53:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX93P-0003qL-7c for qemu-devel@nongnu.org; Mon, 07 Apr 2014 08:53:50 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:60206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX93O-0003q2-DP for qemu-devel@nongnu.org; Mon, 07 Apr 2014 08:53:35 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Apr 2014 22:53:26 +1000 From: Alexey Kardashevskiy Date: Mon, 7 Apr 2014 22:53:21 +1000 Message-Id: <1396875201-8316-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH] spapr_pci: Fix number of returned vectors in ibm, change-msi List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf Current guest kernels try allocating as many vectors as the quota is. For example, in the case of virtio-net (which has just 3 vectors) the guest requests 4 vectors (that is the quota in the test) and the existing ibm,change-msi handler returns 4. But before it returns, it calls msix_set_message() in a loop and corrupts memory behind the end of msix_table. This limits the number of vectors returned by ibm,change-msi to the maximum supported by the actual device. Signed-off-by: Alexey Kardashevskiy --- This might go to 2.0 actually. --- hw/ppc/spapr_pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index cbef095..cdfa369 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -343,6 +343,9 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPREnvironment *spapr, /* There is no cached config, allocate MSIs */ if (!phb->msi_table[ndev].nvec) { + if (req_num > pdev->msix_entries_nr) { + req_num = pdev->msix_entries_nr; + } irq = spapr_allocate_irq_block(req_num, false, ret_intr_type == RTAS_TYPE_MSI); if (irq < 0) { -- 1.8.4.rc4