Skip to content

qemu-arm fails to execute a cortex-M binary (page_set_flags: Assertion 'last <= GUEST_ADDR_MAX' failed.)

Host environment

  • Operating system: Ubuntu 22.04

  • OS/kernel version: Linux ex42-01-dev 5.11.0-40-generic #44 (closed)~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  • Architecture: x86

  • QEMU flavor: qemu-arm

  • QEMU version: qemu-arm version 8.0.50 (v8.0.0-2316-gd145c0da)

  • QEMU command line: see below

Emulated/Virtualized environment

  • Architecture: arm

Description of problem

I've noticed that qemu-arm (so linux-user mode) fails to execute a binary targeting cortex-M. This used to work until commit "Make the commpage executable".

Steps to reproduce

  1. Compile a simple hello.c for arm-eabi. If you don't have such a toolchain, you can download one from https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads For instance https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz (for an x86_64 linux host)

2.# compile for cortex-m3:

  1. arm-none-eabi-gcc hello.c -o hello.exe.m3 -mcpu=cortex-m3 -specs=rdimon.specs

4.qemu-arm -cpu cortex-m3 hello.exe.m3 .....user-exec.c:492: page_set_flags: Assertion 'last <= GUEST_ADDR_MAX' failed.

  1. compile for cortex-a9:

  2. arm-none-eabi-gcc hello.c -o hello.exe.a9 -mcpu=cortex-a9 -specs=rdimon.specs

  3. qemu-arm -cpu cortex-a9 hello.exe.a9 Hello

Edited by Christophe Lyon
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information