Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qemu-user-i386: unable to reserve virtual address space #6172

Closed
easyaspi314 opened this issue Dec 24, 2020 · 3 comments
Closed

qemu-user-i386: unable to reserve virtual address space #6172

easyaspi314 opened this issue Dec 24, 2020 · 3 comments

Comments

@easyaspi314
Copy link
Contributor

easyaspi314 commented Dec 24, 2020

Problem description

Trying to run any binary in qemu-user-i386 results in this error:

qemu-i386: Unable to reserve 0xfffff000 bytes of virtual address space at 0x1000 (Success) for use as guest address space (check yourvirtual memory ulimit setting, min_mmap_addr or reserve less using -R option)

Note that the -R option does not fix the problem. It is either too small or it throws the same error.

It seems that the "Success" part is the result of strerror(errno), but errno == 0

Steps to reproduce

  1. Install qemu-user-i386
  2. Compile and try to run any random i386 binary. For example, the bare minimum which just syscalls exit(0):
    .globl _start
_start:
    movl $1, %eax # SYS_exit
    xorl %ebx, %ebx
    int $0x80
$ clang --target=i386-linux-gnu -nostdlib -static -fuse-ld=$(which ld.lld) no-op.s -o no-op
$ qemu-i386 -cpu max ./no-op

Expected behavior

It runs as expected.

Additional information

Note that it is impossible to read the vm.mmap_min_addr sysctl without root on my device.

Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24/ stable main
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
# x11-repo (sources.list.d/x11.list)
deb https://dl.bintray.com/xeffyr/x11-packages x11 main
# unstable-repo (sources.list.d/unstable.list)
deb https://dl.bintray.com/xeffyr/unstable-packages unstable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
Updatable packages:
libcairo/stable 1.16.0-7 aarch64 [upgradable from: 1.16.0-2]
pulseaudio/stable 14.0 aarch64 [upgradable from: 12.2-21]
Android version:
11
Kernel build information:
Linux localhost 4.4.223-g52750b8f2138-ab6846512 #1 SMP PREEMPT Fri Sep 18 09:49:34 UTC 2020 aarch64 Android
Device manufacturer:
Google
Device model:
Pixel 2 XL

@ghost
Copy link

ghost commented Dec 24, 2020

That's a quite strange error. I didn't observed it on my device and x86 binaries are executed fine both on AArch64 and ARM devices.

ghost pushed a commit that referenced this issue Dec 24, 2020
@ghost
Copy link

ghost commented Dec 24, 2020

Problem is that it tries to read vm.mmap_min_addr which is not accessible on devices where SELinux is strict regarding sysctl.

I have added a patch which changes a fallback value from 4096 (1 page) to 32768 (8 pages) as in sysctl vm.mmap_min_addr on my device.

@easyaspi314
Copy link
Contributor Author

That seems to work, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant