[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 45/47] linux-user/arm: Do not allocate a commpage at all for M-pro
From: |
Richard Henderson |
Subject: |
[PULL 45/47] linux-user/arm: Do not allocate a commpage at all for M-profile CPUs |
Date: |
Sat, 15 Jul 2023 14:53:15 +0100 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Since commit fbd3c4cff6 ("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 4f5c67f8df ("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 6cda41daa2.
Re-introduce the M-profile fix from commit 4f5c67f8df.
Fixes: fbd3c4cff6 ("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>
---
linux-user/elfload.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index d3d1352c4e..a26200d9f3 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -424,10 +424,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");
--
2.34.1
- [PULL 33/47] accel/tcg: Introduce page_find_range_empty, (continued)
- [PULL 33/47] accel/tcg: Introduce page_find_range_empty, Richard Henderson, 2023/07/15
- [PULL 28/47] linux-user: Implement MAP_FIXED_NOREPLACE, Richard Henderson, 2023/07/15
- [PULL 24/47] linux-user: Split TARGET_PROT_* out of syscall_defs.h, Richard Henderson, 2023/07/15
- [PULL 21/47] linux-user: Fix formatting of mmap.c, Richard Henderson, 2023/07/15
- [PULL 38/47] linux-user: Rename mmap_reserve to mmap_reserve_or_unmap, Richard Henderson, 2023/07/15
- [PULL 37/47] linux-user: Rewrite mmap_reserve, Richard Henderson, 2023/07/15
- [PULL 26/47] accel/tcg: Introduce page_check_range_empty, Richard Henderson, 2023/07/15
- [PULL 42/47] linux-user: Remove can_passthrough_madvise, Richard Henderson, 2023/07/15
- [PULL 43/47] linux-user: Simplify target_madvise, Richard Henderson, 2023/07/15
- [PULL 44/47] linux-user: Drop uint and ulong, Richard Henderson, 2023/07/15
- [PULL 45/47] linux-user/arm: Do not allocate a commpage at all for M-profile CPUs,
Richard Henderson <=
- [PULL 47/47] tcg: Use HAVE_CMPXCHG128 instead of CONFIG_CMPXCHG128, Richard Henderson, 2023/07/15
- [PULL 41/47] accel/tcg: Return bool from page_check_range, Richard Henderson, 2023/07/15
- [PULL 46/47] accel/tcg: Always lock pages before translation, Richard Henderson, 2023/07/15
- [PULL 40/47] accel/tcg: Accept more page flags in page_check_range, Richard Henderson, 2023/07/15
- Re: [PULL 00/47] tcg + linux-user patch queue, Richard Henderson, 2023/07/16