Re: [PATCH 1/2] add helper for highmem checks

From: Dave Hansen
Date: Fri Feb 08 2013 - 18:16:37 EST


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;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/