Skip to content

Commit

Permalink
linux-user/arm: Do not allocate a commpage at all for M-profile CPUs
Browse files Browse the repository at this point in the history
Since commit fbd3c4c ("linux-user/arm: Mark the commpage
executable") executing bare-metal (linked with rdimon.specs)
cortex-M code fails as:

  $ qemu-arm -cpu cortex-m3 ~/hello.exe.m3
  qemu-arm: ../../accel/tcg/user-exec.c:492: page_set_flags: Assertion `last <= GUEST_ADDR_MAX' failed.
  Aborted (core dumped)

Commit 4f5c67f ("linux-user/arm: Take more care allocating
commpage") already took care of not allocating a commpage for
M-profile CPUs, however it had to be reverted as commit 6cda41d.

Re-introduce the M-profile fix from commit 4f5c67f.

Fixes: fbd3c4c ("linux-user/arm: Mark the commpage executable")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1755
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230711153408.68389-1-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit d713cf4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
philmd authored and Michael Tokarev committed Jul 18, 2023
1 parent 1dfc8d9 commit 91e7b5d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,23 @@ enum {

static bool init_guest_commpage(void)
{
abi_ptr commpage = HI_COMMPAGE & -qemu_host_page_size;
void *want = g2h_untagged(commpage);
void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
ARMCPU *cpu = ARM_CPU(thread_cpu);
abi_ptr commpage;
void *want;
void *addr;

/*
* M-profile allocates maximum of 2GB address space, so can never
* allocate the commpage. Skip it.
*/
if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
return true;
}

commpage = HI_COMMPAGE & -qemu_host_page_size;
want = g2h_untagged(commpage);
addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);

if (addr == MAP_FAILED) {
perror("Allocating guest commpage");
Expand Down

0 comments on commit 91e7b5d

Please sign in to comment.