[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Consuming PCI device in PV kernel



On Fri, 2014-07-25 at 14:21 +0100, Simon Martin wrote:
> 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.

Hopefully someone who knows the x86 PV stuff can chime in then, I looked
but can't see what this represents.

>  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);

The first argument should be the virtual address, I think. But maybe you
have a 1:1 mapping so this doesn't matter?

>     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);

Are you sure about that BAR decode? Don't you need to at least mask the
bottom 4 bits?

You might also need to mask it to a page boundary, depending on what the
address is...

I'm not 100% sure about that shift, it might already be encoded in the
BAR register due to the layout. Sometimes h/w people arrange it that
way... IOW you might only need to mask and not shift. 

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.