[PATCH] percpu: fix per_cpu_ptr_to_phys() handling ofnon-page-aligned addresses.
From: Eugene Surovegin
Date: Thu Dec 15 2011 - 14:32:39 EST
per_cpu_ptr_to_phys() incorrectly rounds up its result for non-kmalloc case
to the page boundary, which is bogus for any non-page-aligned address.
This fixes the only in-tree user of this function - sysfs handler for
per-cpu 'crash_notes' physical address. The manifestation of this bug is
missing 'CORE' ELF notes in kdump.
Signed-off-by: Eugene Surovegin <ebs@xxxxxxxxxxx>
---
mm/percpu.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index 3bb810a..716eb4a 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1023,9 +1023,11 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
if (!is_vmalloc_addr(addr))
return __pa(addr);
else
- return page_to_phys(vmalloc_to_page(addr));
+ return page_to_phys(vmalloc_to_page(addr)) +
+ offset_in_page(addr);
} else
- return page_to_phys(pcpu_addr_to_page(addr));
+ return page_to_phys(pcpu_addr_to_page(addr)) +
+ offset_in_page(addr);
}
/**
--
1.7.5.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/