Hi Richard,
Christophe Fergeau found that Fedora's
qemu-user-static-x86-8.1.3-1.fc39.aarch64 fails when running a
statically linked hello world binary:

  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

That error message was introduced in QEMU 8.1 commit dd55885516f4
("linux-user: Rewrite non-fixed probe_guest_base").

Fedora's qemu-x86_64-static /proc/self/maps looks like this on aarch64:

00400000-00401000 r--p 00000000 00:22 78921                              
/usr/bin/qemu-x86_64-static
^^^^^^^^^^^^^^^^^
00410000-0066b000 r-xp 00010000 00:22 78921                              
/usr/bin/qemu-x86_64-static
00670000-0078e000 r--p 00270000 00:22 78921                              
/usr/bin/qemu-x86_64-static
00793000-007b0000 r--p 00393000 00:22 78921                              
/usr/bin/qemu-x86_64-static
007b0000-007dd000 rw-p 003b0000 00:22 78921                              
/usr/bin/qemu-x86_64-static
007dd000-007ef000 rw-p 00000000 00:00 0                                  [heap]
007ef000-008b7000 rw-p 00000000 00:00 0                                  [heap]
ffffe8000000-ffffeffff000 rwxp 00000000 00:00 0 
ffffeffff000-fffff0000000 ---p 00000000 00:00 0 
fffff0000000-fffff0021000 rw-p 00000000 00:00 0 
fffff0021000-fffff4000000 ---p 00000000 00:00 0 
fffff776c000-fffff77ed000 rw-p 00000000 00:00 0 
fffff77ed000-fffff77fd000 ---p 00000000 00:00 0 
fffff77fd000-fffff7ffd000 rw-p 00000000 00:00 0 
fffff7ffd000-fffff7fff000 r--p 00000000 00:00 0                          [vvar]
fffff7fff000-fffff8000000 r-xp 00000000 00:00 0                          [vdso]
fffffffdf000-1000000000000 rw-p 00000000 00:00 0                         [stack]

Address 0x400000 is used by both the statically linked QEMU and the
statically linked hello world binary:

$ readelf -a podman_hello_world.alpine
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x401047
  Start of program headers:          64 (bytes into file)
  Start of section headers:          75000 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.gnu.pr[...] NOTE             0000000000400238  00000238
       0000000000000030  0000000000000000   A       0     0     8
  [ 2] .note.gnu.bu[...] NOTE             0000000000400268  00000268
       0000000000000024  0000000000000000   A       0     0     4
  [ 3] .init             PROGBITS         0000000000401000  00001000
       0000000000000003  0000000000000000  AX       0     0     1
  [ 4] .text             PROGBITS         0000000000401010  00001010
       0000000000000e90  0000000000000000  AX       0     0     16
  [ 5] .fini             PROGBITS         0000000000401ea0  00001ea0
       0000000000000003  0000000000000000  AX       0     0     1
  [ 6] .rodata           PROGBITS         0000000000402000  00002000
       00000000000001ad  0000000000000001 AMS       0     0     8
  [ 7] .eh_frame         PROGBITS         00000000004021b0  000021b0
       0000000000000034  0000000000000000   A       0     0     8
  [ 8] .init_array       INIT_ARRAY       0000000000403fb8  00002fb8
       0000000000000008  0000000000000008  WA       0     0     8
  [ 9] .fini_array       FINI_ARRAY       0000000000403fc0  00002fc0
       0000000000000008  0000000000000008  WA       0     0     8
  [10] .data.rel.ro      PROGBITS         0000000000403fc8  00002fc8
       0000000000000010  0000000000000000  WA       0     0     8
  [11] .got              PROGBITS         0000000000403fd8  00002fd8
       0000000000000028  0000000000000008  WA       0     0     8
  [12] .data             PROGBITS         0000000000404000  00003000
       0000000000000110  0000000000000000  WA       0     0     32
  [13] .bss              NOBITS           0000000000404120  00003110
       00000000000006d0  0000000000000000  WA       0     0     32
  [14] .comment          PROGBITS         0000000000000000  00003110
       0000000000000031  0000000000000001  MS       0     0     1
  [15] .debug_aranges    PROGBITS         0000000000000000  00003150
       00000000000006a0  0000000000000000           0     0     16
  [16] .debug_info       PROGBITS         0000000000000000  000037f0
       0000000000006157  0000000000000000           0     0     1
  [17] .debug_abbrev     PROGBITS         0000000000000000  00009947
       000000000000247d  0000000000000000           0     0     1
  [18] .debug_line       PROGBITS         0000000000000000  0000bdc4
       0000000000001d6c  0000000000000000           0     0     1
  [19] .debug_frame      PROGBITS         0000000000000000  0000db30
       0000000000000858  0000000000000000           0     0     8
  [20] .debug_str        PROGBITS         0000000000000000  0000e388
       0000000000000ea5  0000000000000001  MS       0     0     1
  [21] .debug_line_str   PROGBITS         0000000000000000  0000f22d
       000000000000044d  0000000000000001  MS       0     0     1
  [22] .debug_loclists   PROGBITS         0000000000000000  0000f67a
       00000000000016bc  0000000000000000           0     0     1
  [23] .debug_rnglists   PROGBITS         0000000000000000  00010d36
       0000000000000431  0000000000000000           0     0     1
  [24] .symtab           SYMTAB           0000000000000000  00011168
       0000000000000c90  0000000000000018          25    62     8
  [25] .strtab           STRTAB           0000000000000000  00011df8
       00000000000005e0  0000000000000000           0     0     1
  [26] .shstrtab         STRTAB           0000000000000000  000123d8
       0000000000000120  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), l (large), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 0x000000000000028c 0x000000000000028c  R      0x1000
  LOAD           0x0000000000001000 0x0000000000401000 0x0000000000401000
                 0x0000000000000ea3 0x0000000000000ea3  R E    0x1000
  LOAD           0x0000000000002000 0x0000000000402000 0x0000000000402000
                 0x00000000000001e4 0x00000000000001e4  R      0x1000
  LOAD           0x0000000000002fb8 0x0000000000403fb8 0x0000000000403fb8
                 0x0000000000000158 0x0000000000000838  RW     0x1000
  NOTE           0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x0000000000000030 0x0000000000000030  R      0x8
  NOTE           0x0000000000000268 0x0000000000400268 0x0000000000400268
                 0x0000000000000024 0x0000000000000024  R      0x4
  GNU_PROPERTY   0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x0000000000000030 0x0000000000000030  R      0x8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10
  GNU_RELRO      0x0000000000002fb8 0x0000000000403fb8 0x0000000000403fb8
                 0x0000000000000048 0x0000000000000048  R      0x1

Oddly, when I compile static QEMU from source on this machine, then the
resulting binary does not use 0x400000 and it can successfully run the
hello world binary. Maybe the address is related to the compiler flags
or something else in Fedora's RPM build environment.

There is a bugzilla tracking this here:
https://bugzilla.redhat.com/show_bug.cgi?id=2256916

Any ideas what can be done to solve this problem?

Thanks,
Stefan

Attachment: signature.asc
Description: PGP signature

Reply via email to