From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Martin Subject: Re: Consuming PCI device in PV kernel Date: Fri, 25 Jul 2014 14:21:16 +0100 Message-ID: <1035381797.20140725142116@gmail.com> References: <524794479.20140703121338@gmail.com> <20140703180957.GD13710@konrad-lan.dumpdata.com> <1376452421.20140707092147@gmail.com> <1083121389.20140707122233@gmail.com> <623751089.20140718153713@gmail.com> <20140718190942.GG15947@laptop.dumpdata.com> <538610044.20140721111330@gmail.com> <1405940004.25022.10.camel@kazak.uk.xensource.com> <357303711.20140725135638@gmail.com> <1406293821.24842.8.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1406293821.24842.8.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Hello Ian, Thanks for the response. >> I have tried calling HYPERCALL_update_va_mapping and >> HYPERCALL_mmu_update and they both fail. HYPERCALL_update_va_mapping >> gives me the following in xl dmesg: >> >> (XEN) mm.c:1700:d292v0 Bad L1 flags 400000 >> >> Looking at the code I can't see where bit 22 is being set! > Without seeing you code I've no idea about this (even if I could see it, > I dunno...) Bit 22 is being set in Xen code. This is what I am doing: void *micropv_remap_page(uint64_t physical_address, uint64_t machine_address, int readonly) { // Update the mapping. I have had problems using a readonly mapping, however I'm not sure whether that was to do with // this call, or the page that was being mapped. int rc = HYPERVISOR_update_va_mapping(physical_address, __pte(machine_address | (readonly ? L1_PROT_RO : L1_PROT)), UVMF_INVLPG); if (rc) { PRINTK("HYPERVISOR_update_va_mapping returns %i", rc); return NULL; } else { PRINTK("Machine Address %lx mapped to Physical Address %lx", machine_address, physical_address); return (void*)physical_address; } } This is the call when I try to map the PCI BAR. ptr = micropv_remap_page((uint64_t)buffer, pci_device.bar[0].memory.address << 4, 0); if (!ptr) { PRINTK("Error mapping PCI MMIO"); goto fail; } Where buffer is a page (4096) aligned buffer, one page long and pci_device.bar.memory.address is the top 28 bits of the PCI BAR register (hence it is left shifted to give the correct address). -- Best regards, Simon mailto:furryfuttock@gmail.com