Subject: Re: [PATCH] DMA 4GB boundary protection

From: Segher Boessenkool <[email-masked]>
Date: Thu, 22 Mar 2007 23:52:02 +0100

> I would also like it to be the last page in the range, not the first
> (since otherwise you'll reserve even if the window is less than 4GB.
>
> Something like (untested):
>
> 	entries_per_4g = 0x100000000 >> IOMMU_PAGE_SHIFT;
>
> 	/* Mark the last bit before a 4GB boundary as used */
> 	start_index = tbl->it_offset | (entries_per_4g - 1);
> 	end_index = tbl->it_offset + tbl->it_size;
>
> 	for (index = start_index; index < end_index; index += entries_per_4g)
> 		__set_bit(index, tbl->it_map);

As a very minor optimisation, avoid reserving the last page
of the I/O window if it ends on a 4GB boundary?

Segher