On 07-Nov-19 5:44 AM, Wangyu (Eric) wrote:
Hi, Anatoly

Thank you for advices. This problem will happen in both VFIO and UIO, I will 
modify both according to your advices and test them.

I did some tests with mmap() on my system, when I provided address not 
page-aligned, mmap() could return page-aligned address too, but the code will 
return fault because mmap() return address was not equal with address I 
provided(problem occurs in pci_uio_map_secondary()).


I still don't understand how do you get addresses aligned on a 16K boundary with 64K page size.

The mapping process is as follows:

0) start with max_va_end, or with previous addres + previous len
1) reserve virtual area with mmap() (accepts any return address)
2) map the BAR with MAP_FIXED (checks return address, but should work because we already have that area reserved)

The error you're referring to would've happened at step 2 (MAP_FIXED with unaligned addresses will cause the mmap() to fail), but at that point we already have a valid virtual area for the bar. If you get a 16K-aligned page address for the BAR, you get it on step 1, not step 2.

So, if, by your own admission, your mmap() implementation does return a 64K-aligned address... What exactly is the issue then? How does your BAR end up with an invalid address?

--
Thanks,
Anatoly

Reply via email to