[ARM] Fix virtual to physical translation macro corner cases
The current use of these macros works well when the conversion is entirely linear. In this case, we can be assured that the following holds true: __va(p + s) - s = __va(p) However, this is not always the case, especially when there is a non-linear conversion (eg, when there is a 3.5GB hole in memory.) In this case, if 's' is the size of the region (eg, PAGE_SIZE) and 'p' is the final page, the above is most definitely not true. So, we must ensure that __va() and __pa() are only used with valid kernel direct mapped RAM addresses. This patch tweaks the code to achieve this. Tested-by: Charles Moschel <fred99@carolina.rr.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
committed by
Russell King
parent
305b07680f
commit
1522ac3ec9
@ -124,7 +124,7 @@ int valid_phys_addr_range(unsigned long addr, size_t size)
|
||||
{
|
||||
if (addr < PHYS_OFFSET)
|
||||
return 0;
|
||||
if (addr + size > __pa(high_memory))
|
||||
if (addr + size >= __pa(high_memory - 1))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user