| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include "qemu/osdep.h" |
| 4 | #include "qemu/error-report.h" |
| 5 | #include "exec/page-protection.h" |
| 6 | #include "qemu.h" |
| 7 | #include "loader.h" |
| 8 | #include "target_elf.h" |
| 9 | |
| 10 | |
| 11 | const char *get_elf_cpu_model(uint32_t eflags) |
| 12 | { |
| 13 | return "max"; |
| 14 | } |
| 15 | |
| 16 | abi_ulong get_elf_hwcap(CPUState *cs) |
| 17 | { |
| 18 | return cpu_env(cs)->features[FEAT_1_EDX]; |
| 19 | } |
| 20 | |
| 21 | const char *get_elf_platform(CPUState *cs) |
| 22 | { |
| 23 | return "x86_64"; |
| 24 | } |
| 25 | |
| 26 | bool init_guest_commpage(void) |
| 27 | { |
| 28 | /* |
| 29 | * The vsyscall page is at a high negative address aka kernel space, |
| 30 | * which means that we cannot actually allocate it with target_mmap. |
| 31 | * We still should be able to use page_set_flags, unless the user |
| 32 | * has specified -R reserved_va, which would trigger an assert(). |
| 33 | */ |
| 34 | if (reserved_va != 0 && |
| 35 | TARGET_VSYSCALL_PAGE + TARGET_PAGE_SIZE - 1 > reserved_va) { |
| 36 | error_report("Cannot allocate vsyscall page"); |
| 37 | exit(EXIT_FAILURE); |
| 38 | } |
| 39 | page_set_flags(TARGET_VSYSCALL_PAGE, |
| 40 | TARGET_VSYSCALL_PAGE | ~TARGET_PAGE_MASK, |
| 41 | PAGE_EXEC | PAGE_VALID, PAGE_VALID); |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | void elf_core_copy_regs(target_elf_gregset_t *r, const CPUX86State *env) |
| 46 | { |
| 47 | r->pt.r15 = tswapal(env->regs[15]); |
| 48 | r->pt.r14 = tswapal(env->regs[14]); |
| 49 | r->pt.r13 = tswapal(env->regs[13]); |
| 50 | r->pt.r12 = tswapal(env->regs[12]); |
| 51 | r->pt.bp = tswapal(env->regs[R_EBP]); |
| 52 | r->pt.bx = tswapal(env->regs[R_EBX]); |
| 53 | r->pt.r11 = tswapal(env->regs[11]); |
| 54 | r->pt.r10 = tswapal(env->regs[10]); |
| 55 | r->pt.r9 = tswapal(env->regs[9]); |
| 56 | r->pt.r8 = tswapal(env->regs[8]); |
| 57 | r->pt.ax = tswapal(env->regs[R_EAX]); |
| 58 | r->pt.cx = tswapal(env->regs[R_ECX]); |
| 59 | r->pt.dx = tswapal(env->regs[R_EDX]); |
| 60 | r->pt.si = tswapal(env->regs[R_ESI]); |
| 61 | r->pt.di = tswapal(env->regs[R_EDI]); |
| 62 | r->pt.orig_ax = tswapal(get_task_state(env_cpu_const(env))->orig_ax); |
| 63 | r->pt.ip = tswapal(env->eip); |
| 64 | r->pt.cs = tswapal(env->segs[R_CS].selector & 0xffff); |
| 65 | r->pt.flags = tswapal(env->eflags); |
| 66 | r->pt.sp = tswapal(env->regs[R_ESP]); |
| 67 | r->pt.ss = tswapal(env->segs[R_SS].selector & 0xffff); |
| 68 | r->pt.fs_base = tswapal(env->segs[R_FS].base); |
| 69 | r->pt.gs_base = tswapal(env->segs[R_GS].base); |
| 70 | r->pt.ds = tswapal(env->segs[R_DS].selector & 0xffff); |
| 71 | r->pt.es = tswapal(env->segs[R_ES].selector & 0xffff); |
| 72 | r->pt.fs = tswapal(env->segs[R_FS].selector & 0xffff); |
| 73 | r->pt.gs = tswapal(env->segs[R_GS].selector & 0xffff); |
| 74 | } |