From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMoIC-0000ur-Jt for qemu-devel@nongnu.org; Tue, 04 Aug 2015 22:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMoI7-00014o-1n for qemu-devel@nongnu.org; Tue, 04 Aug 2015 22:18:56 -0400 Received: from mga02.intel.com ([134.134.136.20]:52871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMoI6-00014S-Ra for qemu-devel@nongnu.org; Tue, 04 Aug 2015 22:18:50 -0400 From: Feng Wu Date: Wed, 5 Aug 2015 10:02:21 +0800 Message-Id: <1438740141-19905-1-git-send-email-feng.wu@intel.com> Subject: [Qemu-devel] [PATCH v1] xenpt: Properly handle 64-bit bar with more than 4G size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stefano.stabellini@eu.citrix.com Cc: xen-devel@lists.xensource.com, Feng Wu , qemu-devel@nongnu.org This patch corrects a logic error when handling 64-bt bar with more than 4G size. With 64-bit Bar, it has two items in PCIDevice: io_regions[x] and io_regions[x+1], io_regions[x] has all the informations for this BAR, while io_regions[x+1] contains nothing, so we need to get the size from io_regions[x] when handling XEN_PT_BAR_FLAG_UPPER. Signed-off-by: Feng Wu --- I cannot test this patch sicne I don't have such a device, if someone have it, it would be highly appreicated if he can help to verfiy this patch. hw/xen/xen_pt_config_init.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index dd37be3..6fcef66 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -326,23 +326,6 @@ static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, #define XEN_PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define XEN_PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ -static bool is_64bit_bar(PCIIORegion *r) -{ - return !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64); -} - -static uint64_t xen_pt_get_bar_size(PCIIORegion *r) -{ - if (is_64bit_bar(r)) { - uint64_t size64; - size64 = (r + 1)->size; - size64 <<= 32; - size64 += r->size; - return size64; - } - return r->size; -} - static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s, int index) { @@ -365,7 +348,7 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s, /* check unused BAR */ r = &d->io_regions[index]; - if (!xen_pt_get_bar_size(r)) { + if (r->size == 0) { return XEN_PT_BAR_FLAG_UNUSED; } @@ -491,8 +474,9 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, bar_ro_mask = XEN_PT_BAR_IO_RO_MASK | (r_size - 1); break; case XEN_PT_BAR_FLAG_UPPER: + r = &d->io_regions[index-1]; bar_emu_mask = XEN_PT_BAR_ALLF; - bar_ro_mask = r_size ? r_size - 1 : 0; + bar_ro_mask = (r->size - 1) >> 32; break; default: break; -- 1.7.1