Hi!
While using Linux in a virtualization environment (L4), I found a
strange inconsistency in "iounmap" regarding the use of the
"high_memory" variable.
According to [1]: "high_memory is the virtual address where high memory
begins", so high_memory contains the first address in high memory.
Accordingly, also linux-source/mm/memory.c, ca. line 72 says:
"A number of key systems in x86 including ioremap() rely on the
assumption that high_memory defines the upper bound on direct map
memory, then end of ZONE_NORMAL. Under CONFIG_DISCONTIG this means that
max_low_pfn and highstart_pfn must be the same; there must be no gap
between ZONE_NORMAL and ZONE_HIGHMEM."
(BTW: CONFIG_DISCONTIG is no longer existent / has been renamed).
Obviously, this is applied correctly, for example in
linux-source/arch/i386/mm/ioremap.c in function "__ioremap":
/*
* Don't allow anybody to remap normal RAM that we're using..
*/
if (phys_addr <= virt_to_phys(high_memory - 1))
However, in linux-source/arch/i386/mm/ioremap.c in "iounmap" oviously
the meaning of "high_memory" is understood differently:
if ((void __force *)addr <= high_memory) return;
In that case (by means of <=) we could not unmap again the "first"
mapping in high memory: the first mapping usually is being mapped to the
start of the high memory and thus is addr == high_memory in the iounmap
call. (This was the case in which we found the inconsistency).
For this reason in my opinion it rather should be:
if ((void __force *)addr < high_memory) return;
What do you think?
Regards,
Oskar.
[1] Mel Gorman, Code Commentary On The Linux Virtual Memory Manager
p. 24, http://www.csn.ul.ie/~mel/projects/vm/guide/pdf/code.pdf