Bug 543 - Bitbake complains about mmap_min_addr for an unknown reason
Summary: Bitbake complains about mmap_min_addr for an unknown reason
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 0.9
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.0 M4
Assignee: Edwin Zhai
QA Contact:
URL:
Whiteboard:
: 662 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-19 14:33 UTC by Darren Hart
Modified: 2011-03-06 17:18 UTC (History)
9 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darren Hart 2010-11-19 14:33:14 UTC
When changing my MACHINE from atom-pc to beagleboard, trying to build a recipe results in the following. It isn't clear to me from this why it's doing any kind of a qemu check as the machine isn't a qemu machine. It also isn't clear why this change should be necessary in the first place as qemu works on my system without that change.

Similar thoughts on the OE wiki: http://wiki.openembedded.net/index.php/Category_talk:FAQ#9._sanity_checker_complains_.22.2Fproc.2Fsys.2Fvm.2Fmmap_min_addr_is_not_0.22_on_Ubuntu

$ bitbake perl
FATAL:  Poky's config sanity checker detected a potential misconfiguration.
	Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
	Following is the list of potential problems / advisories:

	/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).

To fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.
Comment 1 Saul Wold 2011-02-22 10:02:22 UTC
*** Bug 662 has been marked as a duplicate of this bug. ***
Comment 2 Saul Wold 2011-02-22 10:03:44 UTC
Edwin, Please confirm that the mmap_min_addr patch is no longer needed with the latest qemu and if so, then remove this sanity check.
Comment 3 Edwin Zhai 2011-02-22 17:06:40 UTC
(In reply to comment #2)
> Edwin, Please confirm that the mmap_min_addr patch is no longer needed with the
> latest qemu and if so, then remove this sanity check.

Saul,
I'm not in the mmap_min_addr context, but I assume if I can build qemuarm minimal image, and run without these checks, then it's okay.

Right?
Comment 4 Tom Rini 2011-02-22 17:11:58 UTC
So, when I brought this up to Richard before, his answer was (to paraphrase) that he had a recollection of someone saying there were still corner cases and that it wasn't 100% fixed upstream (despite upstream saying it was fixed).
Comment 5 Martin Jansa 2011-02-25 07:38:25 UTC
(In reply to comment #4)
> So, when I brought this up to Richard before, his answer was (to paraphrase)
> that he had a recollection of someone saying there were still corner cases and
> that it wasn't 100% fixed upstream (despite upstream saying it was fixed).

The corner cases are when user account running bitbake (and then qemu) is not allowed to read /proc/sys/vm/mmap_min_addr and adjust mmap_min_addr in qemu accordingly.

That's why OE still has
http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=93a439a42b538be1f96c9250122504bfbdbd8d7b

And that's why this check will fail to read /proc/sys/vm/mmap_min_addr on some kernels and report "maybe false positive", see:
http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg02340.html

And here is response on qemu-devel:
http://www.mail-archive.com/qemu-devel@nongnu.org/msg31804.html
but c581deda322080e8beb88b2e468d4af54454e4b3 afaik didn't solve it completely
Comment 6 Edwin Zhai 2011-02-27 23:56:52 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > So, when I brought this up to Richard before, his answer was (to paraphrase)
> > that he had a recollection of someone saying there were still corner cases and
> > that it wasn't 100% fixed upstream (despite upstream saying it was fixed).
> 
> The corner cases are when user account running bitbake (and then qemu) is not
> allowed to read /proc/sys/vm/mmap_min_addr and adjust mmap_min_addr in qemu
> accordingly.
> 
> That's why OE still has
> http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=93a439a42b538be1f96c9250122504bfbdbd8d7b
> 
> And that's why this check will fail to read /proc/sys/vm/mmap_min_addr on some
> kernels and report "maybe false positive", see:
> http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg02340.html
> 
> And here is response on qemu-devel:
> http://www.mail-archive.com/qemu-devel@nongnu.org/msg31804.html
> but c581deda322080e8beb88b2e468d4af54454e4b3 afaik didn't solve it completely

Martin,
Thanks for your reply. It's more clear now. There is in fact 2 issues:
1. qemu linux-user doesn't reload it well, so we need set the mmap_min_addr to 0.  And qemu c581deda322080e8beb88b2e468d4af54454e4b3 fix it (already in 0.13.0).

2. Another issue is user on some distribution can't access the mmap_min_addr, so your patch assume 65536(from most of popular distribution) in such case.

Is it right?
I think issue 1 depends on 2, but not sure if these 2 fixes conflict?
Comment 7 Edwin Zhai 2011-02-28 00:14:56 UTC
So proper solution is adding Martin's patch in case that end user has no access of the /proc/..../mmap_min_addr and removed our checks. 

If so I'll have a test to see if qemuarm can be built and run well with this solution.

Another question is: does our check in sanity.bbclass have such access issue?
Comment 8 Dexuan Cui 2011-03-04 00:20:01 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > So, when I brought this up to Richard before, his answer was (to paraphrase)
> > > that he had a recollection of someone saying there were still corner cases and
> > > that it wasn't 100% fixed upstream (despite upstream saying it was fixed).
> > 
> > The corner cases are when user account running bitbake (and then qemu) is not
> > allowed to read /proc/sys/vm/mmap_min_addr and adjust mmap_min_addr in qemu
> > accordingly.
> > 
> > That's why OE still has
> > http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=93a439a42b538be1f96c9250122504bfbdbd8d7b
> > 
> > And that's why this check will fail to read /proc/sys/vm/mmap_min_addr on some
> > kernels and report "maybe false positive", see:
> > http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg02340.html
> > 
> > And here is response on qemu-devel:
> > http://www.mail-archive.com/qemu-devel@nongnu.org/msg31804.html
> > but c581deda322080e8beb88b2e468d4af54454e4b3 afaik didn't solve it completely
> Martin,
> Thanks for your reply. It's more clear now. There is in fact 2 issues:
> 1. qemu linux-user doesn't reload it well, so we need set the mmap_min_addr to
> 0.  And qemu c581deda322080e8beb88b2e468d4af54454e4b3 fix it (already in
> 0.13.0).
> 2. Another issue is user on some distribution can't access the mmap_min_addr,
> so your patch assume 65536(from most of popular distribution) in such case.
> Is it right?
> I think issue 1 depends on 2, but not sure if these 2 fixes conflict?

Now in poky we have qemu 0.13.0, and we also have the patch:
http://git.pokylinux.org/cgit/cgit.cgi/poky/commit/?id=ea63409781dc9a5de2d852ec044e55dc82e31a96
"qemu-0.13.0: Add patch to avoid mmap_min_addr
* This patch is taken from OE commit 40e293342ca76921904a43b03b635d9219432edf

(From OE-Core rev: 11d76595e036f46906859b59dc06094b2e979771)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>"

So I think the bug was actually fixed? (In reply to comment #7)

> So proper solution is adding Martin's patch in case that end user has no access
> of the /proc/..../mmap_min_addr and removed our checks. 
> If so I'll have a test to see if qemuarm can be built and run well with this
> solution.
> Another question is: does our check in sanity.bbclass have such access issue?
The code in sanity.bbclass is:
 if data.getVar('TARGET_ARCH', e.data, True) == "arm":
        # This path is no longer user-readable in modern (very recent) Linux
        try:
            if os.path.exists("/proc/sys/vm/mmap_min_addr"):
                f = file("/proc/sys/vm/mmap_min_addr", "r")
                if (f.read().strip() != "0"):
                        messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
                f.close()
        except:
            pass
So I think bitbake can ignore the exception safely.
Comment 9 Edwin Zhai 2011-03-04 00:31:57 UTC
I have tested arm build without Raj's patch, and everything works well.
In theory, Raj's patch should not cause any regression.

I'll make a new test with Raj's patch, then send pull request if no regression.
Comment 10 Edwin Zhai 2011-03-06 17:18:41 UTC
Fixed in poky master @ 0bc244181fce67725ddd0981481e5611b700cf51