From patchwork Wed Feb 22 14:56:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 142476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5FD82B6FA9 for ; Thu, 23 Feb 2012 01:57:09 +1100 (EST) Received: from localhost ([::1]:47938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Dct-0005tC-RK for incoming@patchwork.ozlabs.org; Wed, 22 Feb 2012 09:57:03 -0500 Received: from eggs.gnu.org ([140.186.70.92]:44357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Dci-0005sG-83 for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:56:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0DcY-0006du-KG for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:56:52 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:26381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0DcY-0006do-G2 for qemu-devel@nongnu.org; Wed, 22 Feb 2012 09:56:42 -0500 X-IronPort-AV: E=Sophos;i="4.73,464,1325480400"; d="scan'208";a="182956542" Received: from ftlpmailmx02.citrite.net ([10.13.107.66]) by FTLPIPO02.CITRIX.COM with ESMTP/TLS/RC4-MD5; 22 Feb 2012 09:56:41 -0500 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.66) with Microsoft SMTP Server id 8.3.213.0; Wed, 22 Feb 2012 09:56:41 -0500 Received: from [10.80.3.61] (helo=dhcp-3-61.uk.xensource.com) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1S0DcX-0004Ic-2X; Wed, 22 Feb 2012 14:56:41 +0000 Date: Wed, 22 Feb 2012 14:56:40 +0000 From: Anthony PERARD X-X-Sender: anthony@perard.uk.xensource.com To: Tobias Geiger In-Reply-To: Message-ID: References: <1329498525-8454-1-git-send-email-anthony.perard@citrix.com> <201202201151.12291.tobias.geiger@vido.info> <201202201711.11807.tobias.geiger@vido.info> <4F42A601.7000701@vido.info> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: "xen-devel@lists.xensource.com" , QEMU-devel , Stefano Stabellini Subject: Re: [Qemu-devel] [Xen-devel] [PATCH V7 00/11] Xen PCI Passthrough X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Mon, 20 Feb 2012, Anthony PERARD wrote: > On Mon, Feb 20, 2012 at 19:58, Tobias Geiger wrote: > > [00:06.0] pt_pci_read_config: address=0x0030 val=0x00000000 len=4 > > [00:06.0] pt_pci_write_config: address=0x0030 val=0xffffffff len=4 > > [00:06.0] pt_iomem_map: BAR 6, e_phys=0xffffffffffffffff maddr=0xc3140000 len=0x20000 first_map=1 > > [00:06.0] pt_pci_read_config: address=0x0030 val=0xfffe0001 len=4 > > [00:06.0] pt_pci_write_config: address=0x0030 val=0x00000000 len=4 > > [00:06.0] pt_iomem_map: BAR 6, e_phys=0xffffffffffffffff maddr=0xc3140000 len=0x20000 first_map=0 > ... > > [00:06.0] pt_pci_read_config: address=0x0004 val=0x00000000 len=2 > > [00:06.0] pt_pci_write_config: address=0x0004 val=0x00000004 len=2 > > qemu-system-x86_64: /usr/src/xen-with-upstream-qemu-patch/upstream-qemu/qemu/memory.c:1378: memory_region_del_subregion: Assertion `subregion->parent == mr' failed. > > This last line is why QEMU fail and I thinks it's because I never try > a PCI device with a ROM pci bar. I'll try to fix this tomorrow. Could you tell me if this "patch" resolve the issue? Thanks, diff --git a/hw/xen_pci_passthrough_config_init.c b/hw/xen_pci_passthrough_config_init.c index f1fffd1..37aa383 100644 --- a/hw/xen_pci_passthrough_config_init.c +++ b/hw/xen_pci_passthrough_config_init.c @@ -555,18 +555,16 @@ static int pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *reg_entry = NULL; XenPTRegion *base = NULL; PCIDevice *d = (PCIDevice *)&s->dev; - PCIIORegion *r; uint32_t writable_mask = 0; uint32_t throughable_mask = 0; pcibus_t r_size = 0; uint32_t bar_emu_mask = 0; uint32_t bar_ro_mask = 0; - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; + r_size = d->io_regions[PCI_ROM_SLOT].size; base = &s->bases[PCI_ROM_SLOT]; /* align memory type resource size */ - pt_get_emul_size(base->bar_flag, r_size); + r_size = pt_get_emul_size(base->bar_flag, r_size); /* set emulate mask and read-only mask */ bar_emu_mask = reg->emu_mask; @@ -576,19 +574,6 @@ static int pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s, writable_mask = ~bar_ro_mask & valid_mask; cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - /* update the corresponding virtual region address */ - /* - * When guest code tries to get block size of mmio, it will write all "1"s - * into pci bar register. In this case, cfg_entry->data == writable_mask. - * Especially for devices with large mmio, the value of writable_mask - * is likely to be a guest physical address that has been mapped to ram - * rather than mmio. Remapping this value to mmio should be prevented. - */ - - if (cfg_entry->data != writable_mask) { - r->addr = cfg_entry->data; - } - /* create value for writing to I/O device register */ throughable_mask = ~bar_emu_mask & valid_mask; *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask);