From patchwork Thu Nov 11 07:51:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 316732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAB7patM032628 for ; Thu, 11 Nov 2010 07:51:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757799Ab0KKHvd (ORCPT ); Thu, 11 Nov 2010 02:51:33 -0500 Received: from mga01.intel.com ([192.55.52.88]:53245 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757795Ab0KKHvd (ORCPT ); Thu, 11 Nov 2010 02:51:33 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 10 Nov 2010 23:51:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,181,1288594800"; d="scan'208";a="856424633" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.14]) by fmsmga001.fm.intel.com with ESMTP; 10 Nov 2010 23:51:32 -0800 Received: from yasker by syang10-desktop with local (Exim 4.72) (envelope-from ) id 1PGRwV-0001v7-7a; Thu, 11 Nov 2010 15:51:35 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti , "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH 1/5] qemu-kvm: device assignment: Reset MSI-X table mask bit as set Date: Thu, 11 Nov 2010 15:51:30 +0800 Message-Id: <1289461894-7355-2-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1289461894-7355-1-git-send-email-sheng@linux.intel.com> References: <1289461894-7355-1-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 11 Nov 2010 07:51:37 +0000 (UTC) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 2605bd1..dfca764 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1106,6 +1106,8 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev, unsigned int ctrl_pos) #endif #ifdef KVM_CAP_DEVICE_MSIX + +#define PCI_MSIX_CTRL_MASKBIT 1ul static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) { AssignedDevice *adev = container_of(pci_dev, AssignedDevice, dev); @@ -1128,9 +1130,8 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) /* Get the usable entry number for allocating */ for (i = 0; i < entries_max_nr; i++) { memcpy(&msg_ctrl, va + i * 16 + 12, 4); - memcpy(&msg_data, va + i * 16 + 8, 4); /* Ignore unused entry even it's unmasked */ - if (msg_data == 0) + if (msg_ctrl & PCI_MSIX_CTRL_MASKBIT) continue; entries_nr ++; } @@ -1163,10 +1164,10 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) if (entries_nr >= msix_nr.entry_nr) break; memcpy(&msg_ctrl, va + i * 16 + 12, 4); - memcpy(&msg_data, va + i * 16 + 8, 4); - if (msg_data == 0) + if (msg_ctrl & PCI_MSIX_CTRL_MASKBIT) continue; + memcpy(&msg_data, va + i * 16 + 8, 4); memcpy(&msg_addr, va + i * 16, 4); memcpy(&msg_upper_addr, va + i * 16 + 4, 4); @@ -1398,6 +1399,7 @@ static CPUReadMemoryFunc *msix_mmio_read[] = { static int assigned_dev_register_msix_mmio(AssignedDevice *dev) { + int i; dev->msix_table_page = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0); @@ -1407,6 +1409,8 @@ static int assigned_dev_register_msix_mmio(AssignedDevice *dev) return -EFAULT; } memset(dev->msix_table_page, 0, 0x1000); + for (i = 0; i < 0x1000; i += 0x10) + *(uint32_t *)(dev->msix_table_page + i + 0xc) = 1; dev->mmio_index = cpu_register_io_memory( msix_mmio_read, msix_mmio_write, dev); return 0;