Latest working kernel version: 2.6.25.x Earliest failing kernel version: 2.6.26-rcX Distribution: Hardware Environment: i386 Software Environment: Problem Description: vbetest fails due to changes to read_mem/xlate_dev_mem_ptr probably. strace excerpt: open("/dev/mem", O_RDONLY) = 3 read(3, 0, 1282) = -1 EFAULT (Bad address) xlate_dev_mem_ptr used to be a simple __va() on i386, now it calls page_is_ram which will report the first page as not ram, which in turn ends up ioremap'ing that page which also fails. of course a simple dd if=/dev/mem also fails the same way. Steps to reproduce: vbetest or 'dd if=/dev/mem'
Reply-To: akpm@linux-foundation.org On Tue, 8 Jul 2008 19:46:17 -0700 (PDT) bugme-daemon@bugzilla.kernel.org wrote: > http://bugzilla.kernel.org/show_bug.cgi?id=11057 > > Summary: vbetest fails on 2.6.26-rc9 > Product: Memory Management > Version: 2.5 > Platform: All > OS/Version: Linux > Tree: Mainline > Status: NEW > Severity: normal > Priority: P1 > Component: Other > AssignedTo: akpm@osdl.org > ReportedBy: pageexec@freemail.hu > > > Latest working kernel version: 2.6.25.x > Earliest failing kernel version: 2.6.26-rcX > Distribution: > Hardware Environment: i386 > Software Environment: > Problem Description: > vbetest fails due to changes to read_mem/xlate_dev_mem_ptr probably. strace > excerpt: > > open("/dev/mem", O_RDONLY) = 3 > read(3, 0, 1282) = -1 EFAULT (Bad address) > > xlate_dev_mem_ptr used to be a simple __va() on i386, now it calls > page_is_ram > which will report the first page as not ram, which in turn ends up > ioremap'ing > that page which also fails. of course a simple dd if=/dev/mem also fails the > same way. > > Steps to reproduce: > vbetest or 'dd if=/dev/mem' > Thanks. afaik this wasn't known about before?
Do you have CONFIG_NONPROMISC_DEVMEM enabled ?
no, it isn't: # CONFIG_NONPROMISC_DEVMEM is not set note that failing the range_is_allowed() check would produce an EPERM in read_mem and EINVAL in mmap_mem (that's an inconsistency worth fixing maybe btw), not EFAULT.
On Wed, 9 Jul 2008, bugme-daemon@bugzilla.kernel.org wrote: > no, it isn't: > > # CONFIG_NONPROMISC_DEVMEM is not set > > note that failing the range_is_allowed() check would produce an EPERM in > read_mem and EINVAL in mmap_mem (that's an inconsistency worth fixing maybe > btw), not EFAULT. Oops, right. But looking at your strace outout again: read(3, 0, 1282) = -1 EFAULT (Bad address) --------^ definitely causes an EFAULT :)
no, it won't, here's more context :) open("/dev/zero", O_RDONLY) = 3 mmap2(NULL, 1282, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0 close(3) = 0 open("/dev/mem", O_RDONLY) = 3 read(3, 0, 1282) = -1 EFAULT (Bad address) so virtual address 0 is a valid mapping, the EFAULT is a regression (imho). and if you check the 'dd if=/dev/mem' case, it'll be even more obvious: brk(0x807c000) = 0x807c000 [...] open("/dev/mem", O_RDONLY|O_LARGEFILE) = 3 dup2(3, 0) = 0 [...] _llseek(0, 0, [0], SEEK_CUR) = 0 [...] read(0, 0x805c000, 512) = -1 EFAULT (Bad address)
This entry is being used for tracking a regression from 2.6.25. Please don't close it until the problem is fixed in the mainline.
Can you share the .config that shows up the problem and also the dmesg from the system. Tried reproducing on few local systems, but both read of /dev/mem and dd goes through fine using the ioremap() in xlate().
Clarifying on what I tested on my end #dd if=/dev/mem of=/tmp/1 bs=4096 count=1 works fine without any error.
Created attachment 16773 [details] failing .config here's a .config from a box where i ran into this problem by chance, it definitely fails both vbetest and dd. let me know if dmesg is still needed, it's somewhat too verbose to disclose for my taste ;).
dmesg is required to see that there is nothing wierd with e820 table on this box. Other potential issue is that this address (0-4095 physical) is mapped by some kernel or driver as WB and we are having a conflict here when vbetest tries to map it UC_MINUS, causing ioremap() to fail.
Created attachment 16778 [details] proposed patch to fix this bug Can you please test whether this patch resolves the problem?
applied the fix to tip/x86/urgent.
i confirm that the patch fixes both vbetest and dd, thanks! small note on whitespace: some of the comment lines are indented with all spaces, not tab+space. also 'ret' could be declared as 'void __iomem *' to avoid the casts.
Created attachment 16792 [details] Updated patch Yes. I noticed the whitespace messup after attaching the patch yday. Here is the an updated patch with whitespace and void __iomem * cleanups.
Handled-By : Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Patch : http://bugzilla.kernel.org/attachment.cgi?id=16792&action=view
Fixed by: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a361ee5cb8011763ece7b4add393e206439db8b3