Re: failure in /mm/memory.c

From: William Lee Irwin III
Date: Sat Oct 16 2004 - 07:13:11 EST


On Sat, Oct 16, 2004 at 12:32:35PM +0100, christophpfister@xxxxxxxxxxx wrote:
> i found a failure in function remap_pte_range in memory.c
> static inline void remap_pte_range(...)
> {
> unsigned long end;
> unsigned long pfn;
> address &= ~PMD_MASK;
> end = address + size;
> if (end > PMD_SIZE)
> end = PMD_SIZE;
> pfn = phys_addr >> PAGE_SHIFT;
> do {
> BUG_ON(!pte_none(*pte));
> if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn))) *****
> set_pte(pte, pfn_pte(pfn, prot));
> address += PAGE_SIZE;
> pfn++;
> pte++;
> } while (address && (address < end));
> }

Well, there are issues...

On Sat, Oct 16, 2004 at 12:32:35PM +0100, christophpfister@xxxxxxxxxxx wrote:
> by ****
> the condition is wrong, because it just maps the page, if it's invalid or
> reserved
> correct: if (!(pfn_valid(pfn) || PageReserved(pfn_to_page(pfn))))
> (it doesn't seems to be used, otherwise there must be bugs)

This isn't one of them. De Morgan teach us that what you wrote is just
!pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn))
which would evaluate pfn_to_page() on an invalid pfn, and so nonsensical.


-- wli
-
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/