lkml.org 
[lkml]   [2013]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] add helper for highmem checks
On 02/08/2013 12:50 PM, H. Peter Anvin wrote:
> On 02/08/2013 12:28 PM, Dave Hansen wrote:
>> +static inline phys_addr_t last_lowmem_phys_addr(void)
>> +{
>> + /*
>> + * 'high_memory' is not a pointer that can be dereferenced, so
>> + * avoid calling __pa() on it directly.
>> + */
>> + return __pa(high_memory - 1);
>> +}
>> +static inline bool phys_addr_is_highmem(phys_addr_t addr)
>> +{
>> + return addr > last_lowmem_paddr();
>> +}
>> +
>
> Are we sure that high_memory - 1 is always a valid reference? Consider
> especially the case where there is MMIO beyond end of memory on a system
> which has less RAM than the HIGHMEM boundary...

Yeah, I think it is. "high_memory" should point at either the end of
RAM, or the end of the linear map, whichever is lower. See setup_arch():

max_pfn = e820_end_of_ram_pfn();
...
high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;

or in the highmem init code:

high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;



\
 
 \ /
  Last update: 2013-02-09 00:42    [W:0.081 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site