Bug 2256916 - qemu-x86_64-static can no longer run some static binaries
Summary: qemu-x86_64-static can no longer run some static binaries
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: qemu
Version: 39
Hardware: aarch64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Fedora Virtualization Maintainers
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-01-05 08:53 UTC by Christophe Fergeau
Modified: 2024-04-28 18:18 UTC (History)
12 users (show)

Fixed In Version: qemu-8.1.3-5.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-04-18 01:11:56 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
x86_64 binary I can no longer run in an aarch64 VM (74.93 KB, application/octet-stream)
2024-01-05 08:54 UTC, Christophe Fergeau
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Gitlab qemu-project qemu issues 2082 0 None opened "Unable to find a guest_base to satisfy all guest address mapping requirements" running certain x86_64 binaries on aarch... 2024-01-09 10:13:32 UTC

Description Christophe Fergeau 2024-01-05 08:53:34 UTC
My setup is a fcos 39 VM running on a macbook (macOS) with a m1 CPU. The VM is running in QEMU. This was all created/started using `podman machine`.

With qemu-x86_64-static from qemu-8.1.3-1.fc39, I can no longer run on the m1 the x86_64 binary created by https://github.com/containers/PodmanHello

If I try with qemu-x86_64-static from qemu-7.2.7-1.fc38 then this works.

If I build the binary manually on a fc39 x86 system with `gcc -O2 -static -o podman_hello_world podman_hello_world.c`, then I can also run it successfully with qemu-8.1.3-1.fc39.
It's only the static binary built inside the alpine container which cannot be run on the M1.


Misc tests I ran:

# ./qemu-x86_64-static-8.1.3 podman_hello_world.alpine 
qemu-x86_64-static-8.1.3: /var/roothome/podman_hello_world.alpine: Unable to find a guest_base to satisfy all guest address mapping requirements
  0000000000000000-0000000000000fff
  0000000000400000-00000000004047ef

# ./qemu-x86_64-static-7.2.7 podman_hello_world.alpine 
!... Hello Podman World ...!
[...]

# ./qemu-x86_64-static-8.1.3 podman_hello_world.fc39 
!... Hello Podman World ...!
[...]

Reproducible: Always

Comment 1 Christophe Fergeau 2024-01-05 08:54:49 UTC
Created attachment 2007328 [details]
x86_64 binary I can no longer run in an aarch64 VM

Comment 2 Christophe Fergeau 2024-01-05 08:59:30 UTC
The issue is still present with qemu-8.2.0-0.3.rc2.fc40

Comment 3 Stefan Hajnoczi 2024-01-08 16:10:56 UTC
I wanted to reproduce this with upstream QEMU built from source but was not successful. Note that I'm using an x86_64 Linux host, not a m1 Mac. The alpine binary runs successfully on v8.1.3 and commit ffd454c67e38 (qemu.git/master on 8/1/2024).

Maybe the issue is related to aarch64 hosts.

Comment 4 Christophe Fergeau 2024-01-08 21:16:34 UTC
I also could not reproduce on x86_64 machines. I just tried it on fc39 installed on non-Apple aarch64 hardware, and I'm seeing the same issue:

# rpm -qf /usr/bin/qemu-x86_64-static 
qemu-user-static-x86-8.1.3-1.fc39.aarch64

# qemu-x86_64-static ./podman_hello_world.alpine 
qemu-x86_64-static: /root/podman_hello_world.alpine: Unable to find a guest_base to satisfy all guest address mapping requirements
  0000000000000000-0000000000000fff
  0000000000400000-00000000004047ef

Comment 5 Daniel Berrangé 2024-01-09 10:13:32 UTC
I've opened an upstream bug, since this kind of thing usually requires TCG maintainer expert opinion to diagnose:

https://gitlab.com/qemu-project/qemu/-/issues/2082

Please CC yourself to that bug and continue diagnosis there.

We'll backport to Fedora if any bug is identified upstream.

Comment 6 Christophe Fergeau 2024-01-30 14:17:18 UTC
After reading https://gitlab.com/qemu-project/qemu/-/issues/1953 and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053101, I built a test qemu fedora package with --enable-pie (the .spec disables it) and this solved (worked around?) the issue

Comment 7 Christophe Fergeau 2024-01-30 14:17:39 UTC
Scratch build is at https://koji.fedoraproject.org/koji/taskinfo?taskID=112603010

Comment 8 Daniel Berrangé 2024-01-30 14:46:30 UTC
After reading https://gitlab.com/qemu-project/qemu/-/issues/1953 and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053101, I built a test qemu fedora package with --enable-pie (the .spec disables it) and this solved (worked around?) the issue

Urgh, pie should *not* be disabled. Can you submit a PR with the fix for the spec.

Comment 9 Christophe Fergeau 2024-03-26 14:27:02 UTC
This was fixed in https://src.fedoraproject.org/rpms/qemu/pull-request/59 (and the follow-up https://src.fedoraproject.org/rpms/qemu/pull-request/60). This is available in f40 and newer, would be nice to get this in f39 as well as this is what podman-machine images are built from.

Comment 10 Fedora Update System 2024-04-09 19:51:10 UTC
FEDORA-2024-5f3a01426a (qemu-8.1.3-5.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-5f3a01426a

Comment 11 Fedora Update System 2024-04-10 01:47:19 UTC
FEDORA-2024-5f3a01426a has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-5f3a01426a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-5f3a01426a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2024-04-18 01:11:56 UTC
FEDORA-2024-5f3a01426a (qemu-8.1.3-5.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Teoh Han Hui 2024-04-28 18:18:32 UTC
It does not fix the problem, at least for `qemu-i386-static`.

```
teohhanhui@Han-MacBook-Air:~$ ~/Downloads/disk\ tools/chkntfs
qemu-i386-static: /home/teohhanhui/Downloads/disk tools/chkufsd: Unable to find a guest_base to satisfy all guest address mapping requirements
  00000000-ffffffff
teohhanhui@Han-MacBook-Air:~$ rpm -qf $(command -v qemu-i386-static)
qemu-user-static-x86-8.1.3-5.fc39.aarch64
```

Setting `QEMU_GUEST_BASE=0x14000` as mentioned here works though: https://social.treehouse.systems/@mstephenson6/112299009772931025

```
teohhanhui@Han-MacBook-Air:~$ QEMU_GUEST_BASE=0x14000 ~/Downloads/disk\ tools/chkntfs
Check ufsd volume for error
Usage: chkufsd device [-f]
  -fs:ntfs        force to treat volume as ntfs.
  -fs:hfs         force to treat volume as hfs+/hfsj.
  -fs:exfat       force to treat volume as exfat/texfat.
  -fs:fat         force to treat volume as fat32/fat16.
  -f              fix errors on the disk.
  -a              auto check. Full check if volume is dirty
  -b:size         Override the default block (sector) size. Default settings
                  are strongly recommended for general use.
                  One can use 512, 1024, 2048, 4096.
  -m:size         memory limit
  -h              display this help
  --short         check the minimum
  --safe          do not try to fix errors;
                  only clear 'dirty' flag if there are no errors
  --help          display this help
  --showminors    show minor errors
  --no-orphans    do not restore real orphan files
  --trace         turn on UFSD trace
  --verbose       explain what is being done
  --nopercents    do not print percents
  --version       show version and exit
E.g. chkufsd /dev/hdb1
```


Note You need to log in before you can comment on or make changes to this bug.