qemu-arm-static 5.1 can't run gcc

Bug #1891748 reported by Ech
36
This bug affects 8 people
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Unassigned
Juju Charms Collection
New
Undecided
Unassigned

Bug Description

Issue discovered while trying to build pikvm (1)

Long story short: when using qemu-arm-static 5.1, gcc exits whith message:

Allocating guest commpage: Operation not permitted

when using qemu-arm-static v5.0, gcc "works"

Steps to reproduce will follow

(1) https://github.com/pikvm/pikvm/blob/master/pages/building_os.md

Revision history for this message
Ech (ech1965) wrote :

Steps to reproduce

1. Download and extract attached tarball.

$ make # will build the docker container

$ make run # will enter the container

# once in the container, run

# /qemu-arm-static-50 /bin/bash /runme.sh

Revision history for this message
Ech (ech1965) wrote :

Additional info,

error message text ( "Allocating guest commpage" ) found in this commit:

https://fossies.org/diffs/qemu/5.0.0_vs_5.1.0-rc0/linux-user/elfload.c-diff.html

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Anyone? Seriously, the problem really exists and we even made a case that reproduces it. Someone please take a look at this.

Revision history for this message
Tyler Price (tsp84) wrote :

Plz take a look at this issue please.

Revision history for this message
Richard Henderson (rth) wrote :

This has been fixed in mainline, probably commit
8ef618859c379fdce81c91bc93e0574e36ea76ff.

Changed in qemu:
status: New → Fix Committed
Revision history for this message
Thomas Huth (th-huth) wrote :

Released with QEMU v5.2.0.

Changed in qemu:
status: Fix Committed → Fix Released
Revision history for this message
Andreas K. Hüttel (dilfridge) wrote :

I'm still seeing this with qemu 5.2.0

armv7a-softfp-linux-gnueabi-gcc -O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,-O1 -Wl,--as-needed glibc-test.c -o glibc-test
Allocating guest commpage: Operation not permitted

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

$ qemu-arm --version
qemu-arm version 5.2.0 (Debian 1:5.2+dfsg-6)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

I’m seeing this error on a totally different file:

I’ve made a short test program (hello world-ish) and compiled it with the OpenWrt toolchain but added -static so I can run it on the host using qemu-user-arm:

$ STAGING_DIR=$PWD/staging_dir PATH=staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.5.0_musl_eabi/bin:$PATH arm-openwrt-linux-muslgnueabi-gcc -Os -pipe -g3 -fno-caller-saves -fno-plt -fhonour-copts -mfloat-abi=hard -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -static x.c
$ ./a.out
Allocating guest commpage: Operation not permitted

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Heh, even if I omit -static …

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

It works with sudo, but that can’t be the fix…

Revision history for this message
Laurent Vivier (laurent-vivier) wrote :

Could you check the result of "sysctl vm.mmap_min_addr"

65536 is the value that works for me.

Alex Bennée (ajbennee)
tags: added: arm linux-user tcg
Revision history for this message
Maxim Devaev (mdevaev) wrote :

@aurent-vivier Checked.
This value does not affect the bug, after changing it, I still get an error.

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Anyone?

Revision history for this message
Alex Bennée (ajbennee) wrote :

I've been unable to replicate the crash with any of the instructions here. Certainly all the statically compiled unit tests work and I've just done a build of QEMU in an emulated Debian Buster (Armel) docker image.

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Okay, what do you think this problem might be related to? I'm glad your tests are working, but I'm definitely not the only one with this problem.

Revision history for this message
Laurent Vivier (laurent-vivier) wrote :

I think the output of "sysctl vm" could help to identify which parameter is involved in the problem. You can also compare the output of "sudo sysctl vm" and "sysctl vm"

Revision history for this message
Maxim Devaev (mdevaev) wrote :

In my case, sudo does not affect this bug. My output in attachements.

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Sup?

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Okay, it was found experimentally that the problem is reproduced if vm.mmap_min_addr is greater than 53249. If from 0 to 53249 - everything works. What can this be related to?

Revision history for this message
Maxim Devaev (mdevaev) wrote :

I mean [0...52348] is working.

Revision history for this message
Maxim Devaev (mdevaev) wrote :

Sorry, an error in previous message.

Fixed and detailed diagnostics:

[0 ... 53248] - working
[53249 ... 61440] - Cannot allocate memory
[61441 ... 65536 and higher] - Operation not permitted

Revision history for this message
xornet (xornet) wrote :

Can confirm this bug on fresh Linux Arch and Debian Linux installation.
I need just nothing to reproduce it: Just install fresh arch and do steps described in comment #1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.