| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include "qemu/osdep.h" |
| 4 | #include "exec/page-protection.h" |
| 5 | #include "qemu.h" |
| 6 | #include "loader.h" |
| 7 | #include "target_elf.h" |
| 8 | |
| 9 | |
| 10 | const char *get_elf_cpu_model(uint32_t eflags) |
| 11 | { |
| 12 | return "pa-7300lc"; |
| 13 | } |
| 14 | |
| 15 | const char *get_elf_platform(CPUState *cs) |
| 16 | { |
| 17 | return "PARISC"; |
| 18 | } |
| 19 | |
| 20 | void elf_core_copy_fpregs(target_elf_fpregset_t *r, const CPUArchState *env) |
| 21 | { |
| 22 | for (int i = 0; i < 32; i++) { |
| 23 | r->fpr[i] = tswap64(env->fr[i]); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | void elf_core_copy_regs(target_elf_gregset_t *r, const CPUArchState *env) |
| 28 | { |
| 29 | int i; |
| 30 | |
| 31 | memset(r, 0, sizeof(*r)); |
| 32 | for (i = 0; i < 32; i++) { |
| 33 | r->gr[i] = tswapal(env->gr[i]); |
| 34 | } |
| 35 | r->iaoq[0] = tswapal(env->iaoq_f); |
| 36 | r->iaoq[1] = tswapal(env->iaoq_b); |
| 37 | r->sar = tswapal(env->cr[CR_SAR]); |
| 38 | } |
| 39 | |
| 40 | bool init_guest_commpage(void) |
| 41 | { |
| 42 | /* If reserved_va, then we have already mapped 0 page on the host. */ |
| 43 | if (!reserved_va) { |
| 44 | void *want, *addr; |
| 45 | |
| 46 | want = g2h_untagged(COMMPAGE); |
| 47 | addr = mmap(want, TARGET_PAGE_SIZE, PROT_NONE, |
| 48 | MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0); |
| 49 | if (addr == MAP_FAILED) { |
| 50 | perror("Allocating guest commpage"); |
| 51 | exit(EXIT_FAILURE); |
| 52 | } |
| 53 | if (addr != want) { |
| 54 | return false; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * On Linux, page zero is normally marked execute only + gateway. |
| 60 | * Normal read or write is supposed to fail (thus PROT_NONE above), |
| 61 | * but specific offsets have kernel code mapped to raise permissions |
| 62 | * and implement syscalls. Here, simply mark the page executable. |
| 63 | * Special case the entry points during translation (see do_page_zero). |
| 64 | */ |
| 65 | page_set_flags(COMMPAGE, COMMPAGE | ~TARGET_PAGE_MASK, |
| 66 | PAGE_EXEC | PAGE_VALID, PAGE_VALID); |
| 67 | return true; |
| 68 | } |