[PATCH v2] ARM: LPAE: don't reject mapping /dev/mem above 4GB

Sergey Dyasly dserrg at gmail.com
Wed Jul 3 11:37:52 EDT 2013


On Tue, 2 Jul 2013 18:15:31 +0100
Catalin Marinas <catalin.marinas at arm.com> wrote:
> >  int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
> >  {
> > -	return !(pfn + (size >> PAGE_SHIFT) > 0x00100000);
> > +	return !(((pfn << PAGE_SHIFT) + size) & ~PHYS_MASK);
> 
> I don't think that's what I suggested. For classic MMU ~PHYS_MASK is 0.
> 

Thanks for your comments!

Indeed, I did some testing today and v2 check doesn't work at all because of
32-bit overflow in case of using '<<' operator. Also, it turned out that v1
doesn't reject mappings > 40 bit in case of LPAE (the same overflow).

I didn't want to additionally define PHYS_MASK_SHIFT, so I came up with
something like:

	return (pfn + (size >> PAGE_SHIFT)) <= (1 + (PHYS_MASK >> PAGE_SHIFT))

I will post v3 tomorrow.

Best regards,
Sergey Dyasly



More information about the linux-arm-kernel mailing list