Files
qemu/linux-user/x86_64/elfload.c
Philippe Mathieu-Daudé 67e17ab2b3 exec/cpu-common.h: Avoid including unused exec/page-protection.h header
Since commit e74781c0888e ("exec/cpu: Extract page-protection
definitions to page-protection.h") the "exec/cpu-common.h" isn't
using anything defined in "exec/page-protection.h"; remove it.

Include it in few files where it is currently pulled in indirectly,
otherwise we'd get:

  linux-user/qemu.h:182:22: error: ‘PAGE_READ’ undeclared
    182 | #define VERIFY_READ  PAGE_READ
        |                      ^~~~~~~~~
  target/loongarch/cpu_helper.c:329:25: error: use of undeclared identifier 'PAGE_READ'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                         ^
  target/loongarch/cpu_helper.c:329:37: error: use of undeclared identifier 'PAGE_WRITE'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                                     ^
  target/loongarch/cpu_helper.c:329:50: error: use of undeclared identifier 'PAGE_EXEC'
    329 |         context->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
        |                                                  ^
  target/ppc/mmu-hash32.h:98:20: error: use of undeclared identifier 'PAGE_READ'
     98 |             prot = PAGE_READ | PAGE_WRITE;
        |                    ^
  target/ppc/mmu-hash32.h:98:32: error: use of undeclared identifier 'PAGE_WRITE'
     98 |             prot = PAGE_READ | PAGE_WRITE;
        |                                ^
  hw/ppc/ppc_booke.c:39:17: error: use of undeclared identifier 'PAGE_RWX'
     39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
        |                 ^
  hw/ppc/ppc_booke.c:39:33: error: use of undeclared identifier 'PAGE_VALID'
     39 |     tlb->prot = PAGE_RWX << 4 | PAGE_VALID;
        |                                 ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260617160426.64461-6-philmd@oss.qualcomm.com>
2026-06-18 14:27:21 +02:00

75 lines
2.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "qemu/osdep.h"
#include "qemu/error-report.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 "max";
}
abi_ulong get_elf_hwcap(CPUState *cs)
{
return cpu_env(cs)->features[FEAT_1_EDX];
}
const char *get_elf_platform(CPUState *cs)
{
return "x86_64";
}
bool init_guest_commpage(void)
{
/*
* The vsyscall page is at a high negative address aka kernel space,
* which means that we cannot actually allocate it with target_mmap.
* We still should be able to use page_set_flags, unless the user
* has specified -R reserved_va, which would trigger an assert().
*/
if (reserved_va != 0 &&
TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE - 1 > reserved_va) {
error_report("Cannot allocate vsyscall page");
exit(EXIT_FAILURE);
}
page_set_flags(TARGET_VSYSCALL_PAGE,
TARGET_VSYSCALL_PAGE | ~TARGET_PAGE_MASK,
PAGE_EXEC | PAGE_VALID, PAGE_VALID);
return true;
}
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUX86State *env)
{
r->pt.r15 = tswapal(env->regs[15]);
r->pt.r14 = tswapal(env->regs[14]);
r->pt.r13 = tswapal(env->regs[13]);
r->pt.r12 = tswapal(env->regs[12]);
r->pt.bp = tswapal(env->regs[R_EBP]);
r->pt.bx = tswapal(env->regs[R_EBX]);
r->pt.r11 = tswapal(env->regs[11]);
r->pt.r10 = tswapal(env->regs[10]);
r->pt.r9 = tswapal(env->regs[9]);
r->pt.r8 = tswapal(env->regs[8]);
r->pt.ax = tswapal(env->regs[R_EAX]);
r->pt.cx = tswapal(env->regs[R_ECX]);
r->pt.dx = tswapal(env->regs[R_EDX]);
r->pt.si = tswapal(env->regs[R_ESI]);
r->pt.di = tswapal(env->regs[R_EDI]);
r->pt.orig_ax = tswapal(get_task_state(env_cpu_const(env))->orig_ax);
r->pt.ip = tswapal(env->eip);
r->pt.cs = tswapal(env->segs[R_CS].selector & 0xffff);
r->pt.flags = tswapal(env->eflags);
r->pt.sp = tswapal(env->regs[R_ESP]);
r->pt.ss = tswapal(env->segs[R_SS].selector & 0xffff);
r->pt.fs_base = tswapal(env->segs[R_FS].base);
r->pt.gs_base = tswapal(env->segs[R_GS].base);
r->pt.ds = tswapal(env->segs[R_DS].selector & 0xffff);
r->pt.es = tswapal(env->segs[R_ES].selector & 0xffff);
r->pt.fs = tswapal(env->segs[R_FS].selector & 0xffff);
r->pt.gs = tswapal(env->segs[R_GS].selector & 0xffff);
}