summary refs log tree commit diff stats
path: root/results/classifier/zero-shot-user-mode/syscall/2157
blob: 41c585dd5198bf0fa19ecd0bb89299dd8690c5d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
syscall: 0.496
instruction: 0.323
runtime: 0.181



qemu-user fails to run 32-bit x86 binaries on hosts with a page size > 4KB
Description of problem:
`qemu-i386` refuses to run 32-bit x86 binaries on hosts with a page size > 4KB
(such as LoongArch, ppc64le, arm64 with 3 level page tables).
Steps to reproduce:
1. Compile x86 binary which makes a single exit(0) syscall:
   ```
   cat > exit0.S << EOF
   #include <sys/syscall.h>
   .text
   .global _start
    _start:
      movl $__NR_exit, %eax
      movl $0, %ebx
      int $0x80
   EOF
   i586-linux-gnu-gcc -nostdlib -static -no-pie -o exit0 exit0.S
   ```
   Alternatively one might compile it on a x86 host:
   ```
   gcc -m32 -nostdlib -static -no-pie -o exit0 exit0.S
   ```
   and transfer the `exit0` binary to ppc64/LoongArch/arm64 system

   2. Run the `exit0` binary with `qemu-i386`
   ```
   qemu-i386-static ./exit0
   ```

   #
Additional information:
`.text` segment of (32-bit) x86 binaries is typically aligned at 4KB:
```
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08048000 0x00100 0x00100 R   0x1000
  LOAD           0x001000 0x08049000 0x08049000 0x0000c 0x0000c R E 0x1000
  NOTE           0x0000b4 0x080480b4 0x080480b4 0x0004c 0x0004c R   0x4
  GNU_PROPERTY   0x0000d8 0x080480d8 0x080480d8 0x00028 0x00028 R   0x4
```

Thus on a host with a page size being 64 KB (ppc64, arm64 with 3 level page tables) or 16 KB (LoongArch)
alignment requirements in [pbg_dynamic](https://gitlab.com/qemu-project/qemu/-/blob/master/linux-user/elfload.c?ref_type=heads#L3020) can not be satisfied.