Messages in this thread Patch in this message | | | Date | Thu, 12 Feb 2004 20:28:04 +0100 | From | Manfred Spraul <> | Subject | Re: userspace mptable parsing broken in 2.6 |
| |
Dave Jones wrote:
>Reading from some parts of /dev/mem is still broken in 2.6.3rc2, >which breaks at least x86info. > >Manfred, in the end of the last thread on this at.. >http://www.ussg.iu.edu/hypermail/linux/kernel/0311.1/0373.html >you mentioned you were going to add some code to /dev/mem for the >DEBUG_PAGEALLOC case. Did you get anywhere with that? > > Sorry, I forgot about the issue.
What about the attached patch?
-- Manfred --- 2.6/drivers/char/mem.c 2004-02-08 13:08:30.000000000 +0100 +++ build-2.6/drivers/char/mem.c 2004-02-12 20:10:56.000000000 +0100 @@ -25,6 +25,7 @@ #include <linux/devfs_fs_kernel.h> #include <linux/ptrace.h> #include <linux/device.h> +#include <linux/pagemap.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -151,10 +152,41 @@ } } #endif +#if CONFIG_DEBUG_PAGEALLOC + while (count) { + size_t i; + struct page *page; + + i = PAGE_SIZE - (p%PAGE_SIZE); + if (i > count) + i = count; + if (virt_addr_valid(__va(p))) { + page = virt_to_page(__va(p)); + get_page(page); + kernel_map_pages(page, 1, 1); + } else { + page = NULL; + } + if (copy_to_user(buf, __va(p), i)) { + if (page) + put_page(page); + return -EFAULT; + } + if (page) + put_page(page); + buf += i; + p += i; + count -= i; + read += i; + } +#else if (copy_to_user(buf, __va(p), count)) return -EFAULT; + + p += count; read += count; - *ppos += read; +#endif + *ppos = p; return read; } | |