Skip to content

32bit qemu-arm can't run GCC due to failure to allocate memory range for guest (Allocating guest commpage error)

Host environment

  • Operating system: Arch Linux
  • OS/kernel version: Linux reki 5.14.14-arch1-1 #1 SMP PREEMPT Wed, 20 Oct 2021 21:35:18 +0000 x86_64 GNU/Linux
  • Architecture: i386 (32 bit)
  • QEMU flavor: qemu-arm-static
  • QEMU version: qemu-arm version 6.1.0 (Debian 1:6.1+dfsg-6)
  • QEMU command line: like qemu-arm-static gcc, see the complete test below.

Emulated/Virtualized environment

  • Operating system: Linux
  • OS/kernel version: Any Linux
  • Architecture: ARM

Description of problem

I'm running ARM binaries using 32 bit qemu-arm-static on x86_64 host. Since version 5.1 (include latest 6.1), QEMU cannot run GCC and some other things with an error Allocating guest commpage: Operation not permitted. The problem is NOT reproducible on QEMU 5.0, so probably the problem was caused by a rework of init_guest_space or the following commits a year ago.

Also the problem is not reproducible for all users. It is known that it is reproduced on all Arch Linux host machines and some Debian, and probably depends on some kernel build parameters.

The sysctl vm.mmap_min_addr parameter also affects the problem. The error varies depending on its value:

[0 ... 53248] - No error at all
[53249 ... 61440] - Cannot allocate memory
[61441 ... 65536 and higher] - Operation not permitted

Steps to reproduce

  1. Download and extract attached tarball: qemu-test-gcc.tgz
  2. $ make # will build the docker container
  3. $ make run # will enter the container
  4. Once in the container, run: # /qemu-arm-static-50 /bin/bash /runme.sh

Additional information

A detailed description of the problem and feedback from other users is here: https://bugs.launchpad.net/qemu/+bug/1891748

Edited by Alex Bennée
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information