Files
qemu/linux-user/hppa/elfload.c
Richard Henderson 6fe7a5bba7 linux-user: Use PGBRange for commpage
This simplifies check for no commpage to a NULL pointer
check, rather than reserved values for LO_COMMPAGE and
HI_COMMPAGE.

Unify {LO,HI}_COMMPAGE into a single COMMPAGE define.

Acked-by: Warner Losh <imp@bsdimp.com>
Tested-by: Helge Deller <deller@gmx.de>
Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-07-10 14:38:10 -07:00

62 lines
1.6 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "qemu/osdep.h"
#include "exec/page-protection.h"
#include "qemu.h"
#include "loader.h"
#include "target_elf.h"
const char *get_elf_cpu_model(uint32_t eflags)
{
return "pa-7300lc";
}
const char *get_elf_platform(CPUState *cs)
{
return "PARISC";
}
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUArchState *env)
{
int i;
memset(r, 0, sizeof(*r));
for (i = 0; i < 32; i++) {
r->gr[i] = tswapal(env->gr[i]);
}
r->iaoq[0] = tswapal(env->iaoq_f);
r->iaoq[1] = tswapal(env->iaoq_b);
r->sar = tswapal(env->cr[CR_SAR]);
}
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(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(COMMPAGE, COMMPAGE | ~TARGET_PAGE_MASK,
PAGE_EXEC | PAGE_VALID, PAGE_VALID);
return true;
}