Lines Matching +full:arm +full:- +full:linux +full:- +full:user
2 * qemu user cpu loop
4 * Copyright (c) 2003-2008 Fabrice Bellard
22 #include "user-internals.h"
24 #include "user/cpu_loop.h"
25 #include "signal-common.h"
26 #include "semihosting/common-semi.h"
27 #include "exec/page-protection.h"
28 #include "exec/mmap-lock.h"
29 #include "user/page-protection.h"
30 #include "target/arm/syndrome.h"
46 * Similar to code in accel/tcg/user-exec.c, but outside the execution loop.
48 * We get the PC of the entry address - which is as good as anything,
57 if (unlikely(addr & (size - 1))) { in atomic_mmu_lookup()
74 * See the Linux kernel's Documentation/arm/kernel_user_helpers.rst
81 * r0 = 0 if *ptr was changed, non-0 if no exchange happened
89 oldval = tswap32(env->regs[0]); in arm_kernel_cmpxchg32_helper()
90 newval = tswap32(env->regs[1]); in arm_kernel_cmpxchg32_helper()
91 addr = env->regs[2]; in arm_kernel_cmpxchg32_helper()
105 env->regs[0] = cpsr ? 0 : -1; in arm_kernel_cmpxchg32_helper()
109 * See the Linux kernel's Documentation/arm/kernel_user_helpers.rst
116 * r0 = 0 if *ptr was changed, non-0 if no exchange happened
128 addr = env->regs[0]; in arm_kernel_cmpxchg64_helper()
133 addr = env->regs[1]; in arm_kernel_cmpxchg64_helper()
139 addr = env->regs[2]; in arm_kernel_cmpxchg64_helper()
156 * the host has no 64-bit cmpxchg, it is the best that we can do. in arm_kernel_cmpxchg64_helper()
171 env->regs[0] = cpsr ? 0 : -1; in arm_kernel_cmpxchg64_helper()
186 switch (env->regs[15]) { in do_kernel_trap()
194 env->regs[0] = cpu_get_tls(env); in do_kernel_trap()
204 addr = env->regs[14]; in do_kernel_trap()
206 env->thumb = true; in do_kernel_trap()
209 env->regs[15] = addr; in do_kernel_trap()
224 * Note that we get the two halves of the 32-bit T32 insn in insn_is_linux_bkpt()
235 int rc = EmulateAll(opcode, &ts->fpa, env); in emulate_arm_fpa11()
244 env->regs[15] += 4; in emulate_arm_fpa11()
249 rc = -rc; in emulate_arm_fpa11()
270 enabled = ts->fpa.fpsr >> 16; in emulate_arm_fpa11()
271 ts->fpa.fpsr |= raise & ~enabled; in emulate_arm_fpa11()
282 env->regs[15] += 4; in emulate_arm_fpa11()
307 /* we handle the FPU emulation here, as Linux */ in cpu_loop()
309 /* FIXME - what to do if get_user() fails? */ in cpu_loop()
310 get_user_code_u32(opcode, env->regs[15], env); in cpu_loop()
313 * The Linux kernel treats some UDF patterns specially in cpu_loop()
318 if (insn_is_linux_bkpt(opcode, env->thumb)) { in cpu_loop()
322 if (!env->thumb && emulate_arm_fpa11(env, opcode)) { in cpu_loop()
327 env->regs[15]); in cpu_loop()
332 env->eabi = true; in cpu_loop()
334 if (env->thumb) { in cpu_loop()
336 n = env->regs[7]; in cpu_loop()
340 * Arm SVC insn to extract the immediate, which is the in cpu_loop()
343 /* FIXME - what to do if get_user() fails? */ in cpu_loop()
344 get_user_code_u32(insn, env->regs[15] - 4, env); in cpu_loop()
348 n = env->regs[7]; in cpu_loop()
353 * converted into the correct EABI-style syscall in cpu_loop()
355 * > 0xfffff and are handled below as out-of-range. in cpu_loop()
358 env->eabi = false; in cpu_loop()
366 env->regs[0] = 0; in cpu_loop()
369 cpu_set_tls(env, env->regs[0]); in cpu_loop()
370 env->regs[0] = 0; in cpu_loop()
373 env->regs[15] -= env->thumb ? 2 : 4; in cpu_loop()
376 env->regs[0] = cpu_get_tls(env); in cpu_loop()
383 * to return -ENOSYS rather than raising in cpu_loop()
388 "qemu: Unsupported ARM syscall: 0x%x\n", in cpu_loop()
390 env->regs[0] = -TARGET_ENOSYS; in cpu_loop()
400 abi_ulong faultaddr = env->regs[15]; in cpu_loop()
401 faultaddr -= env->thumb ? 2 : 4; in cpu_loop()
410 env->regs[0], in cpu_loop()
411 env->regs[1], in cpu_loop()
412 env->regs[2], in cpu_loop()
413 env->regs[3], in cpu_loop()
414 env->regs[4], in cpu_loop()
415 env->regs[5], in cpu_loop()
417 if (ret == -QEMU_ERESTARTSYS) { in cpu_loop()
418 env->regs[15] -= env->thumb ? 2 : 4; in cpu_loop()
419 } else if (ret != -QEMU_ESIGRETURN) { in cpu_loop()
420 env->regs[0] = ret; in cpu_loop()
427 env->regs[15] += env->thumb ? 2 : 4; in cpu_loop()
434 /* For user-only we don't set TTBCR_EAE, so look at the FSR. */ in cpu_loop()
435 switch (env->exception.fsr & 0x1f) { in cpu_loop()
457 force_sig_fault(si_signo, si_code, env->exception.vaddress); in cpu_loop()
462 force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[15]); in cpu_loop()
469 /* nothing to do here for user-mode, just resume guest code */ in cpu_loop()
476 EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); in cpu_loop()
487 struct image_info *info = ts->info; in target_cpu_copy_regs()
490 cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC, in target_cpu_copy_regs()
493 env->regs[i] = regs->uregs[i]; in target_cpu_copy_regs()
497 if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4 in target_cpu_copy_regs()
498 && (info->elf_flags & EF_ARM_BE8)) { in target_cpu_copy_regs()
499 env->uncached_cpsr |= CPSR_E; in target_cpu_copy_regs()
500 env->cp15.sctlr_el[1] |= SCTLR_E0E; in target_cpu_copy_regs()
502 env->cp15.sctlr_el[1] |= SCTLR_B; in target_cpu_copy_regs()
507 ts->stack_base = info->start_stack; in target_cpu_copy_regs()
508 ts->heap_base = info->brk; in target_cpu_copy_regs()
510 ts->heap_limit = 0; in target_cpu_copy_regs()