On Mon, 20 Jun 2005, Richard B. Johnson wrote:
To the memory expert that made the massive changes to mm/memory.c:
Code in linux-2.6.12 fails with the following (remap_pfn_range
gets the exact same values):
UNIQUE.dma.len = 04001fe0
vma->vm_end-vma->vm_start=04002000
About to execute remap_pfn_range
vma->vm_start = 20000000
base address = 30003000
length = 04001fe0 >> PAGE_SHIFT
vma->vm_page_prot = 0000003f
------------[ cut here ]------------
kernel BUG at mm/memory.c:1112!
I can test any patches.
You are right, and it's my fault. May I wriggle a little and point
out that your length is unusual, and even you seem confused whether
you want to map 0x4001 or 0x4002 pages? But the blame lies with me.
Please try this patch, which I'll send to Andrew and -stable if you
can confirm that it fixes your problem. remap_pfn_range is, I believe
(and shall recheck), the only exported interface vulnerable to this
loop-termination issue.
Thanks,
Hugh
--- 2.6.12/mm/memory.c 2005-06-17 20:48:29.000000000 +0100
+++ linux/mm/memory.c 2005-06-21 20:31:42.000000000 +0100
@@ -1164,7 +1164,7 @@ int remap_pfn_range(struct vm_area_struc
{
pgd_t *pgd;
unsigned long next;
- unsigned long end = addr + size;
+ unsigned long end = addr + PAGE_ALIGN(size);
struct mm_struct *mm = vma->vm_mm;
int err;