aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2025-07-29 09:13:54 -1000
committerRichard Henderson <richard.henderson@linaro.org>2025-08-30 07:04:04 +1000
commit6a91f64ee12fe54d1a9573e9ecbbae037b113097 (patch)
tree00b2acf213b3fe82ac05b638a2e6524c6de17436 /linux-user
parenta56ef5e8454e42c0d263a97a1297ae67f4ce19cd (diff)
downloadqemu-6a91f64ee12fe54d1a9573e9ecbbae037b113097.zip
qemu-6a91f64ee12fe54d1a9573e9ecbbae037b113097.tar.gz
qemu-6a91f64ee12fe54d1a9573e9ecbbae037b113097.tar.bz2
linux-user: Move init_guest_commpage to hppa/elfload.c
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c32
-rw-r--r--linux-user/hppa/elfload.c31
-rw-r--r--linux-user/hppa/target_elf.h2
-rw-r--r--linux-user/loader.h2
4 files changed, 33 insertions, 34 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 2281853..25f29e6 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -415,38 +415,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)
#define VDSO_HEADER "vdso.c.inc"
-#define LO_COMMPAGE 0
-
-static bool init_guest_commpage(void)
-{
- /* If reserved_va, then we have already mapped 0 page on the host. */
- if (!reserved_va) {
- void *want, *addr;
-
- want = g2h_untagged(LO_COMMPAGE);
- addr = mmap(want, TARGET_PAGE_SIZE, PROT_NONE,
- MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0);
- if (addr == MAP_FAILED) {
- perror("Allocating guest commpage");
- exit(EXIT_FAILURE);
- }
- if (addr != want) {
- return false;
- }
- }
-
- /*
- * On Linux, page zero is normally marked execute only + gateway.
- * Normal read or write is supposed to fail (thus PROT_NONE above),
- * but specific offsets have kernel code mapped to raise permissions
- * and implement syscalls. Here, simply mark the page executable.
- * Special case the entry points during translation (see do_page_zero).
- */
- page_set_flags(LO_COMMPAGE, LO_COMMPAGE | ~TARGET_PAGE_MASK,
- PAGE_EXEC | PAGE_VALID);
- return true;
-}
-
#endif /* TARGET_HPPA */
#ifdef TARGET_XTENSA
diff --git a/linux-user/hppa/elfload.c b/linux-user/hppa/elfload.c
index 9dd3fe0..018034f 100644
--- a/linux-user/hppa/elfload.c
+++ b/linux-user/hppa/elfload.c
@@ -3,6 +3,7 @@
#include "qemu/osdep.h"
#include "qemu.h"
#include "loader.h"
+#include "target_elf.h"
const char *get_elf_cpu_model(uint32_t eflags)
@@ -14,3 +15,33 @@ const char *get_elf_platform(CPUState *cs)
{
return "PARISC";
}
+
+bool init_guest_commpage(void)
+{
+ /* If reserved_va, then we have already mapped 0 page on the host. */
+ if (!reserved_va) {
+ void *want, *addr;
+
+ want = g2h_untagged(LO_COMMPAGE);
+ addr = mmap(want, TARGET_PAGE_SIZE, PROT_NONE,
+ MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0);
+ if (addr == MAP_FAILED) {
+ perror("Allocating guest commpage");
+ exit(EXIT_FAILURE);
+ }
+ if (addr != want) {
+ return false;
+ }
+ }
+
+ /*
+ * On Linux, page zero is normally marked execute only + gateway.
+ * Normal read or write is supposed to fail (thus PROT_NONE above),
+ * but specific offsets have kernel code mapped to raise permissions
+ * and implement syscalls. Here, simply mark the page executable.
+ * Special case the entry points during translation (see do_page_zero).
+ */
+ page_set_flags(LO_COMMPAGE, LO_COMMPAGE | ~TARGET_PAGE_MASK,
+ PAGE_EXEC | PAGE_VALID);
+ return true;
+}
diff --git a/linux-user/hppa/target_elf.h b/linux-user/hppa/target_elf.h
index 85be005..b654758 100644
--- a/linux-user/hppa/target_elf.h
+++ b/linux-user/hppa/target_elf.h
@@ -10,4 +10,6 @@
#define HAVE_ELF_PLATFORM 1
+#define LO_COMMPAGE 0
+
#endif
diff --git a/linux-user/loader.h b/linux-user/loader.h
index 0c2cc55..c3b8f92 100644
--- a/linux-user/loader.h
+++ b/linux-user/loader.h
@@ -105,9 +105,7 @@ const char *elf_hwcap_str(uint32_t bit);
const char *elf_hwcap2_str(uint32_t bit);
const char *get_elf_platform(CPUState *cs);
const char *get_elf_base_platform(CPUState *cs);
-#if defined(TARGET_X86_64) || defined(TARGET_ARM)
bool init_guest_commpage(void);
-#endif
struct target_elf_gregset_t;
void elf_core_copy_regs(struct target_elf_gregset_t *, const CPUArchState *);