Skip to contentSkip to conversation

linux-user: move arch specific parts to arch directories

PATCH Superseded Laurent Vivier 4 participants 15 messages Mar 22, 2018 – Mar 23, 2018 RISC-V

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover linux-user: move arch specific parts to arch directories

Some files like signal.c are really hard to read because all architectures are mixed in the same file.

This series moves from signal.c these parts to the architecture dedicated directories in linux-user. Moerover, this allows to compare easier functions between architectures (it helps to debug problems). Adding new functions for a new architecture will be facilitated too.

As we are doing that for signal.c, we can also do that for main.c, for the cpu loop part
and the cpu loop prologue too.

checkpatch.pl is not happy... but I only want to move code from a file to another. I don't want to change the content of the parts I move.

Laurent Vivier (5):
linux-user: cleanup signal.c
linux-user: remove unneeded #ifdef in signal.c
linux-user: define TARGET_ARCH_HAS_SETUP_FRAME
linux-user: cleanup cpu_loop()
linux-user: cleanup main()

 linux-user/aarch64/cpu_loop.inc.c    |    1 +
 linux-user/aarch64/prologue.inc.c    |   21 +
 linux-user/aarch64/signal.inc.c      |  557 +++
 linux-user/alpha/cpu_loop.inc.c      |  191 +
 linux-user/alpha/prologue.inc.c      |    9 +
 linux-user/alpha/signal.inc.c        |  259 ++
 linux-user/arm/cpu_loop.inc.c        |  488 +++
 linux-user/arm/prologue.inc.c        |   23 +
 linux-user/arm/signal.inc.c          |  750 ++++
 linux-user/cris/cpu_loop.inc.c       |   67 +
 linux-user/cris/prologue.inc.c       |   19 +
 linux-user/cris/signal.inc.c         |  167 +
 linux-user/hppa/cpu_loop.inc.c       |  178 +
 linux-user/hppa/prologue.inc.c       |    8 +
 linux-user/hppa/signal.inc.c         |  188 +
 linux-user/i386/cpu_loop.inc.c       |  229 ++
 linux-user/i386/prologue.inc.c       |  113 +
 linux-user/i386/signal.inc.c         |  580 +++
 linux-user/m68k/cpu_loop.inc.c       |  115 +
 linux-user/m68k/prologue.inc.c       |   26 +
 linux-user/m68k/signal.inc.c         |  407 +++
 linux-user/main.c                    | 4318 +---------------------
 linux-user/microblaze/cpu_loop.inc.c |  116 +
 linux-user/microblaze/prologue.inc.c |   35 +
 linux-user/microblaze/signal.inc.c   |  227 ++
 linux-user/mips/cpu_loop.inc.c       |  695 ++++
 linux-user/mips/prologue.inc.c       |   25 +
 linux-user/mips/signal.inc.c         |  379 ++
 linux-user/mips64/cpu_loop.inc.c     |    1 +
 linux-user/mips64/prologue.inc.c     |    1 +
 linux-user/mips64/signal.inc.c       |    1 +
 linux-user/nios2/cpu_loop.inc.c      |   98 +
 linux-user/nios2/prologue.inc.c      |   29 +
 linux-user/nios2/signal.inc.c        |  232 ++
 linux-user/openrisc/cpu_loop.inc.c   |   81 +
 linux-user/openrisc/prologue.inc.c   |    9 +
 linux-user/openrisc/signal.inc.c     |  209 ++
 linux-user/ppc/cpu_loop.inc.c        |  538 +++
 linux-user/ppc/prologue.inc.c        |   16 +
 linux-user/ppc/signal.inc.c          |  668 ++++
 linux-user/riscv/cpu_loop.inc.c      |   89 +
 linux-user/riscv/prologue.inc.c      |    4 +
 linux-user/riscv/signal.inc.c        |  196 +
 linux-user/s390x/cpu_loop.inc.c      |  132 +
 linux-user/s390x/prologue.inc.c      |    8 +
 linux-user/s390x/signal.inc.c        |  306 ++
 linux-user/sh4/cpu_loop.inc.c        |   78 +
 linux-user/sh4/prologue.inc.c        |    8 +
 linux-user/sh4/signal.inc.c          |  328 ++
 linux-user/signal.c                  | 6623 +---------------------------------
 linux-user/sparc/cpu_loop.inc.c      |  271 ++
 linux-user/sparc/prologue.inc.c      |   10 +
 linux-user/sparc/signal.inc.c        |  602 +++
 linux-user/sparc64/cpu_loop.inc.c    |    1 +
 linux-user/sparc64/prologue.inc.c    |    1 +
 linux-user/sparc64/signal.inc.c      |    1 +
 linux-user/tilegx/cpu_loop.inc.c     |  251 ++
 linux-user/tilegx/prologue.inc.c     |   10 +
 linux-user/tilegx/signal.inc.c       |  163 +
 linux-user/x86_64/cpu_loop.inc.c     |    1 +
 linux-user/x86_64/prologue.inc.c     |    1 +
 linux-user/x86_64/signal.inc.c       |    1 +
 linux-user/xtensa/cpu_loop.inc.c     |  231 ++
 linux-user/xtensa/prologue.inc.c     |    8 +
 linux-user/xtensa/signal.inc.c       |  253 ++
 65 files changed, 10776 insertions(+), 10875 deletions(-)
 create mode 100644 linux-user/aarch64/cpu_loop.inc.c
 create mode 100644 linux-user/aarch64/prologue.inc.c
 create mode 100644 linux-user/aarch64/signal.inc.c
 create mode 100644 linux-user/alpha/cpu_loop.inc.c
 create mode 100644 linux-user/alpha/prologue.inc.c
 create mode 100644 linux-user/alpha/signal.inc.c
 create mode 100644 linux-user/arm/cpu_loop.inc.c
 create mode 100644 linux-user/arm/prologue.inc.c
 create mode 100644 linux-user/arm/signal.inc.c
 create mode 100644 linux-user/cris/cpu_loop.inc.c
 create mode 100644 linux-user/cris/prologue.inc.c
 create mode 100644 linux-user/cris/signal.inc.c
 create mode 100644 linux-user/hppa/cpu_loop.inc.c
 create mode 100644 linux-user/hppa/prologue.inc.c
 create mode 100644 linux-user/hppa/signal.inc.c
 create mode 100644 linux-user/i386/cpu_loop.inc.c
 create mode 100644 linux-user/i386/prologue.inc.c
 create mode 100644 linux-user/i386/signal.inc.c
 create mode 100644 linux-user/m68k/cpu_loop.inc.c
 create mode 100644 linux-user/m68k/prologue.inc.c
 create mode 100644 linux-user/m68k/signal.inc.c
 create mode 100644 linux-user/microblaze/cpu_loop.inc.c
 create mode 100644 linux-user/microblaze/prologue.inc.c
 create mode 100644 linux-user/microblaze/signal.inc.c
 create mode 100644 linux-user/mips/cpu_loop.inc.c
 create mode 100644 linux-user/mips/prologue.inc.c
 create mode 100644 linux-user/mips/signal.inc.c
 create mode 100644 linux-user/mips64/cpu_loop.inc.c
 create mode 100644 linux-user/mips64/prologue.inc.c
 create mode 100644 linux-user/mips64/signal.inc.c
 create mode 100644 linux-user/nios2/cpu_loop.inc.c
 create mode 100644 linux-user/nios2/prologue.inc.c
 create mode 100644 linux-user/nios2/signal.inc.c
 create mode 100644 linux-user/openrisc/cpu_loop.inc.c
 create mode 100644 linux-user/openrisc/prologue.inc.c
 create mode 100644 linux-user/openrisc/signal.inc.c
 create mode 100644 linux-user/ppc/cpu_loop.inc.c
 create mode 100644 linux-user/ppc/prologue.inc.c
 create mode 100644 linux-user/ppc/signal.inc.c
 create mode 100644 linux-user/riscv/cpu_loop.inc.c
 create mode 100644 linux-user/riscv/prologue.inc.c
 create mode 100644 linux-user/riscv/signal.inc.c
 create mode 100644 linux-user/s390x/cpu_loop.inc.c
 create mode 100644 linux-user/s390x/prologue.inc.c
 create mode 100644 linux-user/s390x/signal.inc.c
 create mode 100644 linux-user/sh4/cpu_loop.inc.c
 create mode 100644 linux-user/sh4/prologue.inc.c
 create mode 100644 linux-user/sh4/signal.inc.c
 create mode 100644 linux-user/sparc/cpu_loop.inc.c
 create mode 100644 linux-user/sparc/prologue.inc.c
 create mode 100644 linux-user/sparc/signal.inc.c
 create mode 100644 linux-user/sparc64/cpu_loop.inc.c
 create mode 100644 linux-user/sparc64/prologue.inc.c
 create mode 100644 linux-user/sparc64/signal.inc.c
 create mode 100644 linux-user/tilegx/cpu_loop.inc.c
 create mode 100644 linux-user/tilegx/prologue.inc.c
 create mode 100644 linux-user/tilegx/signal.inc.c
 create mode 100644 linux-user/x86_64/cpu_loop.inc.c
 create mode 100644 linux-user/x86_64/prologue.inc.c
 create mode 100644 linux-user/x86_64/signal.inc.c
 create mode 100644 linux-user/xtensa/cpu_loop.inc.c
 create mode 100644 linux-user/xtensa/prologue.inc.c
 create mode 100644 linux-user/xtensa/signal.inc.c
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/5 linux-user: cleanup signal.c

move all target specific parts to
signal.inc.c in arch directory

---
 linux-user/aarch64/signal.inc.c    |  556 +++
 linux-user/alpha/signal.inc.c      |  258 ++
 linux-user/arm/signal.inc.c        |  749 +++++
 linux-user/cris/signal.inc.c       |  166 +
 linux-user/hppa/signal.inc.c       |  188 ++
 linux-user/i386/signal.inc.c       |  579 ++++
 linux-user/m68k/signal.inc.c       |  406 +++
 linux-user/microblaze/signal.inc.c |  226 ++
 linux-user/mips/signal.inc.c       |  378 +++
 linux-user/mips64/signal.inc.c     |    1 +
 linux-user/nios2/signal.inc.c      |  232 ++
 linux-user/openrisc/signal.inc.c   |  209 ++
 linux-user/ppc/signal.inc.c        |  667 ++++
 linux-user/riscv/signal.inc.c      |  196 ++
 linux-user/s390x/signal.inc.c      |  305 ++
 linux-user/sh4/signal.inc.c        |  327 ++
 linux-user/signal.c                | 6487 +-----------------------------------
 linux-user/sparc/signal.inc.c      |  601 ++++
 linux-user/sparc64/signal.inc.c    |    1 +
 linux-user/tilegx/signal.inc.c     |  163 +
 linux-user/x86_64/signal.inc.c     |    1 +
 linux-user/xtensa/signal.inc.c     |  253 ++
 22 files changed, 6463 insertions(+), 6486 deletions(-)
 create mode 100644 linux-user/aarch64/signal.inc.c
 create mode 100644 linux-user/alpha/signal.inc.c
 create mode 100644 linux-user/arm/signal.inc.c
 create mode 100644 linux-user/cris/signal.inc.c
 create mode 100644 linux-user/hppa/signal.inc.c
 create mode 100644 linux-user/i386/signal.inc.c
 create mode 100644 linux-user/m68k/signal.inc.c
 create mode 100644 linux-user/microblaze/signal.inc.c
 create mode 100644 linux-user/mips/signal.inc.c
 create mode 100644 linux-user/mips64/signal.inc.c
 create mode 100644 linux-user/nios2/signal.inc.c
 create mode 100644 linux-user/openrisc/signal.inc.c
 create mode 100644 linux-user/ppc/signal.inc.c
 create mode 100644 linux-user/riscv/signal.inc.c
 create mode 100644 linux-user/s390x/signal.inc.c
 create mode 100644 linux-user/sh4/signal.inc.c
 create mode 100644 linux-user/sparc/signal.inc.c
 create mode 100644 linux-user/sparc64/signal.inc.c
 create mode 100644 linux-user/tilegx/signal.inc.c
 create mode 100644 linux-user/x86_64/signal.inc.c
 create mode 100644 linux-user/xtensa/signal.inc.c
linux-user/aarch64/signal.inc.c new file +556 -0
new file mode 100644
index 0000000000..28fa0f2f22
@@ -0,0 +1,556 @@
+struct target_sigcontext {
+    uint64_t fault_address;
+    /* AArch64 registers */
+    uint64_t regs[31];
+    uint64_t sp;
+    uint64_t pc;
+    uint64_t pstate;
+    /* 4K reserved for FP/SIMD state and future expansion */
+    char __reserved[4096] __attribute__((__aligned__(16)));
+};
+
+struct target_ucontext {
+    abi_ulong tuc_flags;
+    abi_ulong tuc_link;
+    target_stack_t tuc_stack;
+    target_sigset_t tuc_sigmask;
+    /* glibc uses a 1024-bit sigset_t */
+    char __unused[1024 / 8 - sizeof(target_sigset_t)];
+    /* last for future expansion */
+    struct target_sigcontext tuc_mcontext;
+};
+
+/*
+ * Header to be used at the beginning of structures extending the user
+ * context. Such structures must be placed after the rt_sigframe on the stack
+ * and be 16-byte aligned. The last structure must be a dummy one with the
+ * magic and size set to 0.
+ */
+struct target_aarch64_ctx {
+    uint32_t magic;
+    uint32_t size;
+};
+
+#define TARGET_FPSIMD_MAGIC 0x46508001
+
+struct target_fpsimd_context {
+    struct target_aarch64_ctx head;
+    uint32_t fpsr;
+    uint32_t fpcr;
+    uint64_t vregs[32 * 2]; /* really uint128_t vregs[32] */
+};
+
+#define TARGET_EXTRA_MAGIC  0x45585401
+
+struct target_extra_context {
+    struct target_aarch64_ctx head;
+    uint64_t datap; /* 16-byte aligned pointer to extra space cast to __u64 */
+    uint32_t size; /* size in bytes of the extra space */
+    uint32_t reserved[3];
+};
+
+#define TARGET_SVE_MAGIC    0x53564501
+
+struct target_sve_context {
+    struct target_aarch64_ctx head;
+    uint16_t vl;
+    uint16_t reserved[3];
+    /* The actual SVE data immediately follows.  It is layed out
+     * according to TARGET_SVE_SIG_{Z,P}REG_OFFSET, based off of
+     * the original struct pointer.
+     */
+};
+
+#define TARGET_SVE_VQ_BYTES  16
+
+#define TARGET_SVE_SIG_ZREG_SIZE(VQ)  ((VQ) * TARGET_SVE_VQ_BYTES)
+#define TARGET_SVE_SIG_PREG_SIZE(VQ)  ((VQ) * (TARGET_SVE_VQ_BYTES / 8))
+
+#define TARGET_SVE_SIG_REGS_OFFSET \
+    QEMU_ALIGN_UP(sizeof(struct target_sve_context), TARGET_SVE_VQ_BYTES)
+#define TARGET_SVE_SIG_ZREG_OFFSET(VQ, N) \
+    (TARGET_SVE_SIG_REGS_OFFSET + TARGET_SVE_SIG_ZREG_SIZE(VQ) * (N))
+#define TARGET_SVE_SIG_PREG_OFFSET(VQ, N) \
+    (TARGET_SVE_SIG_ZREG_OFFSET(VQ, 32) + TARGET_SVE_SIG_PREG_SIZE(VQ) * (N))
+#define TARGET_SVE_SIG_FFR_OFFSET(VQ) \
+    (TARGET_SVE_SIG_PREG_OFFSET(VQ, 16))
+#define TARGET_SVE_SIG_CONTEXT_SIZE(VQ) \
+    (TARGET_SVE_SIG_PREG_OFFSET(VQ, 17))
+
+struct target_rt_sigframe {
+    struct target_siginfo info;
+    struct target_ucontext uc;
+};
+
+struct target_rt_frame_record {
+    uint64_t fp;
+    uint64_t lr;
+    uint32_t tramp[2];
+};
+
+static void target_setup_general_frame(struct target_rt_sigframe *sf,
+                                       CPUARMState *env, target_sigset_t *set)
+{
+    int i;
+
+    __put_user(0, &sf->uc.tuc_flags);
+    __put_user(0, &sf->uc.tuc_link);
+
+    __put_user(target_sigaltstack_used.ss_sp, &sf->uc.tuc_stack.ss_sp);
+    __put_user(sas_ss_flags(env->xregs[31]), &sf->uc.tuc_stack.ss_flags);
+    __put_user(target_sigaltstack_used.ss_size, &sf->uc.tuc_stack.ss_size);
+
+    for (i = 0; i < 31; i++) {
+        __put_user(env->xregs[i], &sf->uc.tuc_mcontext.regs[i]);
+    }
+    __put_user(env->xregs[31], &sf->uc.tuc_mcontext.sp);
+    __put_user(env->pc, &sf->uc.tuc_mcontext.pc);
+    __put_user(pstate_read(env), &sf->uc.tuc_mcontext.pstate);
+
+    __put_user(env->exception.vaddress, &sf->uc.tuc_mcontext.fault_address);
+
+    for (i = 0; i < TARGET_NSIG_WORDS; i++) {
+        __put_user(set->sig[i], &sf->uc.tuc_sigmask.sig[i]);
+    }
+}
+
+static void target_setup_fpsimd_record(struct target_fpsimd_context *fpsimd,
+                                       CPUARMState *env)
+{
+    int i;
+
+    __put_user(TARGET_FPSIMD_MAGIC, &fpsimd->head.magic);
+    __put_user(sizeof(struct target_fpsimd_context), &fpsimd->head.size);
+    __put_user(vfp_get_fpsr(env), &fpsimd->fpsr);
+    __put_user(vfp_get_fpcr(env), &fpsimd->fpcr);
+
+    for (i = 0; i < 32; i++) {
+        uint64_t *q = aa64_vfp_qreg(env, i);
+#ifdef TARGET_WORDS_BIGENDIAN
+        __put_user(q[0], &fpsimd->vregs[i * 2 + 1]);
+        __put_user(q[1], &fpsimd->vregs[i * 2]);
+#else
+        __put_user(q[0], &fpsimd->vregs[i * 2]);
+        __put_user(q[1], &fpsimd->vregs[i * 2 + 1]);
+#endif
+    }
+}
+
+static void target_setup_extra_record(struct target_extra_context *extra,
+                                      uint64_t datap, uint32_t extra_size)
+{
+    __put_user(TARGET_EXTRA_MAGIC, &extra->head.magic);
+    __put_user(sizeof(struct target_extra_context), &extra->head.size);
+    __put_user(datap, &extra->datap);
+    __put_user(extra_size, &extra->size);
+}
+
+static void target_setup_end_record(struct target_aarch64_ctx *end)
+{
+    __put_user(0, &end->magic);
+    __put_user(0, &end->size);
+}
+
+static void target_setup_sve_record(struct target_sve_context *sve,
+                                    CPUARMState *env, int vq, int size)
+{
+    int i, j;
+
+    __put_user(TARGET_SVE_MAGIC, &sve->head.magic);
+    __put_user(size, &sve->head.size);
+    __put_user(vq * TARGET_SVE_VQ_BYTES, &sve->vl);
+
+    /* Note that SVE regs are stored as a byte stream, with each byte element
+     * at a subsequent address.  This corresponds to a little-endian store
+     * of our 64-bit hunks.
+     */
+    for (i = 0; i < 32; ++i) {
+        uint64_t *z = (void *)sve + TARGET_SVE_SIG_ZREG_OFFSET(vq, i);
+        for (j = 0; j < vq * 2; ++j) {
+            __put_user_e(env->vfp.zregs[i].d[j], z + j, le);
+        }
+    }
+    for (i = 0; i <= 16; ++i) {
+        uint16_t *p = (void *)sve + TARGET_SVE_SIG_PREG_OFFSET(vq, i);
+        for (j = 0; j < vq; ++j) {
+            uint64_t r = env->vfp.pregs[i].p[j >> 2];
+            __put_user_e(r >> ((j & 3) * 16), p + j, le);
+        }
+    }
+}
+
+static void target_restore_general_frame(CPUARMState *env,
+                                         struct target_rt_sigframe *sf)
+{
+    sigset_t set;
+    uint64_t pstate;
+    int i;
+
+    target_to_host_sigset(&set, &sf->uc.tuc_sigmask);
+    set_sigmask(&set);
+
+    for (i = 0; i < 31; i++) {
+        __get_user(env->xregs[i], &sf->uc.tuc_mcontext.regs[i]);
+    }
+
+    __get_user(env->xregs[31], &sf->uc.tuc_mcontext.sp);
+    __get_user(env->pc, &sf->uc.tuc_mcontext.pc);
+    __get_user(pstate, &sf->uc.tuc_mcontext.pstate);
+    pstate_write(env, pstate);
+}
+
+static void target_restore_fpsimd_record(CPUARMState *env,
+                                         struct target_fpsimd_context *fpsimd)
+{
+    uint32_t fpsr, fpcr;
+    int i;
+
+    __get_user(fpsr, &fpsimd->fpsr);
+    vfp_set_fpsr(env, fpsr);
+    __get_user(fpcr, &fpsimd->fpcr);
+    vfp_set_fpcr(env, fpcr);
+
+    for (i = 0; i < 32; i++) {
+        uint64_t *q = aa64_vfp_qreg(env, i);
+#ifdef TARGET_WORDS_BIGENDIAN
+        __get_user(q[0], &fpsimd->vregs[i * 2 + 1]);
+        __get_user(q[1], &fpsimd->vregs[i * 2]);
+#else
+        __get_user(q[0], &fpsimd->vregs[i * 2]);
+        __get_user(q[1], &fpsimd->vregs[i * 2 + 1]);
+#endif
+    }
+}
+
+static void target_restore_sve_record(CPUARMState *env,
+                                      struct target_sve_context *sve, int vq)
+{
+    int i, j;
+
+    /* Note that SVE regs are stored as a byte stream, with each byte element
+     * at a subsequent address.  This corresponds to a little-endian load
+     * of our 64-bit hunks.
+     */
+    for (i = 0; i < 32; ++i) {
+        uint64_t *z = (void *)sve + TARGET_SVE_SIG_ZREG_OFFSET(vq, i);
+        for (j = 0; j < vq * 2; ++j) {
+            __get_user_e(env->vfp.zregs[i].d[j], z + j, le);
+        }
+    }
+    for (i = 0; i <= 16; ++i) {
+        uint16_t *p = (void *)sve + TARGET_SVE_SIG_PREG_OFFSET(vq, i);
+        for (j = 0; j < vq; ++j) {
+            uint16_t r;
+            __get_user_e(r, p + j, le);
+            if (j & 3) {
+                env->vfp.pregs[i].p[j >> 2] |= (uint64_t)r << ((j & 3) * 16);
+            } else {
+                env->vfp.pregs[i].p[j >> 2] = r;
+            }
+        }
+    }
+}
+
+static int target_restore_sigframe(CPUARMState *env,
+                                   struct target_rt_sigframe *sf)
+{
+    struct target_aarch64_ctx *ctx, *extra = NULL;
+    struct target_fpsimd_context *fpsimd = NULL;
+    struct target_sve_context *sve = NULL;
+    uint64_t extra_datap = 0;
+    bool used_extra = false;
+    bool err = false;
+    int vq = 0, sve_size = 0;
+
+    target_restore_general_frame(env, sf);
+
+    ctx = (struct target_aarch64_ctx *)sf->uc.tuc_mcontext.__reserved;
+    while (ctx) {
+        uint32_t magic, size, extra_size;
+
+        __get_user(magic, &ctx->magic);
+        __get_user(size, &ctx->size);
+        switch (magic) {
+        case 0:
+            if (size != 0) {
+                err = true;
+                goto exit;
+            }
+            if (used_extra) {
+                ctx = NULL;
+            } else {
+                ctx = extra;
+                used_extra = true;
+            }
+            continue;
+
+        case TARGET_FPSIMD_MAGIC:
+            if (fpsimd || size != sizeof(struct target_fpsimd_context)) {
+                err = true;
+                goto exit;
+            }
+            fpsimd = (struct target_fpsimd_context *)ctx;
+            break;
+
+        case TARGET_SVE_MAGIC:
+            if (arm_feature(env, ARM_FEATURE_SVE)) {
+                vq = (env->vfp.zcr_el[1] & 0xf) + 1;
+                sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16);
+                if (!sve && size == sve_size) {
+                    sve = (struct target_sve_context *)ctx;
+                    break;
+                }
+            }
+            err = true;
+            goto exit;
+
+        case TARGET_EXTRA_MAGIC:
+            if (extra || size != sizeof(struct target_extra_context)) {
+                err = true;
+                goto exit;
+            }
+            __get_user(extra_datap,
+                       &((struct target_extra_context *)ctx)->datap);
+            __get_user(extra_size,
+                       &((struct target_extra_context *)ctx)->size);
+            extra = lock_user(VERIFY_READ, extra_datap, extra_size, 0);
+            break;
+
+        default:
+            /* Unknown record -- we certainly didn't generate it.
+             * Did we in fact get out of sync?
+             */
+            err = true;
+            goto exit;
+        }
+        ctx = (void *)ctx + size;
+    }
+
+    /* Require FPSIMD always.  */
+    if (fpsimd) {
+        target_restore_fpsimd_record(env, fpsimd);
+    } else {
+        err = true;
+    }
+
+    /* SVE data, if present, overwrites FPSIMD data.  */
+    if (sve) {
+        target_restore_sve_record(env, sve, vq);
+    }
+
+ exit:
+    unlock_user(extra, extra_datap, 0);
+    return err;
+}
+
+static abi_ulong get_sigframe(struct target_sigaction *ka,
+                              CPUARMState *env, int size)
+{
+    abi_ulong sp;
+
+    sp = env->xregs[31];
+
+    /*
+     * This is the X/Open sanctioned signal stack switching.
+     */
+    if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) {
+        sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+    }
+
+    sp = (sp - size) & ~15;
+
+    return sp;
+}
+
+typedef struct {
+    int total_size;
+    int extra_base;
+    int extra_size;
+    int std_end_ofs;
+    int extra_ofs;
+    int extra_end_ofs;
+} target_sigframe_layout;
+
+static int alloc_sigframe_space(int this_size, target_sigframe_layout *l)
+{
+    /* Make sure there will always be space for the end marker.  */
+    const int std_size = sizeof(struct target_rt_sigframe)
+                         - sizeof(struct target_aarch64_ctx);
+    int this_loc = l->total_size;
+
+    if (l->extra_base) {
+        /* Once we have begun an extra space, all allocations go there.  */
+        l->extra_size += this_size;
+    } else if (this_size + this_loc > std_size) {
+        /* This allocation does not fit in the standard space.  */
+        /* Allocate the extra record.  */
+        l->extra_ofs = this_loc;
+        l->total_size += sizeof(struct target_extra_context);
+
+        /* Allocate the standard end record.  */
+        l->std_end_ofs = l->total_size;
+        l->total_size += sizeof(struct target_aarch64_ctx);
+
+        /* Allocate the requested record.  */
+        l->extra_base = this_loc = l->total_size;
+        l->extra_size = this_size;
+    }
+    l->total_size += this_size;
+
+    return this_loc;
+}
+
+static void target_setup_frame(int usig, struct target_sigaction *ka,
+                               target_siginfo_t *info, target_sigset_t *set,
+                               CPUARMState *env)
+{
+    target_sigframe_layout layout = {
+        /* Begin with the size pointing to the reserved space.  */
+        .total_size = offsetof(struct target_rt_sigframe,
+                               uc.tuc_mcontext.__reserved),
+    };
+    int fpsimd_ofs, fr_ofs, sve_ofs = 0, vq = 0, sve_size = 0;
+    struct target_rt_sigframe *frame;
+    struct target_rt_frame_record *fr;
+    abi_ulong frame_addr, return_addr;
+
+    /* FPSIMD record is always in the standard space.  */
+    fpsimd_ofs = alloc_sigframe_space(sizeof(struct target_fpsimd_context),
+                                      &layout);
+
+    /* SVE state needs saving only if it exists.  */
+    if (arm_feature(env, ARM_FEATURE_SVE)) {
+        vq = (env->vfp.zcr_el[1] & 0xf) + 1;
+        sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16);
+        sve_ofs = alloc_sigframe_space(sve_size, &layout);
+    }
+
+    if (layout.extra_ofs) {
+        /* Reserve space for the extra end marker.  The standard end marker
+         * will have been allocated when we allocated the extra record.
+         */
+        layout.extra_end_ofs
+            = alloc_sigframe_space(sizeof(struct target_aarch64_ctx), &layout);
+    } else {
+        /* Reserve space for the standard end marker.
+         * Do not use alloc_sigframe_space because we cheat
+         * std_size therein to reserve space for this.
+         */
+        layout.std_end_ofs = layout.total_size;
+        layout.total_size += sizeof(struct target_aarch64_ctx);
+    }
+
+    /* Reserve space for the return code.  On a real system this would
+     * be within the VDSO.  So, despite the name this is not a "real"
+     * record within the frame.
+     */
+    fr_ofs = layout.total_size;
+    layout.total_size += sizeof(struct target_rt_frame_record);
+
+    frame_addr = get_sigframe(ka, env, layout.total_size);
+    trace_user_setup_frame(env, frame_addr);
+    if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
+        goto give_sigsegv;
+    }
+
+    target_setup_general_frame(frame, env, set);
+    target_setup_fpsimd_record((void *)frame + fpsimd_ofs, env);
+    target_setup_end_record((void *)frame + layout.std_end_ofs);
+    if (layout.extra_ofs) {
+        target_setup_extra_record((void *)frame + layout.extra_ofs,
+                                  frame_addr + layout.extra_base,
+                                  layout.extra_size);
+        target_setup_end_record((void *)frame + layout.extra_end_ofs);
+    }
+    if (sve_ofs) {
+        target_setup_sve_record((void *)frame + sve_ofs, env, vq, sve_size);
+    }
+
+    /* Set up the stack frame for unwinding.  */
+    fr = (void *)frame + fr_ofs;
+    __put_user(env->xregs[29], &fr->fp);
+    __put_user(env->xregs[30], &fr->lr);
+
+    if (ka->sa_flags & TARGET_SA_RESTORER) {
+        return_addr = ka->sa_restorer;
+    } else {
+        /*
+         * mov x8,#__NR_rt_sigreturn; svc #0
+         * Since these are instructions they need to be put as little-endian
+         * regardless of target default or current CPU endianness.
+         */
+        __put_user_e(0xd2801168, &fr->tramp[0], le);
+        __put_user_e(0xd4000001, &fr->tramp[1], le);
+        return_addr = frame_addr + fr_ofs
+            + offsetof(struct target_rt_frame_record, tramp);
+    }
+    env->xregs[0] = usig;
+    env->xregs[31] = frame_addr;
+    env->xregs[29] = frame_addr + fr_ofs;
+    env->pc = ka->_sa_handler;
+    env->xregs[30] = return_addr;
+    if (info) {
+        tswap_siginfo(&frame->info, info);
+        env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info);
+        env->xregs[2] = frame_addr + offsetof(struct target_rt_sigframe, uc);
+    }
+
+    unlock_user_struct(frame, frame_addr, 1);
+    return;
+
+ give_sigsegv:
+    unlock_user_struct(frame, frame_addr, 1);
+    force_sigsegv(usig);
+}
+
+static void setup_rt_frame(int sig, struct target_sigaction *ka,
+                           target_siginfo_t *info, target_sigset_t *set,
+                           CPUARMState *env)
+{
+    target_setup_frame(sig, ka, info, set, env);
+}
+
+static void setup_frame(int sig, struct target_sigaction *ka,
+                        target_sigset_t *set, CPUARMState *env)
+{
+    target_setup_frame(sig, ka, 0, set, env);
+}
+
+long do_rt_sigreturn(CPUARMState *env)
+{
+    struct target_rt_sigframe *frame = NULL;
+    abi_ulong frame_addr = env->xregs[31];
+
+    trace_user_do_rt_sigreturn(env, frame_addr);
+    if (frame_addr & 15) {
+        goto badframe;
+    }
+
+    if  (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
+        goto badframe;
+    }
+
+    if (target_restore_sigframe(env, frame)) {
+        goto badframe;
+    }
+
+    if (do_sigaltstack(frame_addr +
+            offsetof(struct target_rt_sigframe, uc.tuc_stack),
+            0, get_sp_from_cpustate(env)) == -EFAULT) {
+        goto badframe;
+    }
+
+    unlock_user_struct(frame, frame_addr, 0);
+    return -TARGET_QEMU_ESIGRETURN;
+
+ badframe:
+    unlock_user_struct(frame, frame_addr, 0);
+    force_sig(TARGET_SIGSEGV);
+    return -TARGET_QEMU_ESIGRETURN;
+}
+
+long do_sigreturn(CPUARMState *env)
+{
+    return do_rt_sigreturn(env);
+}
+
linux-user/alpha/signal.inc.c new file +258 -0

258 lines not on this page · raw message

linux-user/arm/signal.inc.c new file +749 -0

749 lines not on this page · raw message

linux-user/cris/signal.inc.c new file +166 -0

166 lines not on this page · raw message

linux-user/hppa/signal.inc.c new file +188 -0

188 lines not on this page · raw message

linux-user/i386/signal.inc.c new file +579 -0

579 lines not on this page · raw message

linux-user/m68k/signal.inc.c new file +406 -0

406 lines not on this page · raw message

linux-user/microblaze/signal.inc.c new file +226 -0

98 lines not on this page · raw message

linux-user/mips/signal.inc.c new file +378 -0

378 lines not on this page · raw message

linux-user/mips64/signal.inc.c new file +1 -0
new file mode 100644
index 0000000000..9ab0afa7a8

Lines of this file are not shown. View the raw message.

linux-user/nios2/signal.inc.c new file +232 -0

232 lines not on this page · raw message

linux-user/openrisc/signal.inc.c new file +209 -0

209 lines not on this page · raw message

linux-user/ppc/signal.inc.c new file +667 -0

667 lines not on this page · raw message

linux-user/riscv/signal.inc.c new file +196 -0

196 lines not on this page · raw message

linux-user/s390x/signal.inc.c new file +305 -0

305 lines not on this page · raw message

linux-user/sh4/signal.inc.c new file +327 -0

327 lines not on this page · raw message

linux-user/signal.c +1 -6486

6,487 lines not on this page · raw message

linux-user/sparc/signal.inc.c new file +601 -0

601 lines not on this page · raw message

linux-user/sparc64/signal.inc.c new file +1 -0
new file mode 100644
index 0000000000..4fac07ea26

Lines of this file are not shown. View the raw message.

linux-user/tilegx/signal.inc.c new file +163 -0

163 lines not on this page · raw message

linux-user/x86_64/signal.inc.c new file +1 -0
new file mode 100644
index 0000000000..902efa8186

Lines of this file are not shown. View the raw message.

linux-user/xtensa/signal.inc.c new file +253 -0

253 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.14.3

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [Qemu-devel] [PATCH for 2.13 1/5] linux-user: cleanup signal.c

Quoted 20 lines · Laurent Vivier

move all target specific parts to
signal.inc.c in arch directory

---
 linux-user/aarch64/signal.inc.c    |  556 +++
 linux-user/alpha/signal.inc.c      |  258 ++
 linux-user/arm/signal.inc.c        |  749 +++++
 linux-user/cris/signal.inc.c       |  166 +
 linux-user/hppa/signal.inc.c       |  188 ++
 linux-user/i386/signal.inc.c       |  579 ++++
 linux-user/m68k/signal.inc.c       |  406 +++
 linux-user/microblaze/signal.inc.c |  226 ++
 linux-user/mips/signal.inc.c       |  378 +++
 linux-user/mips64/signal.inc.c     |    1 +
 linux-user/nios2/signal.inc.c      |  232 ++
 linux-user/openrisc/signal.inc.c   |  209 ++
 linux-user/ppc/signal.inc.c        |  667 ++++
 linux-user/riscv/signal.inc.c      |  196 ++
 linux-user/s390x/signal.inc.c      |  305 ++
Quoted 8 lines
 linux-user/sh4/signal.inc.c        |  327 ++
 linux-user/signal.c                | 6487 +-----------------------------------
 linux-user/sparc/signal.inc.c      |  601 ++++
 linux-user/sparc64/signal.inc.c    |    1 +
 linux-user/tilegx/signal.inc.c     |  163 +
 linux-user/x86_64/signal.inc.c     |    1 +
 linux-user/xtensa/signal.inc.c     |  253 ++
 22 files changed, 6463 insertions(+), 6486 deletions(-)

I think anything with a diffstat like this is basically unreviewable, at least for me :-(

linux-user/aarch64/signal.inc.c

Quoted 5 lines
linux-user/aarch64/signal.inc.c new file +0 -0
new file mode 100644
index 0000000000..28fa0f2f22

I was hoping we could have these be standalone .c files, rather than just #included from linux-user/signal.c. I appreciate this requires a bit more teasing out of what needs to become non-static in the common code signal.c to be callable from the per-target code, though.

linux-user/aarch64/signal.inc.c line 1

Quoted 2 lines
linux-user/aarch64/signal.inc.c new file +1 -0
@@ -0,0 +1,556 @@
+struct target_sigcontext {

New source files should all have the usual sort of comment header with a copyright and license statement.

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH for 2.13 1/5] linux-user: cleanup signal.c

Le 23/03/2018 à 15:22, Peter Maydell a écrit :

Quoted 33 lines · Laurent Vivier
Quoted 20 lines

move all target specific parts to
signal.inc.c in arch directory

---
 linux-user/aarch64/signal.inc.c    |  556 +++
 linux-user/alpha/signal.inc.c      |  258 ++
 linux-user/arm/signal.inc.c        |  749 +++++
 linux-user/cris/signal.inc.c       |  166 +
 linux-user/hppa/signal.inc.c       |  188 ++
 linux-user/i386/signal.inc.c       |  579 ++++
 linux-user/m68k/signal.inc.c       |  406 +++
 linux-user/microblaze/signal.inc.c |  226 ++
 linux-user/mips/signal.inc.c       |  378 +++
 linux-user/mips64/signal.inc.c     |    1 +
 linux-user/nios2/signal.inc.c      |  232 ++
 linux-user/openrisc/signal.inc.c   |  209 ++
 linux-user/ppc/signal.inc.c        |  667 ++++
 linux-user/riscv/signal.inc.c      |  196 ++
 linux-user/s390x/signal.inc.c      |  305 ++
Quoted 8 lines
 linux-user/sh4/signal.inc.c        |  327 ++
 linux-user/signal.c                | 6487 +-----------------------------------
 linux-user/sparc/signal.inc.c      |  601 ++++
 linux-user/sparc64/signal.inc.c    |    1 +
 linux-user/tilegx/signal.inc.c     |  163 +
 linux-user/x86_64/signal.inc.c     |    1 +
 linux-user/xtensa/signal.inc.c     |  253 ++
 22 files changed, 6463 insertions(+), 6486 deletions(-)

I think anything with a diffstat like this is basically unreviewable, at least for me :-(

Quoted 12 lines

linux-user/aarch64/signal.inc.c

Quoted 5 lines
linux-user/aarch64/signal.inc.c new file +0 -0
new file mode 100644
index 0000000000..28fa0f2f22

I was hoping we could have these be standalone .c files, rather than just #included from linux-user/signal.c. I appreciate this requires a bit more teasing out of what needs to become non-static in the common code signal.c to be callable from the per-target code, though.

Thank you for your review.

I tried the easy way first... but I'm going to try to do standalone c files.

Thanks,
Laurent

#4 lore raw

Re: [Qemu-devel] [PATCH for 2.13 1/5] linux-user: cleanup signal.c

Quoted 47 lines · Laurent Vivier
Quoted 33 lines · Peter Maydell
Quoted 20 lines · Laurent Vivier

move all target specific parts to
signal.inc.c in arch directory

---
 linux-user/aarch64/signal.inc.c    |  556 +++
 linux-user/alpha/signal.inc.c      |  258 ++
 linux-user/arm/signal.inc.c        |  749 +++++
 linux-user/cris/signal.inc.c       |  166 +
 linux-user/hppa/signal.inc.c       |  188 ++
 linux-user/i386/signal.inc.c       |  579 ++++
 linux-user/m68k/signal.inc.c       |  406 +++
 linux-user/microblaze/signal.inc.c |  226 ++
 linux-user/mips/signal.inc.c       |  378 +++
 linux-user/mips64/signal.inc.c     |    1 +
 linux-user/nios2/signal.inc.c      |  232 ++
 linux-user/openrisc/signal.inc.c   |  209 ++
 linux-user/ppc/signal.inc.c        |  667 ++++
 linux-user/riscv/signal.inc.c      |  196 ++
 linux-user/s390x/signal.inc.c      |  305 ++
Quoted 8 lines
 linux-user/sh4/signal.inc.c        |  327 ++
 linux-user/signal.c                | 6487 +-----------------------------------
 linux-user/sparc/signal.inc.c      |  601 ++++
 linux-user/sparc64/signal.inc.c    |    1 +
 linux-user/tilegx/signal.inc.c     |  163 +
 linux-user/x86_64/signal.inc.c     |    1 +
 linux-user/xtensa/signal.inc.c     |  253 ++
 22 files changed, 6463 insertions(+), 6486 deletions(-)

I think anything with a diffstat like this is basically unreviewable, at least for me :-(

Quoted 12 lines

linux-user/aarch64/signal.inc.c

Quoted 5 lines
linux-user/aarch64/signal.inc.c new file +0 -0
new file mode 100644
index 0000000000..28fa0f2f22

I was hoping we could have these be standalone .c files, rather than just #included from linux-user/signal.c. I appreciate this requires a bit more teasing out of what needs to become non-static in the common code signal.c to be callable from the per-target code, though.

Quoted 3 lines

Thank you for your review.

I tried the easy way first... but I'm going to try to do standalone c files.

Structuring your patchset so it can move one architecture at a time out ouf the common file will probably help in making the patch more reviewable, though it's likely a bit more painful to do.

I think at the time I was looking at this I was contemplating an approach like:
(1) for architecture A, move that arch's code from signal.c to $ARCH/signal.c, and temporarily use a #include to include it from signal.c
(2) repeat for architectures B, C, ..., one per patch
(3) make the makefile and code changes needed to drop the #includes and build $ARCH/signal.c as standalone files, as a final patch

and note in the commit messages for the 1, 2... patches that they're purely code movement with no textual changes.

thanks
-- PMM

#5 lore raw

PATCH 2/5 linux-user: remove unneeded #ifdef in signal.c

In reply to Laurent Vivier
---
 linux-user/signal.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
linux-user/signal.c +2 -7
index 2c08ca14cf..514145b299 100644
@@ -253,17 +253,15 @@ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
     return 0;
 }
 
-#if !defined(TARGET_OPENRISC) && !defined(TARGET_NIOS2)
 /* Just set the guest's signal mask to the specified value; the
  * caller is assumed to have called block_signals() already.
  */
-static void set_sigmask(const sigset_t *set)
+static __attribute__((unused)) void set_sigmask(const sigset_t *set)
 {
     TaskState *ts = (TaskState *)thread_cpu->opaque;
 
     ts->signal_mask = *set;
 }
-#endif
 
 /* siginfo conversion */
 
@@ -533,8 +531,7 @@ static void force_sig(int sig)
  * up the signal frame. oldsig is the signal we were trying to handle
  * at the point of failure.
  */
-#if !defined(TARGET_RISCV)
-static void force_sigsegv(int oldsig)
+static __attribute__((unused)) void force_sigsegv(int oldsig)
 {
     if (oldsig == SIGSEGV) {
         /* Make sure we don't try to deliver the signal again; this will
@@ -545,8 +542,6 @@ static void force_sigsegv(int oldsig)
     force_sig(TARGET_SIGSEGV);
 }
 
-#endif
-
 /* abort execution with signal */
 static void QEMU_NORETURN dump_core_and_abort(int target_sig)
 {
Signature · 1 line
2.14.3
#6 lore raw

Re: [Qemu-devel] [PATCH for 2.13 2/5] linux-user: remove unneeded #ifdef in signal.c

Quoted 39 lines · Laurent Vivier
---
 linux-user/signal.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
linux-user/signal.c +2 -5
index 2c08ca14cf..514145b299 100644
@@ -253,17 +253,15 @@ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
     return 0;
 }
 
-#if !defined(TARGET_OPENRISC) && !defined(TARGET_NIOS2)
 /* Just set the guest's signal mask to the specified value; the
  * caller is assumed to have called block_signals() already.
  */
-static void set_sigmask(const sigset_t *set)
+static __attribute__((unused)) void set_sigmask(const sigset_t *set)
 {
     TaskState *ts = (TaskState *)thread_cpu->opaque;
 
     ts->signal_mask = *set;
 }
-#endif
 
 /* siginfo conversion */
 
@@ -533,8 +531,7 @@ static void force_sig(int sig)
  * up the signal frame. oldsig is the signal we were trying to handle
  * at the point of failure.
  */
-#if !defined(TARGET_RISCV)
-static void force_sigsegv(int oldsig)
+static __attribute__((unused)) void force_sigsegv(int oldsig)
 {
     if (oldsig == SIGSEGV) {
         /* Make sure we don't try to deliver the signal again; this will

linux-user/signal.c static void force_sigsegv(int oldsig) · line 547

Quoted 8 lines
linux-user/signal.c +0 -2
@@ -545,8 +542,6 @@ static void force_sigsegv(int oldsig)
     force_sig(TARGET_SIGSEGV);
 }
 
-#endif
-
 /* abort execution with signal */
 static void QEMU_NORETURN dump_core_and_abort(int target_sig)
 {

I don't think this is the right approach. In both of these cases, the fact that the function is unused is a red flag that there is a bug in the signal emulation code for those guest CPUs. If the guest CPU code isn't calling set_sigmask() it is failing to correctly handle the sigmask field in the ucontext on signal return, and if it's not calling force_sigsegv() then it's doing something wrong with the handling of "we couldn't write to the signal frame" on signal entry.

I think it's worth keeping the #ifdef as a flag and a list of what targets we need to fix.

(The "riscv isn't using force_sigsegv()" fix looks like it should be trivial -- their setup_rt_frame() has the code path but it's incorrectly trying to do this by hand rather than calling force_sigsegv().)

thanks
-- PMM

#7 lore raw

PATCH 3/5 linux-user: define TARGET_ARCH_HAS_SETUP_FRAME

In reply to Laurent Vivier

instead of calling setup_frame() conditionnaly to a list of knowm targets, define TARGET_ARCH_HAS_SETUP_FRAME if the target provides the function and call it only if the macro is defined

---
 linux-user/aarch64/signal.inc.c    |  1 +
 linux-user/alpha/signal.inc.c      |  1 +
 linux-user/arm/signal.inc.c        |  1 +
 linux-user/cris/signal.inc.c       |  1 +
 linux-user/i386/signal.inc.c       |  1 +
 linux-user/m68k/signal.inc.c       |  1 +
 linux-user/microblaze/signal.inc.c |  1 +
 linux-user/mips/signal.inc.c       |  1 +
 linux-user/ppc/signal.inc.c        |  1 +
 linux-user/s390x/signal.inc.c      |  1 +
 linux-user/sh4/signal.inc.c        |  1 +
 linux-user/signal.c                | 11 +++--------
 linux-user/sparc/signal.inc.c      |  1 +
 13 files changed, 15 insertions(+), 8 deletions(-)
linux-user/aarch64/signal.inc.c +1 -0
index 28fa0f2f22..369741eae1 100644
@@ -510,6 +510,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
     target_setup_frame(sig, ka, info, set, env);
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUARMState *env)
 {
linux-user/alpha/signal.inc.c +1 -0
index 52e379e214..5910a70ac6 100644
@@ -103,6 +103,7 @@ static inline abi_ulong get_sigframe(struct target_sigaction *sa,
     return (sp - framesize) & -32;
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUAlphaState *env)
 {
linux-user/arm/signal.inc.c +1 -0
index 1d6f9a1f7f..ecca4f2e7b 100644
@@ -334,6 +334,7 @@ sigsegv:
     force_sigsegv(usig);
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int usig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUARMState *regs)
 {
linux-user/cris/signal.inc.c +1 -0
index 3f68793727..d910eb5257 100644
@@ -74,6 +74,7 @@ static abi_ulong get_sigframe(CPUCRISState *env, int framesize)
     return sp - framesize;
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUCRISState *env)
 {
linux-user/i386/signal.inc.c +1 -0
index c522c449ae..8695806da9 100644
@@ -289,6 +289,7 @@ get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size)
 
 #ifndef TARGET_X86_64
 /* compare linux/arch/i386/kernel/signal.c:setup_frame() */
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUX86State *env)
 {
linux-user/m68k/signal.inc.c +1 -0
index 07db1cdeda..eabd4849e4 100644
@@ -106,6 +106,7 @@ get_sigframe(struct target_sigaction *ka, CPUM68KState *regs,
     return ((sp - frame_size) & -8UL);
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUM68KState *env)
 {
linux-user/microblaze/signal.inc.c +1 -0
index 728bd33273..b0db5ab8c4 100644
@@ -117,6 +117,7 @@ static abi_ulong get_sigframe(struct target_sigaction *ka,
     return ((sp - frame_size) & -8UL);
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUMBState *env)
 {
linux-user/mips/signal.inc.c +1 -0
index 19e5b3aad4..76e7ad77c2 100644
@@ -185,6 +185,7 @@ static void mips_set_hflags_isa_mode_from_pc(CPUMIPSState *env)
 
 # if defined(TARGET_ABI_MIPSO32)
 /* compare linux/arch/mips/kernel/signal.c:setup_frame() */
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction * ka,
                         target_sigset_t *set, CPUMIPSState *regs)
 {
linux-user/ppc/signal.inc.c +1 -0
index ea3ee45202..1aaef0dbd8 100644
@@ -411,6 +411,7 @@ static void restore_user_regs(CPUPPCState *env,
 }
 
 #if !defined(TARGET_PPC64)
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUPPCState *env)
 {
linux-user/s390x/signal.inc.c +1 -0
index d0f362084f..3c17bdea0b 100644
@@ -108,6 +108,7 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)
     }
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUS390XState *env)
 {
linux-user/sh4/signal.inc.c +1 -0
index 4c6369bbdb..496e6aef60 100644
@@ -143,6 +143,7 @@ static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc)
     regs->flags &= ~(DELAY_SLOT_MASK | GUSA_MASK);
 }
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUSH4State *regs)
 {
linux-user/signal.c +3 -8
index 514145b299..6bd5f136c3 100644
@@ -886,18 +886,13 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,
         }
 #endif
         /* prepare the stack frame of the virtual CPU */
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \
-        || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
-        || defined(TARGET_PPC64) || defined(TARGET_HPPA) \
-        || defined(TARGET_NIOS2) || defined(TARGET_X86_64) \
-        || defined(TARGET_RISCV) || defined(TARGET_XTENSA)
-        /* These targets do not have traditional signals.  */
-        setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
-#else
+#if defined(TARGET_ARCH_HAS_SETUP_FRAME)
         if (sa->sa_flags & TARGET_SA_SIGINFO)
             setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
         else
             setup_frame(sig, sa, &target_old_set, cpu_env);
+#else
+        setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
 #endif
         if (sa->sa_flags & TARGET_SA_RESETHAND) {
             sa->_sa_handler = TARGET_SIG_DFL;
linux-user/sparc/signal.inc.c +1 -0
index fe5ab902f6..186376d240 100644
@@ -153,6 +153,7 @@ setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
 #endif
 #define NF_ALIGNEDSZ  (((sizeof(struct target_signal_frame) + 7) & (~7)))
 
+#define TARGET_ARCH_HAS_SETUP_FRAME
 static void setup_frame(int sig, struct target_sigaction *ka,
                         target_sigset_t *set, CPUSPARCState *env)
 {
Signature · 1 line
2.14.3
Reviewed-by on v1 3/5
#8 lore raw

Re: [Qemu-devel] [PATCH for 2.13 3/5] linux-user: define TARGET_ARCH_HAS_SETUP_FRAME

Quoted 1 line · Laurent Vivier

instead of calling setup_frame() conditionnaly to a list of knowm targets,

"Instead". "conditionally". "known".

Quoted 2 lines

define TARGET_ARCH_HAS_SETUP_FRAME if the target provides the function and call it only if the macro is defined

Trailing ".".

Quoted 18 lines

---

linux-user/signal.c +0 -8
@@ -886,18 +886,13 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,
         }
 #endif
         /* prepare the stack frame of the virtual CPU */
-#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \
-        || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) \
-        || defined(TARGET_PPC64) || defined(TARGET_HPPA) \
-        || defined(TARGET_NIOS2) || defined(TARGET_X86_64) \
-        || defined(TARGET_RISCV) || defined(TARGET_XTENSA)
-        /* These targets do not have traditional signals.  */
-        setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
-#else

linux-user/signal.c static void handle_pending_signal(CPUArchState *cpu_env, int sig, · line 898

Quoted 10 lines
linux-user/signal.c +3 -0
+#if defined(TARGET_ARCH_HAS_SETUP_FRAME)
         if (sa->sa_flags & TARGET_SA_SIGINFO)
             setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
         else
             setup_frame(sig, sa, &target_old_set, cpu_env);
+#else
+        setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env);
 #endif
         if (sa->sa_flags & TARGET_SA_RESETHAND) {
             sa->_sa_handler = TARGET_SIG_DFL;

You might like to add the {} to the if (sa->sa_flags...) while we're here.

Either way,

thanks
-- PMM

#9 lore raw

PATCH 4/5 linux-user: cleanup cpu_loop()

In reply to Laurent Vivier

move all target specific cpu_loop parts to
cpu_loop.inc.c in arch directory

---
 linux-user/aarch64/cpu_loop.inc.c    |    1 +
 linux-user/alpha/cpu_loop.inc.c      |  191 ++
 linux-user/arm/cpu_loop.inc.c        |  488 +++++
 linux-user/cris/cpu_loop.inc.c       |   67 +
 linux-user/hppa/cpu_loop.inc.c       |  178 ++
 linux-user/i386/cpu_loop.inc.c       |  229 ++
 linux-user/m68k/cpu_loop.inc.c       |  115 +
 linux-user/main.c                    | 3918 +---------------------------------
 linux-user/microblaze/cpu_loop.inc.c |  116 +
 linux-user/mips/cpu_loop.inc.c       |  695 ++++++
 linux-user/mips64/cpu_loop.inc.c     |    1 +
 linux-user/nios2/cpu_loop.inc.c      |   98 +
 linux-user/openrisc/cpu_loop.inc.c   |   81 +
 linux-user/ppc/cpu_loop.inc.c        |  538 +++++
 linux-user/riscv/cpu_loop.inc.c      |   89 +
 linux-user/s390x/cpu_loop.inc.c      |  132 ++
 linux-user/sh4/cpu_loop.inc.c        |   78 +
 linux-user/sparc/cpu_loop.inc.c      |  271 +++
 linux-user/sparc64/cpu_loop.inc.c    |    1 +
 linux-user/tilegx/cpu_loop.inc.c     |  251 +++
 linux-user/x86_64/cpu_loop.inc.c     |    1 +
 linux-user/xtensa/cpu_loop.inc.c     |  231 ++
 22 files changed, 3853 insertions(+), 3917 deletions(-)
 create mode 100644 linux-user/aarch64/cpu_loop.inc.c
 create mode 100644 linux-user/alpha/cpu_loop.inc.c
 create mode 100644 linux-user/arm/cpu_loop.inc.c
 create mode 100644 linux-user/cris/cpu_loop.inc.c
 create mode 100644 linux-user/hppa/cpu_loop.inc.c
 create mode 100644 linux-user/i386/cpu_loop.inc.c
 create mode 100644 linux-user/m68k/cpu_loop.inc.c
 create mode 100644 linux-user/microblaze/cpu_loop.inc.c
 create mode 100644 linux-user/mips/cpu_loop.inc.c
 create mode 100644 linux-user/mips64/cpu_loop.inc.c
 create mode 100644 linux-user/nios2/cpu_loop.inc.c
 create mode 100644 linux-user/openrisc/cpu_loop.inc.c
 create mode 100644 linux-user/ppc/cpu_loop.inc.c
 create mode 100644 linux-user/riscv/cpu_loop.inc.c
 create mode 100644 linux-user/s390x/cpu_loop.inc.c
 create mode 100644 linux-user/sh4/cpu_loop.inc.c
 create mode 100644 linux-user/sparc/cpu_loop.inc.c
 create mode 100644 linux-user/sparc64/cpu_loop.inc.c
 create mode 100644 linux-user/tilegx/cpu_loop.inc.c
 create mode 100644 linux-user/x86_64/cpu_loop.inc.c
 create mode 100644 linux-user/xtensa/cpu_loop.inc.c
linux-user/aarch64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..a9a57861e7
@@ -0,0 +1 @@
+#include "../arm/cpu_loop.inc.c"
linux-user/alpha/cpu_loop.inc.c new file +191 -0

191 lines not on this page · raw message

linux-user/arm/cpu_loop.inc.c new file +488 -0

488 lines not on this page · raw message

linux-user/cris/cpu_loop.inc.c new file +67 -0

67 lines not on this page · raw message

linux-user/hppa/cpu_loop.inc.c new file +178 -0

178 lines not on this page · raw message

linux-user/i386/cpu_loop.inc.c new file +229 -0

229 lines not on this page · raw message

linux-user/m68k/cpu_loop.inc.c new file +115 -0

115 lines not on this page · raw message

linux-user/main.c +1 -3917

1,731 lines not on this page · raw message

linux-user/microblaze/cpu_loop.inc.c new file +116 -0

116 lines not on this page · raw message

linux-user/mips/cpu_loop.inc.c new file +695 -0

695 lines not on this page · raw message

linux-user/mips64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..0eb0f9572a

Lines of this file are not shown. View the raw message.

linux-user/nios2/cpu_loop.inc.c new file +98 -0

98 lines not on this page · raw message

linux-user/openrisc/cpu_loop.inc.c new file +81 -0

81 lines not on this page · raw message

linux-user/ppc/cpu_loop.inc.c new file +538 -0

538 lines not on this page · raw message

linux-user/riscv/cpu_loop.inc.c new file +89 -0

89 lines not on this page · raw message

linux-user/s390x/cpu_loop.inc.c new file +132 -0

132 lines not on this page · raw message

linux-user/sh4/cpu_loop.inc.c new file +78 -0

78 lines not on this page · raw message

linux-user/sparc/cpu_loop.inc.c new file +271 -0

271 lines not on this page · raw message

linux-user/sparc64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..ba4765b4db

Lines of this file are not shown. View the raw message.

linux-user/tilegx/cpu_loop.inc.c new file +251 -0

251 lines not on this page · raw message

linux-user/x86_64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..b62e12ef9b

Lines of this file are not shown. View the raw message.

linux-user/xtensa/cpu_loop.inc.c new file +231 -0

231 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.14.3

Part of the diff is not shown here. View the raw message.

Reviewed-by on v1 4/5
#10 lore raw

Re: [Qemu-devel] [PATCH for 2.13 4/5] linux-user: cleanup cpu_loop()

Quoted 4 lines · Laurent Vivier

move all target specific cpu_loop parts to
cpu_loop.inc.c in arch directory

Quoted 7,954 lines
---
 linux-user/aarch64/cpu_loop.inc.c    |    1 +
 linux-user/alpha/cpu_loop.inc.c      |  191 ++
 linux-user/arm/cpu_loop.inc.c        |  488 +++++
 linux-user/cris/cpu_loop.inc.c       |   67 +
 linux-user/hppa/cpu_loop.inc.c       |  178 ++
 linux-user/i386/cpu_loop.inc.c       |  229 ++
 linux-user/m68k/cpu_loop.inc.c       |  115 +
 linux-user/main.c                    | 3918 +---------------------------------
 linux-user/microblaze/cpu_loop.inc.c |  116 +
 linux-user/mips/cpu_loop.inc.c       |  695 ++++++
 linux-user/mips64/cpu_loop.inc.c     |    1 +
 linux-user/nios2/cpu_loop.inc.c      |   98 +
 linux-user/openrisc/cpu_loop.inc.c   |   81 +
 linux-user/ppc/cpu_loop.inc.c        |  538 +++++
 linux-user/riscv/cpu_loop.inc.c      |   89 +
 linux-user/s390x/cpu_loop.inc.c      |  132 ++
 linux-user/sh4/cpu_loop.inc.c        |   78 +
 linux-user/sparc/cpu_loop.inc.c      |  271 +++
 linux-user/sparc64/cpu_loop.inc.c    |    1 +
 linux-user/tilegx/cpu_loop.inc.c     |  251 +++
 linux-user/x86_64/cpu_loop.inc.c     |    1 +
 linux-user/xtensa/cpu_loop.inc.c     |  231 ++
 22 files changed, 3853 insertions(+), 3917 deletions(-)
 create mode 100644 linux-user/aarch64/cpu_loop.inc.c
 create mode 100644 linux-user/alpha/cpu_loop.inc.c
 create mode 100644 linux-user/arm/cpu_loop.inc.c
 create mode 100644 linux-user/cris/cpu_loop.inc.c
 create mode 100644 linux-user/hppa/cpu_loop.inc.c
 create mode 100644 linux-user/i386/cpu_loop.inc.c
 create mode 100644 linux-user/m68k/cpu_loop.inc.c
 create mode 100644 linux-user/microblaze/cpu_loop.inc.c
 create mode 100644 linux-user/mips/cpu_loop.inc.c
 create mode 100644 linux-user/mips64/cpu_loop.inc.c
 create mode 100644 linux-user/nios2/cpu_loop.inc.c
 create mode 100644 linux-user/openrisc/cpu_loop.inc.c
 create mode 100644 linux-user/ppc/cpu_loop.inc.c
 create mode 100644 linux-user/riscv/cpu_loop.inc.c
 create mode 100644 linux-user/s390x/cpu_loop.inc.c
 create mode 100644 linux-user/sh4/cpu_loop.inc.c
 create mode 100644 linux-user/sparc/cpu_loop.inc.c
 create mode 100644 linux-user/sparc64/cpu_loop.inc.c
 create mode 100644 linux-user/tilegx/cpu_loop.inc.c
 create mode 100644 linux-user/x86_64/cpu_loop.inc.c
 create mode 100644 linux-user/xtensa/cpu_loop.inc.c
linux-user/aarch64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..a9a57861e7
@@ -0,0 +1 @@
+#include "../arm/cpu_loop.inc.c"
linux-user/alpha/cpu_loop.inc.c new file +191 -0
new file mode 100644
index 0000000000..e9426bdb1a
@@ -0,0 +1,191 @@
+void cpu_loop(CPUAlphaState *env)
+{
+    CPUState *cs = CPU(alpha_env_get_cpu(env));
+    int trapnr;
+    target_siginfo_t info;
+    abi_long sysret;
+
+    while (1) {
+        bool arch_interrupt = true;
+
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch (trapnr) {
+        case EXCP_RESET:
+            fprintf(stderr, "Reset requested. Exit\n");
+            exit(EXIT_FAILURE);
+            break;
+        case EXCP_MCHK:
+            fprintf(stderr, "Machine check exception. Exit\n");
+            exit(EXIT_FAILURE);
+            break;
+        case EXCP_SMP_INTERRUPT:
+        case EXCP_CLK_INTERRUPT:
+        case EXCP_DEV_INTERRUPT:
+            fprintf(stderr, "External interrupt. Exit\n");
+            exit(EXIT_FAILURE);
+            break;
+        case EXCP_MMFAULT:
+            info.si_signo = TARGET_SIGSEGV;
+            info.si_errno = 0;
+            info.si_code = (page_get_flags(env->trap_arg0) & PAGE_VALID
+                            ? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR);
+            info._sifields._sigfault._addr = env->trap_arg0;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_UNALIGN:
+            info.si_signo = TARGET_SIGBUS;
+            info.si_errno = 0;
+            info.si_code = TARGET_BUS_ADRALN;
+            info._sifields._sigfault._addr = env->trap_arg0;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_OPCDEC:
+        do_sigill:
+            info.si_signo = TARGET_SIGILL;
+            info.si_errno = 0;
+            info.si_code = TARGET_ILL_ILLOPC;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_ARITH:
+            info.si_signo = TARGET_SIGFPE;
+            info.si_errno = 0;
+            info.si_code = TARGET_FPE_FLTINV;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_FEN:
+            /* No-op.  Linux simply re-enables the FPU.  */
+            break;
+        case EXCP_CALL_PAL:
+            switch (env->error_code) {
+            case 0x80:
+                /* BPT */
+                info.si_signo = TARGET_SIGTRAP;
+                info.si_errno = 0;
+                info.si_code = TARGET_TRAP_BRKPT;
+                info._sifields._sigfault._addr = env->pc;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                break;
+            case 0x81:
+                /* BUGCHK */
+                info.si_signo = TARGET_SIGTRAP;
+                info.si_errno = 0;
+                info.si_code = 0;
+                info._sifields._sigfault._addr = env->pc;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                break;
+            case 0x83:
+                /* CALLSYS */
+                trapnr = env->ir[IR_V0];
+                sysret = do_syscall(env, trapnr,
+                                    env->ir[IR_A0], env->ir[IR_A1],
+                                    env->ir[IR_A2], env->ir[IR_A3],
+                                    env->ir[IR_A4], env->ir[IR_A5],
+                                    0, 0);
+                if (sysret == -TARGET_ERESTARTSYS) {
+                    env->pc -= 4;
+                    break;
+                }
+                if (sysret == -TARGET_QEMU_ESIGRETURN) {
+                    break;
+                }
+                /* Syscall writes 0 to V0 to bypass error check, similar
+                   to how this is handled internal to Linux kernel.
+                   (Ab)use trapnr temporarily as boolean indicating error.  */
+                trapnr = (env->ir[IR_V0] != 0 && sysret < 0);
+                env->ir[IR_V0] = (trapnr ? -sysret : sysret);
+                env->ir[IR_A3] = trapnr;
+                break;
+            case 0x86:
+                /* IMB */
+                /* ??? We can probably elide the code using page_unprotect
+                   that is checking for self-modifying code.  Instead we
+                   could simply call tb_flush here.  Until we work out the
+                   changes required to turn off the extra write protection,
+                   this can be a no-op.  */
+                break;
+            case 0x9E:
+                /* RDUNIQUE */
+                /* Handled in the translator for usermode.  */
+                abort();
+            case 0x9F:
+                /* WRUNIQUE */
+                /* Handled in the translator for usermode.  */
+                abort();
+            case 0xAA:
+                /* GENTRAP */
+                info.si_signo = TARGET_SIGFPE;
+                switch (env->ir[IR_A0]) {
+                case TARGET_GEN_INTOVF:
+                    info.si_code = TARGET_FPE_INTOVF;
+                    break;
+                case TARGET_GEN_INTDIV:
+                    info.si_code = TARGET_FPE_INTDIV;
+                    break;
+                case TARGET_GEN_FLTOVF:
+                    info.si_code = TARGET_FPE_FLTOVF;
+                    break;
+                case TARGET_GEN_FLTUND:
+                    info.si_code = TARGET_FPE_FLTUND;
+                    break;
+                case TARGET_GEN_FLTINV:
+                    info.si_code = TARGET_FPE_FLTINV;
+                    break;
+                case TARGET_GEN_FLTINE:
+                    info.si_code = TARGET_FPE_FLTRES;
+                    break;
+                case TARGET_GEN_ROPRAND:
+                    info.si_code = 0;
+                    break;
+                default:
+                    info.si_signo = TARGET_SIGTRAP;
+                    info.si_code = 0;
+                    break;
+                }
+                info.si_errno = 0;
+                info._sifields._sigfault._addr = env->pc;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                break;
+            default:
+                goto do_sigill;
+            }
+            break;
+        case EXCP_DEBUG:
+            info.si_signo = gdb_handlesig(cs, TARGET_SIGTRAP);
+            if (info.si_signo) {
+                info.si_errno = 0;
+                info.si_code = TARGET_TRAP_BRKPT;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            } else {
+                arch_interrupt = false;
+            }
+            break;
+        case EXCP_INTERRUPT:
+            /* Just indicate that signals should be handled asap.  */
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            arch_interrupt = false;
+            break;
+        default:
+            printf ("Unhandled trap: 0x%x\n", trapnr);
+            cpu_dump_state(cs, stderr, fprintf, 0);
+            exit(EXIT_FAILURE);
+        }
+        process_pending_signals (env);
+
+        /* Most of the traps imply a transition through PALcode, which
+           implies an REI instruction has been executed.  Which means
+           that RX and LOCK_ADDR should be cleared.  But there are a
+           few exceptions for traps internal to QEMU.  */
+        if (arch_interrupt) {
+            env->flags &= ~ENV_FLAG_RX_FLAG;
+            env->lock_addr = -1;
+        }
+    }
+}
linux-user/arm/cpu_loop.inc.c new file +488 -0
new file mode 100644
index 0000000000..887381d6bd
@@ -0,0 +1,488 @@
+#define get_user_code_u32(x, gaddr, env)                \
+    ({ abi_long __r = get_user_u32((x), (gaddr));       \
+        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+            (x) = bswap32(x);                           \
+        }                                               \
+        __r;                                            \
+    })
+
+#define get_user_code_u16(x, gaddr, env)                \
+    ({ abi_long __r = get_user_u16((x), (gaddr));       \
+        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
+            (x) = bswap16(x);                           \
+        }                                               \
+        __r;                                            \
+    })
+
+#define get_user_data_u32(x, gaddr, env)                \
+    ({ abi_long __r = get_user_u32((x), (gaddr));       \
+        if (!__r && arm_cpu_bswap_data(env)) {          \
+            (x) = bswap32(x);                           \
+        }                                               \
+        __r;                                            \
+    })
+
+#define get_user_data_u16(x, gaddr, env)                \
+    ({ abi_long __r = get_user_u16((x), (gaddr));       \
+        if (!__r && arm_cpu_bswap_data(env)) {          \
+            (x) = bswap16(x);                           \
+        }                                               \
+        __r;                                            \
+    })
+
+#define put_user_data_u32(x, gaddr, env)                \
+    ({ typeof(x) __x = (x);                             \
+        if (arm_cpu_bswap_data(env)) {                  \
+            __x = bswap32(__x);                         \
+        }                                               \
+        put_user_u32(__x, (gaddr));                     \
+    })
+
+#define put_user_data_u16(x, gaddr, env)                \
+    ({ typeof(x) __x = (x);                             \
+        if (arm_cpu_bswap_data(env)) {                  \
+            __x = bswap16(__x);                         \
+        }                                               \
+        put_user_u16(__x, (gaddr));                     \
+    })
+
+#ifdef TARGET_ABI32
+/* Commpage handling -- there is no commpage for AArch64 */
+
+/*
+ * See the Linux kernel's Documentation/arm/kernel_user_helpers.txt
+ * Input:
+ * r0 = pointer to oldval
+ * r1 = pointer to newval
+ * r2 = pointer to target value
+ *
+ * Output:
+ * r0 = 0 if *ptr was changed, non-0 if no exchange happened
+ * C set if *ptr was changed, clear if no exchange happened
+ *
+ * Note segv's in kernel helpers are a bit tricky, we can set the
+ * data address sensibly but the PC address is just the entry point.
+ */
+static void arm_kernel_cmpxchg64_helper(CPUARMState *env)
+{
+    uint64_t oldval, newval, val;
+    uint32_t addr, cpsr;
+    target_siginfo_t info;
+
+    /* Based on the 32 bit code in do_kernel_trap */
+
+    /* XXX: This only works between threads, not between processes.
+       It's probably possible to implement this with native host
+       operations. However things like ldrex/strex are much harder so
+       there's not much point trying.  */
+    start_exclusive();
+    cpsr = cpsr_read(env);
+    addr = env->regs[2];
+
+    if (get_user_u64(oldval, env->regs[0])) {
+        env->exception.vaddress = env->regs[0];
+        goto segv;
+    };
+
+    if (get_user_u64(newval, env->regs[1])) {
+        env->exception.vaddress = env->regs[1];
+        goto segv;
+    };
+
+    if (get_user_u64(val, addr)) {
+        env->exception.vaddress = addr;
+        goto segv;
+    }
+
+    if (val == oldval) {
+        val = newval;
+
+        if (put_user_u64(val, addr)) {
+            env->exception.vaddress = addr;
+            goto segv;
+        };
+
+        env->regs[0] = 0;
+        cpsr |= CPSR_C;
+    } else {
+        env->regs[0] = -1;
+        cpsr &= ~CPSR_C;
+    }
+    cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
+    end_exclusive();
+    return;
+
+segv:
+    end_exclusive();
+    /* We get the PC of the entry address - which is as good as anything,
+       on a real kernel what you get depends on which mode it uses. */
+    info.si_signo = TARGET_SIGSEGV;
+    info.si_errno = 0;
+    /* XXX: check env->error_code */
+    info.si_code = TARGET_SEGV_MAPERR;
+    info._sifields._sigfault._addr = env->exception.vaddress;
+    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+}
+
+/* Handle a jump to the kernel code page.  */
+static int
+do_kernel_trap(CPUARMState *env)
+{
+    uint32_t addr;
+    uint32_t cpsr;
+    uint32_t val;
+
+    switch (env->regs[15]) {
+    case 0xffff0fa0: /* __kernel_memory_barrier */
+        /* ??? No-op. Will need to do better for SMP.  */
+        break;
+    case 0xffff0fc0: /* __kernel_cmpxchg */
+         /* XXX: This only works between threads, not between processes.
+            It's probably possible to implement this with native host
+            operations. However things like ldrex/strex are much harder so
+            there's not much point trying.  */
+        start_exclusive();
+        cpsr = cpsr_read(env);
+        addr = env->regs[2];
+        /* FIXME: This should SEGV if the access fails.  */
+        if (get_user_u32(val, addr))
+            val = ~env->regs[0];
+        if (val == env->regs[0]) {
+            val = env->regs[1];
+            /* FIXME: Check for segfaults.  */
+            put_user_u32(val, addr);
+            env->regs[0] = 0;
+            cpsr |= CPSR_C;
+        } else {
+            env->regs[0] = -1;
+            cpsr &= ~CPSR_C;
+        }
+        cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
+        end_exclusive();
+        break;
+    case 0xffff0fe0: /* __kernel_get_tls */
+        env->regs[0] = cpu_get_tls(env);
+        break;
+    case 0xffff0f60: /* __kernel_cmpxchg64 */
+        arm_kernel_cmpxchg64_helper(env);
+        break;
+
+    default:
+        return 1;
+    }
+    /* Jump back to the caller.  */
+    addr = env->regs[14];
+    if (addr & 1) {
+        env->thumb = 1;
+        addr &= ~1;
+    }
+    env->regs[15] = addr;
+
+    return 0;
+}
+
+void cpu_loop(CPUARMState *env)
+{
+    CPUState *cs = CPU(arm_env_get_cpu(env));
+    int trapnr;
+    unsigned int n, insn;
+    target_siginfo_t info;
+    uint32_t addr;
+    abi_ulong ret;
+
+    for(;;) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch(trapnr) {
+        case EXCP_UDEF:
+        case EXCP_NOCP:
+        case EXCP_INVSTATE:
+            {
+                TaskState *ts = cs->opaque;
+                uint32_t opcode;
+                int rc;
+
+                /* we handle the FPU emulation here, as Linux */
+                /* we get the opcode */
+                /* FIXME - what to do if get_user() fails? */
+                get_user_code_u32(opcode, env->regs[15], env);
+
+                rc = EmulateAll(opcode, &ts->fpa, env);
+                if (rc == 0) { /* illegal instruction */
+                    info.si_signo = TARGET_SIGILL;
+                    info.si_errno = 0;
+                    info.si_code = TARGET_ILL_ILLOPN;
+                    info._sifields._sigfault._addr = env->regs[15];
+                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                } else if (rc < 0) { /* FP exception */
+                    int arm_fpe=0;
+
+                    /* translate softfloat flags to FPSR flags */
+                    if (-rc & float_flag_invalid)
+                      arm_fpe |= BIT_IOC;
+                    if (-rc & float_flag_divbyzero)
+                      arm_fpe |= BIT_DZC;
+                    if (-rc & float_flag_overflow)
+                      arm_fpe |= BIT_OFC;
+                    if (-rc & float_flag_underflow)
+                      arm_fpe |= BIT_UFC;
+                    if (-rc & float_flag_inexact)
+                      arm_fpe |= BIT_IXC;
+
+                    FPSR fpsr = ts->fpa.fpsr;
+                    //printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe);
+
+                    if (fpsr & (arm_fpe << 16)) { /* exception enabled? */
+                      info.si_signo = TARGET_SIGFPE;
+                      info.si_errno = 0;
+
+                      /* ordered by priority, least first */
+                      if (arm_fpe & BIT_IXC) info.si_code = TARGET_FPE_FLTRES;
+                      if (arm_fpe & BIT_UFC) info.si_code = TARGET_FPE_FLTUND;
+                      if (arm_fpe & BIT_OFC) info.si_code = TARGET_FPE_FLTOVF;
+                      if (arm_fpe & BIT_DZC) info.si_code = TARGET_FPE_FLTDIV;
+                      if (arm_fpe & BIT_IOC) info.si_code = TARGET_FPE_FLTINV;
+
+                      info._sifields._sigfault._addr = env->regs[15];
+                      queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                    } else {
+                      env->regs[15] += 4;
+                    }
+
+                    /* accumulate unenabled exceptions */
+                    if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC))
+                      fpsr |= BIT_IXC;
+                    if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC))
+                      fpsr |= BIT_UFC;
+                    if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC))
+                      fpsr |= BIT_OFC;
+                    if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC))
+                      fpsr |= BIT_DZC;
+                    if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC))
+                      fpsr |= BIT_IOC;
+                    ts->fpa.fpsr=fpsr;
+                } else { /* everything OK */
+                    /* increment PC */
+                    env->regs[15] += 4;
+                }
+            }
+            break;
+        case EXCP_SWI:
+        case EXCP_BKPT:
+            {
+                env->eabi = 1;
+                /* system call */
+                if (trapnr == EXCP_BKPT) {
+                    if (env->thumb) {
+                        /* FIXME - what to do if get_user() fails? */
+                        get_user_code_u16(insn, env->regs[15], env);
+                        n = insn & 0xff;
+                        env->regs[15] += 2;
+                    } else {
+                        /* FIXME - what to do if get_user() fails? */
+                        get_user_code_u32(insn, env->regs[15], env);
+                        n = (insn & 0xf) | ((insn >> 4) & 0xff0);
+                        env->regs[15] += 4;
+                    }
+                } else {
+                    if (env->thumb) {
+                        /* FIXME - what to do if get_user() fails? */
+                        get_user_code_u16(insn, env->regs[15] - 2, env);
+                        n = insn & 0xff;
+                    } else {
+                        /* FIXME - what to do if get_user() fails? */
+                        get_user_code_u32(insn, env->regs[15] - 4, env);
+                        n = insn & 0xffffff;
+                    }
+                }
+
+                if (n == ARM_NR_cacheflush) {
+                    /* nop */
+                } else if (n == ARM_NR_semihosting
+                           || n == ARM_NR_thumb_semihosting) {
+                    env->regs[0] = do_arm_semihosting (env);
+                } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) {
+                    /* linux syscall */
+                    if (env->thumb || n == 0) {
+                        n = env->regs[7];
+                    } else {
+                        n -= ARM_SYSCALL_BASE;
+                        env->eabi = 0;
+                    }
+                    if ( n > ARM_NR_BASE) {
+                        switch (n) {
+                        case ARM_NR_cacheflush:
+                            /* nop */
+                            break;
+                        case ARM_NR_set_tls:
+                            cpu_set_tls(env, env->regs[0]);
+                            env->regs[0] = 0;
+                            break;
+                        case ARM_NR_breakpoint:
+                            env->regs[15] -= env->thumb ? 2 : 4;
+                            goto excp_debug;
+                        default:
+                            gemu_log("qemu: Unsupported ARM syscall: 0x%x\n",
+                                     n);
+                            env->regs[0] = -TARGET_ENOSYS;
+                            break;
+                        }
+                    } else {
+                        ret = do_syscall(env,
+                                         n,
+                                         env->regs[0],
+                                         env->regs[1],
+                                         env->regs[2],
+                                         env->regs[3],
+                                         env->regs[4],
+                                         env->regs[5],
+                                         0, 0);
+                        if (ret == -TARGET_ERESTARTSYS) {
+                            env->regs[15] -= env->thumb ? 2 : 4;
+                        } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                            env->regs[0] = ret;
+                        }
+                    }
+                } else {
+                    goto error;
+                }
+            }
+            break;
+        case EXCP_SEMIHOST:
+            env->regs[0] = do_arm_semihosting(env);
+            break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
+        case EXCP_PREFETCH_ABORT:
+        case EXCP_DATA_ABORT:
+            addr = env->exception.vaddress;
+            {
+                info.si_signo = TARGET_SIGSEGV;
+                info.si_errno = 0;
+                /* XXX: check env->error_code */
+                info.si_code = TARGET_SEGV_MAPERR;
+                info._sifields._sigfault._addr = addr;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP_DEBUG:
+        excp_debug:
+            {
+                int sig;
+
+                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
+                if (sig)
+                  {
+                    info.si_signo = sig;
+                    info.si_errno = 0;
+                    info.si_code = TARGET_TRAP_BRKPT;
+                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                  }
+            }
+            break;
+        case EXCP_KERNEL_TRAP:
+            if (do_kernel_trap(env))
+              goto error;
+            break;
+        case EXCP_YIELD:
+            /* nothing to do here for user-mode, just resume guest code */
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            break;
+        default:
+        error:
+            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
+            abort();
+        }
+        process_pending_signals(env);
+    }
+}
+
+#else
+
+/* AArch64 main loop */
+void cpu_loop(CPUARMState *env)
+{
+    CPUState *cs = CPU(arm_env_get_cpu(env));
+    int trapnr, sig;
+    abi_long ret;
+    target_siginfo_t info;
+
+    for (;;) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch (trapnr) {
+        case EXCP_SWI:
+            ret = do_syscall(env,
+                             env->xregs[8],
+                             env->xregs[0],
+                             env->xregs[1],
+                             env->xregs[2],
+                             env->xregs[3],
+                             env->xregs[4],
+                             env->xregs[5],
+                             0, 0);
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->pc -= 4;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->xregs[0] = ret;
+            }
+            break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
+        case EXCP_UDEF:
+            info.si_signo = TARGET_SIGILL;
+            info.si_errno = 0;
+            info.si_code = TARGET_ILL_ILLOPN;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_PREFETCH_ABORT:
+        case EXCP_DATA_ABORT:
+            info.si_signo = TARGET_SIGSEGV;
+            info.si_errno = 0;
+            /* XXX: check env->error_code */
+            info.si_code = TARGET_SEGV_MAPERR;
+            info._sifields._sigfault._addr = env->exception.vaddress;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_DEBUG:
+        case EXCP_BKPT:
+            sig = gdb_handlesig(cs, TARGET_SIGTRAP);
+            if (sig) {
+                info.si_signo = sig;
+                info.si_errno = 0;
+                info.si_code = TARGET_TRAP_BRKPT;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP_SEMIHOST:
+            env->xregs[0] = do_arm_semihosting(env);
+            break;
+        case EXCP_YIELD:
+            /* nothing to do here for user-mode, just resume guest code */
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            break;
+        default:
+            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
+            abort();
+        }
+        process_pending_signals(env);
+        /* Exception return on AArch64 always clears the exclusive monitor,
+         * so any return to running guest code implies this.
+         */
+        env->exclusive_addr = -1;
+    }
+}
+#endif /* ndef TARGET_ABI32 */
linux-user/cris/cpu_loop.inc.c new file +67 -0
new file mode 100644
index 0000000000..e5fc51922d
@@ -0,0 +1,67 @@
+void cpu_loop(CPUCRISState *env)
+{
+    CPUState *cs = CPU(cris_env_get_cpu(env));
+    int trapnr, ret;
+    target_siginfo_t info;
+
+    while (1) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch (trapnr) {
+        case 0xaa:
+            {
+                info.si_signo = TARGET_SIGSEGV;
+                info.si_errno = 0;
+                /* XXX: check env->error_code */
+                info.si_code = TARGET_SEGV_MAPERR;
+                info._sifields._sigfault._addr = env->pregs[PR_EDA];
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+	case EXCP_INTERRUPT:
+	  /* just indicate that signals should be handled asap */
+	  break;
+        case EXCP_BREAK:
+            ret = do_syscall(env,
+                             env->regs[9],
+                             env->regs[10],
+                             env->regs[11],
+                             env->regs[12],
+                             env->regs[13],
+                             env->pregs[7],
+                             env->pregs[11],
+                             0, 0);
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->pc -= 2;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->regs[10] = ret;
+            }
+            break;
+        case EXCP_DEBUG:
+            {
+                int sig;
+
+                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
+                if (sig)
+                  {
+                    info.si_signo = sig;
+                    info.si_errno = 0;
+                    info.si_code = TARGET_TRAP_BRKPT;
+                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                  }
+            }
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            break;
+        default:
+            printf ("Unhandled trap: 0x%x\n", trapnr);
+            cpu_dump_state(cs, stderr, fprintf, 0);
+            exit(EXIT_FAILURE);
+        }
+        process_pending_signals (env);
+    }
+}
linux-user/hppa/cpu_loop.inc.c new file +178 -0
new file mode 100644
index 0000000000..99a4443e8f
@@ -0,0 +1,178 @@
+static abi_ulong hppa_lws(CPUHPPAState *env)
+{
+    uint32_t which = env->gr[20];
+    abi_ulong addr = env->gr[26];
+    abi_ulong old = env->gr[25];
+    abi_ulong new = env->gr[24];
+    abi_ulong size, ret;
+
+    switch (which) {
+    default:
+        return -TARGET_ENOSYS;
+
+    case 0: /* elf32 atomic 32bit cmpxchg */
+        if ((addr & 3) || !access_ok(VERIFY_WRITE, addr, 4)) {
+            return -TARGET_EFAULT;
+        }
+        old = tswap32(old);
+        new = tswap32(new);
+        ret = atomic_cmpxchg((uint32_t *)g2h(addr), old, new);
+        ret = tswap32(ret);
+        break;
+
+    case 2: /* elf32 atomic "new" cmpxchg */
+        size = env->gr[23];
+        if (size >= 4) {
+            return -TARGET_ENOSYS;
+        }
+        if (((addr | old | new) & ((1 << size) - 1))
+            || !access_ok(VERIFY_WRITE, addr, 1 << size)
+            || !access_ok(VERIFY_READ, old, 1 << size)
+            || !access_ok(VERIFY_READ, new, 1 << size)) {
+            return -TARGET_EFAULT;
+        }
+        /* Note that below we use host-endian loads so that the cmpxchg
+           can be host-endian as well.  */
+        switch (size) {
+        case 0:
+            old = *(uint8_t *)g2h(old);
+            new = *(uint8_t *)g2h(new);
+            ret = atomic_cmpxchg((uint8_t *)g2h(addr), old, new);
+            ret = ret != old;
+            break;
+        case 1:
+            old = *(uint16_t *)g2h(old);
+            new = *(uint16_t *)g2h(new);
+            ret = atomic_cmpxchg((uint16_t *)g2h(addr), old, new);
+            ret = ret != old;
+            break;
+        case 2:
+            old = *(uint32_t *)g2h(old);
+            new = *(uint32_t *)g2h(new);
+            ret = atomic_cmpxchg((uint32_t *)g2h(addr), old, new);
+            ret = ret != old;
+            break;
+        case 3:
+            {
+                uint64_t o64, n64, r64;
+                o64 = *(uint64_t *)g2h(old);
+                n64 = *(uint64_t *)g2h(new);
+#ifdef CONFIG_ATOMIC64
+                r64 = atomic_cmpxchg__nocheck((uint64_t *)g2h(addr), o64, n64);
+                ret = r64 != o64;
+#else
+                start_exclusive();
+                r64 = *(uint64_t *)g2h(addr);
+                ret = 1;
+                if (r64 == o64) {
+                    *(uint64_t *)g2h(addr) = n64;
+                    ret = 0;
+                }
+                end_exclusive();
+#endif
+            }
+            break;
+        }
+        break;
+    }
+
+    env->gr[28] = ret;
+    return 0;
+}
+
+void cpu_loop(CPUHPPAState *env)
+{
+    CPUState *cs = CPU(hppa_env_get_cpu(env));
+    target_siginfo_t info;
+    abi_ulong ret;
+    int trapnr;
+
+    while (1) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch (trapnr) {
+        case EXCP_SYSCALL:
+            ret = do_syscall(env, env->gr[20],
+                             env->gr[26], env->gr[25],
+                             env->gr[24], env->gr[23],
+                             env->gr[22], env->gr[21], 0, 0);
+            switch (ret) {
+            default:
+                env->gr[28] = ret;
+                /* We arrived here by faking the gateway page.  Return.  */
+                env->iaoq_f = env->gr[31];
+                env->iaoq_b = env->gr[31] + 4;
+                break;
+            case -TARGET_ERESTARTSYS:
+            case -TARGET_QEMU_ESIGRETURN:
+                break;
+            }
+            break;
+        case EXCP_SYSCALL_LWS:
+            env->gr[21] = hppa_lws(env);
+            /* We arrived here by faking the gateway page.  Return.  */
+            env->iaoq_f = env->gr[31];
+            env->iaoq_b = env->gr[31] + 4;
+            break;
+        case EXCP_ITLB_MISS:
+        case EXCP_DTLB_MISS:
+        case EXCP_NA_ITLB_MISS:
+        case EXCP_NA_DTLB_MISS:
+        case EXCP_IMP:
+        case EXCP_DMP:
+        case EXCP_DMB:
+        case EXCP_PAGE_REF:
+        case EXCP_DMAR:
+        case EXCP_DMPI:
+            info.si_signo = TARGET_SIGSEGV;
+            info.si_errno = 0;
+            info.si_code = TARGET_SEGV_ACCERR;
+            info._sifields._sigfault._addr = env->cr[CR_IOR];
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_UNALIGN:
+            info.si_signo = TARGET_SIGBUS;
+            info.si_errno = 0;
+            info.si_code = 0;
+            info._sifields._sigfault._addr = env->cr[CR_IOR];
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_ILL:
+        case EXCP_PRIV_OPR:
+        case EXCP_PRIV_REG:
+            info.si_signo = TARGET_SIGILL;
+            info.si_errno = 0;
+            info.si_code = TARGET_ILL_ILLOPN;
+            info._sifields._sigfault._addr = env->iaoq_f;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_OVERFLOW:
+        case EXCP_COND:
+        case EXCP_ASSIST:
+            info.si_signo = TARGET_SIGFPE;
+            info.si_errno = 0;
+            info.si_code = 0;
+            info._sifields._sigfault._addr = env->iaoq_f;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_DEBUG:
+            trapnr = gdb_handlesig(cs, TARGET_SIGTRAP);
+            if (trapnr) {
+                info.si_signo = trapnr;
+                info.si_errno = 0;
+                info.si_code = TARGET_TRAP_BRKPT;
+                queue_signal(env, trapnr, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
+        default:
+            g_assert_not_reached();
+        }
+        process_pending_signals(env);
+    }
+}
linux-user/i386/cpu_loop.inc.c new file +229 -0
new file mode 100644
index 0000000000..8f9b6a8278
@@ -0,0 +1,229 @@
+/***********************************************************/
+/* CPUX86 core interface */
+
+uint64_t cpu_get_tsc(CPUX86State *env)
+{
+    return cpu_get_host_ticks();
+}
+
+static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
+                     int flags)
+{
+    unsigned int e1, e2;
+    uint32_t *p;
+    e1 = (addr << 16) | (limit & 0xffff);
+    e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000);
+    e2 |= flags;
+    p = ptr;
+    p[0] = tswap32(e1);
+    p[1] = tswap32(e2);
+}
+
+static uint64_t *idt_table;
+#ifdef TARGET_X86_64
+static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
+                       uint64_t addr, unsigned int sel)
+{
+    uint32_t *p, e1, e2;
+    e1 = (addr & 0xffff) | (sel << 16);
+    e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
+    p = ptr;
+    p[0] = tswap32(e1);
+    p[1] = tswap32(e2);
+    p[2] = tswap32(addr >> 32);
+    p[3] = 0;
+}
+/* only dpl matters as we do only user space emulation */
+static void set_idt(int n, unsigned int dpl)
+{
+    set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
+}
+#else
+static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
+                     uint32_t addr, unsigned int sel)
+{
+    uint32_t *p, e1, e2;
+    e1 = (addr & 0xffff) | (sel << 16);
+    e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
+    p = ptr;
+    p[0] = tswap32(e1);
+    p[1] = tswap32(e2);
+}
+
+/* only dpl matters as we do only user space emulation */
+static void set_idt(int n, unsigned int dpl)
+{
+    set_gate(idt_table + n, 0, dpl, 0, 0);
+}
+#endif
+
+void cpu_loop(CPUX86State *env)
+{
+    CPUState *cs = CPU(x86_env_get_cpu(env));
+    int trapnr;
+    abi_ulong pc;
+    abi_ulong ret;
+    target_siginfo_t info;
+
+    for(;;) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch(trapnr) {
+        case 0x80:
+            /* linux syscall from int $0x80 */
+            ret = do_syscall(env,
+                             env->regs[R_EAX],
+                             env->regs[R_EBX],
+                             env->regs[R_ECX],
+                             env->regs[R_EDX],
+                             env->regs[R_ESI],
+                             env->regs[R_EDI],
+                             env->regs[R_EBP],
+                             0, 0);
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->eip -= 2;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->regs[R_EAX] = ret;
+            }
+            break;
+#ifndef TARGET_ABI32
+        case EXCP_SYSCALL:
+            /* linux syscall from syscall instruction */
+            ret = do_syscall(env,
+                             env->regs[R_EAX],
+                             env->regs[R_EDI],
+                             env->regs[R_ESI],
+                             env->regs[R_EDX],
+                             env->regs[10],
+                             env->regs[8],
+                             env->regs[9],
+                             0, 0);
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->eip -= 2;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->regs[R_EAX] = ret;
+            }
+            break;
+#endif
+        case EXCP0B_NOSEG:
+        case EXCP0C_STACK:
+            info.si_signo = TARGET_SIGBUS;
+            info.si_errno = 0;
+            info.si_code = TARGET_SI_KERNEL;
+            info._sifields._sigfault._addr = 0;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP0D_GPF:
+            /* XXX: potential problem if ABI32 */
+#ifndef TARGET_X86_64
+            if (env->eflags & VM_MASK) {
+                handle_vm86_fault(env);
+            } else
+#endif
+            {
+                info.si_signo = TARGET_SIGSEGV;
+                info.si_errno = 0;
+                info.si_code = TARGET_SI_KERNEL;
+                info._sifields._sigfault._addr = 0;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP0E_PAGE:
+            info.si_signo = TARGET_SIGSEGV;
+            info.si_errno = 0;
+            if (!(env->error_code & 1))
+                info.si_code = TARGET_SEGV_MAPERR;
+            else
+                info.si_code = TARGET_SEGV_ACCERR;
+            info._sifields._sigfault._addr = env->cr[2];
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP00_DIVZ:
+#ifndef TARGET_X86_64
+            if (env->eflags & VM_MASK) {
+                handle_vm86_trap(env, trapnr);
+            } else
+#endif
+            {
+                /* division by zero */
+                info.si_signo = TARGET_SIGFPE;
+                info.si_errno = 0;
+                info.si_code = TARGET_FPE_INTDIV;
+                info._sifields._sigfault._addr = env->eip;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP01_DB:
+        case EXCP03_INT3:
+#ifndef TARGET_X86_64
+            if (env->eflags & VM_MASK) {
+                handle_vm86_trap(env, trapnr);
+            } else
+#endif
+            {
+                info.si_signo = TARGET_SIGTRAP;
+                info.si_errno = 0;
+                if (trapnr == EXCP01_DB) {
+                    info.si_code = TARGET_TRAP_BRKPT;
+                    info._sifields._sigfault._addr = env->eip;
+                } else {
+                    info.si_code = TARGET_SI_KERNEL;
+                    info._sifields._sigfault._addr = 0;
+                }
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP04_INTO:
+        case EXCP05_BOUND:
+#ifndef TARGET_X86_64
+            if (env->eflags & VM_MASK) {
+                handle_vm86_trap(env, trapnr);
+            } else
+#endif
+            {
+                info.si_signo = TARGET_SIGSEGV;
+                info.si_errno = 0;
+                info.si_code = TARGET_SI_KERNEL;
+                info._sifields._sigfault._addr = 0;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP06_ILLOP:
+            info.si_signo = TARGET_SIGILL;
+            info.si_errno = 0;
+            info.si_code = TARGET_ILL_ILLOPN;
+            info._sifields._sigfault._addr = env->eip;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
+        case EXCP_DEBUG:
+            {
+                int sig;
+
+                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
+                if (sig)
+                  {
+                    info.si_signo = sig;
+                    info.si_errno = 0;
+                    info.si_code = TARGET_TRAP_BRKPT;
+                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                  }
+            }
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            break;
+        default:
+            pc = env->segs[R_CS].base + env->eip;
+            EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
+                      (long)pc, trapnr);
+            abort();
+        }
+        process_pending_signals(env);
+    }
+}
linux-user/m68k/cpu_loop.inc.c new file +115 -0
new file mode 100644
index 0000000000..196ac16be1
@@ -0,0 +1,115 @@
+void cpu_loop(CPUM68KState *env)
+{
+    CPUState *cs = CPU(m68k_env_get_cpu(env));
+    int trapnr;
+    unsigned int n;
+    target_siginfo_t info;
+    TaskState *ts = cs->opaque;
+
+    for(;;) {
+        cpu_exec_start(cs);
+        trapnr = cpu_exec(cs);
+        cpu_exec_end(cs);
+        process_queued_cpu_work(cs);
+
+        switch(trapnr) {
+        case EXCP_ILLEGAL:
+            {
+                if (ts->sim_syscalls) {
+                    uint16_t nr;
+                    get_user_u16(nr, env->pc + 2);
+                    env->pc += 4;
+                    do_m68k_simcall(env, nr);
+                } else {
+                    goto do_sigill;
+                }
+            }
+            break;
+        case EXCP_HALT_INSN:
+            /* Semihosing syscall.  */
+            env->pc += 4;
+            do_m68k_semihosting(env, env->dregs[0]);
+            break;
+        case EXCP_LINEA:
+        case EXCP_LINEF:
+        case EXCP_UNSUPPORTED:
+        do_sigill:
+            info.si_signo = TARGET_SIGILL;
+            info.si_errno = 0;
+            info.si_code = TARGET_ILL_ILLOPN;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_CHK:
+            info.si_signo = TARGET_SIGFPE;
+            info.si_errno = 0;
+            info.si_code = TARGET_FPE_INTOVF;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_DIV0:
+            info.si_signo = TARGET_SIGFPE;
+            info.si_errno = 0;
+            info.si_code = TARGET_FPE_INTDIV;
+            info._sifields._sigfault._addr = env->pc;
+            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            break;
+        case EXCP_TRAP0:
+            {
+                abi_long ret;
+                ts->sim_syscalls = 0;
+                n = env->dregs[0];
+                env->pc += 2;
+                ret = do_syscall(env,
+                                 n,
+                                 env->dregs[1],
+                                 env->dregs[2],
+                                 env->dregs[3],
+                                 env->dregs[4],
+                                 env->dregs[5],
+                                 env->aregs[0],
+                                 0, 0);
+                if (ret == -TARGET_ERESTARTSYS) {
+                    env->pc -= 2;
+                } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                    env->dregs[0] = ret;
+                }
+            }
+            break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
+        case EXCP_ACCESS:
+            {
+                info.si_signo = TARGET_SIGSEGV;
+                info.si_errno = 0;
+                /* XXX: check env->error_code */
+                info.si_code = TARGET_SEGV_MAPERR;
+                info._sifields._sigfault._addr = env->mmu.ar;
+                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+            }
+            break;
+        case EXCP_DEBUG:
+            {
+                int sig;
+
+                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
+                if (sig)
+                  {
+                    info.si_signo = sig;
+                    info.si_errno = 0;
+                    info.si_code = TARGET_TRAP_BRKPT;
+                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
+                  }
+            }
+            break;
+        case EXCP_ATOMIC:
+            cpu_exec_step_atomic(cs);
+            break;
+        default:
+            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
+            abort();
+        }
+        process_pending_signals(env);
+    }
+}
linux-user/main.c +1 -3917
index ba09b7d0c8..fd71113855 100644
@@ -160,3923 +160,7 @@ void fork_end(int child)
     }
 }
 
-#ifdef TARGET_I386
-/***********************************************************/
-/* CPUX86 core interface */
-
-uint64_t cpu_get_tsc(CPUX86State *env)
-{
-    return cpu_get_host_ticks();
-}
-
-static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
-                     int flags)
-{
-    unsigned int e1, e2;
-    uint32_t *p;
-    e1 = (addr << 16) | (limit & 0xffff);
-    e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000);
-    e2 |= flags;
-    p = ptr;
-    p[0] = tswap32(e1);
-    p[1] = tswap32(e2);
-}
-
-static uint64_t *idt_table;
-#ifdef TARGET_X86_64
-static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
-                       uint64_t addr, unsigned int sel)
-{
-    uint32_t *p, e1, e2;
-    e1 = (addr & 0xffff) | (sel << 16);
-    e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
-    p = ptr;
-    p[0] = tswap32(e1);
-    p[1] = tswap32(e2);
-    p[2] = tswap32(addr >> 32);
-    p[3] = 0;
-}
-/* only dpl matters as we do only user space emulation */
-static void set_idt(int n, unsigned int dpl)
-{
-    set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
-}
-#else
-static void set_gate(void *ptr, unsigned int type, unsigned int dpl,
-                     uint32_t addr, unsigned int sel)
-{
-    uint32_t *p, e1, e2;
-    e1 = (addr & 0xffff) | (sel << 16);
-    e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
-    p = ptr;
-    p[0] = tswap32(e1);
-    p[1] = tswap32(e2);
-}
-
-/* only dpl matters as we do only user space emulation */
-static void set_idt(int n, unsigned int dpl)
-{
-    set_gate(idt_table + n, 0, dpl, 0, 0);
-}
-#endif
-
-void cpu_loop(CPUX86State *env)
-{
-    CPUState *cs = CPU(x86_env_get_cpu(env));
-    int trapnr;
-    abi_ulong pc;
-    abi_ulong ret;
-    target_siginfo_t info;
-
-    for(;;) {
-        cpu_exec_start(cs);
-        trapnr = cpu_exec(cs);
-        cpu_exec_end(cs);
-        process_queued_cpu_work(cs);
-
-        switch(trapnr) {
-        case 0x80:
-            /* linux syscall from int $0x80 */
-            ret = do_syscall(env,
-                             env->regs[R_EAX],
-                             env->regs[R_EBX],
-                             env->regs[R_ECX],
-                             env->regs[R_EDX],
-                             env->regs[R_ESI],
-                             env->regs[R_EDI],
-                             env->regs[R_EBP],
-                             0, 0);
-            if (ret == -TARGET_ERESTARTSYS) {
-                env->eip -= 2;
-            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
-                env->regs[R_EAX] = ret;
-            }
-            break;
-#ifndef TARGET_ABI32
-        case EXCP_SYSCALL:
-            /* linux syscall from syscall instruction */
-            ret = do_syscall(env,
-                             env->regs[R_EAX],
-                             env->regs[R_EDI],
-                             env->regs[R_ESI],
-                             env->regs[R_EDX],
-                             env->regs[10],
-                             env->regs[8],
-                             env->regs[9],
-                             0, 0);
-            if (ret == -TARGET_ERESTARTSYS) {
-                env->eip -= 2;
-            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
-                env->regs[R_EAX] = ret;
-            }
-            break;
-#endif
-        case EXCP0B_NOSEG:
-        case EXCP0C_STACK:
-            info.si_signo = TARGET_SIGBUS;
-            info.si_errno = 0;
-            info.si_code = TARGET_SI_KERNEL;
-            info._sifields._sigfault._addr = 0;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case EXCP0D_GPF:
-            /* XXX: potential problem if ABI32 */
-#ifndef TARGET_X86_64
-            if (env->eflags & VM_MASK) {
-                handle_vm86_fault(env);
-            } else
-#endif
-            {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SI_KERNEL;
-                info._sifields._sigfault._addr = 0;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP0E_PAGE:
-            info.si_signo = TARGET_SIGSEGV;
-            info.si_errno = 0;
-            if (!(env->error_code & 1))
-                info.si_code = TARGET_SEGV_MAPERR;
-            else
-                info.si_code = TARGET_SEGV_ACCERR;
-            info._sifields._sigfault._addr = env->cr[2];
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case EXCP00_DIVZ:
-#ifndef TARGET_X86_64
-            if (env->eflags & VM_MASK) {
-                handle_vm86_trap(env, trapnr);
-            } else
-#endif
-            {
-                /* division by zero */
-                info.si_signo = TARGET_SIGFPE;
-                info.si_errno = 0;
-                info.si_code = TARGET_FPE_INTDIV;
-                info._sifields._sigfault._addr = env->eip;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP01_DB:
-        case EXCP03_INT3:
-#ifndef TARGET_X86_64
-            if (env->eflags & VM_MASK) {
-                handle_vm86_trap(env, trapnr);
-            } else
-#endif
-            {
-                info.si_signo = TARGET_SIGTRAP;
-                info.si_errno = 0;
-                if (trapnr == EXCP01_DB) {
-                    info.si_code = TARGET_TRAP_BRKPT;
-                    info._sifields._sigfault._addr = env->eip;
-                } else {
-                    info.si_code = TARGET_SI_KERNEL;
-                    info._sifields._sigfault._addr = 0;
-                }
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP04_INTO:
-        case EXCP05_BOUND:
-#ifndef TARGET_X86_64
-            if (env->eflags & VM_MASK) {
-                handle_vm86_trap(env, trapnr);
-            } else
-#endif
-            {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SI_KERNEL;
-                info._sifields._sigfault._addr = 0;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP06_ILLOP:
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_ILLOPN;
-            info._sifields._sigfault._addr = env->eip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case EXCP_INTERRUPT:
-            /* just indicate that signals should be handled asap */
-            break;
-        case EXCP_DEBUG:
-            {
-                int sig;
-
-                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
-                if (sig)
-                  {
-                    info.si_signo = sig;
-                    info.si_errno = 0;
-                    info.si_code = TARGET_TRAP_BRKPT;
-                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                  }
-            }
-            break;
-        case EXCP_ATOMIC:
-            cpu_exec_step_atomic(cs);
-            break;
-        default:
-            pc = env->segs[R_CS].base + env->eip;
-            EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
-                      (long)pc, trapnr);
-            abort();
-        }
-        process_pending_signals(env);
-    }
-}
-#endif
-
-#ifdef TARGET_ARM
-
-#define get_user_code_u32(x, gaddr, env)                \
-    ({ abi_long __r = get_user_u32((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
-            (x) = bswap32(x);                           \
-        }                                               \
-        __r;                                            \
-    })
-
-#define get_user_code_u16(x, gaddr, env)                \
-    ({ abi_long __r = get_user_u16((x), (gaddr));       \
-        if (!__r && bswap_code(arm_sctlr_b(env))) {     \
-            (x) = bswap16(x);                           \
-        }                                               \
-        __r;                                            \
-    })
-
-#define get_user_data_u32(x, gaddr, env)                \
-    ({ abi_long __r = get_user_u32((x), (gaddr));       \
-        if (!__r && arm_cpu_bswap_data(env)) {          \
-            (x) = bswap32(x);                           \
-        }                                               \
-        __r;                                            \
-    })
-
-#define get_user_data_u16(x, gaddr, env)                \
-    ({ abi_long __r = get_user_u16((x), (gaddr));       \
-        if (!__r && arm_cpu_bswap_data(env)) {          \
-            (x) = bswap16(x);                           \
-        }                                               \
-        __r;                                            \
-    })
-
-#define put_user_data_u32(x, gaddr, env)                \
-    ({ typeof(x) __x = (x);                             \
-        if (arm_cpu_bswap_data(env)) {                  \
-            __x = bswap32(__x);                         \
-        }                                               \
-        put_user_u32(__x, (gaddr));                     \
-    })
-
-#define put_user_data_u16(x, gaddr, env)                \
-    ({ typeof(x) __x = (x);                             \
-        if (arm_cpu_bswap_data(env)) {                  \
-            __x = bswap16(__x);                         \
-        }                                               \
-        put_user_u16(__x, (gaddr));                     \
-    })
-
-#ifdef TARGET_ABI32
-/* Commpage handling -- there is no commpage for AArch64 */
-
-/*
- * See the Linux kernel's Documentation/arm/kernel_user_helpers.txt
- * Input:
- * r0 = pointer to oldval
- * r1 = pointer to newval
- * r2 = pointer to target value
- *
- * Output:
- * r0 = 0 if *ptr was changed, non-0 if no exchange happened
- * C set if *ptr was changed, clear if no exchange happened
- *
- * Note segv's in kernel helpers are a bit tricky, we can set the
- * data address sensibly but the PC address is just the entry point.
- */
-static void arm_kernel_cmpxchg64_helper(CPUARMState *env)
-{
-    uint64_t oldval, newval, val;
-    uint32_t addr, cpsr;
-    target_siginfo_t info;
-
-    /* Based on the 32 bit code in do_kernel_trap */
-
-    /* XXX: This only works between threads, not between processes.
-       It's probably possible to implement this with native host
-       operations. However things like ldrex/strex are much harder so
-       there's not much point trying.  */
-    start_exclusive();
-    cpsr = cpsr_read(env);
-    addr = env->regs[2];
-
-    if (get_user_u64(oldval, env->regs[0])) {
-        env->exception.vaddress = env->regs[0];
-        goto segv;
-    };
-
-    if (get_user_u64(newval, env->regs[1])) {
-        env->exception.vaddress = env->regs[1];
-        goto segv;
-    };
-
-    if (get_user_u64(val, addr)) {
-        env->exception.vaddress = addr;
-        goto segv;
-    }
-
-    if (val == oldval) {
-        val = newval;
-
-        if (put_user_u64(val, addr)) {
-            env->exception.vaddress = addr;
-            goto segv;
-        };
-
-        env->regs[0] = 0;
-        cpsr |= CPSR_C;
-    } else {
-        env->regs[0] = -1;
-        cpsr &= ~CPSR_C;
-    }
-    cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
-    end_exclusive();
-    return;
-
-segv:
-    end_exclusive();
-    /* We get the PC of the entry address - which is as good as anything,
-       on a real kernel what you get depends on which mode it uses. */
-    info.si_signo = TARGET_SIGSEGV;
-    info.si_errno = 0;
-    /* XXX: check env->error_code */
-    info.si_code = TARGET_SEGV_MAPERR;
-    info._sifields._sigfault._addr = env->exception.vaddress;
-    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-}
-
-/* Handle a jump to the kernel code page.  */
-static int
-do_kernel_trap(CPUARMState *env)
-{
-    uint32_t addr;
-    uint32_t cpsr;
-    uint32_t val;
-
-    switch (env->regs[15]) {
-    case 0xffff0fa0: /* __kernel_memory_barrier */
-        /* ??? No-op. Will need to do better for SMP.  */
-        break;
-    case 0xffff0fc0: /* __kernel_cmpxchg */
-         /* XXX: This only works between threads, not between processes.
-            It's probably possible to implement this with native host
-            operations. However things like ldrex/strex are much harder so
-            there's not much point trying.  */
-        start_exclusive();
-        cpsr = cpsr_read(env);
-        addr = env->regs[2];
-        /* FIXME: This should SEGV if the access fails.  */
-        if (get_user_u32(val, addr))
-            val = ~env->regs[0];
-        if (val == env->regs[0]) {
-            val = env->regs[1];
-            /* FIXME: Check for segfaults.  */
-            put_user_u32(val, addr);
-            env->regs[0] = 0;
-            cpsr |= CPSR_C;
-        } else {
-            env->regs[0] = -1;
-            cpsr &= ~CPSR_C;
-        }
-        cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
-        end_exclusive();
-        break;
-    case 0xffff0fe0: /* __kernel_get_tls */
-        env->regs[0] = cpu_get_tls(env);
-        break;
-    case 0xffff0f60: /* __kernel_cmpxchg64 */
-        arm_kernel_cmpxchg64_helper(env);
-        break;
-
-    default:
-        return 1;
-    }
-    /* Jump back to the caller.  */
-    addr = env->regs[14];
-    if (addr & 1) {
-        env->thumb = 1;
-        addr &= ~1;
-    }
-    env->regs[15] = addr;
-
-    return 0;
-}
-
-void cpu_loop(CPUARMState *env)
-{
-    CPUState *cs = CPU(arm_env_get_cpu(env));
-    int trapnr;
-    unsigned int n, insn;
-    target_siginfo_t info;
-    uint32_t addr;
-    abi_ulong ret;
-
-    for(;;) {
-        cpu_exec_start(cs);
-        trapnr = cpu_exec(cs);
-        cpu_exec_end(cs);
-        process_queued_cpu_work(cs);
-
-        switch(trapnr) {
-        case EXCP_UDEF:
-        case EXCP_NOCP:
-        case EXCP_INVSTATE:
-            {
-                TaskState *ts = cs->opaque;
-                uint32_t opcode;
-                int rc;
-
-                /* we handle the FPU emulation here, as Linux */
-                /* we get the opcode */
-                /* FIXME - what to do if get_user() fails? */
-                get_user_code_u32(opcode, env->regs[15], env);
-
-                rc = EmulateAll(opcode, &ts->fpa, env);
-                if (rc == 0) { /* illegal instruction */
-                    info.si_signo = TARGET_SIGILL;
-                    info.si_errno = 0;
-                    info.si_code = TARGET_ILL_ILLOPN;
-                    info._sifields._sigfault._addr = env->regs[15];
-                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                } else if (rc < 0) { /* FP exception */
-                    int arm_fpe=0;
-
-                    /* translate softfloat flags to FPSR flags */
-                    if (-rc & float_flag_invalid)
-                      arm_fpe |= BIT_IOC;
-                    if (-rc & float_flag_divbyzero)
-                      arm_fpe |= BIT_DZC;
-                    if (-rc & float_flag_overflow)
-                      arm_fpe |= BIT_OFC;
-                    if (-rc & float_flag_underflow)
-                      arm_fpe |= BIT_UFC;
-                    if (-rc & float_flag_inexact)
-                      arm_fpe |= BIT_IXC;
-
-                    FPSR fpsr = ts->fpa.fpsr;
-                    //printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe);
-
-                    if (fpsr & (arm_fpe << 16)) { /* exception enabled? */
-                      info.si_signo = TARGET_SIGFPE;
-                      info.si_errno = 0;
-
-                      /* ordered by priority, least first */
-                      if (arm_fpe & BIT_IXC) info.si_code = TARGET_FPE_FLTRES;
-                      if (arm_fpe & BIT_UFC) info.si_code = TARGET_FPE_FLTUND;
-                      if (arm_fpe & BIT_OFC) info.si_code = TARGET_FPE_FLTOVF;
-                      if (arm_fpe & BIT_DZC) info.si_code = TARGET_FPE_FLTDIV;
-                      if (arm_fpe & BIT_IOC) info.si_code = TARGET_FPE_FLTINV;
-
-                      info._sifields._sigfault._addr = env->regs[15];
-                      queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                    } else {
-                      env->regs[15] += 4;
-                    }
-
-                    /* accumulate unenabled exceptions */
-                    if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC))
-                      fpsr |= BIT_IXC;
-                    if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC))
-                      fpsr |= BIT_UFC;
-                    if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC))
-                      fpsr |= BIT_OFC;
-                    if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC))
-                      fpsr |= BIT_DZC;
-                    if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC))
-                      fpsr |= BIT_IOC;
-                    ts->fpa.fpsr=fpsr;
-                } else { /* everything OK */
-                    /* increment PC */
-                    env->regs[15] += 4;
-                }
-            }
-            break;
-        case EXCP_SWI:
-        case EXCP_BKPT:
-            {
-                env->eabi = 1;
-                /* system call */
-                if (trapnr == EXCP_BKPT) {
-                    if (env->thumb) {
-                        /* FIXME - what to do if get_user() fails? */
-                        get_user_code_u16(insn, env->regs[15], env);
-                        n = insn & 0xff;
-                        env->regs[15] += 2;
-                    } else {
-                        /* FIXME - what to do if get_user() fails? */
-                        get_user_code_u32(insn, env->regs[15], env);
-                        n = (insn & 0xf) | ((insn >> 4) & 0xff0);
-                        env->regs[15] += 4;
-                    }
-                } else {
-                    if (env->thumb) {
-                        /* FIXME - what to do if get_user() fails? */
-                        get_user_code_u16(insn, env->regs[15] - 2, env);
-                        n = insn & 0xff;
-                    } else {
-                        /* FIXME - what to do if get_user() fails? */
-                        get_user_code_u32(insn, env->regs[15] - 4, env);
-                        n = insn & 0xffffff;
-                    }
-                }
-
-                if (n == ARM_NR_cacheflush) {
-                    /* nop */
-                } else if (n == ARM_NR_semihosting
-                           || n == ARM_NR_thumb_semihosting) {
-                    env->regs[0] = do_arm_semihosting (env);
-                } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) {
-                    /* linux syscall */
-                    if (env->thumb || n == 0) {
-                        n = env->regs[7];
-                    } else {
-                        n -= ARM_SYSCALL_BASE;
-                        env->eabi = 0;
-                    }
-                    if ( n > ARM_NR_BASE) {
-                        switch (n) {
-                        case ARM_NR_cacheflush:
-                            /* nop */
-                            break;
-                        case ARM_NR_set_tls:
-                            cpu_set_tls(env, env->regs[0]);
-                            env->regs[0] = 0;
-                            break;
-                        case ARM_NR_breakpoint:
-                            env->regs[15] -= env->thumb ? 2 : 4;
-                            goto excp_debug;
-                        default:
-                            gemu_log("qemu: Unsupported ARM syscall: 0x%x\n",
-                                     n);
-                            env->regs[0] = -TARGET_ENOSYS;
-                            break;
-                        }
-                    } else {
-                        ret = do_syscall(env,
-                                         n,
-                                         env->regs[0],
-                                         env->regs[1],
-                                         env->regs[2],
-                                         env->regs[3],
-                                         env->regs[4],
-                                         env->regs[5],
-                                         0, 0);
-                        if (ret == -TARGET_ERESTARTSYS) {
-                            env->regs[15] -= env->thumb ? 2 : 4;
-                        } else if (ret != -TARGET_QEMU_ESIGRETURN) {
-                            env->regs[0] = ret;
-                        }
-                    }
-                } else {
-                    goto error;
-                }
-            }
-            break;
-        case EXCP_SEMIHOST:
-            env->regs[0] = do_arm_semihosting(env);
-            break;
-        case EXCP_INTERRUPT:
-            /* just indicate that signals should be handled asap */
-            break;
-        case EXCP_PREFETCH_ABORT:
-        case EXCP_DATA_ABORT:
-            addr = env->exception.vaddress;
-            {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                /* XXX: check env->error_code */
-                info.si_code = TARGET_SEGV_MAPERR;
-                info._sifields._sigfault._addr = addr;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP_DEBUG:
-        excp_debug:
-            {
-                int sig;
-
-                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
-                if (sig)
-                  {
-                    info.si_signo = sig;
-                    info.si_errno = 0;
-                    info.si_code = TARGET_TRAP_BRKPT;
-                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                  }
-            }
-            break;
-        case EXCP_KERNEL_TRAP:
-            if (do_kernel_trap(env))
-              goto error;
-            break;
-        case EXCP_YIELD:
-            /* nothing to do here for user-mode, just resume guest code */
-            break;
-        case EXCP_ATOMIC:
-            cpu_exec_step_atomic(cs);
-            break;
-        default:
-        error:
-            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
-            abort();
-        }
-        process_pending_signals(env);
-    }
-}
-
-#else
-
-/* AArch64 main loop */
-void cpu_loop(CPUARMState *env)
-{
-    CPUState *cs = CPU(arm_env_get_cpu(env));
-    int trapnr, sig;
-    abi_long ret;
-    target_siginfo_t info;
-
-    for (;;) {
-        cpu_exec_start(cs);
-        trapnr = cpu_exec(cs);
-        cpu_exec_end(cs);
-        process_queued_cpu_work(cs);
-
-        switch (trapnr) {
-        case EXCP_SWI:
-            ret = do_syscall(env,
-                             env->xregs[8],
-                             env->xregs[0],
-                             env->xregs[1],
-                             env->xregs[2],
-                             env->xregs[3],
-                             env->xregs[4],
-                             env->xregs[5],
-                             0, 0);
-            if (ret == -TARGET_ERESTARTSYS) {
-                env->pc -= 4;
-            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
-                env->xregs[0] = ret;
-            }
-            break;
-        case EXCP_INTERRUPT:
-            /* just indicate that signals should be handled asap */
-            break;
-        case EXCP_UDEF:
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_ILLOPN;
-            info._sifields._sigfault._addr = env->pc;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case EXCP_PREFETCH_ABORT:
-        case EXCP_DATA_ABORT:
-            info.si_signo = TARGET_SIGSEGV;
-            info.si_errno = 0;
-            /* XXX: check env->error_code */
-            info.si_code = TARGET_SEGV_MAPERR;
-            info._sifields._sigfault._addr = env->exception.vaddress;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case EXCP_DEBUG:
-        case EXCP_BKPT:
-            sig = gdb_handlesig(cs, TARGET_SIGTRAP);
-            if (sig) {
-                info.si_signo = sig;
-                info.si_errno = 0;
-                info.si_code = TARGET_TRAP_BRKPT;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP_SEMIHOST:
-            env->xregs[0] = do_arm_semihosting(env);
-            break;
-        case EXCP_YIELD:
-            /* nothing to do here for user-mode, just resume guest code */
-            break;
-        case EXCP_ATOMIC:
-            cpu_exec_step_atomic(cs);
-            break;
-        default:
-            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
-            abort();
-        }
-        process_pending_signals(env);
-        /* Exception return on AArch64 always clears the exclusive monitor,
-         * so any return to running guest code implies this.
-         */
-        env->exclusive_addr = -1;
-    }
-}
-#endif /* ndef TARGET_ABI32 */
-
-#endif
-
-#ifdef TARGET_SPARC
-#define SPARC64_STACK_BIAS 2047
-
-//#define DEBUG_WIN
-
-/* WARNING: dealing with register windows _is_ complicated. More info
-   can be found at http://www.sics.se/~psm/sparcstack.html */
-static inline int get_reg_index(CPUSPARCState *env, int cwp, int index)
-{
-    index = (index + cwp * 16) % (16 * env->nwindows);
-    /* wrap handling : if cwp is on the last window, then we use the
-       registers 'after' the end */
-    if (index < 8 && env->cwp == env->nwindows - 1)
-        index += 16 * env->nwindows;
-    return index;
-}
-
-/* save the register window 'cwp1' */
-static inline void save_window_offset(CPUSPARCState *env, int cwp1)
-{
-    unsigned int i;
-    abi_ulong sp_ptr;
-
-    sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
-#ifdef TARGET_SPARC64
-    if (sp_ptr & 3)
-        sp_ptr += SPARC64_STACK_BIAS;
-#endif
-#if defined(DEBUG_WIN)
-    printf("win_overflow: sp_ptr=0x" TARGET_ABI_FMT_lx " save_cwp=%d\n",
-           sp_ptr, cwp1);
-#endif
-    for(i = 0; i < 16; i++) {
-        /* FIXME - what to do if put_user() fails? */
-        put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
-        sp_ptr += sizeof(abi_ulong);
-    }
-}
-
-static void save_window(CPUSPARCState *env)
-{
-#ifndef TARGET_SPARC64
-    unsigned int new_wim;
-    new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) &
-        ((1LL << env->nwindows) - 1);
-    save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
-    env->wim = new_wim;
-#else
-    save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
-    env->cansave++;
-    env->canrestore--;
-#endif
-}
-
-static void restore_window(CPUSPARCState *env)
-{
-#ifndef TARGET_SPARC64
-    unsigned int new_wim;
-#endif
-    unsigned int i, cwp1;
-    abi_ulong sp_ptr;
-
-#ifndef TARGET_SPARC64
-    new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) &
-        ((1LL << env->nwindows) - 1);
-#endif
-
-    /* restore the invalid window */
-    cwp1 = cpu_cwp_inc(env, env->cwp + 1);
-    sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
-#ifdef TARGET_SPARC64
-    if (sp_ptr & 3)
-        sp_ptr += SPARC64_STACK_BIAS;
-#endif
-#if defined(DEBUG_WIN)
-    printf("win_underflow: sp_ptr=0x" TARGET_ABI_FMT_lx " load_cwp=%d\n",
-           sp_ptr, cwp1);
-#endif
-    for(i = 0; i < 16; i++) {
-        /* FIXME - what to do if get_user() fails? */
-        get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
-        sp_ptr += sizeof(abi_ulong);
-    }
-#ifdef TARGET_SPARC64
-    env->canrestore++;
-    if (env->cleanwin < env->nwindows - 1)
-        env->cleanwin++;
-    env->cansave--;
-#else
-    env->wim = new_wim;
-#endif
-}
-
-static void flush_windows(CPUSPARCState *env)
-{
-    int offset, cwp1;
-
-    offset = 1;
-    for(;;) {
-        /* if restore would invoke restore_window(), then we can stop */
-        cwp1 = cpu_cwp_inc(env, env->cwp + offset);
-#ifndef TARGET_SPARC64
-        if (env->wim & (1 << cwp1))
-            break;
-#else
-        if (env->canrestore == 0)
-            break;
-        env->cansave++;
-        env->canrestore--;
-#endif
-        save_window_offset(env, cwp1);
-        offset++;
-    }
-    cwp1 = cpu_cwp_inc(env, env->cwp + 1);
-#ifndef TARGET_SPARC64
-    /* set wim so that restore will reload the registers */
-    env->wim = 1 << cwp1;
-#endif
-#if defined(DEBUG_WIN)
-    printf("flush_windows: nb=%d\n", offset - 1);
-#endif
-}
-
-void cpu_loop (CPUSPARCState *env)
-{
-    CPUState *cs = CPU(sparc_env_get_cpu(env));
-    int trapnr;
-    abi_long ret;
-    target_siginfo_t info;
-
-    while (1) {
-        cpu_exec_start(cs);
-        trapnr = cpu_exec(cs);
-        cpu_exec_end(cs);
-        process_queued_cpu_work(cs);
-
-        /* Compute PSR before exposing state.  */
-        if (env->cc_op != CC_OP_FLAGS) {
-            cpu_get_psr(env);
-        }
-
-        switch (trapnr) {
-#ifndef TARGET_SPARC64
-        case 0x88:
-        case 0x90:
-#else
-        case 0x110:
-        case 0x16d:
-#endif
-            ret = do_syscall (env, env->gregs[1],
-                              env->regwptr[0], env->regwptr[1],
-                              env->regwptr[2], env->regwptr[3],
-                              env->regwptr[4], env->regwptr[5],
-                              0, 0);
-            if (ret == -TARGET_ERESTARTSYS || ret == -TARGET_QEMU_ESIGRETURN) {
-                break;
-            }
-            if ((abi_ulong)ret >= (abi_ulong)(-515)) {
-#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
-                env->xcc |= PSR_CARRY;
-#else
-                env->psr |= PSR_CARRY;
-#endif
-                ret = -ret;
-            } else {
-#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
-                env->xcc &= ~PSR_CARRY;
-#else
-                env->psr &= ~PSR_CARRY;
-#endif
-            }
-            env->regwptr[0] = ret;
-            /* next instruction */
-            env->pc = env->npc;
-            env->npc = env->npc + 4;
-            break;
-        case 0x83: /* flush windows */
-#ifdef TARGET_ABI32
-        case 0x103:
-#endif
-            flush_windows(env);
-            /* next instruction */
-            env->pc = env->npc;
-            env->npc = env->npc + 4;
-            break;
-#ifndef TARGET_SPARC64
-        case TT_WIN_OVF: /* window overflow */
-            save_window(env);
-            break;
-        case TT_WIN_UNF: /* window underflow */
-            restore_window(env);
-            break;
-        case TT_TFAULT:
-        case TT_DFAULT:
-            {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                /* XXX: check env->error_code */
-                info.si_code = TARGET_SEGV_MAPERR;
-                info._sifields._sigfault._addr = env->mmuregs[4];
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-#else
-        case TT_SPILL: /* window overflow */
-            save_window(env);
-            break;
-        case TT_FILL: /* window underflow */
-            restore_window(env);
-            break;
-        case TT_TFAULT:
-        case TT_DFAULT:
-            {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                /* XXX: check env->error_code */
-                info.si_code = TARGET_SEGV_MAPERR;
-                if (trapnr == TT_DFAULT)
-                    info._sifields._sigfault._addr = env->dmmu.mmuregs[4];
-                else
-                    info._sifields._sigfault._addr = cpu_tsptr(env)->tpc;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-#ifndef TARGET_ABI32
-        case 0x16e:
-            flush_windows(env);
-            sparc64_get_context(env);
-            break;
-        case 0x16f:
-            flush_windows(env);
-            sparc64_set_context(env);
-            break;
-#endif
-#endif
-        case EXCP_INTERRUPT:
-            /* just indicate that signals should be handled asap */
-            break;
-        case TT_ILL_INSN:
-            {
-                info.si_signo = TARGET_SIGILL;
-                info.si_errno = 0;
-                info.si_code = TARGET_ILL_ILLOPC;
-                info._sifields._sigfault._addr = env->pc;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP_DEBUG:
-            {
-                int sig;
-
-                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
-                if (sig)
-                  {
-                    info.si_signo = sig;
-                    info.si_errno = 0;
-                    info.si_code = TARGET_TRAP_BRKPT;
-                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                  }
-            }
-            break;
-        case EXCP_ATOMIC:
-            cpu_exec_step_atomic(cs);
-            break;
-        default:
-            printf ("Unhandled trap: 0x%x\n", trapnr);
-            cpu_dump_state(cs, stderr, fprintf, 0);
-            exit(EXIT_FAILURE);
-        }
-        process_pending_signals (env);
-    }
-}
-
-#endif
-
-#ifdef TARGET_PPC
-static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
-{
-    return cpu_get_host_ticks();
-}
-
-uint64_t cpu_ppc_load_tbl(CPUPPCState *env)
-{
-    return cpu_ppc_get_tb(env);
-}
-
-uint32_t cpu_ppc_load_tbu(CPUPPCState *env)
-{
-    return cpu_ppc_get_tb(env) >> 32;
-}
-
-uint64_t cpu_ppc_load_atbl(CPUPPCState *env)
-{
-    return cpu_ppc_get_tb(env);
-}
-
-uint32_t cpu_ppc_load_atbu(CPUPPCState *env)
-{
-    return cpu_ppc_get_tb(env) >> 32;
-}
-
-uint32_t cpu_ppc601_load_rtcu(CPUPPCState *env)
-__attribute__ (( alias ("cpu_ppc_load_tbu") ));
-
-uint32_t cpu_ppc601_load_rtcl(CPUPPCState *env)
-{
-    return cpu_ppc_load_tbl(env) & 0x3FFFFF80;
-}
-
-/* XXX: to be fixed */
-int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp)
-{
-    return -1;
-}
-
-int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)
-{
-    return -1;
-}
-
-static int do_store_exclusive(CPUPPCState *env)
-{
-    target_ulong addr;
-    target_ulong page_addr;
-    target_ulong val, val2 __attribute__((unused)) = 0;
-    int flags;
-    int segv = 0;
-
-    addr = env->reserve_ea;
-    page_addr = addr & TARGET_PAGE_MASK;
-    start_exclusive();
-    mmap_lock();
-    flags = page_get_flags(page_addr);
-    if ((flags & PAGE_READ) == 0) {
-        segv = 1;
-    } else {
-        int reg = env->reserve_info & 0x1f;
-        int size = env->reserve_info >> 5;
-        int stored = 0;
-
-        if (addr == env->reserve_addr) {
-            switch (size) {
-            case 1: segv = get_user_u8(val, addr); break;
-            case 2: segv = get_user_u16(val, addr); break;
-            case 4: segv = get_user_u32(val, addr); break;
-#if defined(TARGET_PPC64)
-            case 8: segv = get_user_u64(val, addr); break;
-            case 16: {
-                segv = get_user_u64(val, addr);
-                if (!segv) {
-                    segv = get_user_u64(val2, addr + 8);
-                }
-                break;
-            }
-#endif
-            default: abort();
-            }
-            if (!segv && val == env->reserve_val) {
-                val = env->gpr[reg];
-                switch (size) {
-                case 1: segv = put_user_u8(val, addr); break;
-                case 2: segv = put_user_u16(val, addr); break;
-                case 4: segv = put_user_u32(val, addr); break;
-#if defined(TARGET_PPC64)
-                case 8: segv = put_user_u64(val, addr); break;
-                case 16: {
-                    if (val2 == env->reserve_val2) {
-                        if (msr_le) {
-                            val2 = val;
-                            val = env->gpr[reg+1];
-                        } else {
-                            val2 = env->gpr[reg+1];
-                        }
-                        segv = put_user_u64(val, addr);
-                        if (!segv) {
-                            segv = put_user_u64(val2, addr + 8);
-                        }
-                    }
-                    break;
-                }
-#endif
-                default: abort();
-                }
-                if (!segv) {
-                    stored = 1;
-                }
-            }
-        }
-        env->crf[0] = (stored << 1) | xer_so;
-        env->reserve_addr = (target_ulong)-1;
-    }
-    if (!segv) {
-        env->nip += 4;
-    }
-    mmap_unlock();
-    end_exclusive();
-    return segv;
-}
-
-void cpu_loop(CPUPPCState *env)
-{
-    CPUState *cs = CPU(ppc_env_get_cpu(env));
-    target_siginfo_t info;
-    int trapnr;
-    target_ulong ret;
-
-    for(;;) {
-        cpu_exec_start(cs);
-        trapnr = cpu_exec(cs);
-        cpu_exec_end(cs);
-        process_queued_cpu_work(cs);
-
-        switch(trapnr) {
-        case POWERPC_EXCP_NONE:
-            /* Just go on */
-            break;
-        case POWERPC_EXCP_CRITICAL: /* Critical input                        */
-            cpu_abort(cs, "Critical interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_MCHECK:   /* Machine check exception               */
-            cpu_abort(cs, "Machine check exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_DSI:      /* Data storage exception                */
-            /* XXX: check this. Seems bugged */
-            switch (env->error_code & 0xFF000000) {
-            case 0x40000000:
-            case 0x42000000:
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_MAPERR;
-                break;
-            case 0x04000000:
-                info.si_signo = TARGET_SIGILL;
-                info.si_errno = 0;
-                info.si_code = TARGET_ILL_ILLADR;
-                break;
-            case 0x08000000:
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_ACCERR;
-                break;
-            default:
-                /* Let's send a regular segfault... */
-                EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
-                          env->error_code);
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_MAPERR;
-                break;
-            }
-            info._sifields._sigfault._addr = env->spr[SPR_DAR];
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_ISI:      /* Instruction storage exception         */
-            /* XXX: check this */
-            switch (env->error_code & 0xFF000000) {
-            case 0x40000000:
-                info.si_signo = TARGET_SIGSEGV;
-            info.si_errno = 0;
-                info.si_code = TARGET_SEGV_MAPERR;
-                break;
-            case 0x10000000:
-            case 0x08000000:
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_ACCERR;
-                break;
-            default:
-                /* Let's send a regular segfault... */
-                EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
-                          env->error_code);
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_MAPERR;
-                break;
-            }
-            info._sifields._sigfault._addr = env->nip - 4;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_EXTERNAL: /* External input                        */
-            cpu_abort(cs, "External interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_ALIGN:    /* Alignment exception                   */
-            /* XXX: check this */
-            info.si_signo = TARGET_SIGBUS;
-            info.si_errno = 0;
-            info.si_code = TARGET_BUS_ADRALN;
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_PROGRAM:  /* Program exception                     */
-        case POWERPC_EXCP_HV_EMU:   /* HV emulation                          */
-            /* XXX: check this */
-            switch (env->error_code & ~0xF) {
-            case POWERPC_EXCP_FP:
-                info.si_signo = TARGET_SIGFPE;
-                info.si_errno = 0;
-                switch (env->error_code & 0xF) {
-                case POWERPC_EXCP_FP_OX:
-                    info.si_code = TARGET_FPE_FLTOVF;
-                    break;
-                case POWERPC_EXCP_FP_UX:
-                    info.si_code = TARGET_FPE_FLTUND;
-                    break;
-                case POWERPC_EXCP_FP_ZX:
-                case POWERPC_EXCP_FP_VXZDZ:
-                    info.si_code = TARGET_FPE_FLTDIV;
-                    break;
-                case POWERPC_EXCP_FP_XX:
-                    info.si_code = TARGET_FPE_FLTRES;
-                    break;
-                case POWERPC_EXCP_FP_VXSOFT:
-                    info.si_code = TARGET_FPE_FLTINV;
-                    break;
-                case POWERPC_EXCP_FP_VXSNAN:
-                case POWERPC_EXCP_FP_VXISI:
-                case POWERPC_EXCP_FP_VXIDI:
-                case POWERPC_EXCP_FP_VXIMZ:
-                case POWERPC_EXCP_FP_VXVC:
-                case POWERPC_EXCP_FP_VXSQRT:
-                case POWERPC_EXCP_FP_VXCVI:
-                    info.si_code = TARGET_FPE_FLTSUB;
-                    break;
-                default:
-                    EXCP_DUMP(env, "Unknown floating point exception (%02x)\n",
-                              env->error_code);
-                    break;
-                }
-                break;
-            case POWERPC_EXCP_INVAL:
-                info.si_signo = TARGET_SIGILL;
-                info.si_errno = 0;
-                switch (env->error_code & 0xF) {
-                case POWERPC_EXCP_INVAL_INVAL:
-                    info.si_code = TARGET_ILL_ILLOPC;
-                    break;
-                case POWERPC_EXCP_INVAL_LSWX:
-                    info.si_code = TARGET_ILL_ILLOPN;
-                    break;
-                case POWERPC_EXCP_INVAL_SPR:
-                    info.si_code = TARGET_ILL_PRVREG;
-                    break;
-                case POWERPC_EXCP_INVAL_FP:
-                    info.si_code = TARGET_ILL_COPROC;
-                    break;
-                default:
-                    EXCP_DUMP(env, "Unknown invalid operation (%02x)\n",
-                              env->error_code & 0xF);
-                    info.si_code = TARGET_ILL_ILLADR;
-                    break;
-                }
-                break;
-            case POWERPC_EXCP_PRIV:
-                info.si_signo = TARGET_SIGILL;
-                info.si_errno = 0;
-                switch (env->error_code & 0xF) {
-                case POWERPC_EXCP_PRIV_OPC:
-                    info.si_code = TARGET_ILL_PRVOPC;
-                    break;
-                case POWERPC_EXCP_PRIV_REG:
-                    info.si_code = TARGET_ILL_PRVREG;
-                    break;
-                default:
-                    EXCP_DUMP(env, "Unknown privilege violation (%02x)\n",
-                              env->error_code & 0xF);
-                    info.si_code = TARGET_ILL_PRVOPC;
-                    break;
-                }
-                break;
-            case POWERPC_EXCP_TRAP:
-                cpu_abort(cs, "Tried to call a TRAP\n");
-                break;
-            default:
-                /* Should not happen ! */
-                cpu_abort(cs, "Unknown program exception (%02x)\n",
-                          env->error_code);
-                break;
-            }
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_FPU:      /* Floating-point unavailable exception  */
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_COPROC;
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_SYSCALL:  /* System call exception                 */
-            cpu_abort(cs, "Syscall exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_APU:      /* Auxiliary processor unavailable       */
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_COPROC;
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_DECR:     /* Decrementer exception                 */
-            cpu_abort(cs, "Decrementer interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_FIT:      /* Fixed-interval timer interrupt        */
-            cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_WDT:      /* Watchdog timer interrupt              */
-            cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_DTLB:     /* Data TLB error                        */
-            cpu_abort(cs, "Data TLB exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_ITLB:     /* Instruction TLB error                 */
-            cpu_abort(cs, "Instruction TLB exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_SPEU:     /* SPE/embedded floating-point unavail.  */
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_COPROC;
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_EFPDI:    /* Embedded floating-point data IRQ      */
-            cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
-            break;
-        case POWERPC_EXCP_EFPRI:    /* Embedded floating-point round IRQ     */
-            cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
-            break;
-        case POWERPC_EXCP_EPERFM:   /* Embedded performance monitor IRQ      */
-            cpu_abort(cs, "Performance monitor exception not handled\n");
-            break;
-        case POWERPC_EXCP_DOORI:    /* Embedded doorbell interrupt           */
-            cpu_abort(cs, "Doorbell interrupt while in user mode. "
-                       "Aborting\n");
-            break;
-        case POWERPC_EXCP_DOORCI:   /* Embedded doorbell critical interrupt  */
-            cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_RESET:    /* System reset exception                */
-            cpu_abort(cs, "Reset interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_DSEG:     /* Data segment exception                */
-            cpu_abort(cs, "Data segment exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_ISEG:     /* Instruction segment exception         */
-            cpu_abort(cs, "Instruction segment exception "
-                      "while in user mode. Aborting\n");
-            break;
-        /* PowerPC 64 with hypervisor mode support */
-        case POWERPC_EXCP_HDECR:    /* Hypervisor decrementer exception      */
-            cpu_abort(cs, "Hypervisor decrementer interrupt "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_TRACE:    /* Trace exception                       */
-            /* Nothing to do:
-             * we use this exception to emulate step-by-step execution mode.
-             */
-            break;
-        /* PowerPC 64 with hypervisor mode support */
-        case POWERPC_EXCP_HDSI:     /* Hypervisor data storage exception     */
-            cpu_abort(cs, "Hypervisor data storage exception "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_HISI:     /* Hypervisor instruction storage excp   */
-            cpu_abort(cs, "Hypervisor instruction storage exception "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_HDSEG:    /* Hypervisor data segment exception     */
-            cpu_abort(cs, "Hypervisor data segment exception "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_HISEG:    /* Hypervisor instruction segment excp   */
-            cpu_abort(cs, "Hypervisor instruction segment exception "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_VPU:      /* Vector unavailable exception          */
-            info.si_signo = TARGET_SIGILL;
-            info.si_errno = 0;
-            info.si_code = TARGET_ILL_COPROC;
-            info._sifields._sigfault._addr = env->nip;
-            queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            break;
-        case POWERPC_EXCP_PIT:      /* Programmable interval timer IRQ       */
-            cpu_abort(cs, "Programmable interval timer interrupt "
-                      "while in user mode. Aborting\n");
-            break;
-        case POWERPC_EXCP_IO:       /* IO error exception                    */
-            cpu_abort(cs, "IO error exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_RUNM:     /* Run mode exception                    */
-            cpu_abort(cs, "Run mode exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_EMUL:     /* Emulation trap exception              */
-            cpu_abort(cs, "Emulation trap exception not handled\n");
-            break;
-        case POWERPC_EXCP_IFTLB:    /* Instruction fetch TLB error           */
-            cpu_abort(cs, "Instruction fetch TLB exception "
-                      "while in user-mode. Aborting");
-            break;
-        case POWERPC_EXCP_DLTLB:    /* Data load TLB miss                    */
-            cpu_abort(cs, "Data load TLB exception while in user-mode. "
-                      "Aborting");
-            break;
-        case POWERPC_EXCP_DSTLB:    /* Data store TLB miss                   */
-            cpu_abort(cs, "Data store TLB exception while in user-mode. "
-                      "Aborting");
-            break;
-        case POWERPC_EXCP_FPA:      /* Floating-point assist exception       */
-            cpu_abort(cs, "Floating-point assist exception not handled\n");
-            break;
-        case POWERPC_EXCP_IABR:     /* Instruction address breakpoint        */
-            cpu_abort(cs, "Instruction address breakpoint exception "
-                      "not handled\n");
-            break;
-        case POWERPC_EXCP_SMI:      /* System management interrupt           */
-            cpu_abort(cs, "System management interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_THERM:    /* Thermal interrupt                     */
-            cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_PERFM:   /* Embedded performance monitor IRQ      */
-            cpu_abort(cs, "Performance monitor exception not handled\n");
-            break;
-        case POWERPC_EXCP_VPUA:     /* Vector assist exception               */
-            cpu_abort(cs, "Vector assist exception not handled\n");
-            break;
-        case POWERPC_EXCP_SOFTP:    /* Soft patch exception                  */
-            cpu_abort(cs, "Soft patch exception not handled\n");
-            break;
-        case POWERPC_EXCP_MAINT:    /* Maintenance exception                 */
-            cpu_abort(cs, "Maintenance exception while in user mode. "
-                      "Aborting\n");
-            break;
-        case POWERPC_EXCP_STOP:     /* stop translation                      */
-            /* We did invalidate the instruction cache. Go on */
-            break;
-        case POWERPC_EXCP_BRANCH:   /* branch instruction:                   */
-            /* We just stopped because of a branch. Go on */
-            break;
-        case POWERPC_EXCP_SYSCALL_USER:
-            /* system call in user-mode emulation */
-            /* WARNING:
-             * PPC ABI uses overflow flag in cr0 to signal an error
-             * in syscalls.
-             */
-            env->crf[0] &= ~0x1;
-            env->nip += 4;
-            ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
-                             env->gpr[5], env->gpr[6], env->gpr[7],
-                             env->gpr[8], 0, 0);
-            if (ret == -TARGET_ERESTARTSYS) {
-                env->nip -= 4;
-                break;
-            }
-            if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
-                /* Returning from a successful sigreturn syscall.
-                   Avoid corrupting register state.  */
-                break;
-            }
-            if (ret > (target_ulong)(-515)) {
-                env->crf[0] |= 0x1;
-                ret = -ret;
-            }
-            env->gpr[3] = ret;
-            break;
-        case POWERPC_EXCP_STCX:
-            if (do_store_exclusive(env)) {
-                info.si_signo = TARGET_SIGSEGV;
-                info.si_errno = 0;
-                info.si_code = TARGET_SEGV_MAPERR;
-                info._sifields._sigfault._addr = env->nip;
-                queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-            }
-            break;
-        case EXCP_DEBUG:
-            {
-                int sig;
-
-                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
-                if (sig) {
-                    info.si_signo = sig;
-                    info.si_errno = 0;
-                    info.si_code = TARGET_TRAP_BRKPT;
-                    queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
-                  }
-            }
-            break;
-        case EXCP_INTERRUPT:
-            /* just indicate that signals should be handled asap */
-            break;
-        case EXCP_ATOMIC:
-            cpu_exec_step_atomic(cs);
-            break;
-        default:
-            cpu_abort(cs, "Unknown exception 0x%x. Aborting\n", trapnr);
-            break;
-        }
-        process_pending_signals(env);
-    }
-}
-#endif
-
-#ifdef TARGET_MIPS
-
-# ifdef TARGET_ABI_MIPSO32
-#  define MIPS_SYS(name, args) args,
-static const uint8_t mips_syscall_args[] = {
-	MIPS_SYS(sys_syscall	, 8)	/* 4000 */
-	MIPS_SYS(sys_exit	, 1)
-	MIPS_SYS(sys_fork	, 0)
-	MIPS_SYS(sys_read	, 3)
-	MIPS_SYS(sys_write	, 3)
-	MIPS_SYS(sys_open	, 3)	/* 4005 */
-	MIPS_SYS(sys_close	, 1)
-	MIPS_SYS(sys_waitpid	, 3)
-	MIPS_SYS(sys_creat	, 2)
-	MIPS_SYS(sys_link	, 2)
-	MIPS_SYS(sys_unlink	, 1)	/* 4010 */
-	MIPS_SYS(sys_execve	, 0)
-	MIPS_SYS(sys_chdir	, 1)
-	MIPS_SYS(sys_time	, 1)
-	MIPS_SYS(sys_mknod	, 3)
-	MIPS_SYS(sys_chmod	, 2)	/* 4015 */
-	MIPS_SYS(sys_lchown	, 3)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was sys_stat */
-	MIPS_SYS(sys_lseek	, 3)
-	MIPS_SYS(sys_getpid	, 0)	/* 4020 */
-	MIPS_SYS(sys_mount	, 5)
-	MIPS_SYS(sys_umount	, 1)
-	MIPS_SYS(sys_setuid	, 1)
-	MIPS_SYS(sys_getuid	, 0)
-	MIPS_SYS(sys_stime	, 1)	/* 4025 */
-	MIPS_SYS(sys_ptrace	, 4)
-	MIPS_SYS(sys_alarm	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was sys_fstat */
-	MIPS_SYS(sys_pause	, 0)
-	MIPS_SYS(sys_utime	, 2)	/* 4030 */
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_access	, 2)
-	MIPS_SYS(sys_nice	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* 4035 */
-	MIPS_SYS(sys_sync	, 0)
-	MIPS_SYS(sys_kill	, 2)
-	MIPS_SYS(sys_rename	, 2)
-	MIPS_SYS(sys_mkdir	, 2)
-	MIPS_SYS(sys_rmdir	, 1)	/* 4040 */
-	MIPS_SYS(sys_dup		, 1)
-	MIPS_SYS(sys_pipe	, 0)
-	MIPS_SYS(sys_times	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_brk		, 1)	/* 4045 */
-	MIPS_SYS(sys_setgid	, 1)
-	MIPS_SYS(sys_getgid	, 0)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was signal(2) */
-	MIPS_SYS(sys_geteuid	, 0)
-	MIPS_SYS(sys_getegid	, 0)	/* 4050 */
-	MIPS_SYS(sys_acct	, 0)
-	MIPS_SYS(sys_umount2	, 2)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_ioctl	, 3)
-	MIPS_SYS(sys_fcntl	, 3)	/* 4055 */
-	MIPS_SYS(sys_ni_syscall	, 2)
-	MIPS_SYS(sys_setpgid	, 2)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_olduname	, 1)
-	MIPS_SYS(sys_umask	, 1)	/* 4060 */
-	MIPS_SYS(sys_chroot	, 1)
-	MIPS_SYS(sys_ustat	, 2)
-	MIPS_SYS(sys_dup2	, 2)
-	MIPS_SYS(sys_getppid	, 0)
-	MIPS_SYS(sys_getpgrp	, 0)	/* 4065 */
-	MIPS_SYS(sys_setsid	, 0)
-	MIPS_SYS(sys_sigaction	, 3)
-	MIPS_SYS(sys_sgetmask	, 0)
-	MIPS_SYS(sys_ssetmask	, 1)
-	MIPS_SYS(sys_setreuid	, 2)	/* 4070 */
-	MIPS_SYS(sys_setregid	, 2)
-	MIPS_SYS(sys_sigsuspend	, 0)
-	MIPS_SYS(sys_sigpending	, 1)
-	MIPS_SYS(sys_sethostname	, 2)
-	MIPS_SYS(sys_setrlimit	, 2)	/* 4075 */
-	MIPS_SYS(sys_getrlimit	, 2)
-	MIPS_SYS(sys_getrusage	, 2)
-	MIPS_SYS(sys_gettimeofday, 2)
-	MIPS_SYS(sys_settimeofday, 2)
-	MIPS_SYS(sys_getgroups	, 2)	/* 4080 */
-	MIPS_SYS(sys_setgroups	, 2)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* old_select */
-	MIPS_SYS(sys_symlink	, 2)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was sys_lstat */
-	MIPS_SYS(sys_readlink	, 3)	/* 4085 */
-	MIPS_SYS(sys_uselib	, 1)
-	MIPS_SYS(sys_swapon	, 2)
-	MIPS_SYS(sys_reboot	, 3)
-	MIPS_SYS(old_readdir	, 3)
-	MIPS_SYS(old_mmap	, 6)	/* 4090 */
-	MIPS_SYS(sys_munmap	, 2)
-	MIPS_SYS(sys_truncate	, 2)
-	MIPS_SYS(sys_ftruncate	, 2)
-	MIPS_SYS(sys_fchmod	, 2)
-	MIPS_SYS(sys_fchown	, 3)	/* 4095 */
-	MIPS_SYS(sys_getpriority	, 2)
-	MIPS_SYS(sys_setpriority	, 3)
-	MIPS_SYS(sys_ni_syscall	, 0)
-	MIPS_SYS(sys_statfs	, 2)
-	MIPS_SYS(sys_fstatfs	, 2)	/* 4100 */
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was ioperm(2) */
-	MIPS_SYS(sys_socketcall	, 2)
-	MIPS_SYS(sys_syslog	, 3)
-	MIPS_SYS(sys_setitimer	, 3)
-	MIPS_SYS(sys_getitimer	, 2)	/* 4105 */
-	MIPS_SYS(sys_newstat	, 2)
-	MIPS_SYS(sys_newlstat	, 2)
-	MIPS_SYS(sys_newfstat	, 2)
-	MIPS_SYS(sys_uname	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* 4110 was iopl(2) */
-	MIPS_SYS(sys_vhangup	, 0)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was sys_idle() */
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was sys_vm86 */
-	MIPS_SYS(sys_wait4	, 4)
-	MIPS_SYS(sys_swapoff	, 1)	/* 4115 */
-	MIPS_SYS(sys_sysinfo	, 1)
-	MIPS_SYS(sys_ipc		, 6)
-	MIPS_SYS(sys_fsync	, 1)
-	MIPS_SYS(sys_sigreturn	, 0)
-	MIPS_SYS(sys_clone	, 6)	/* 4120 */
-	MIPS_SYS(sys_setdomainname, 2)
-	MIPS_SYS(sys_newuname	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* sys_modify_ldt */
-	MIPS_SYS(sys_adjtimex	, 1)
-	MIPS_SYS(sys_mprotect	, 3)	/* 4125 */
-	MIPS_SYS(sys_sigprocmask	, 3)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* was create_module */
-	MIPS_SYS(sys_init_module	, 5)
-	MIPS_SYS(sys_delete_module, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* 4130	was get_kernel_syms */
-	MIPS_SYS(sys_quotactl	, 0)
-	MIPS_SYS(sys_getpgid	, 1)
-	MIPS_SYS(sys_fchdir	, 1)
-	MIPS_SYS(sys_bdflush	, 2)
-	MIPS_SYS(sys_sysfs	, 3)	/* 4135 */
-	MIPS_SYS(sys_personality	, 1)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* for afs_syscall */
-	MIPS_SYS(sys_setfsuid	, 1)
-	MIPS_SYS(sys_setfsgid	, 1)
-	MIPS_SYS(sys_llseek	, 5)	/* 4140 */
-	MIPS_SYS(sys_getdents	, 3)
-	MIPS_SYS(sys_select	, 5)
-	MIPS_SYS(sys_flock	, 2)
-	MIPS_SYS(sys_msync	, 3)
-	MIPS_SYS(sys_readv	, 3)	/* 4145 */
-	MIPS_SYS(sys_writev	, 3)
-	MIPS_SYS(sys_cacheflush	, 3)
-	MIPS_SYS(sys_cachectl	, 3)
-	MIPS_SYS(sys_sysmips	, 4)
-	MIPS_SYS(sys_ni_syscall	, 0)	/* 4150 */
-	MIPS_SYS(sys_getsid	, 1)
-	MIPS_SYS(sys_fdatasync	, 0)
-	MIPS_SYS(sys_sysctl	, 1)
-	MIPS_SYS(sys_mlock	, 2)
-	MIPS_SYS(sys_munlock	, 2)	/* 4155 */
-	MIPS_SYS(sys_mlockall	, 1)
-	MIPS_SYS(sys_munlockall	, 0)
-	MIPS_SYS(sys_sched_setparam, 2)
-	MIPS_SYS(sys_sched_getparam, 2)
-	MIPS_SYS(sys_sched_setscheduler, 3)	/* 4160 */
-	MIPS_SYS(sys_sched_getscheduler, 1)
-	MIPS_SYS(sys_sched_yield	, 0)
-	MIPS_SYS(sys_sched_get_priority_max, 1)
-	MIPS_SYS(sys_sched_get_priority_min, 1)
-	MIPS_SYS(sys_sched_rr_get_interval, 2)	/* 4165 */
-	MIPS_SYS(sys_nanosleep,	2)
-	MIPS_SYS(sys_mremap	, 5)
-	MIPS_SYS(sys_accept	, 3)
-	MIPS_SYS(sys_bind	, 3)
-	MIPS_SYS(sys_connect	, 3)	/* 4170 */
-	MIPS_SYS(sys_getpeername	, 3)
-	MIPS_SYS(sys_getsockname	, 3)
-	MIPS_SYS(sys_getsockopt	, 5)
-	MIPS_SYS(sys_listen	, 2)
-	MIPS_SYS(sys_recv	, 4)	/* 4175 */
-	MIPS_SYS(sys_recvfrom	, 6)
-	MIPS_SYS(sys_recvmsg	, 3)
-	MIPS_SYS(sys_send	, 4)
-	MIPS_SYS(sys_sendmsg	, 3)
-	MIPS_SYS(sys_sendto	, 6)	/* 4180 */
-	MIPS_SYS(sys_setsockopt	, 5)
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

linux-user/microblaze/cpu_loop.inc.c new file +116 -0
new file mode 100644
index 0000000000..91f0e15989

Lines of this file are not shown. View the raw message.

linux-user/mips/cpu_loop.inc.c new file +695 -0
new file mode 100644
index 0000000000..85d793d82e

Lines of this file are not shown. View the raw message.

linux-user/mips64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..0eb0f9572a

Lines of this file are not shown. View the raw message.

linux-user/nios2/cpu_loop.inc.c new file +98 -0
new file mode 100644
index 0000000000..d6f318d640

Lines of this file are not shown. View the raw message.

linux-user/openrisc/cpu_loop.inc.c new file +81 -0
new file mode 100644
index 0000000000..4cf9752142

Lines of this file are not shown. View the raw message.

linux-user/ppc/cpu_loop.inc.c new file +538 -0
new file mode 100644
index 0000000000..008c1d603e

Lines of this file are not shown. View the raw message.

linux-user/riscv/cpu_loop.inc.c new file +89 -0
new file mode 100644
index 0000000000..ebb02648f8

Lines of this file are not shown. View the raw message.

linux-user/s390x/cpu_loop.inc.c new file +132 -0
new file mode 100644
index 0000000000..ea7e6d206a

Lines of this file are not shown. View the raw message.

linux-user/sh4/cpu_loop.inc.c new file +78 -0
new file mode 100644
index 0000000000..768f3e8156

Lines of this file are not shown. View the raw message.

linux-user/sparc/cpu_loop.inc.c new file +271 -0
new file mode 100644
index 0000000000..589c7a3caa

Lines of this file are not shown. View the raw message.

linux-user/sparc64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..ba4765b4db

Lines of this file are not shown. View the raw message.

linux-user/tilegx/cpu_loop.inc.c new file +251 -0
new file mode 100644
index 0000000000..afde8103bb

Lines of this file are not shown. View the raw message.

linux-user/x86_64/cpu_loop.inc.c new file +1 -0
new file mode 100644
index 0000000000..b62e12ef9b

Lines of this file are not shown. View the raw message.

linux-user/xtensa/cpu_loop.inc.c new file +231 -0
new file mode 100644
index 0000000000..ca8e014959

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#11 lore raw

PATCH 5/5 linux-user: cleanup main()

In reply to Laurent Vivier

move all prologue specific parts to
prologue.inc.c in arch directory

---
 linux-user/aarch64/prologue.inc.c    |  21 ++
 linux-user/alpha/prologue.inc.c      |   9 +
 linux-user/arm/prologue.inc.c        |  23 ++
 linux-user/cris/prologue.inc.c       |  19 ++
 linux-user/hppa/prologue.inc.c       |   8 +
 linux-user/i386/prologue.inc.c       | 113 ++++++++++
 linux-user/m68k/prologue.inc.c       |  26 +++
 linux-user/main.c                    | 400 +----------------------------------
 linux-user/microblaze/prologue.inc.c |  35 +++
 linux-user/mips/prologue.inc.c       |  25 +++
 linux-user/mips64/prologue.inc.c     |   1 +
 linux-user/nios2/prologue.inc.c      |  29 +++
 linux-user/openrisc/prologue.inc.c   |   9 +
 linux-user/ppc/prologue.inc.c        |  16 ++
 linux-user/riscv/prologue.inc.c      |   4 +
 linux-user/s390x/prologue.inc.c      |   8 +
 linux-user/sh4/prologue.inc.c        |   8 +
 linux-user/sparc/prologue.inc.c      |  10 +
 linux-user/sparc64/prologue.inc.c    |   1 +
 linux-user/tilegx/prologue.inc.c     |  10 +
 linux-user/x86_64/prologue.inc.c     |   1 +
 linux-user/xtensa/prologue.inc.c     |   8 +
 22 files changed, 385 insertions(+), 399 deletions(-)
 create mode 100644 linux-user/aarch64/prologue.inc.c
 create mode 100644 linux-user/alpha/prologue.inc.c
 create mode 100644 linux-user/arm/prologue.inc.c
 create mode 100644 linux-user/cris/prologue.inc.c
 create mode 100644 linux-user/hppa/prologue.inc.c
 create mode 100644 linux-user/i386/prologue.inc.c
 create mode 100644 linux-user/m68k/prologue.inc.c
 create mode 100644 linux-user/microblaze/prologue.inc.c
 create mode 100644 linux-user/mips/prologue.inc.c
 create mode 100644 linux-user/mips64/prologue.inc.c
 create mode 100644 linux-user/nios2/prologue.inc.c
 create mode 100644 linux-user/openrisc/prologue.inc.c
 create mode 100644 linux-user/ppc/prologue.inc.c
 create mode 100644 linux-user/riscv/prologue.inc.c
 create mode 100644 linux-user/s390x/prologue.inc.c
 create mode 100644 linux-user/sh4/prologue.inc.c
 create mode 100644 linux-user/sparc/prologue.inc.c
 create mode 100644 linux-user/sparc64/prologue.inc.c
 create mode 100644 linux-user/tilegx/prologue.inc.c
 create mode 100644 linux-user/x86_64/prologue.inc.c
 create mode 100644 linux-user/xtensa/prologue.inc.c
linux-user/aarch64/prologue.inc.c new file +21 -0
new file mode 100644
index 0000000000..5ffb50ae84
@@ -0,0 +1,21 @@
+    {
+        int i;
+
+        if (!(arm_feature(env, ARM_FEATURE_AARCH64))) {
+            fprintf(stderr,
+                    "The selected ARM CPU does not support 64 bit mode\n");
+            exit(EXIT_FAILURE);
+        }
+
+        for (i = 0; i < 31; i++) {
+            env->xregs[i] = regs->regs[i];
+        }
+        env->pc = regs->pc;
+        env->xregs[31] = regs->sp;
+#ifdef TARGET_WORDS_BIGENDIAN
+        env->cp15.sctlr_el[1] |= SCTLR_E0E;
+        for (i = 1; i < 4; ++i) {
+            env->cp15.sctlr_el[i] |= SCTLR_EE;
+        }
+#endif
+    }
linux-user/alpha/prologue.inc.c new file +9 -0
new file mode 100644
index 0000000000..e7a34c38cd
@@ -0,0 +1,9 @@
+    {
+        int i;
+
+        for(i = 0; i < 28; i++) {
+            env->ir[i] = ((abi_ulong *)regs)[i];
+        }
+        env->ir[IR_SP] = regs->usp;
+        env->pc = regs->pc;
+    }
linux-user/arm/prologue.inc.c new file +23 -0
new file mode 100644
index 0000000000..712f34fb4d
@@ -0,0 +1,23 @@
+    {
+        int i;
+        cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC,
+                   CPSRWriteByInstr);
+        for(i = 0; i < 16; i++) {
+            env->regs[i] = regs->uregs[i];
+        }
+#ifdef TARGET_WORDS_BIGENDIAN
+        /* Enable BE8.  */
+        if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
+            && (info->elf_flags & EF_ARM_BE8)) {
+            env->uncached_cpsr |= CPSR_E;
+            env->cp15.sctlr_el[1] |= SCTLR_E0E;
+        } else {
+            env->cp15.sctlr_el[1] |= SCTLR_B;
+        }
+#endif
+    }
+
+    ts->stack_base = info->start_stack;
+    ts->heap_base = info->brk;
+    /* This will be filled in on the first SYS_HEAPINFO call.  */
+    ts->heap_limit = 0;
linux-user/cris/prologue.inc.c new file +19 -0
new file mode 100644
index 0000000000..9bc35d0825
@@ -0,0 +1,19 @@
+    {
+	    env->regs[0] = regs->r0;
+	    env->regs[1] = regs->r1;
+	    env->regs[2] = regs->r2;
+	    env->regs[3] = regs->r3;
+	    env->regs[4] = regs->r4;
+	    env->regs[5] = regs->r5;
+	    env->regs[6] = regs->r6;
+	    env->regs[7] = regs->r7;
+	    env->regs[8] = regs->r8;
+	    env->regs[9] = regs->r9;
+	    env->regs[10] = regs->r10;
+	    env->regs[11] = regs->r11;
+	    env->regs[12] = regs->r12;
+	    env->regs[13] = regs->r13;
+	    env->regs[14] = info->start_stack;
+	    env->regs[15] = regs->acr;
+	    env->pc = regs->erp;
+    }
linux-user/hppa/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..922de62eac
@@ -0,0 +1,8 @@
+    {
+        int i;
+        for (i = 1; i < 32; i++) {
+            env->gr[i] = regs->gr[i];
+        }
+        env->iaoq_f = regs->iaoq[0];
+        env->iaoq_b = regs->iaoq[1];
+    }
linux-user/i386/prologue.inc.c new file +113 -0

113 lines not on this page · raw message

linux-user/m68k/prologue.inc.c new file +26 -0
new file mode 100644
index 0000000000..b9bd66cd7a
@@ -0,0 +1,26 @@
+    {
+        env->pc = regs->pc;
+        env->dregs[0] = regs->d0;
+        env->dregs[1] = regs->d1;
+        env->dregs[2] = regs->d2;
+        env->dregs[3] = regs->d3;
+        env->dregs[4] = regs->d4;
+        env->dregs[5] = regs->d5;
+        env->dregs[6] = regs->d6;
+        env->dregs[7] = regs->d7;
+        env->aregs[0] = regs->a0;
+        env->aregs[1] = regs->a1;
+        env->aregs[2] = regs->a2;
+        env->aregs[3] = regs->a3;
+        env->aregs[4] = regs->a4;
+        env->aregs[5] = regs->a5;
+        env->aregs[6] = regs->a6;
+        env->aregs[7] = regs->usp;
+        env->sr = regs->sr;
+        ts->sim_syscalls = 1;
+    }
+
+    ts->stack_base = info->start_stack;
+    ts->heap_base = info->brk;
+    /* This will be filled in on the first SYS_HEAPINFO call.  */
+    ts->heap_limit = 0;
linux-user/main.c +1 -399

406 lines not on this page · raw message

linux-user/microblaze/prologue.inc.c new file +35 -0
new file mode 100644
index 0000000000..a7248cb788
@@ -0,0 +1,35 @@
+    {
+        env->regs[0] = regs->r0;
+        env->regs[1] = regs->r1;
+        env->regs[2] = regs->r2;
+        env->regs[3] = regs->r3;
+        env->regs[4] = regs->r4;
+        env->regs[5] = regs->r5;
+        env->regs[6] = regs->r6;
+        env->regs[7] = regs->r7;
+        env->regs[8] = regs->r8;
+        env->regs[9] = regs->r9;
+        env->regs[10] = regs->r10;
+        env->regs[11] = regs->r11;
+        env->regs[12] = regs->r12;
+        env->regs[13] = regs->r13;
+        env->regs[14] = regs->r14;
+        env->regs[15] = regs->r15;
+        env->regs[16] = regs->r16;
+        env->regs[17] = regs->r17;
+        env->regs[18] = regs->r18;
+        env->regs[19] = regs->r19;
+        env->regs[20] = regs->r20;
+        env->regs[21] = regs->r21;
+        env->regs[22] = regs->r22;
+        env->regs[23] = regs->r23;
+        env->regs[24] = regs->r24;
+        env->regs[25] = regs->r25;
+        env->regs[26] = regs->r26;
+        env->regs[27] = regs->r27;
+        env->regs[28] = regs->r28;
+        env->regs[29] = regs->r29;
+        env->regs[30] = regs->r30;
+        env->regs[31] = regs->r31;
+        env->sregs[SR_PC] = regs->pc;
+    }
linux-user/mips/prologue.inc.c new file +25 -0
new file mode 100644
index 0000000000..bd7f2b3c0e
@@ -0,0 +1,25 @@
+    {
+        int i;
+
+        for(i = 0; i < 32; i++) {
+            env->active_tc.gpr[i] = regs->regs[i];
+        }
+        env->active_tc.PC = regs->cp0_epc & ~(target_ulong)1;
+        if (regs->cp0_epc & 1) {
+            env->hflags |= MIPS_HFLAG_M16;
+        }
+        if (((info->elf_flags & EF_MIPS_NAN2008) != 0) !=
+            ((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0)) {
+            if ((env->active_fpu.fcr31_rw_bitmask &
+                  (1 << FCR31_NAN2008)) == 0) {
+                fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
+                exit(1);
+            }
+            if ((info->elf_flags & EF_MIPS_NAN2008) != 0) {
+                env->active_fpu.fcr31 |= (1 << FCR31_NAN2008);
+            } else {
+                env->active_fpu.fcr31 &= ~(1 << FCR31_NAN2008);
+            }
+            restore_snan_bit_mode(env);
+        }
+    }
linux-user/mips64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..d74fa9e773
@@ -0,0 +1 @@
+#include "../mips/prologue.inc.c"
linux-user/nios2/prologue.inc.c new file +29 -0
new file mode 100644
index 0000000000..d05b4ecba6
@@ -0,0 +1,29 @@
+    {
+        env->regs[0] = 0;
+        env->regs[1] = regs->r1;
+        env->regs[2] = regs->r2;
+        env->regs[3] = regs->r3;
+        env->regs[4] = regs->r4;
+        env->regs[5] = regs->r5;
+        env->regs[6] = regs->r6;
+        env->regs[7] = regs->r7;
+        env->regs[8] = regs->r8;
+        env->regs[9] = regs->r9;
+        env->regs[10] = regs->r10;
+        env->regs[11] = regs->r11;
+        env->regs[12] = regs->r12;
+        env->regs[13] = regs->r13;
+        env->regs[14] = regs->r14;
+        env->regs[15] = regs->r15;
+        /* TODO: unsigned long  orig_r2; */
+        env->regs[R_RA] = regs->ra;
+        env->regs[R_FP] = regs->fp;
+        env->regs[R_SP] = regs->sp;
+        env->regs[R_GP] = regs->gp;
+        env->regs[CR_ESTATUS] = regs->estatus;
+        env->regs[R_EA] = regs->ea;
+        /* TODO: unsigned long  orig_r7; */
+
+        /* Emulate eret when starting thread. */
+        env->regs[R_PC] = regs->ea;
+    }
linux-user/openrisc/prologue.inc.c new file +9 -0
new file mode 100644
index 0000000000..a09fde3352
@@ -0,0 +1,9 @@
+    {
+        int i;
+
+        for (i = 0; i < 32; i++) {
+            cpu_set_gpr(env, i, regs->gpr[i]);
+        }
+        env->pc = regs->pc;
+        cpu_set_sr(env, regs->sr);
+    }
linux-user/ppc/prologue.inc.c new file +16 -0
new file mode 100644
index 0000000000..92ed1c1b11
@@ -0,0 +1,16 @@
+    {
+        int i;
+
+#if defined(TARGET_PPC64)
+        int flag = (env->insns_flags2 & PPC2_BOOKE206) ? MSR_CM : MSR_SF;
+#if defined(TARGET_ABI32)
+        env->msr &= ~((target_ulong)1 << flag);
+#else
+        env->msr |= (target_ulong)1 << flag;
+#endif
+#endif
+        env->nip = regs->nip;
+        for(i = 0; i < 32; i++) {
+            env->gpr[i] = regs->gpr[i];
+        }
+    }
linux-user/riscv/prologue.inc.c new file +4 -0
new file mode 100644
index 0000000000..eaaf0d5016
@@ -0,0 +1,4 @@
+    {
+        env->pc = regs->sepc;
+        env->gpr[xSP] = regs->sp;
+    }
linux-user/s390x/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..b036127022
@@ -0,0 +1,8 @@
+    {
+            int i;
+            for (i = 0; i < 16; i++) {
+                env->regs[i] = regs->gprs[i];
+            }
+            env->psw.mask = regs->psw.mask;
+            env->psw.addr = regs->psw.addr;
+    }
linux-user/sh4/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..ae1d8270ef
@@ -0,0 +1,8 @@
+    {
+        int i;
+
+        for(i = 0; i < 16; i++) {
+            env->gregs[i] = regs->regs[i];
+        }
+        env->pc = regs->pc;
+    }
linux-user/sparc/prologue.inc.c new file +10 -0
new file mode 100644
index 0000000000..3bfea0a553
@@ -0,0 +1,10 @@
+    {
+        int i;
+	env->pc = regs->pc;
+	env->npc = regs->npc;
+        env->y = regs->y;
+        for(i = 0; i < 8; i++)
+            env->gregs[i] = regs->u_regs[i];
+        for(i = 0; i < 8; i++)
+            env->regwptr[i] = regs->u_regs[i + 8];
+    }
linux-user/sparc64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..e1b5fea628
@@ -0,0 +1 @@
+#include "../sparc/prologue.inc.c"
linux-user/tilegx/prologue.inc.c new file +10 -0
new file mode 100644
index 0000000000..9ea7429760
@@ -0,0 +1,10 @@
+    {
+        int i;
+        for (i = 0; i < TILEGX_R_COUNT; i++) {
+            env->regs[i] = regs->regs[i];
+        }
+        for (i = 0; i < TILEGX_SPR_COUNT; i++) {
+            env->spregs[i] = 0;
+        }
+        env->pc = regs->pc;
+    }
linux-user/x86_64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..ecfe04e909
@@ -0,0 +1 @@
+#include "../i386/prologue.inc.c"
linux-user/xtensa/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..0c97de8244
@@ -0,0 +1,8 @@
+    {
+        int i;
+        for (i = 0; i < 16; ++i) {
+            env->regs[i] = regs->areg[i];
+        }
+        env->sregs[WINDOW_START] = regs->windowstart;
+        env->pc = regs->pc;
+    }
Signature · 1 line
2.14.3
Reviewed-by on v1 5/5
#12 lore raw

Re: [Qemu-devel] [PATCH for 2.13 5/5] linux-user: cleanup main()

Quoted 4 lines · Laurent Vivier

move all prologue specific parts to
prologue.inc.c in arch directory

Quoted 968 lines
---
 linux-user/aarch64/prologue.inc.c    |  21 ++
 linux-user/alpha/prologue.inc.c      |   9 +
 linux-user/arm/prologue.inc.c        |  23 ++
 linux-user/cris/prologue.inc.c       |  19 ++
 linux-user/hppa/prologue.inc.c       |   8 +
 linux-user/i386/prologue.inc.c       | 113 ++++++++++
 linux-user/m68k/prologue.inc.c       |  26 +++
 linux-user/main.c                    | 400 +----------------------------------
 linux-user/microblaze/prologue.inc.c |  35 +++
 linux-user/mips/prologue.inc.c       |  25 +++
 linux-user/mips64/prologue.inc.c     |   1 +
 linux-user/nios2/prologue.inc.c      |  29 +++
 linux-user/openrisc/prologue.inc.c   |   9 +
 linux-user/ppc/prologue.inc.c        |  16 ++
 linux-user/riscv/prologue.inc.c      |   4 +
 linux-user/s390x/prologue.inc.c      |   8 +
 linux-user/sh4/prologue.inc.c        |   8 +
 linux-user/sparc/prologue.inc.c      |  10 +
 linux-user/sparc64/prologue.inc.c    |   1 +
 linux-user/tilegx/prologue.inc.c     |  10 +
 linux-user/x86_64/prologue.inc.c     |   1 +
 linux-user/xtensa/prologue.inc.c     |   8 +
 22 files changed, 385 insertions(+), 399 deletions(-)
 create mode 100644 linux-user/aarch64/prologue.inc.c
 create mode 100644 linux-user/alpha/prologue.inc.c
 create mode 100644 linux-user/arm/prologue.inc.c
 create mode 100644 linux-user/cris/prologue.inc.c
 create mode 100644 linux-user/hppa/prologue.inc.c
 create mode 100644 linux-user/i386/prologue.inc.c
 create mode 100644 linux-user/m68k/prologue.inc.c
 create mode 100644 linux-user/microblaze/prologue.inc.c
 create mode 100644 linux-user/mips/prologue.inc.c
 create mode 100644 linux-user/mips64/prologue.inc.c
 create mode 100644 linux-user/nios2/prologue.inc.c
 create mode 100644 linux-user/openrisc/prologue.inc.c
 create mode 100644 linux-user/ppc/prologue.inc.c
 create mode 100644 linux-user/riscv/prologue.inc.c
 create mode 100644 linux-user/s390x/prologue.inc.c
 create mode 100644 linux-user/sh4/prologue.inc.c
 create mode 100644 linux-user/sparc/prologue.inc.c
 create mode 100644 linux-user/sparc64/prologue.inc.c
 create mode 100644 linux-user/tilegx/prologue.inc.c
 create mode 100644 linux-user/x86_64/prologue.inc.c
 create mode 100644 linux-user/xtensa/prologue.inc.c
linux-user/aarch64/prologue.inc.c new file +21 -0
new file mode 100644
index 0000000000..5ffb50ae84
@@ -0,0 +1,21 @@
+    {
+        int i;
+
+        if (!(arm_feature(env, ARM_FEATURE_AARCH64))) {
+            fprintf(stderr,
+                    "The selected ARM CPU does not support 64 bit mode\n");
+            exit(EXIT_FAILURE);
+        }
+
+        for (i = 0; i < 31; i++) {
+            env->xregs[i] = regs->regs[i];
+        }
+        env->pc = regs->pc;
+        env->xregs[31] = regs->sp;
+#ifdef TARGET_WORDS_BIGENDIAN
+        env->cp15.sctlr_el[1] |= SCTLR_E0E;
+        for (i = 1; i < 4; ++i) {
+            env->cp15.sctlr_el[i] |= SCTLR_EE;
+        }
+#endif
+    }
linux-user/alpha/prologue.inc.c new file +9 -0
new file mode 100644
index 0000000000..e7a34c38cd
@@ -0,0 +1,9 @@
+    {
+        int i;
+
+        for(i = 0; i < 28; i++) {
+            env->ir[i] = ((abi_ulong *)regs)[i];
+        }
+        env->ir[IR_SP] = regs->usp;
+        env->pc = regs->pc;
+    }
linux-user/arm/prologue.inc.c new file +23 -0
new file mode 100644
index 0000000000..712f34fb4d
@@ -0,0 +1,23 @@
+    {
+        int i;
+        cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC,
+                   CPSRWriteByInstr);
+        for(i = 0; i < 16; i++) {
+            env->regs[i] = regs->uregs[i];
+        }
+#ifdef TARGET_WORDS_BIGENDIAN
+        /* Enable BE8.  */
+        if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
+            && (info->elf_flags & EF_ARM_BE8)) {
+            env->uncached_cpsr |= CPSR_E;
+            env->cp15.sctlr_el[1] |= SCTLR_E0E;
+        } else {
+            env->cp15.sctlr_el[1] |= SCTLR_B;
+        }
+#endif
+    }
+
+    ts->stack_base = info->start_stack;
+    ts->heap_base = info->brk;
+    /* This will be filled in on the first SYS_HEAPINFO call.  */
+    ts->heap_limit = 0;
linux-user/cris/prologue.inc.c new file +19 -0
new file mode 100644
index 0000000000..9bc35d0825
@@ -0,0 +1,19 @@
+    {
+	    env->regs[0] = regs->r0;
+	    env->regs[1] = regs->r1;
+	    env->regs[2] = regs->r2;
+	    env->regs[3] = regs->r3;
+	    env->regs[4] = regs->r4;
+	    env->regs[5] = regs->r5;
+	    env->regs[6] = regs->r6;
+	    env->regs[7] = regs->r7;
+	    env->regs[8] = regs->r8;
+	    env->regs[9] = regs->r9;
+	    env->regs[10] = regs->r10;
+	    env->regs[11] = regs->r11;
+	    env->regs[12] = regs->r12;
+	    env->regs[13] = regs->r13;
+	    env->regs[14] = info->start_stack;
+	    env->regs[15] = regs->acr;
+	    env->pc = regs->erp;
+    }
linux-user/hppa/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..922de62eac
@@ -0,0 +1,8 @@
+    {
+        int i;
+        for (i = 1; i < 32; i++) {
+            env->gr[i] = regs->gr[i];
+        }
+        env->iaoq_f = regs->iaoq[0];
+        env->iaoq_b = regs->iaoq[1];
+    }
linux-user/i386/prologue.inc.c new file +113 -0
new file mode 100644
index 0000000000..3a40a0a2e8
@@ -0,0 +1,113 @@
+    env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
+    env->hflags |= HF_PE_MASK | HF_CPL_MASK;
+    if (env->features[FEAT_1_EDX] & CPUID_SSE) {
+        env->cr[4] |= CR4_OSFXSR_MASK;
+        env->hflags |= HF_OSFXSR_MASK;
+    }
+#ifndef TARGET_ABI32
+    /* enable 64 bit mode if possible */
+    if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
+        fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
+        exit(EXIT_FAILURE);
+    }
+    env->cr[4] |= CR4_PAE_MASK;
+    env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
+    env->hflags |= HF_LMA_MASK;
+#endif
+
+    /* flags setup : we activate the IRQs by default as in user mode */
+    env->eflags |= IF_MASK;
+
+    /* linux register setup */
+#ifndef TARGET_ABI32
+    env->regs[R_EAX] = regs->rax;
+    env->regs[R_EBX] = regs->rbx;
+    env->regs[R_ECX] = regs->rcx;
+    env->regs[R_EDX] = regs->rdx;
+    env->regs[R_ESI] = regs->rsi;
+    env->regs[R_EDI] = regs->rdi;
+    env->regs[R_EBP] = regs->rbp;
+    env->regs[R_ESP] = regs->rsp;
+    env->eip = regs->rip;
+#else
+    env->regs[R_EAX] = regs->eax;
+    env->regs[R_EBX] = regs->ebx;
+    env->regs[R_ECX] = regs->ecx;
+    env->regs[R_EDX] = regs->edx;
+    env->regs[R_ESI] = regs->esi;
+    env->regs[R_EDI] = regs->edi;
+    env->regs[R_EBP] = regs->ebp;
+    env->regs[R_ESP] = regs->esp;
+    env->eip = regs->eip;
+#endif
+
+    /* linux interrupt setup */
+#ifndef TARGET_ABI32
+    env->idt.limit = 511;
+#else
+    env->idt.limit = 255;
+#endif
+    env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
+                                PROT_READ|PROT_WRITE,
+                                MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+    idt_table = g2h(env->idt.base);
+    set_idt(0, 0);
+    set_idt(1, 0);
+    set_idt(2, 0);
+    set_idt(3, 3);
+    set_idt(4, 3);
+    set_idt(5, 0);
+    set_idt(6, 0);
+    set_idt(7, 0);
+    set_idt(8, 0);
+    set_idt(9, 0);
+    set_idt(10, 0);
+    set_idt(11, 0);
+    set_idt(12, 0);
+    set_idt(13, 0);
+    set_idt(14, 0);
+    set_idt(15, 0);
+    set_idt(16, 0);
+    set_idt(17, 0);
+    set_idt(18, 0);
+    set_idt(19, 0);
+    set_idt(0x80, 3);
+
+    /* linux segment setup */
+    {
+        uint64_t *gdt_table;
+        env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
+                                    PROT_READ|PROT_WRITE,
+                                    MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+        env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
+        gdt_table = g2h(env->gdt.base);
+#ifdef TARGET_ABI32
+        write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
+                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
+                 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
+#else
+        /* 64 bit code segment */
+        write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
+                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
+                 DESC_L_MASK |
+                 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
+#endif
+        write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff,
+                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
+                 (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT));
+    }
+    cpu_x86_load_seg(env, R_CS, __USER_CS);
+    cpu_x86_load_seg(env, R_SS, __USER_DS);
+#ifdef TARGET_ABI32
+    cpu_x86_load_seg(env, R_DS, __USER_DS);
+    cpu_x86_load_seg(env, R_ES, __USER_DS);
+    cpu_x86_load_seg(env, R_FS, __USER_DS);
+    cpu_x86_load_seg(env, R_GS, __USER_DS);
+    /* This hack makes Wine work... */
+    env->segs[R_FS].selector = 0;
+#else
+    cpu_x86_load_seg(env, R_DS, 0);
+    cpu_x86_load_seg(env, R_ES, 0);
+    cpu_x86_load_seg(env, R_FS, 0);
+    cpu_x86_load_seg(env, R_GS, 0);
+#endif
linux-user/m68k/prologue.inc.c new file +26 -0
new file mode 100644
index 0000000000..b9bd66cd7a
@@ -0,0 +1,26 @@
+    {
+        env->pc = regs->pc;
+        env->dregs[0] = regs->d0;
+        env->dregs[1] = regs->d1;
+        env->dregs[2] = regs->d2;
+        env->dregs[3] = regs->d3;
+        env->dregs[4] = regs->d4;
+        env->dregs[5] = regs->d5;
+        env->dregs[6] = regs->d6;
+        env->dregs[7] = regs->d7;
+        env->aregs[0] = regs->a0;
+        env->aregs[1] = regs->a1;
+        env->aregs[2] = regs->a2;
+        env->aregs[3] = regs->a3;
+        env->aregs[4] = regs->a4;
+        env->aregs[5] = regs->a5;
+        env->aregs[6] = regs->a6;
+        env->aregs[7] = regs->usp;
+        env->sr = regs->sr;
+        ts->sim_syscalls = 1;
+    }
+
+    ts->stack_base = info->start_stack;
+    ts->heap_base = info->brk;
+    /* This will be filled in on the first SYS_HEAPINFO call.  */
+    ts->heap_limit = 0;
linux-user/main.c +1 -399
index fd71113855..c2a5813694 100644
@@ -817,405 +817,7 @@ int main(int argc, char **argv, char **envp)
     tcg_prologue_init(tcg_ctx);
     tcg_region_init();
 
-#if defined(TARGET_I386)
-    env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
-    env->hflags |= HF_PE_MASK | HF_CPL_MASK;
-    if (env->features[FEAT_1_EDX] & CPUID_SSE) {
-        env->cr[4] |= CR4_OSFXSR_MASK;
-        env->hflags |= HF_OSFXSR_MASK;
-    }
-#ifndef TARGET_ABI32
-    /* enable 64 bit mode if possible */
-    if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
-        fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
-        exit(EXIT_FAILURE);
-    }
-    env->cr[4] |= CR4_PAE_MASK;
-    env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
-    env->hflags |= HF_LMA_MASK;
-#endif
-
-    /* flags setup : we activate the IRQs by default as in user mode */
-    env->eflags |= IF_MASK;
-
-    /* linux register setup */
-#ifndef TARGET_ABI32
-    env->regs[R_EAX] = regs->rax;
-    env->regs[R_EBX] = regs->rbx;
-    env->regs[R_ECX] = regs->rcx;
-    env->regs[R_EDX] = regs->rdx;
-    env->regs[R_ESI] = regs->rsi;
-    env->regs[R_EDI] = regs->rdi;
-    env->regs[R_EBP] = regs->rbp;
-    env->regs[R_ESP] = regs->rsp;
-    env->eip = regs->rip;
-#else
-    env->regs[R_EAX] = regs->eax;
-    env->regs[R_EBX] = regs->ebx;
-    env->regs[R_ECX] = regs->ecx;
-    env->regs[R_EDX] = regs->edx;
-    env->regs[R_ESI] = regs->esi;
-    env->regs[R_EDI] = regs->edi;
-    env->regs[R_EBP] = regs->ebp;
-    env->regs[R_ESP] = regs->esp;
-    env->eip = regs->eip;
-#endif
-
-    /* linux interrupt setup */
-#ifndef TARGET_ABI32
-    env->idt.limit = 511;
-#else
-    env->idt.limit = 255;
-#endif
-    env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1),
-                                PROT_READ|PROT_WRITE,
-                                MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-    idt_table = g2h(env->idt.base);
-    set_idt(0, 0);
-    set_idt(1, 0);
-    set_idt(2, 0);
-    set_idt(3, 3);
-    set_idt(4, 3);
-    set_idt(5, 0);
-    set_idt(6, 0);
-    set_idt(7, 0);
-    set_idt(8, 0);
-    set_idt(9, 0);
-    set_idt(10, 0);
-    set_idt(11, 0);
-    set_idt(12, 0);
-    set_idt(13, 0);
-    set_idt(14, 0);
-    set_idt(15, 0);
-    set_idt(16, 0);
-    set_idt(17, 0);
-    set_idt(18, 0);
-    set_idt(19, 0);
-    set_idt(0x80, 3);
-
-    /* linux segment setup */
-    {
-        uint64_t *gdt_table;
-        env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES,
-                                    PROT_READ|PROT_WRITE,
-                                    MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-        env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1;
-        gdt_table = g2h(env->gdt.base);
-#ifdef TARGET_ABI32
-        write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
-                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
-                 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
-#else
-        /* 64 bit code segment */
-        write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff,
-                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
-                 DESC_L_MASK |
-                 (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT));
-#endif
-        write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff,
-                 DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK |
-                 (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT));
-    }
-    cpu_x86_load_seg(env, R_CS, __USER_CS);
-    cpu_x86_load_seg(env, R_SS, __USER_DS);
-#ifdef TARGET_ABI32
-    cpu_x86_load_seg(env, R_DS, __USER_DS);
-    cpu_x86_load_seg(env, R_ES, __USER_DS);
-    cpu_x86_load_seg(env, R_FS, __USER_DS);
-    cpu_x86_load_seg(env, R_GS, __USER_DS);
-    /* This hack makes Wine work... */
-    env->segs[R_FS].selector = 0;
-#else
-    cpu_x86_load_seg(env, R_DS, 0);
-    cpu_x86_load_seg(env, R_ES, 0);
-    cpu_x86_load_seg(env, R_FS, 0);
-    cpu_x86_load_seg(env, R_GS, 0);
-#endif
-#elif defined(TARGET_AARCH64)
-    {
-        int i;
-
-        if (!(arm_feature(env, ARM_FEATURE_AARCH64))) {
-            fprintf(stderr,
-                    "The selected ARM CPU does not support 64 bit mode\n");
-            exit(EXIT_FAILURE);
-        }
-
-        for (i = 0; i < 31; i++) {
-            env->xregs[i] = regs->regs[i];
-        }
-        env->pc = regs->pc;
-        env->xregs[31] = regs->sp;
-#ifdef TARGET_WORDS_BIGENDIAN
-        env->cp15.sctlr_el[1] |= SCTLR_E0E;
-        for (i = 1; i < 4; ++i) {
-            env->cp15.sctlr_el[i] |= SCTLR_EE;
-        }
-#endif
-    }
-#elif defined(TARGET_ARM)
-    {
-        int i;
-        cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC,
-                   CPSRWriteByInstr);
-        for(i = 0; i < 16; i++) {
-            env->regs[i] = regs->uregs[i];
-        }
-#ifdef TARGET_WORDS_BIGENDIAN
-        /* Enable BE8.  */
-        if (EF_ARM_EABI_VERSION(info->elf_flags) >= EF_ARM_EABI_VER4
-            && (info->elf_flags & EF_ARM_BE8)) {
-            env->uncached_cpsr |= CPSR_E;
-            env->cp15.sctlr_el[1] |= SCTLR_E0E;
-        } else {
-            env->cp15.sctlr_el[1] |= SCTLR_B;
-        }
-#endif
-    }
-#elif defined(TARGET_SPARC)
-    {
-        int i;
-	env->pc = regs->pc;
-	env->npc = regs->npc;
-        env->y = regs->y;
-        for(i = 0; i < 8; i++)
-            env->gregs[i] = regs->u_regs[i];
-        for(i = 0; i < 8; i++)
-            env->regwptr[i] = regs->u_regs[i + 8];
-    }
-#elif defined(TARGET_PPC)
-    {
-        int i;
-
-#if defined(TARGET_PPC64)
-        int flag = (env->insns_flags2 & PPC2_BOOKE206) ? MSR_CM : MSR_SF;
-#if defined(TARGET_ABI32)
-        env->msr &= ~((target_ulong)1 << flag);
-#else
-        env->msr |= (target_ulong)1 << flag;
-#endif
-#endif
-        env->nip = regs->nip;
-        for(i = 0; i < 32; i++) {
-            env->gpr[i] = regs->gpr[i];
-        }
-    }
-#elif defined(TARGET_M68K)
-    {
-        env->pc = regs->pc;
-        env->dregs[0] = regs->d0;
-        env->dregs[1] = regs->d1;
-        env->dregs[2] = regs->d2;
-        env->dregs[3] = regs->d3;
-        env->dregs[4] = regs->d4;
-        env->dregs[5] = regs->d5;
-        env->dregs[6] = regs->d6;
-        env->dregs[7] = regs->d7;
-        env->aregs[0] = regs->a0;
-        env->aregs[1] = regs->a1;
-        env->aregs[2] = regs->a2;
-        env->aregs[3] = regs->a3;
-        env->aregs[4] = regs->a4;
-        env->aregs[5] = regs->a5;
-        env->aregs[6] = regs->a6;
-        env->aregs[7] = regs->usp;
-        env->sr = regs->sr;
-        ts->sim_syscalls = 1;
-    }
-#elif defined(TARGET_MICROBLAZE)
-    {
-        env->regs[0] = regs->r0;
-        env->regs[1] = regs->r1;
-        env->regs[2] = regs->r2;
-        env->regs[3] = regs->r3;
-        env->regs[4] = regs->r4;
-        env->regs[5] = regs->r5;
-        env->regs[6] = regs->r6;
-        env->regs[7] = regs->r7;
-        env->regs[8] = regs->r8;
-        env->regs[9] = regs->r9;
-        env->regs[10] = regs->r10;
-        env->regs[11] = regs->r11;
-        env->regs[12] = regs->r12;
-        env->regs[13] = regs->r13;
-        env->regs[14] = regs->r14;
-        env->regs[15] = regs->r15;	    
-        env->regs[16] = regs->r16;	    
-        env->regs[17] = regs->r17;	    
-        env->regs[18] = regs->r18;	    
-        env->regs[19] = regs->r19;	    
-        env->regs[20] = regs->r20;	    
-        env->regs[21] = regs->r21;	    
-        env->regs[22] = regs->r22;	    
-        env->regs[23] = regs->r23;	    
-        env->regs[24] = regs->r24;	    
-        env->regs[25] = regs->r25;	    
-        env->regs[26] = regs->r26;	    
-        env->regs[27] = regs->r27;	    
-        env->regs[28] = regs->r28;	    
-        env->regs[29] = regs->r29;	    
-        env->regs[30] = regs->r30;	    
-        env->regs[31] = regs->r31;	    
-        env->sregs[SR_PC] = regs->pc;
-    }
-#elif defined(TARGET_MIPS)
-    {
-        int i;
-
-        for(i = 0; i < 32; i++) {
-            env->active_tc.gpr[i] = regs->regs[i];
-        }
-        env->active_tc.PC = regs->cp0_epc & ~(target_ulong)1;
-        if (regs->cp0_epc & 1) {
-            env->hflags |= MIPS_HFLAG_M16;
-        }
-        if (((info->elf_flags & EF_MIPS_NAN2008) != 0) !=
-            ((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0)) {
-            if ((env->active_fpu.fcr31_rw_bitmask &
-                  (1 << FCR31_NAN2008)) == 0) {
-                fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
-                exit(1);
-            }
-            if ((info->elf_flags & EF_MIPS_NAN2008) != 0) {
-                env->active_fpu.fcr31 |= (1 << FCR31_NAN2008);
-            } else {
-                env->active_fpu.fcr31 &= ~(1 << FCR31_NAN2008);
-            }
-            restore_snan_bit_mode(env);
-        }
-    }
-#elif defined(TARGET_NIOS2)
-    {
-        env->regs[0] = 0;
-        env->regs[1] = regs->r1;
-        env->regs[2] = regs->r2;
-        env->regs[3] = regs->r3;
-        env->regs[4] = regs->r4;
-        env->regs[5] = regs->r5;
-        env->regs[6] = regs->r6;
-        env->regs[7] = regs->r7;
-        env->regs[8] = regs->r8;
-        env->regs[9] = regs->r9;
-        env->regs[10] = regs->r10;
-        env->regs[11] = regs->r11;
-        env->regs[12] = regs->r12;
-        env->regs[13] = regs->r13;
-        env->regs[14] = regs->r14;
-        env->regs[15] = regs->r15;
-        /* TODO: unsigned long  orig_r2; */
-        env->regs[R_RA] = regs->ra;
-        env->regs[R_FP] = regs->fp;
-        env->regs[R_SP] = regs->sp;
-        env->regs[R_GP] = regs->gp;
-        env->regs[CR_ESTATUS] = regs->estatus;
-        env->regs[R_EA] = regs->ea;
-        /* TODO: unsigned long  orig_r7; */
-
-        /* Emulate eret when starting thread. */
-        env->regs[R_PC] = regs->ea;
-    }
-#elif defined(TARGET_OPENRISC)
-    {
-        int i;
-
-        for (i = 0; i < 32; i++) {
-            cpu_set_gpr(env, i, regs->gpr[i]);
-        }
-        env->pc = regs->pc;
-        cpu_set_sr(env, regs->sr);
-    }
-#elif defined(TARGET_RISCV)
-    {
-        env->pc = regs->sepc;
-        env->gpr[xSP] = regs->sp;
-    }
-#elif defined(TARGET_SH4)
-    {
-        int i;
-
-        for(i = 0; i < 16; i++) {
-            env->gregs[i] = regs->regs[i];
-        }
-        env->pc = regs->pc;
-    }
-#elif defined(TARGET_ALPHA)
-    {
-        int i;
-
-        for(i = 0; i < 28; i++) {
-            env->ir[i] = ((abi_ulong *)regs)[i];
-        }
-        env->ir[IR_SP] = regs->usp;
-        env->pc = regs->pc;
-    }
-#elif defined(TARGET_CRIS)
-    {
-	    env->regs[0] = regs->r0;
-	    env->regs[1] = regs->r1;
-	    env->regs[2] = regs->r2;
-	    env->regs[3] = regs->r3;
-	    env->regs[4] = regs->r4;
-	    env->regs[5] = regs->r5;
-	    env->regs[6] = regs->r6;
-	    env->regs[7] = regs->r7;
-	    env->regs[8] = regs->r8;
-	    env->regs[9] = regs->r9;
-	    env->regs[10] = regs->r10;
-	    env->regs[11] = regs->r11;
-	    env->regs[12] = regs->r12;
-	    env->regs[13] = regs->r13;
-	    env->regs[14] = info->start_stack;
-	    env->regs[15] = regs->acr;	    
-	    env->pc = regs->erp;
-    }
-#elif defined(TARGET_S390X)
-    {
-            int i;
-            for (i = 0; i < 16; i++) {
-                env->regs[i] = regs->gprs[i];
-            }
-            env->psw.mask = regs->psw.mask;
-            env->psw.addr = regs->psw.addr;
-    }
-#elif defined(TARGET_TILEGX)
-    {
-        int i;
-        for (i = 0; i < TILEGX_R_COUNT; i++) {
-            env->regs[i] = regs->regs[i];
-        }
-        for (i = 0; i < TILEGX_SPR_COUNT; i++) {
-            env->spregs[i] = 0;
-        }
-        env->pc = regs->pc;
-    }
-#elif defined(TARGET_HPPA)
-    {
-        int i;
-        for (i = 1; i < 32; i++) {
-            env->gr[i] = regs->gr[i];
-        }
-        env->iaoq_f = regs->iaoq[0];
-        env->iaoq_b = regs->iaoq[1];
-    }
-#elif defined(TARGET_XTENSA)
-    {
-        int i;
-        for (i = 0; i < 16; ++i) {
-            env->regs[i] = regs->areg[i];
-        }
-        env->sregs[WINDOW_START] = regs->windowstart;
-        env->pc = regs->pc;
-    }
-#else
-#error unsupported target CPU
-#endif
-
-#if defined(TARGET_ARM) || defined(TARGET_M68K)
-    ts->stack_base = info->start_stack;
-    ts->heap_base = info->brk;
-    /* This will be filled in on the first SYS_HEAPINFO call.  */
-    ts->heap_limit = 0;
-#endif
+#include "prologue.inc.c"
 
     if (gdbstub_port) {
         if (gdbserver_start(gdbstub_port) < 0) {
linux-user/microblaze/prologue.inc.c new file +35 -0
new file mode 100644
index 0000000000..a7248cb788
@@ -0,0 +1,35 @@
+    {
+        env->regs[0] = regs->r0;
+        env->regs[1] = regs->r1;
+        env->regs[2] = regs->r2;
+        env->regs[3] = regs->r3;
+        env->regs[4] = regs->r4;
+        env->regs[5] = regs->r5;
+        env->regs[6] = regs->r6;
+        env->regs[7] = regs->r7;
+        env->regs[8] = regs->r8;
+        env->regs[9] = regs->r9;
+        env->regs[10] = regs->r10;
+        env->regs[11] = regs->r11;
+        env->regs[12] = regs->r12;
+        env->regs[13] = regs->r13;
+        env->regs[14] = regs->r14;
+        env->regs[15] = regs->r15;
+        env->regs[16] = regs->r16;
+        env->regs[17] = regs->r17;
+        env->regs[18] = regs->r18;
+        env->regs[19] = regs->r19;
+        env->regs[20] = regs->r20;
+        env->regs[21] = regs->r21;
+        env->regs[22] = regs->r22;
+        env->regs[23] = regs->r23;
+        env->regs[24] = regs->r24;
+        env->regs[25] = regs->r25;
+        env->regs[26] = regs->r26;
+        env->regs[27] = regs->r27;
+        env->regs[28] = regs->r28;
+        env->regs[29] = regs->r29;
+        env->regs[30] = regs->r30;
+        env->regs[31] = regs->r31;
+        env->sregs[SR_PC] = regs->pc;
+    }
linux-user/mips/prologue.inc.c new file +25 -0
new file mode 100644
index 0000000000..bd7f2b3c0e
@@ -0,0 +1,25 @@
+    {
+        int i;
+
+        for(i = 0; i < 32; i++) {
+            env->active_tc.gpr[i] = regs->regs[i];
+        }
+        env->active_tc.PC = regs->cp0_epc & ~(target_ulong)1;
+        if (regs->cp0_epc & 1) {
+            env->hflags |= MIPS_HFLAG_M16;
+        }
+        if (((info->elf_flags & EF_MIPS_NAN2008) != 0) !=
+            ((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0)) {
+            if ((env->active_fpu.fcr31_rw_bitmask &
+                  (1 << FCR31_NAN2008)) == 0) {
+                fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
+                exit(1);
+            }
+            if ((info->elf_flags & EF_MIPS_NAN2008) != 0) {
+                env->active_fpu.fcr31 |= (1 << FCR31_NAN2008);
+            } else {
+                env->active_fpu.fcr31 &= ~(1 << FCR31_NAN2008);
+            }
+            restore_snan_bit_mode(env);
+        }
+    }
linux-user/mips64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..d74fa9e773
@@ -0,0 +1 @@
+#include "../mips/prologue.inc.c"
linux-user/nios2/prologue.inc.c new file +29 -0
new file mode 100644
index 0000000000..d05b4ecba6
@@ -0,0 +1,29 @@
+    {
+        env->regs[0] = 0;
+        env->regs[1] = regs->r1;
+        env->regs[2] = regs->r2;
+        env->regs[3] = regs->r3;
+        env->regs[4] = regs->r4;
+        env->regs[5] = regs->r5;
+        env->regs[6] = regs->r6;
+        env->regs[7] = regs->r7;
+        env->regs[8] = regs->r8;
+        env->regs[9] = regs->r9;
+        env->regs[10] = regs->r10;
+        env->regs[11] = regs->r11;
+        env->regs[12] = regs->r12;
+        env->regs[13] = regs->r13;
+        env->regs[14] = regs->r14;
+        env->regs[15] = regs->r15;
+        /* TODO: unsigned long  orig_r2; */
+        env->regs[R_RA] = regs->ra;
+        env->regs[R_FP] = regs->fp;
+        env->regs[R_SP] = regs->sp;
+        env->regs[R_GP] = regs->gp;
+        env->regs[CR_ESTATUS] = regs->estatus;
+        env->regs[R_EA] = regs->ea;
+        /* TODO: unsigned long  orig_r7; */
+
+        /* Emulate eret when starting thread. */
+        env->regs[R_PC] = regs->ea;
+    }
linux-user/openrisc/prologue.inc.c new file +9 -0
new file mode 100644
index 0000000000..a09fde3352
@@ -0,0 +1,9 @@
+    {
+        int i;
+
+        for (i = 0; i < 32; i++) {
+            cpu_set_gpr(env, i, regs->gpr[i]);
+        }
+        env->pc = regs->pc;
+        cpu_set_sr(env, regs->sr);
+    }
linux-user/ppc/prologue.inc.c new file +16 -0
new file mode 100644
index 0000000000..92ed1c1b11
@@ -0,0 +1,16 @@
+    {
+        int i;
+
+#if defined(TARGET_PPC64)
+        int flag = (env->insns_flags2 & PPC2_BOOKE206) ? MSR_CM : MSR_SF;
+#if defined(TARGET_ABI32)
+        env->msr &= ~((target_ulong)1 << flag);
+#else
+        env->msr |= (target_ulong)1 << flag;
+#endif
+#endif
+        env->nip = regs->nip;
+        for(i = 0; i < 32; i++) {
+            env->gpr[i] = regs->gpr[i];
+        }
+    }
linux-user/riscv/prologue.inc.c new file +4 -0
new file mode 100644
index 0000000000..eaaf0d5016
@@ -0,0 +1,4 @@
+    {
+        env->pc = regs->sepc;
+        env->gpr[xSP] = regs->sp;
+    }
linux-user/s390x/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..b036127022
@@ -0,0 +1,8 @@
+    {
+            int i;
+            for (i = 0; i < 16; i++) {
+                env->regs[i] = regs->gprs[i];
+            }
+            env->psw.mask = regs->psw.mask;
+            env->psw.addr = regs->psw.addr;
+    }
linux-user/sh4/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..ae1d8270ef
@@ -0,0 +1,8 @@
+    {
+        int i;
+
+        for(i = 0; i < 16; i++) {
+            env->gregs[i] = regs->regs[i];
+        }
+        env->pc = regs->pc;
+    }
linux-user/sparc/prologue.inc.c new file +10 -0
new file mode 100644
index 0000000000..3bfea0a553
@@ -0,0 +1,10 @@
+    {
+        int i;
+	env->pc = regs->pc;
+	env->npc = regs->npc;
+        env->y = regs->y;
+        for(i = 0; i < 8; i++)
+            env->gregs[i] = regs->u_regs[i];
+        for(i = 0; i < 8; i++)
+            env->regwptr[i] = regs->u_regs[i + 8];
+    }
linux-user/sparc64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..e1b5fea628
@@ -0,0 +1 @@
+#include "../sparc/prologue.inc.c"
linux-user/tilegx/prologue.inc.c new file +10 -0
new file mode 100644
index 0000000000..9ea7429760
@@ -0,0 +1,10 @@
+    {
+        int i;
+        for (i = 0; i < TILEGX_R_COUNT; i++) {
+            env->regs[i] = regs->regs[i];
+        }
+        for (i = 0; i < TILEGX_SPR_COUNT; i++) {
+            env->spregs[i] = 0;
+        }
+        env->pc = regs->pc;
+    }
linux-user/x86_64/prologue.inc.c new file +1 -0
new file mode 100644
index 0000000000..ecfe04e909
@@ -0,0 +1 @@
+#include "../i386/prologue.inc.c"
linux-user/xtensa/prologue.inc.c new file +8 -0
new file mode 100644
index 0000000000..0c97de8244
@@ -0,0 +1,8 @@
+    {
+        int i;
+        for (i = 0; i < 16; ++i) {
+            env->regs[i] = regs->areg[i];
+        }
+        env->sregs[WINDOW_START] = regs->windowstart;
+        env->pc = regs->pc;
+    }
#13 lore raw
In reply to Laurent Vivier
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH for 2.13 0/5] linux-user: move arch specific parts to arch directories

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
586d8b371e linux-user: cleanup main()
4f63afd0b5 linux-user: cleanup cpu_loop() aa2bebb6ad linux-user: define TARGET_ARCH_HAS_SETUP_FRAME 647d489924 linux-user: remove unneeded #ifdef in signal.c ea340535fe linux-user: cleanup signal.c

=== OUTPUT BEGIN ===
Checking PATCH 1/5: linux-user: cleanup signal.c...
ERROR: code indent should never use tabs #873: FILE: linux-user/arm/signal.inc.c:30:
+ target_sigset_t tuc_sigmask;^I/* mask last for extensibility */$

ERROR: code indent should never use tabs
#881: FILE: linux-user/arm/signal.inc.c:38:
+ target_sigset_t tuc_sigmask;^I/* mask last for extensibility */$

ERROR: open brace '{' following struct go on the same line #921: FILE: linux-user/arm/signal.inc.c:78:
+struct sigframe_v1
+{

ERROR: spaces required around that '-' (ctx:VxV)
#923: FILE: linux-user/arm/signal.inc.c:80:

+    abi_ulong extramask[TARGET_NSIG_WORDS-1];
                                          ^

ERROR: open brace '{' following struct go on the same line #928: FILE: linux-user/arm/signal.inc.c:85:
+struct sigframe_v2
+{

ERROR: open brace '{' following struct go on the same line #934: FILE: linux-user/arm/signal.inc.c:91:
+struct rt_sigframe_v1
+{

ERROR: open brace '{' following struct go on the same line #943: FILE: linux-user/arm/signal.inc.c:100:
+struct rt_sigframe_v2
+{

WARNING: line over 80 characters
#954: FILE: linux-user/arm/signal.inc.c:111:
+#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE))

ERROR: code indent should never use tabs
#954: FILE: linux-user/arm/signal.inc.c:111:
+#define SWI_SYS_SIGRETURN^I(0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE))$

ERROR: spaces required around that '|' (ctx:VxV)
#954: FILE: linux-user/arm/signal.inc.c:111:
+#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE))

                          	           ^

WARNING: line over 80 characters
#955: FILE: linux-user/arm/signal.inc.c:112:
+#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE))

ERROR: code indent should never use tabs
#955: FILE: linux-user/arm/signal.inc.c:112:
+#define SWI_SYS_RT_SIGRETURN^I(0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE))$

ERROR: spaces required around that '|' (ctx:VxV)
#955: FILE: linux-user/arm/signal.inc.c:112:
+#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE))

                             	           ^

ERROR: code indent should never use tabs
#961: FILE: linux-user/arm/signal.inc.c:118:
+#define SWI_THUMB_SIGRETURN^I(0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn))$

WARNING: line over 80 characters
#962: FILE: linux-user/arm/signal.inc.c:119:
+#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn))

ERROR: code indent should never use tabs
#962: FILE: linux-user/arm/signal.inc.c:119:
+#define SWI_THUMB_RT_SIGRETURN^I(0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn))$

ERROR: code indent should never use tabs
#965: FILE: linux-user/arm/signal.inc.c:122:
+^ISWI_SYS_SIGRETURN,^ISWI_THUMB_SIGRETURN,$

ERROR: code indent should never use tabs
#966: FILE: linux-user/arm/signal.inc.c:123:
+^ISWI_SYS_RT_SIGRETURN,^ISWI_THUMB_RT_SIGRETURN$

ERROR: "(foo*)" should be "(foo *)"
#1073: FILE: linux-user/arm/signal.inc.c:230:
+ return (abi_ulong*)(vfpframe+1);

ERROR: spaces required around that '+' (ctx:VxV)
#1073: FILE: linux-user/arm/signal.inc.c:230:

+    return (abi_ulong*)(vfpframe+1);
                                 ^

ERROR: "(foo*)" should be "(foo *)"
#1093: FILE: linux-user/arm/signal.inc.c:250:
+ return (abi_ulong*)(iwmmxtframe+1);

ERROR: spaces required around that '+' (ctx:VxV)
#1093: FILE: linux-user/arm/signal.inc.c:250:

+    return (abi_ulong*)(iwmmxtframe+1);
                                    ^

ERROR: space required before the open parenthesis '(' #1125: FILE: linux-user/arm/signal.inc.c:282:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: space required before the open parenthesis '(' #1145: FILE: linux-user/arm/signal.inc.c:302:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: space required before the open parenthesis '(' #1222: FILE: linux-user/arm/signal.inc.c:379:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: space required before the open parenthesis '(' #1336: FILE: linux-user/arm/signal.inc.c:493:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: if this code is redundant consider removing it #1347: FILE: linux-user/arm/signal.inc.c:504:
+#if 0

ERROR: braces {} are necessary for all arms of this statement #1349: FILE: linux-user/arm/signal.inc.c:506:
+ if (ptrace_cancel_bpt(current))
[...]

ERROR: "(foo*)" should be "(foo *)"
#1387: FILE: linux-user/arm/signal.inc.c:544:
+ return (abi_ulong*)(vfpframe + 1);

ERROR: "(foo*)" should be "(foo *)"
#1412: FILE: linux-user/arm/signal.inc.c:569:
+ return (abi_ulong*)(iwmmxtframe + 1);

ERROR: braces {} are necessary for all arms of this statement #1425: FILE: linux-user/arm/signal.inc.c:582:
+ if (restore_sigcontext(env, &uc->tuc_mcontext))
[...]

ERROR: if this code is redundant consider removing it #1449: FILE: linux-user/arm/signal.inc.c:606:
+#if 0

ERROR: braces {} are necessary for all arms of this statement #1451: FILE: linux-user/arm/signal.inc.c:608:
+ if (ptrace_cancel_bpt(current))
[...]

ERROR: line over 90 characters
#1531: FILE: linux-user/arm/signal.inc.c:688:
+ if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe_v1, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)

ERROR: braces {} are necessary for all arms of this statement #1531: FILE: linux-user/arm/signal.inc.c:688:
+ if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe_v1, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)
[...]

ERROR: if this code is redundant consider removing it #1534: FILE: linux-user/arm/signal.inc.c:691:
+#if 0

ERROR: braces {} are necessary for all arms of this statement #1536: FILE: linux-user/arm/signal.inc.c:693:
+ if (ptrace_cancel_bpt(current))
[...]

ERROR: braces {} are necessary for all arms of this statement #1684: FILE: linux-user/cris/signal.inc.c:86:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
[...]

ERROR: spaces required around that '+' (ctx:VxV)
#1694: FILE: linux-user/cris/signal.inc.c:96:

+    __put_user(0x9c5f, frame->retcode+0);
                                      ^

ERROR: space required before the open parenthesis '(' #1702: FILE: linux-user/cris/signal.inc.c:104:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: space required before the open parenthesis '(' #1745: FILE: linux-user/cris/signal.inc.c:147:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: spaces required around that '-' (ctx:VxV)
#2107: FILE: linux-user/i386/signal.inc.c:143:

+    abi_ulong extramask[TARGET_NSIG_WORDS-1];
                                          ^

WARNING: line over 80 characters
#2234: FILE: linux-user/i386/signal.inc.c:270:
+ esp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;

ERROR: braces {} are necessary for all arms of this statement #2266: FILE: linux-user/i386/signal.inc.c:302:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
[...]

ERROR: space required before the open parenthesis '(' #2274: FILE: linux-user/i386/signal.inc.c:310:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: spaces required around that '+' (ctx:VxV)
#2289: FILE: linux-user/i386/signal.inc.c:325:

+        __put_user(val16, (uint16_t *)(frame->retcode+0));
                                                      ^

ERROR: spaces required around that '+' (ctx:VxV)
#2290: FILE: linux-user/i386/signal.inc.c:326:

+        __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2));
                                                               ^

ERROR: spaces required around that '+' (ctx:VxV)
#2292: FILE: linux-user/i386/signal.inc.c:328:

+        __put_user(val16, (uint16_t *)(frame->retcode+6));
                                                      ^

ERROR: braces {} are necessary for all arms of this statement #2329: FILE: linux-user/i386/signal.inc.c:365:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
[...]

ERROR: space required before the open parenthesis '(' #2355: FILE: linux-user/i386/signal.inc.c:391:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: spaces required around that '+' (ctx:VxV)
#2369: FILE: linux-user/i386/signal.inc.c:405:

+        __put_user(0xb8, (char *)(frame->retcode+0));
                                                 ^

ERROR: spaces required around that '+' (ctx:VxV)
#2370: FILE: linux-user/i386/signal.inc.c:406:

+        __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1));
                                                                  ^

ERROR: spaces required around that '+' (ctx:VxV)
#2372: FILE: linux-user/i386/signal.inc.c:408:

+        __put_user(val16, (uint16_t *)(frame->retcode+5));
                                                      ^

ERROR: code indent should never use tabs
#2459: FILE: linux-user/i386/signal.inc.c:495:
+ //^I^Iregs->orig_eax = -1;^I^I/* disable syscall checks */$

ERROR: do not use C99 // comments
#2459: FILE: linux-user/i386/signal.inc.c:495:
+ // regs->orig_eax = -1; /* disable syscall checks */

ERROR: braces {} are necessary for all arms of this statement #2463: FILE: linux-user/i386/signal.inc.c:499:
+ if (!access_ok(VERIFY_READ, fpstate_addr,
[...]

ERROR: braces {} are necessary for all arms of this statement #2489: FILE: linux-user/i386/signal.inc.c:525:
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
[...]

ERROR: space required before the open parenthesis '(' #2493: FILE: linux-user/i386/signal.inc.c:529:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #2501: FILE: linux-user/i386/signal.inc.c:537:
+ if (restore_sigcontext(env, &frame->sc))
[...]

ERROR: braces {} are necessary for all arms of this statement #2521: FILE: linux-user/i386/signal.inc.c:557:
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
[...]

WARNING: line over 80 characters
#2530: FILE: linux-user/i386/signal.inc.c:566:
+ if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,

ERROR: open brace '{' following struct go on the same line #2563: FILE: linux-user/m68k/signal.inc.c:14:
+struct target_sigframe
+{

ERROR: spaces required around that '-' (ctx:VxV)
#2569: FILE: linux-user/m68k/signal.inc.c:20:

+    abi_ulong extramask[TARGET_NSIG_WORDS-1];
                                          ^

ERROR: spaces required around that '*' (ctx:VxV)
#2579: FILE: linux-user/m68k/signal.inc.c:30:

+    int f_fpregs[8*3];
                   ^

ERROR: open brace '{' following struct go on the same line #2600: FILE: linux-user/m68k/signal.inc.c:51:
+struct target_rt_sigframe
+{

ERROR: space prohibited between function name and open parenthesis '(' #2651: FILE: linux-user/m68k/signal.inc.c:102:
+ if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags (sp) == 0)) {

ERROR: return is not a function, parentheses are not required #2655: FILE: linux-user/m68k/signal.inc.c:106:
+ return ((sp - frame_size) & -8UL);

ERROR: space required before the open parenthesis '(' #2680: FILE: linux-user/m68k/signal.inc.c:131:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #2783: FILE: linux-user/m68k/signal.inc.c:234:
+ if (temp != TARGET_MCONTEXT_VERSION)
[...]

ERROR: braces {} are necessary for all arms of this statement #2855: FILE: linux-user/m68k/signal.inc.c:306:
+ if (err)
[...]

ERROR: space required before the open parenthesis '(' #2858: FILE: linux-user/m68k/signal.inc.c:309:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #2873: FILE: linux-user/m68k/signal.inc.c:324:
+ if (err)
[...]

ERROR: braces {} are necessary for all arms of this statement #2898: FILE: linux-user/m68k/signal.inc.c:349:
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
[...]

ERROR: space required before the open parenthesis '(' #2905: FILE: linux-user/m68k/signal.inc.c:356:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #2931: FILE: linux-user/m68k/signal.inc.c:382:
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
[...]

ERROR: braces {} are necessary for all arms of this statement #2939: FILE: linux-user/m68k/signal.inc.c:390:
+ if (target_rt_restore_ucontext(env, &frame->uc))
[...]

ERROR: braces {} are necessary for all arms of this statement #2942: FILE: linux-user/m68k/signal.inc.c:393:
+ if (do_sigaltstack(frame_addr +
[...]

ERROR: return is not a function, parentheses are not required #3078: FILE: linux-user/microblaze/signal.inc.c:117:
+ return ((sp - frame_size) & -8UL);

ERROR: braces {} are necessary for all arms of this statement #3090: FILE: linux-user/microblaze/signal.inc.c:129:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
[...]

ERROR: space required before the open parenthesis '(' #3096: FILE: linux-user/microblaze/signal.inc.c:135:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: spaces required around that '-' (ctx:VxV) #3106: FILE: linux-user/microblaze/signal.inc.c:145:

+        env->regs[15] = ((unsigned long)ka->sa_restorer)-8;
                                                         ^

ERROR: braces {} are necessary for all arms of this statement #3158: FILE: linux-user/microblaze/signal.inc.c:197:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
[...]

ERROR: space required before the open parenthesis '(' #3163: FILE: linux-user/microblaze/signal.inc.c:202:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: space prohibited between function name and open parenthesis '(' #3363: FILE: linux-user/mips/signal.inc.c:170:
+ if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags (sp) == 0)) {

ERROR: "foo * bar" should be "foo *bar"
#3381: FILE: linux-user/mips/signal.inc.c:188:
+static void setup_frame(int sig, struct target_sigaction * ka,

ERROR: space required before the open parenthesis '(' #3398: FILE: linux-user/mips/signal.inc.c:205:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: space prohibited after that open square bracket '[' #3412: FILE: linux-user/mips/signal.inc.c:219:
+ regs->active_tc.gpr[ 4] = sig;

ERROR: space prohibited after that open square bracket '[' #3413: FILE: linux-user/mips/signal.inc.c:220:
+ regs->active_tc.gpr[ 5] = 0;

ERROR: space prohibited after that open square bracket '[' #3414: FILE: linux-user/mips/signal.inc.c:221:
+ regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc);

ERROR: braces {} are necessary for all arms of this statement #3439: FILE: linux-user/mips/signal.inc.c:246:
+ if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
[...]

ERROR: space required before the open parenthesis '(' #3442: FILE: linux-user/mips/signal.inc.c:249:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: if this code is redundant consider removing it #3451: FILE: linux-user/mips/signal.inc.c:258:
+#if 0

ERROR: spaces required around that ':' (ctx:ExV)
#3459: FILE: linux-user/mips/signal.inc.c:266:

+        :"r" (&regs));
         ^

WARNING: line over 80 characters
#3497: FILE: linux-user/mips/signal.inc.c:304:
+ __put_user(target_sigaltstack_used.ss_size, &frame->rs_uc.tuc_stack.ss_size);

ERROR: space required before the open parenthesis '(' #3503: FILE: linux-user/mips/signal.inc.c:310:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: space prohibited after that open square bracket '[' #3517: FILE: linux-user/mips/signal.inc.c:324:
+ env->active_tc.gpr[ 4] = sig;

ERROR: space prohibited after that open square bracket '[' #3518: FILE: linux-user/mips/signal.inc.c:325:
+ env->active_tc.gpr[ 5] = frame_addr

ERROR: space prohibited after that open square bracket '[' #3520: FILE: linux-user/mips/signal.inc.c:327:
+ env->active_tc.gpr[ 6] = frame_addr

ERROR: braces {} are necessary for all arms of this statement #3555: FILE: linux-user/mips/signal.inc.c:362:
+ if (do_sigaltstack(frame_addr +
[...]

ERROR: if this code is redundant consider removing it #3848: FILE: linux-user/openrisc/signal.inc.c:26:
+#if 0

ERROR: braces {} are necessary for all arms of this statement #4382: FILE: linux-user/ppc/signal.inc.c:345:
+ if (sig)
[...]

ERROR: braces {} are necessary for all arms of this statement #4461: FILE: linux-user/ppc/signal.inc.c:424:
+ if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
[...]

ERROR: braces {} are necessary for all arms of this statement #4488: FILE: linux-user/ppc/signal.inc.c:451:
+ if (err)
[...]

ERROR: braces {} are necessary for all arms of this statement #4525: FILE: linux-user/ppc/signal.inc.c:488:
+ if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1))
[...]

ERROR: space prohibited between function name and open parenthesis '(' #4539: FILE: linux-user/ppc/signal.inc.c:502:
+ __put_user(h2g (&rt_sf->uc.tuc_mcontext),

ERROR: space required before the open parenthesis '(' #4542: FILE: linux-user/ppc/signal.inc.c:505:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #4572: FILE: linux-user/ppc/signal.inc.c:535:
+ if (err)
[...]

ERROR: braces {} are necessary for all arms of this statement #4621: FILE: linux-user/ppc/signal.inc.c:584:
+ if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1))
[...]

ERROR: braces {} are necessary for all arms of this statement #4634: FILE: linux-user/ppc/signal.inc.c:597:
+ if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1))
[...]

WARNING: line over 80 characters
#4658: FILE: linux-user/ppc/signal.inc.c:621:
+ if (copy_from_user(&set, h2g(ucp) + offsetof(struct target_ucontext, tuc_sigmask),

ERROR: braces {} are necessary for all arms of this statement #4658: FILE: linux-user/ppc/signal.inc.c:621:
+ if (copy_from_user(&set, h2g(ucp) + offsetof(struct target_ucontext, tuc_sigmask),
[...]

ERROR: space prohibited between function name and open parenthesis '(' #4659: FILE: linux-user/ppc/signal.inc.c:622:
+ sizeof (set)))

ERROR: braces {} are necessary for all arms of this statement #4669: FILE: linux-user/ppc/signal.inc.c:632:
+ if (!lock_user_struct(VERIFY_READ, mcp, mcp_addr, 1))
[...]

ERROR: braces {} are necessary for all arms of this statement #4686: FILE: linux-user/ppc/signal.inc.c:649:
+ if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))
[...]

ERROR: braces {} are necessary for all arms of this statement #4689: FILE: linux-user/ppc/signal.inc.c:652:
+ if (do_setcontext(&rt_sf->uc, env, 1))
[...]

ERROR: spaces required around that '*' (ctx:VxV)
#4924: FILE: linux-user/s390x/signal.inc.c:12:
+#define _SIGMASK_COPY_SIZE (sizeof(unsigned long)*_SIGCONTEXT_NSIG_WORDS)

                                                     ^

WARNING: line over 80 characters
#4925: FILE: linux-user/s390x/signal.inc.c:13:
+#define PSW_ADDR_AMODE 0x0000000000000000UL /* 0x80000000UL for 31-bit */

ERROR: do not use C99 // comments
#5001: FILE: linux-user/s390x/signal.inc.c:89:
+ //save_access_regs(current->thread.acrs); FIXME

ERROR: do not use C99 // comments
#5017: FILE: linux-user/s390x/signal.inc.c:105:
+ //save_fp_regs(&current->thread.fp_regs); FIXME

ERROR: do not use C99 // comments
#5061: FILE: linux-user/s390x/signal.inc.c:149:
+ env->regs[2] = sig; //map_signal(sig);

ERROR: do not use C99 // comments
#5066: FILE: linux-user/s390x/signal.inc.c:154:
+ env->regs[4] = 0; // FIXME: no clue... current->thread.trap_no;

ERROR: do not use C99 // comments
#5067: FILE: linux-user/s390x/signal.inc.c:155:
+ env->regs[5] = 0; // FIXME: no clue... current->thread.prot_addr;

ERROR: do not use C99 // comments
#5124: FILE: linux-user/s390x/signal.inc.c:212:
+ env->regs[2] = sig; //map_signal(sig);

ERROR: open brace '{' following struct go on the same line #5252: FILE: linux-user/sh4/signal.inc.c:29:
+struct target_sigframe
+{

ERROR: spaces required around that '-' (ctx:VxV)
#5254: FILE: linux-user/sh4/signal.inc.c:31:

+    target_ulong extramask[TARGET_NSIG_WORDS-1];
                                             ^

ERROR: code indent should never use tabs
#5264: FILE: linux-user/sh4/signal.inc.c:41:
+ target_sigset_t tuc_sigmask;^I/* mask last for extensibility */$

ERROR: open brace '{' following struct go on the same line #5268: FILE: linux-user/sh4/signal.inc.c:45:
+struct target_rt_sigframe
+{

ERROR: spaces required around that '|' (ctx:VxV)
#5275: FILE: linux-user/sh4/signal.inc.c:52:
+#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */

                         ^

ERROR: spaces required around that '-' (ctx:VxV)
#5275: FILE: linux-user/sh4/signal.inc.c:52:
+#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */

                              ^

ERROR: spaces required around that '=' (ctx:VxV)
#5331: FILE: linux-user/sh4/signal.inc.c:108:

+    for (i=0; i<16; i++) {
           ^

ERROR: spaces required around that '<' (ctx:VxV)
#5331: FILE: linux-user/sh4/signal.inc.c:108:

+    for (i=0; i<16; i++) {
                ^

ERROR: spaces required around that '=' (ctx:VxV)
#5359: FILE: linux-user/sh4/signal.inc.c:136:

+    for (i=0; i<16; i++) {
           ^

ERROR: spaces required around that '<' (ctx:VxV)
#5359: FILE: linux-user/sh4/signal.inc.c:136:

+    for (i=0; i<16; i++) {
                ^

ERROR: space required before the open parenthesis '(' #5449: FILE: linux-user/sh4/signal.inc.c:226:
+ for(i = 0; i < TARGET_NSIG_WORDS; i++) {

ERROR: space required before the open parenthesis '(' #5499: FILE: linux-user/sh4/signal.inc.c:276:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: braces {} are necessary for all arms of this statement #5503: FILE: linux-user/sh4/signal.inc.c:280:
+ if (err)
[...]

ERROR: space prohibited before open square bracket '[' #12114: FILE: linux-user/sparc/signal.inc.c:60:
+ } si_fpqueue [16];

ERROR: space prohibited between function name and open parenthesis '(' #12122: FILE: linux-user/sparc/signal.inc.c:68:
+ abi_ulong insns[2] __attribute__ ((aligned (8)));

ERROR: code indent should never use tabs
#12149: FILE: linux-user/sparc/signal.inc.c:95:
+#define UREG_L0^I 8$

ERROR: line over 90 characters
#12164: FILE: linux-user/sparc/signal.inc.c:110:
+ && !((target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size) & 7)) {

WARNING: line over 80 characters
#12165: FILE: linux-user/sparc/signal.inc.c:111:
+ sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;

ERROR: spaces required around that '=' (ctx:VxV)
#12180: FILE: linux-user/sparc/signal.inc.c:126:

+    for (i=0; i < 8; i++) {
           ^

ERROR: spaces required around that '=' (ctx:VxV)
#12183: FILE: linux-user/sparc/signal.inc.c:129:

+    for (i=0; i < 8; i++) {
           ^

ERROR: spaces required around that '+' (ctx:VxV)
#12184: FILE: linux-user/sparc/signal.inc.c:130:

+        __put_user(env->regwptr[UREG_I0 + i], &si->si_regs.u_regs[i+8]);
                                                                    ^

ERROR: if this code is redundant consider removing it #12190: FILE: linux-user/sparc/signal.inc.c:136:
+#if 0

ERROR: do not use C99 // comments
#12218: FILE: linux-user/sparc/signal.inc.c:164:
+ //synchronize_user_stack();

ERROR: if this code is redundant consider removing it #12229: FILE: linux-user/sparc/signal.inc.c:175:
+#if 0

ERROR: braces {} are necessary for all arms of this statement #12230: FILE: linux-user/sparc/signal.inc.c:176:
+ if (invalid_frame_pointer(sf, sigframe_size))
[...]

ERROR: do not use C99 // comments
#12237: FILE: linux-user/sparc/signal.inc.c:183:
+ //save_fpu_state(regs, &sf->fpu_state);

ERROR: do not use C99 // comments
#12238: FILE: linux-user/sparc/signal.inc.c:184:
+ //__put_user(&sf->fpu_state, &sf->fpu_save);

ERROR: braces {} are necessary for all arms of this statement #12251: FILE: linux-user/sparc/signal.inc.c:197:
+ if (err)
[...]

ERROR: braces {} are necessary for all arms of this statement #12281: FILE: linux-user/sparc/signal.inc.c:227:
+ if (err)
[...]

ERROR: do not use C99 // comments
#12285: FILE: linux-user/sparc/signal.inc.c:231:
+ // flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));

ERROR: do not use C99 // comments
#12286: FILE: linux-user/sparc/signal.inc.c:232:
+ // tb_flush(env);

ERROR: if this code is redundant consider removing it #12290: FILE: linux-user/sparc/signal.inc.c:236:
+#if 0

ERROR: spaces required around that '=' (ctx:VxV)
#12313: FILE: linux-user/sparc/signal.inc.c:259:

+    int err=0, i;
            ^

ERROR: braces {} are necessary for all arms of this statement #12323: FILE: linux-user/sparc/signal.inc.c:269:
+ if (sf_addr & 3)
[...]

ERROR: spaces required around that '=' (ctx:VxV)
#12343: FILE: linux-user/sparc/signal.inc.c:289:

+    for (i=0; i < 8; i++) {
           ^

ERROR: spaces required around that '=' (ctx:VxV)
#12346: FILE: linux-user/sparc/signal.inc.c:292:

+    for (i=0; i < 8; i++) {
           ^

ERROR: spaces required around that '+' (ctx:VxV)
#12347: FILE: linux-user/sparc/signal.inc.c:293:

+        __get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8]);
                                                                         ^

ERROR: space required before the open parenthesis '(' #12360: FILE: linux-user/sparc/signal.inc.c:306:
+ for(i = 1; i < TARGET_NSIG_WORDS; i++) {

ERROR: do not use C99 // comments
#12420: FILE: linux-user/sparc/signal.inc.c:366:
+ //uint128_t qregs[16];

ERROR: spaces required around that '+' (ctx:VxV)
#12517: FILE: linux-user/sparc/signal.inc.c:463:

+    w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6];
                               ^

ERROR: spaces required around that '/' (ctx:VxV)
#12536: FILE: linux-user/sparc/signal.inc.c:482:

+                __get_user(env->fpr[i/2].l.lower, src);
                                      ^

ERROR: spaces required around that '/' (ctx:VxV)
#12538: FILE: linux-user/sparc/signal.inc.c:484:

+                __get_user(env->fpr[i/2].l.upper, src);
                                      ^

ERROR: braces {} are necessary for all arms of this statement #12595: FILE: linux-user/sparc/signal.inc.c:541:
+ if (err)
[...]

ERROR: do not use C99 // comments
#12600: FILE: linux-user/sparc/signal.inc.c:546:
+ // __put_user(env->tstate, &((*grp)[SPARC_MC_TSTATE]));

ERROR: spaces required around that '+' (ctx:VxV)
#12620: FILE: linux-user/sparc/signal.inc.c:566:

+    w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6];
                               ^

ERROR: spaces required around that '/' (ctx:VxV)
#12637: FILE: linux-user/sparc/signal.inc.c:583:

+                __put_user(env->fpr[i/2].l.lower, dst);
                                      ^

ERROR: spaces required around that '/' (ctx:VxV)
#12639: FILE: linux-user/sparc/signal.inc.c:585:

+                __put_user(env->fpr[i/2].l.upper, dst);
                                      ^

ERROR: braces {} are necessary for all arms of this statement #12647: FILE: linux-user/sparc/signal.inc.c:593:
+ if (err)
[...]

total: 162 errors, 9 warnings, 12955 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 2/5: linux-user: remove unneeded #ifdef in signal.c... Checking PATCH 3/5: linux-user: define TARGET_ARCH_HAS_SETUP_FRAME... Checking PATCH 4/5: linux-user: cleanup cpu_loop()...
ERROR: space prohibited between function name and open parenthesis '(' #200: FILE: linux-user/alpha/cpu_loop.inc.c:176:
+ printf ("Unhandled trap: 0x%x\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #204: FILE: linux-user/alpha/cpu_loop.inc.c:180:
+ process_pending_signals (env);

ERROR: braces {} are necessary for all arms of this statement #369: FILE: linux-user/arm/cpu_loop.inc.c:148:
+ if (get_user_u32(val, addr))
[...]

ERROR: space required before the open parenthesis '(' #414: FILE: linux-user/arm/cpu_loop.inc.c:193:
+ for(;;) {

ERROR: space required before the open parenthesis '(' #420: FILE: linux-user/arm/cpu_loop.inc.c:199:
+ switch(trapnr) {

ERROR: spaces required around that '=' (ctx:VxV)
#442: FILE: linux-user/arm/cpu_loop.inc.c:221:

+                    int arm_fpe=0;
                                ^

ERROR: suspect code indent for conditional statements (20, 22) #445: FILE: linux-user/arm/cpu_loop.inc.c:224:
+ if (-rc & float_flag_invalid)
+ arm_fpe |= BIT_IOC;

ERROR: braces {} are necessary for all arms of this statement #445: FILE: linux-user/arm/cpu_loop.inc.c:224:
+ if (-rc & float_flag_invalid)
[...]

ERROR: suspect code indent for conditional statements (20, 22) #447: FILE: linux-user/arm/cpu_loop.inc.c:226:
+ if (-rc & float_flag_divbyzero)
+ arm_fpe |= BIT_DZC;

ERROR: braces {} are necessary for all arms of this statement #447: FILE: linux-user/arm/cpu_loop.inc.c:226:
+ if (-rc & float_flag_divbyzero)
[...]

ERROR: suspect code indent for conditional statements (20, 22) #449: FILE: linux-user/arm/cpu_loop.inc.c:228:
+ if (-rc & float_flag_overflow)
+ arm_fpe |= BIT_OFC;

ERROR: braces {} are necessary for all arms of this statement #449: FILE: linux-user/arm/cpu_loop.inc.c:228:
+ if (-rc & float_flag_overflow)
[...]

ERROR: suspect code indent for conditional statements (20, 22) #451: FILE: linux-user/arm/cpu_loop.inc.c:230:
+ if (-rc & float_flag_underflow)
+ arm_fpe |= BIT_UFC;

ERROR: braces {} are necessary for all arms of this statement #451: FILE: linux-user/arm/cpu_loop.inc.c:230:
+ if (-rc & float_flag_underflow)
[...]

ERROR: suspect code indent for conditional statements (20, 22) #453: FILE: linux-user/arm/cpu_loop.inc.c:232:
+ if (-rc & float_flag_inexact)
+ arm_fpe |= BIT_IXC;

ERROR: braces {} are necessary for all arms of this statement #453: FILE: linux-user/arm/cpu_loop.inc.c:232:
+ if (-rc & float_flag_inexact)
[...]

ERROR: do not use C99 // comments
#457: FILE: linux-user/arm/cpu_loop.inc.c:236:
+ //printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe);

ERROR: trailing statements should be on next line
#464: FILE: linux-user/arm/cpu_loop.inc.c:243:
+ if (arm_fpe & BIT_IXC) info.si_code = TARGET_FPE_FLTRES;

ERROR: braces {} are necessary for all arms of this statement #464: FILE: linux-user/arm/cpu_loop.inc.c:243:
+ if (arm_fpe & BIT_IXC) info.si_code = TARGET_FPE_FLTRES;
[...]

ERROR: trailing statements should be on next line
#465: FILE: linux-user/arm/cpu_loop.inc.c:244:
+ if (arm_fpe & BIT_UFC) info.si_code = TARGET_FPE_FLTUND;

ERROR: braces {} are necessary for all arms of this statement #465: FILE: linux-user/arm/cpu_loop.inc.c:244:
+ if (arm_fpe & BIT_UFC) info.si_code = TARGET_FPE_FLTUND;
[...]

ERROR: trailing statements should be on next line
#466: FILE: linux-user/arm/cpu_loop.inc.c:245:
+ if (arm_fpe & BIT_OFC) info.si_code = TARGET_FPE_FLTOVF;

ERROR: braces {} are necessary for all arms of this statement #466: FILE: linux-user/arm/cpu_loop.inc.c:245:
+ if (arm_fpe & BIT_OFC) info.si_code = TARGET_FPE_FLTOVF;
[...]

ERROR: trailing statements should be on next line
#467: FILE: linux-user/arm/cpu_loop.inc.c:246:
+ if (arm_fpe & BIT_DZC) info.si_code = TARGET_FPE_FLTDIV;

ERROR: braces {} are necessary for all arms of this statement #467: FILE: linux-user/arm/cpu_loop.inc.c:246:
+ if (arm_fpe & BIT_DZC) info.si_code = TARGET_FPE_FLTDIV;
[...]

ERROR: trailing statements should be on next line
#468: FILE: linux-user/arm/cpu_loop.inc.c:247:
+ if (arm_fpe & BIT_IOC) info.si_code = TARGET_FPE_FLTINV;

ERROR: braces {} are necessary for all arms of this statement #468: FILE: linux-user/arm/cpu_loop.inc.c:247:
+ if (arm_fpe & BIT_IOC) info.si_code = TARGET_FPE_FLTINV;
[...]

ERROR: suspect code indent for conditional statements (20, 22) #477: FILE: linux-user/arm/cpu_loop.inc.c:256:
+ if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC))
+ fpsr |= BIT_IXC;

ERROR: braces {} are necessary for all arms of this statement #477: FILE: linux-user/arm/cpu_loop.inc.c:256:
+ if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC))
[...]

ERROR: suspect code indent for conditional statements (20, 22) #479: FILE: linux-user/arm/cpu_loop.inc.c:258:
+ if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC))
+ fpsr |= BIT_UFC;

ERROR: braces {} are necessary for all arms of this statement #479: FILE: linux-user/arm/cpu_loop.inc.c:258:
+ if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC))
[...]

ERROR: suspect code indent for conditional statements (20, 22) #481: FILE: linux-user/arm/cpu_loop.inc.c:260:
+ if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC))
+ fpsr |= BIT_OFC;

ERROR: braces {} are necessary for all arms of this statement #481: FILE: linux-user/arm/cpu_loop.inc.c:260:
+ if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC))
[...]

ERROR: suspect code indent for conditional statements (20, 22) #483: FILE: linux-user/arm/cpu_loop.inc.c:262:
+ if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC))
+ fpsr |= BIT_DZC;

ERROR: braces {} are necessary for all arms of this statement #483: FILE: linux-user/arm/cpu_loop.inc.c:262:
+ if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC))
[...]

ERROR: suspect code indent for conditional statements (20, 22) #485: FILE: linux-user/arm/cpu_loop.inc.c:264:
+ if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC))
+ fpsr |= BIT_IOC;

ERROR: braces {} are necessary for all arms of this statement #485: FILE: linux-user/arm/cpu_loop.inc.c:264:
+ if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC))
[...]

ERROR: spaces required around that '=' (ctx:VxV)
#487: FILE: linux-user/arm/cpu_loop.inc.c:266:

+                    ts->fpa.fpsr=fpsr;
                                 ^

ERROR: space prohibited between function name and open parenthesis '(' #527: FILE: linux-user/arm/cpu_loop.inc.c:306:
+ env->regs[0] = do_arm_semihosting (env);

ERROR: space prohibited after that open parenthesis '(' #536: FILE: linux-user/arm/cpu_loop.inc.c:315:
+ if ( n > ARM_NR_BASE) {

ERROR: that open brace { should be on the previous line #599: FILE: linux-user/arm/cpu_loop.inc.c:378:
+ if (sig)
+ {

ERROR: suspect code indent for conditional statements (12, 14) #609: FILE: linux-user/arm/cpu_loop.inc.c:388:
+ if (do_kernel_trap(env))
+ goto error;

ERROR: braces {} are necessary for all arms of this statement #609: FILE: linux-user/arm/cpu_loop.inc.c:388:
+ if (do_kernel_trap(env))
[...]

WARNING: line over 80 characters
#620: FILE: linux-user/arm/cpu_loop.inc.c:399:
+ EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

WARNING: line over 80 characters
#699: FILE: linux-user/arm/cpu_loop.inc.c:478:
+ EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

ERROR: code indent should never use tabs
#739: FILE: linux-user/cris/cpu_loop.inc.c:24:
+^Icase EXCP_INTERRUPT:$

ERROR: code indent should never use tabs
#740: FILE: linux-user/cris/cpu_loop.inc.c:25:
+^I /* just indicate that signals should be handled asap */$

ERROR: code indent should never use tabs
#741: FILE: linux-user/cris/cpu_loop.inc.c:26:
+^I break;$

ERROR: that open brace { should be on the previous line #763: FILE: linux-user/cris/cpu_loop.inc.c:48:
+ if (sig)
+ {

ERROR: space prohibited between function name and open parenthesis '(' #776: FILE: linux-user/cris/cpu_loop.inc.c:61:
+ printf ("Unhandled trap: 0x%x\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #780: FILE: linux-user/cris/cpu_loop.inc.c:65:
+ process_pending_signals (env);

ERROR: space required before the open parenthesis '(' #1040: FILE: linux-user/i386/cpu_loop.inc.c:68:
+ for(;;) {

ERROR: space required before the open parenthesis '(' #1046: FILE: linux-user/i386/cpu_loop.inc.c:74:
+ switch(trapnr) {

ERROR: braces {} are necessary for all arms of this statement #1094: FILE: linux-user/i386/cpu_loop.inc.c:122:
+ if (env->eflags & VM_MASK) {
[...]
+ } else
[...]

ERROR: braces {} are necessary for all arms of this statement #1109: FILE: linux-user/i386/cpu_loop.inc.c:137:
+ if (!(env->error_code & 1))
[...]
+ else
[...]

ERROR: braces {} are necessary for all arms of this statement #1118: FILE: linux-user/i386/cpu_loop.inc.c:146:
+ if (env->eflags & VM_MASK) {
[...]
+ } else
[...]

ERROR: braces {} are necessary for all arms of this statement #1134: FILE: linux-user/i386/cpu_loop.inc.c:162:
+ if (env->eflags & VM_MASK) {
[...]
+ } else
[...]

ERROR: braces {} are necessary for all arms of this statement #1154: FILE: linux-user/i386/cpu_loop.inc.c:182:
+ if (env->eflags & VM_MASK) {
[...]
+ } else
[...]

ERROR: that open brace { should be on the previous line #1181: FILE: linux-user/i386/cpu_loop.inc.c:209:
+ if (sig)
+ {

WARNING: line over 80 characters
#1195: FILE: linux-user/i386/cpu_loop.inc.c:223:
+ EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",

ERROR: space required before the open parenthesis '(' #1216: FILE: linux-user/m68k/cpu_loop.inc.c:9:
+ for(;;) {

ERROR: space required before the open parenthesis '(' #1222: FILE: linux-user/m68k/cpu_loop.inc.c:15:
+ switch(trapnr) {

ERROR: that open brace { should be on the previous line #1304: FILE: linux-user/m68k/cpu_loop.inc.c:97:
+ if (sig)
+ {

WARNING: line over 80 characters
#1317: FILE: linux-user/m68k/cpu_loop.inc.c:110:
+ EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

ERROR: code indent should never use tabs #5281: FILE: linux-user/microblaze/cpu_loop.inc.c:24:
+^Icase EXCP_INTERRUPT:$

ERROR: code indent should never use tabs
#5282: FILE: linux-user/microblaze/cpu_loop.inc.c:25:
+^I /* just indicate that signals should be handled asap */$

ERROR: code indent should never use tabs #5283: FILE: linux-user/microblaze/cpu_loop.inc.c:26:
+^I break;$

ERROR: switch and case should be at the same indent #5321: FILE: linux-user/microblaze/cpu_loop.inc.c:64:
+ switch (env->sregs[SR_ESR] & 31) {
+ case ESR_EC_DIVZERO:
[...]
+ case ESR_EC_FPU:
[...]
+ default:

ERROR: space prohibited between function name and open parenthesis '(' #5342: FILE: linux-user/microblaze/cpu_loop.inc.c:85:
+ printf ("Unhandled hw-exception: 0x%x\n",

ERROR: that open brace { should be on the previous line #5354: FILE: linux-user/microblaze/cpu_loop.inc.c:97:
+ if (sig)
+ {

ERROR: space prohibited between function name and open parenthesis '(' #5367: FILE: linux-user/microblaze/cpu_loop.inc.c:110:
+ printf ("Unhandled trap: 0x%x\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #5371: FILE: linux-user/microblaze/cpu_loop.inc.c:114:
+ process_pending_signals (env);

ERROR: Macros with complex values should be enclosed in parenthesis #5381: FILE: linux-user/mips/cpu_loop.inc.c:2:
+# define MIPS_SYS(name, args) args,

ERROR: code indent should never use tabs
#5383: FILE: linux-user/mips/cpu_loop.inc.c:4:
+^IMIPS_SYS(sys_syscall^I, 8)^I/* 4000 */$

ERROR: code indent should never use tabs
#5384: FILE: linux-user/mips/cpu_loop.inc.c:5:
+^IMIPS_SYS(sys_exit^I, 1)$

ERROR: code indent should never use tabs
#5385: FILE: linux-user/mips/cpu_loop.inc.c:6:
+^IMIPS_SYS(sys_fork^I, 0)$

ERROR: code indent should never use tabs
#5386: FILE: linux-user/mips/cpu_loop.inc.c:7:
+^IMIPS_SYS(sys_read^I, 3)$

ERROR: code indent should never use tabs
#5387: FILE: linux-user/mips/cpu_loop.inc.c:8:
+^IMIPS_SYS(sys_write^I, 3)$

ERROR: code indent should never use tabs
#5388: FILE: linux-user/mips/cpu_loop.inc.c:9:
+^IMIPS_SYS(sys_open^I, 3)^I/* 4005 */$

ERROR: code indent should never use tabs
#5389: FILE: linux-user/mips/cpu_loop.inc.c:10:
+^IMIPS_SYS(sys_close^I, 1)$

ERROR: code indent should never use tabs
#5390: FILE: linux-user/mips/cpu_loop.inc.c:11:
+^IMIPS_SYS(sys_waitpid^I, 3)$

ERROR: code indent should never use tabs
#5391: FILE: linux-user/mips/cpu_loop.inc.c:12:
+^IMIPS_SYS(sys_creat^I, 2)$

ERROR: code indent should never use tabs
#5392: FILE: linux-user/mips/cpu_loop.inc.c:13:
+^IMIPS_SYS(sys_link^I, 2)$

ERROR: code indent should never use tabs
#5393: FILE: linux-user/mips/cpu_loop.inc.c:14:
+^IMIPS_SYS(sys_unlink^I, 1)^I/* 4010 */$

ERROR: code indent should never use tabs
#5394: FILE: linux-user/mips/cpu_loop.inc.c:15:
+^IMIPS_SYS(sys_execve^I, 0)$

ERROR: code indent should never use tabs
#5395: FILE: linux-user/mips/cpu_loop.inc.c:16:
+^IMIPS_SYS(sys_chdir^I, 1)$

ERROR: code indent should never use tabs
#5396: FILE: linux-user/mips/cpu_loop.inc.c:17:
+^IMIPS_SYS(sys_time^I, 1)$

ERROR: code indent should never use tabs
#5397: FILE: linux-user/mips/cpu_loop.inc.c:18:
+^IMIPS_SYS(sys_mknod^I, 3)$

ERROR: code indent should never use tabs
#5398: FILE: linux-user/mips/cpu_loop.inc.c:19:
+^IMIPS_SYS(sys_chmod^I, 2)^I/* 4015 */$

ERROR: code indent should never use tabs
#5399: FILE: linux-user/mips/cpu_loop.inc.c:20:
+^IMIPS_SYS(sys_lchown^I, 3)$

ERROR: code indent should never use tabs
#5400: FILE: linux-user/mips/cpu_loop.inc.c:21:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs #5401: FILE: linux-user/mips/cpu_loop.inc.c:22:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_stat */$

ERROR: code indent should never use tabs
#5402: FILE: linux-user/mips/cpu_loop.inc.c:23:
+^IMIPS_SYS(sys_lseek^I, 3)$

ERROR: code indent should never use tabs
#5403: FILE: linux-user/mips/cpu_loop.inc.c:24:
+^IMIPS_SYS(sys_getpid^I, 0)^I/* 4020 */$

ERROR: code indent should never use tabs
#5404: FILE: linux-user/mips/cpu_loop.inc.c:25:
+^IMIPS_SYS(sys_mount^I, 5)$

ERROR: code indent should never use tabs
#5405: FILE: linux-user/mips/cpu_loop.inc.c:26:
+^IMIPS_SYS(sys_umount^I, 1)$

ERROR: code indent should never use tabs
#5406: FILE: linux-user/mips/cpu_loop.inc.c:27:
+^IMIPS_SYS(sys_setuid^I, 1)$

ERROR: code indent should never use tabs
#5407: FILE: linux-user/mips/cpu_loop.inc.c:28:
+^IMIPS_SYS(sys_getuid^I, 0)$

ERROR: code indent should never use tabs
#5408: FILE: linux-user/mips/cpu_loop.inc.c:29:
+^IMIPS_SYS(sys_stime^I, 1)^I/* 4025 */$

ERROR: code indent should never use tabs
#5409: FILE: linux-user/mips/cpu_loop.inc.c:30:
+^IMIPS_SYS(sys_ptrace^I, 4)$

ERROR: code indent should never use tabs
#5410: FILE: linux-user/mips/cpu_loop.inc.c:31:
+^IMIPS_SYS(sys_alarm^I, 1)$

ERROR: code indent should never use tabs #5411: FILE: linux-user/mips/cpu_loop.inc.c:32:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_fstat */$

ERROR: code indent should never use tabs
#5412: FILE: linux-user/mips/cpu_loop.inc.c:33:
+^IMIPS_SYS(sys_pause^I, 0)$

ERROR: code indent should never use tabs
#5413: FILE: linux-user/mips/cpu_loop.inc.c:34:
+^IMIPS_SYS(sys_utime^I, 2)^I/* 4030 */$

ERROR: code indent should never use tabs
#5414: FILE: linux-user/mips/cpu_loop.inc.c:35:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5415: FILE: linux-user/mips/cpu_loop.inc.c:36:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5416: FILE: linux-user/mips/cpu_loop.inc.c:37:
+^IMIPS_SYS(sys_access^I, 2)$

ERROR: code indent should never use tabs
#5417: FILE: linux-user/mips/cpu_loop.inc.c:38:
+^IMIPS_SYS(sys_nice^I, 1)$

ERROR: code indent should never use tabs
#5418: FILE: linux-user/mips/cpu_loop.inc.c:39:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* 4035 */$

ERROR: code indent should never use tabs
#5419: FILE: linux-user/mips/cpu_loop.inc.c:40:
+^IMIPS_SYS(sys_sync^I, 0)$

ERROR: code indent should never use tabs
#5420: FILE: linux-user/mips/cpu_loop.inc.c:41:
+^IMIPS_SYS(sys_kill^I, 2)$

ERROR: code indent should never use tabs
#5421: FILE: linux-user/mips/cpu_loop.inc.c:42:
+^IMIPS_SYS(sys_rename^I, 2)$

ERROR: code indent should never use tabs
#5422: FILE: linux-user/mips/cpu_loop.inc.c:43:
+^IMIPS_SYS(sys_mkdir^I, 2)$

ERROR: code indent should never use tabs
#5423: FILE: linux-user/mips/cpu_loop.inc.c:44:
+^IMIPS_SYS(sys_rmdir^I, 1)^I/* 4040 */$

ERROR: code indent should never use tabs
#5424: FILE: linux-user/mips/cpu_loop.inc.c:45:
+^IMIPS_SYS(sys_dup^I^I, 1)$

ERROR: code indent should never use tabs
#5425: FILE: linux-user/mips/cpu_loop.inc.c:46:
+^IMIPS_SYS(sys_pipe^I, 0)$

ERROR: code indent should never use tabs
#5426: FILE: linux-user/mips/cpu_loop.inc.c:47:
+^IMIPS_SYS(sys_times^I, 1)$

ERROR: code indent should never use tabs
#5427: FILE: linux-user/mips/cpu_loop.inc.c:48:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5428: FILE: linux-user/mips/cpu_loop.inc.c:49:
+^IMIPS_SYS(sys_brk^I^I, 1)^I/* 4045 */$

ERROR: code indent should never use tabs
#5429: FILE: linux-user/mips/cpu_loop.inc.c:50:
+^IMIPS_SYS(sys_setgid^I, 1)$

ERROR: code indent should never use tabs
#5430: FILE: linux-user/mips/cpu_loop.inc.c:51:
+^IMIPS_SYS(sys_getgid^I, 0)$

ERROR: code indent should never use tabs #5431: FILE: linux-user/mips/cpu_loop.inc.c:52:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was signal(2) */$

ERROR: code indent should never use tabs
#5432: FILE: linux-user/mips/cpu_loop.inc.c:53:
+^IMIPS_SYS(sys_geteuid^I, 0)$

ERROR: code indent should never use tabs
#5433: FILE: linux-user/mips/cpu_loop.inc.c:54:
+^IMIPS_SYS(sys_getegid^I, 0)^I/* 4050 */$

ERROR: code indent should never use tabs
#5434: FILE: linux-user/mips/cpu_loop.inc.c:55:
+^IMIPS_SYS(sys_acct^I, 0)$

ERROR: code indent should never use tabs
#5435: FILE: linux-user/mips/cpu_loop.inc.c:56:
+^IMIPS_SYS(sys_umount2^I, 2)$

ERROR: code indent should never use tabs
#5436: FILE: linux-user/mips/cpu_loop.inc.c:57:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5437: FILE: linux-user/mips/cpu_loop.inc.c:58:
+^IMIPS_SYS(sys_ioctl^I, 3)$

ERROR: code indent should never use tabs
#5438: FILE: linux-user/mips/cpu_loop.inc.c:59:
+^IMIPS_SYS(sys_fcntl^I, 3)^I/* 4055 */$

ERROR: code indent should never use tabs
#5439: FILE: linux-user/mips/cpu_loop.inc.c:60:
+^IMIPS_SYS(sys_ni_syscall^I, 2)$

ERROR: code indent should never use tabs
#5440: FILE: linux-user/mips/cpu_loop.inc.c:61:
+^IMIPS_SYS(sys_setpgid^I, 2)$

ERROR: code indent should never use tabs
#5441: FILE: linux-user/mips/cpu_loop.inc.c:62:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5442: FILE: linux-user/mips/cpu_loop.inc.c:63:
+^IMIPS_SYS(sys_olduname^I, 1)$

ERROR: code indent should never use tabs
#5443: FILE: linux-user/mips/cpu_loop.inc.c:64:
+^IMIPS_SYS(sys_umask^I, 1)^I/* 4060 */$

ERROR: code indent should never use tabs
#5444: FILE: linux-user/mips/cpu_loop.inc.c:65:
+^IMIPS_SYS(sys_chroot^I, 1)$

ERROR: code indent should never use tabs
#5445: FILE: linux-user/mips/cpu_loop.inc.c:66:
+^IMIPS_SYS(sys_ustat^I, 2)$

ERROR: code indent should never use tabs
#5446: FILE: linux-user/mips/cpu_loop.inc.c:67:
+^IMIPS_SYS(sys_dup2^I, 2)$

ERROR: code indent should never use tabs
#5447: FILE: linux-user/mips/cpu_loop.inc.c:68:
+^IMIPS_SYS(sys_getppid^I, 0)$

ERROR: code indent should never use tabs
#5448: FILE: linux-user/mips/cpu_loop.inc.c:69:
+^IMIPS_SYS(sys_getpgrp^I, 0)^I/* 4065 */$

ERROR: code indent should never use tabs
#5449: FILE: linux-user/mips/cpu_loop.inc.c:70:
+^IMIPS_SYS(sys_setsid^I, 0)$

ERROR: code indent should never use tabs
#5450: FILE: linux-user/mips/cpu_loop.inc.c:71:
+^IMIPS_SYS(sys_sigaction^I, 3)$

ERROR: code indent should never use tabs
#5451: FILE: linux-user/mips/cpu_loop.inc.c:72:
+^IMIPS_SYS(sys_sgetmask^I, 0)$

ERROR: code indent should never use tabs
#5452: FILE: linux-user/mips/cpu_loop.inc.c:73:
+^IMIPS_SYS(sys_ssetmask^I, 1)$

ERROR: code indent should never use tabs
#5453: FILE: linux-user/mips/cpu_loop.inc.c:74:
+^IMIPS_SYS(sys_setreuid^I, 2)^I/* 4070 */$

ERROR: code indent should never use tabs
#5454: FILE: linux-user/mips/cpu_loop.inc.c:75:
+^IMIPS_SYS(sys_setregid^I, 2)$

ERROR: code indent should never use tabs
#5455: FILE: linux-user/mips/cpu_loop.inc.c:76:
+^IMIPS_SYS(sys_sigsuspend^I, 0)$

ERROR: code indent should never use tabs
#5456: FILE: linux-user/mips/cpu_loop.inc.c:77:
+^IMIPS_SYS(sys_sigpending^I, 1)$

ERROR: code indent should never use tabs
#5457: FILE: linux-user/mips/cpu_loop.inc.c:78:
+^IMIPS_SYS(sys_sethostname^I, 2)$

ERROR: code indent should never use tabs
#5458: FILE: linux-user/mips/cpu_loop.inc.c:79:
+^IMIPS_SYS(sys_setrlimit^I, 2)^I/* 4075 */$

ERROR: code indent should never use tabs
#5459: FILE: linux-user/mips/cpu_loop.inc.c:80:
+^IMIPS_SYS(sys_getrlimit^I, 2)$

ERROR: code indent should never use tabs
#5460: FILE: linux-user/mips/cpu_loop.inc.c:81:
+^IMIPS_SYS(sys_getrusage^I, 2)$

ERROR: code indent should never use tabs
#5461: FILE: linux-user/mips/cpu_loop.inc.c:82:
+^IMIPS_SYS(sys_gettimeofday, 2)$

ERROR: code indent should never use tabs
#5462: FILE: linux-user/mips/cpu_loop.inc.c:83:
+^IMIPS_SYS(sys_settimeofday, 2)$

ERROR: code indent should never use tabs
#5463: FILE: linux-user/mips/cpu_loop.inc.c:84:
+^IMIPS_SYS(sys_getgroups^I, 2)^I/* 4080 */$

ERROR: code indent should never use tabs
#5464: FILE: linux-user/mips/cpu_loop.inc.c:85:
+^IMIPS_SYS(sys_setgroups^I, 2)$

ERROR: code indent should never use tabs #5465: FILE: linux-user/mips/cpu_loop.inc.c:86:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* old_select */$

ERROR: code indent should never use tabs
#5466: FILE: linux-user/mips/cpu_loop.inc.c:87:
+^IMIPS_SYS(sys_symlink^I, 2)$

ERROR: code indent should never use tabs #5467: FILE: linux-user/mips/cpu_loop.inc.c:88:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_lstat */$

ERROR: code indent should never use tabs
#5468: FILE: linux-user/mips/cpu_loop.inc.c:89:
+^IMIPS_SYS(sys_readlink^I, 3)^I/* 4085 */$

ERROR: code indent should never use tabs
#5469: FILE: linux-user/mips/cpu_loop.inc.c:90:
+^IMIPS_SYS(sys_uselib^I, 1)$

ERROR: code indent should never use tabs
#5470: FILE: linux-user/mips/cpu_loop.inc.c:91:
+^IMIPS_SYS(sys_swapon^I, 2)$

ERROR: code indent should never use tabs
#5471: FILE: linux-user/mips/cpu_loop.inc.c:92:
+^IMIPS_SYS(sys_reboot^I, 3)$

ERROR: code indent should never use tabs
#5472: FILE: linux-user/mips/cpu_loop.inc.c:93:
+^IMIPS_SYS(old_readdir^I, 3)$

ERROR: code indent should never use tabs
#5473: FILE: linux-user/mips/cpu_loop.inc.c:94:
+^IMIPS_SYS(old_mmap^I, 6)^I/* 4090 */$

ERROR: code indent should never use tabs
#5474: FILE: linux-user/mips/cpu_loop.inc.c:95:
+^IMIPS_SYS(sys_munmap^I, 2)$

ERROR: code indent should never use tabs
#5475: FILE: linux-user/mips/cpu_loop.inc.c:96:
+^IMIPS_SYS(sys_truncate^I, 2)$

ERROR: code indent should never use tabs
#5476: FILE: linux-user/mips/cpu_loop.inc.c:97:
+^IMIPS_SYS(sys_ftruncate^I, 2)$

ERROR: code indent should never use tabs
#5477: FILE: linux-user/mips/cpu_loop.inc.c:98:
+^IMIPS_SYS(sys_fchmod^I, 2)$

ERROR: code indent should never use tabs
#5478: FILE: linux-user/mips/cpu_loop.inc.c:99:
+^IMIPS_SYS(sys_fchown^I, 3)^I/* 4095 */$

ERROR: code indent should never use tabs
#5479: FILE: linux-user/mips/cpu_loop.inc.c:100:
+^IMIPS_SYS(sys_getpriority^I, 2)$

ERROR: code indent should never use tabs
#5480: FILE: linux-user/mips/cpu_loop.inc.c:101:
+^IMIPS_SYS(sys_setpriority^I, 3)$

ERROR: code indent should never use tabs
#5481: FILE: linux-user/mips/cpu_loop.inc.c:102:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5482: FILE: linux-user/mips/cpu_loop.inc.c:103:
+^IMIPS_SYS(sys_statfs^I, 2)$

ERROR: code indent should never use tabs
#5483: FILE: linux-user/mips/cpu_loop.inc.c:104:
+^IMIPS_SYS(sys_fstatfs^I, 2)^I/* 4100 */$

ERROR: code indent should never use tabs #5484: FILE: linux-user/mips/cpu_loop.inc.c:105:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was ioperm(2) */$

ERROR: code indent should never use tabs
#5485: FILE: linux-user/mips/cpu_loop.inc.c:106:
+^IMIPS_SYS(sys_socketcall^I, 2)$

ERROR: code indent should never use tabs
#5486: FILE: linux-user/mips/cpu_loop.inc.c:107:
+^IMIPS_SYS(sys_syslog^I, 3)$

ERROR: code indent should never use tabs
#5487: FILE: linux-user/mips/cpu_loop.inc.c:108:
+^IMIPS_SYS(sys_setitimer^I, 3)$

ERROR: code indent should never use tabs
#5488: FILE: linux-user/mips/cpu_loop.inc.c:109:
+^IMIPS_SYS(sys_getitimer^I, 2)^I/* 4105 */$

ERROR: code indent should never use tabs
#5489: FILE: linux-user/mips/cpu_loop.inc.c:110:
+^IMIPS_SYS(sys_newstat^I, 2)$

ERROR: code indent should never use tabs
#5490: FILE: linux-user/mips/cpu_loop.inc.c:111:
+^IMIPS_SYS(sys_newlstat^I, 2)$

ERROR: code indent should never use tabs
#5491: FILE: linux-user/mips/cpu_loop.inc.c:112:
+^IMIPS_SYS(sys_newfstat^I, 2)$

ERROR: code indent should never use tabs
#5492: FILE: linux-user/mips/cpu_loop.inc.c:113:
+^IMIPS_SYS(sys_uname^I, 1)$

ERROR: code indent should never use tabs
#5493: FILE: linux-user/mips/cpu_loop.inc.c:114:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* 4110 was iopl(2) */$

ERROR: code indent should never use tabs
#5494: FILE: linux-user/mips/cpu_loop.inc.c:115:
+^IMIPS_SYS(sys_vhangup^I, 0)$

ERROR: code indent should never use tabs #5495: FILE: linux-user/mips/cpu_loop.inc.c:116:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_idle() */$

ERROR: code indent should never use tabs #5496: FILE: linux-user/mips/cpu_loop.inc.c:117:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_vm86 */$

ERROR: code indent should never use tabs
#5497: FILE: linux-user/mips/cpu_loop.inc.c:118:
+^IMIPS_SYS(sys_wait4^I, 4)$

ERROR: code indent should never use tabs
#5498: FILE: linux-user/mips/cpu_loop.inc.c:119:
+^IMIPS_SYS(sys_swapoff^I, 1)^I/* 4115 */$

ERROR: code indent should never use tabs
#5499: FILE: linux-user/mips/cpu_loop.inc.c:120:
+^IMIPS_SYS(sys_sysinfo^I, 1)$

ERROR: code indent should never use tabs
#5500: FILE: linux-user/mips/cpu_loop.inc.c:121:
+^IMIPS_SYS(sys_ipc^I^I, 6)$

ERROR: code indent should never use tabs
#5501: FILE: linux-user/mips/cpu_loop.inc.c:122:
+^IMIPS_SYS(sys_fsync^I, 1)$

ERROR: code indent should never use tabs
#5502: FILE: linux-user/mips/cpu_loop.inc.c:123:
+^IMIPS_SYS(sys_sigreturn^I, 0)$

ERROR: code indent should never use tabs
#5503: FILE: linux-user/mips/cpu_loop.inc.c:124:
+^IMIPS_SYS(sys_clone^I, 6)^I/* 4120 */$

ERROR: code indent should never use tabs
#5504: FILE: linux-user/mips/cpu_loop.inc.c:125:
+^IMIPS_SYS(sys_setdomainname, 2)$

ERROR: code indent should never use tabs
#5505: FILE: linux-user/mips/cpu_loop.inc.c:126:
+^IMIPS_SYS(sys_newuname^I, 1)$

ERROR: code indent should never use tabs #5506: FILE: linux-user/mips/cpu_loop.inc.c:127:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* sys_modify_ldt */$

ERROR: code indent should never use tabs
#5507: FILE: linux-user/mips/cpu_loop.inc.c:128:
+^IMIPS_SYS(sys_adjtimex^I, 1)$

ERROR: code indent should never use tabs
#5508: FILE: linux-user/mips/cpu_loop.inc.c:129:
+^IMIPS_SYS(sys_mprotect^I, 3)^I/* 4125 */$

ERROR: code indent should never use tabs
#5509: FILE: linux-user/mips/cpu_loop.inc.c:130:
+^IMIPS_SYS(sys_sigprocmask^I, 3)$

ERROR: code indent should never use tabs
#5510: FILE: linux-user/mips/cpu_loop.inc.c:131:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was create_module */$

ERROR: code indent should never use tabs
#5511: FILE: linux-user/mips/cpu_loop.inc.c:132:
+^IMIPS_SYS(sys_init_module^I, 5)$

ERROR: code indent should never use tabs
#5512: FILE: linux-user/mips/cpu_loop.inc.c:133:
+^IMIPS_SYS(sys_delete_module, 1)$

ERROR: code indent should never use tabs
#5513: FILE: linux-user/mips/cpu_loop.inc.c:134:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* 4130^Iwas get_kernel_syms */$

ERROR: code indent should never use tabs
#5514: FILE: linux-user/mips/cpu_loop.inc.c:135:
+^IMIPS_SYS(sys_quotactl^I, 0)$

ERROR: code indent should never use tabs
#5515: FILE: linux-user/mips/cpu_loop.inc.c:136:
+^IMIPS_SYS(sys_getpgid^I, 1)$

ERROR: code indent should never use tabs
#5516: FILE: linux-user/mips/cpu_loop.inc.c:137:
+^IMIPS_SYS(sys_fchdir^I, 1)$

ERROR: code indent should never use tabs
#5517: FILE: linux-user/mips/cpu_loop.inc.c:138:
+^IMIPS_SYS(sys_bdflush^I, 2)$

ERROR: code indent should never use tabs
#5518: FILE: linux-user/mips/cpu_loop.inc.c:139:
+^IMIPS_SYS(sys_sysfs^I, 3)^I/* 4135 */$

ERROR: code indent should never use tabs
#5519: FILE: linux-user/mips/cpu_loop.inc.c:140:
+^IMIPS_SYS(sys_personality^I, 1)$

ERROR: code indent should never use tabs
#5520: FILE: linux-user/mips/cpu_loop.inc.c:141:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* for afs_syscall */$

ERROR: code indent should never use tabs
#5521: FILE: linux-user/mips/cpu_loop.inc.c:142:
+^IMIPS_SYS(sys_setfsuid^I, 1)$

ERROR: code indent should never use tabs
#5522: FILE: linux-user/mips/cpu_loop.inc.c:143:
+^IMIPS_SYS(sys_setfsgid^I, 1)$

ERROR: code indent should never use tabs
#5523: FILE: linux-user/mips/cpu_loop.inc.c:144:
+^IMIPS_SYS(sys_llseek^I, 5)^I/* 4140 */$

ERROR: code indent should never use tabs
#5524: FILE: linux-user/mips/cpu_loop.inc.c:145:
+^IMIPS_SYS(sys_getdents^I, 3)$

ERROR: code indent should never use tabs
#5525: FILE: linux-user/mips/cpu_loop.inc.c:146:
+^IMIPS_SYS(sys_select^I, 5)$

ERROR: code indent should never use tabs
#5526: FILE: linux-user/mips/cpu_loop.inc.c:147:
+^IMIPS_SYS(sys_flock^I, 2)$

ERROR: code indent should never use tabs
#5527: FILE: linux-user/mips/cpu_loop.inc.c:148:
+^IMIPS_SYS(sys_msync^I, 3)$

ERROR: code indent should never use tabs
#5528: FILE: linux-user/mips/cpu_loop.inc.c:149:
+^IMIPS_SYS(sys_readv^I, 3)^I/* 4145 */$

ERROR: code indent should never use tabs
#5529: FILE: linux-user/mips/cpu_loop.inc.c:150:
+^IMIPS_SYS(sys_writev^I, 3)$

ERROR: code indent should never use tabs
#5530: FILE: linux-user/mips/cpu_loop.inc.c:151:
+^IMIPS_SYS(sys_cacheflush^I, 3)$

ERROR: code indent should never use tabs
#5531: FILE: linux-user/mips/cpu_loop.inc.c:152:
+^IMIPS_SYS(sys_cachectl^I, 3)$

ERROR: code indent should never use tabs
#5532: FILE: linux-user/mips/cpu_loop.inc.c:153:
+^IMIPS_SYS(sys_sysmips^I, 4)$

ERROR: code indent should never use tabs
#5533: FILE: linux-user/mips/cpu_loop.inc.c:154:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* 4150 */$

ERROR: code indent should never use tabs
#5534: FILE: linux-user/mips/cpu_loop.inc.c:155:
+^IMIPS_SYS(sys_getsid^I, 1)$

ERROR: code indent should never use tabs
#5535: FILE: linux-user/mips/cpu_loop.inc.c:156:
+^IMIPS_SYS(sys_fdatasync^I, 0)$

ERROR: code indent should never use tabs
#5536: FILE: linux-user/mips/cpu_loop.inc.c:157:
+^IMIPS_SYS(sys_sysctl^I, 1)$

ERROR: code indent should never use tabs
#5537: FILE: linux-user/mips/cpu_loop.inc.c:158:
+^IMIPS_SYS(sys_mlock^I, 2)$

ERROR: code indent should never use tabs
#5538: FILE: linux-user/mips/cpu_loop.inc.c:159:
+^IMIPS_SYS(sys_munlock^I, 2)^I/* 4155 */$

ERROR: code indent should never use tabs
#5539: FILE: linux-user/mips/cpu_loop.inc.c:160:
+^IMIPS_SYS(sys_mlockall^I, 1)$

ERROR: code indent should never use tabs
#5540: FILE: linux-user/mips/cpu_loop.inc.c:161:
+^IMIPS_SYS(sys_munlockall^I, 0)$

ERROR: code indent should never use tabs
#5541: FILE: linux-user/mips/cpu_loop.inc.c:162:
+^IMIPS_SYS(sys_sched_setparam, 2)$

ERROR: code indent should never use tabs
#5542: FILE: linux-user/mips/cpu_loop.inc.c:163:
+^IMIPS_SYS(sys_sched_getparam, 2)$

ERROR: code indent should never use tabs #5543: FILE: linux-user/mips/cpu_loop.inc.c:164:
+^IMIPS_SYS(sys_sched_setscheduler, 3)^I/* 4160 */$

ERROR: code indent should never use tabs
#5544: FILE: linux-user/mips/cpu_loop.inc.c:165:
+^IMIPS_SYS(sys_sched_getscheduler, 1)$

ERROR: code indent should never use tabs
#5545: FILE: linux-user/mips/cpu_loop.inc.c:166:
+^IMIPS_SYS(sys_sched_yield^I, 0)$

ERROR: code indent should never use tabs
#5546: FILE: linux-user/mips/cpu_loop.inc.c:167:
+^IMIPS_SYS(sys_sched_get_priority_max, 1)$

ERROR: code indent should never use tabs
#5547: FILE: linux-user/mips/cpu_loop.inc.c:168:
+^IMIPS_SYS(sys_sched_get_priority_min, 1)$

ERROR: code indent should never use tabs #5548: FILE: linux-user/mips/cpu_loop.inc.c:169:
+^IMIPS_SYS(sys_sched_rr_get_interval, 2)^I/* 4165 */$

ERROR: code indent should never use tabs
#5549: FILE: linux-user/mips/cpu_loop.inc.c:170:
+^IMIPS_SYS(sys_nanosleep,^I2)$

ERROR: code indent should never use tabs
#5550: FILE: linux-user/mips/cpu_loop.inc.c:171:
+^IMIPS_SYS(sys_mremap^I, 5)$

ERROR: code indent should never use tabs
#5551: FILE: linux-user/mips/cpu_loop.inc.c:172:
+^IMIPS_SYS(sys_accept^I, 3)$

ERROR: code indent should never use tabs
#5552: FILE: linux-user/mips/cpu_loop.inc.c:173:
+^IMIPS_SYS(sys_bind^I, 3)$

ERROR: code indent should never use tabs
#5553: FILE: linux-user/mips/cpu_loop.inc.c:174:
+^IMIPS_SYS(sys_connect^I, 3)^I/* 4170 */$

ERROR: code indent should never use tabs
#5554: FILE: linux-user/mips/cpu_loop.inc.c:175:
+^IMIPS_SYS(sys_getpeername^I, 3)$

ERROR: code indent should never use tabs
#5555: FILE: linux-user/mips/cpu_loop.inc.c:176:
+^IMIPS_SYS(sys_getsockname^I, 3)$

ERROR: code indent should never use tabs
#5556: FILE: linux-user/mips/cpu_loop.inc.c:177:
+^IMIPS_SYS(sys_getsockopt^I, 5)$

ERROR: code indent should never use tabs
#5557: FILE: linux-user/mips/cpu_loop.inc.c:178:
+^IMIPS_SYS(sys_listen^I, 2)$

ERROR: code indent should never use tabs
#5558: FILE: linux-user/mips/cpu_loop.inc.c:179:
+^IMIPS_SYS(sys_recv^I, 4)^I/* 4175 */$

ERROR: code indent should never use tabs
#5559: FILE: linux-user/mips/cpu_loop.inc.c:180:
+^IMIPS_SYS(sys_recvfrom^I, 6)$

ERROR: code indent should never use tabs
#5560: FILE: linux-user/mips/cpu_loop.inc.c:181:
+^IMIPS_SYS(sys_recvmsg^I, 3)$

ERROR: code indent should never use tabs
#5561: FILE: linux-user/mips/cpu_loop.inc.c:182:
+^IMIPS_SYS(sys_send^I, 4)$

ERROR: code indent should never use tabs
#5562: FILE: linux-user/mips/cpu_loop.inc.c:183:
+^IMIPS_SYS(sys_sendmsg^I, 3)$

ERROR: code indent should never use tabs
#5563: FILE: linux-user/mips/cpu_loop.inc.c:184:
+^IMIPS_SYS(sys_sendto^I, 6)^I/* 4180 */$

ERROR: code indent should never use tabs
#5564: FILE: linux-user/mips/cpu_loop.inc.c:185:
+^IMIPS_SYS(sys_setsockopt^I, 5)$

ERROR: code indent should never use tabs
#5565: FILE: linux-user/mips/cpu_loop.inc.c:186:
+^IMIPS_SYS(sys_shutdown^I, 2)$

ERROR: code indent should never use tabs
#5566: FILE: linux-user/mips/cpu_loop.inc.c:187:
+^IMIPS_SYS(sys_socket^I, 3)$

ERROR: code indent should never use tabs
#5567: FILE: linux-user/mips/cpu_loop.inc.c:188:
+^IMIPS_SYS(sys_socketpair^I, 4)$

ERROR: code indent should never use tabs
#5568: FILE: linux-user/mips/cpu_loop.inc.c:189:
+^IMIPS_SYS(sys_setresuid^I, 3)^I/* 4185 */$

ERROR: code indent should never use tabs
#5569: FILE: linux-user/mips/cpu_loop.inc.c:190:
+^IMIPS_SYS(sys_getresuid^I, 3)$

ERROR: code indent should never use tabs
#5570: FILE: linux-user/mips/cpu_loop.inc.c:191:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* was sys_query_module */$

ERROR: code indent should never use tabs
#5571: FILE: linux-user/mips/cpu_loop.inc.c:192:
+^IMIPS_SYS(sys_poll^I, 3)$

ERROR: code indent should never use tabs
#5572: FILE: linux-user/mips/cpu_loop.inc.c:193:
+^IMIPS_SYS(sys_nfsservctl^I, 3)$

ERROR: code indent should never use tabs
#5573: FILE: linux-user/mips/cpu_loop.inc.c:194:
+^IMIPS_SYS(sys_setresgid^I, 3)^I/* 4190 */$

ERROR: code indent should never use tabs
#5574: FILE: linux-user/mips/cpu_loop.inc.c:195:
+^IMIPS_SYS(sys_getresgid^I, 3)$

ERROR: code indent should never use tabs
#5575: FILE: linux-user/mips/cpu_loop.inc.c:196:
+^IMIPS_SYS(sys_prctl^I, 5)$

ERROR: code indent should never use tabs
#5576: FILE: linux-user/mips/cpu_loop.inc.c:197:
+^IMIPS_SYS(sys_rt_sigreturn, 0)$

ERROR: code indent should never use tabs
#5577: FILE: linux-user/mips/cpu_loop.inc.c:198:
+^IMIPS_SYS(sys_rt_sigaction, 4)$

ERROR: code indent should never use tabs
#5578: FILE: linux-user/mips/cpu_loop.inc.c:199:
+^IMIPS_SYS(sys_rt_sigprocmask, 4)^I/* 4195 */$

ERROR: code indent should never use tabs
#5579: FILE: linux-user/mips/cpu_loop.inc.c:200:
+^IMIPS_SYS(sys_rt_sigpending, 2)$

ERROR: code indent should never use tabs
#5580: FILE: linux-user/mips/cpu_loop.inc.c:201:
+^IMIPS_SYS(sys_rt_sigtimedwait, 4)$

ERROR: code indent should never use tabs
#5581: FILE: linux-user/mips/cpu_loop.inc.c:202:
+^IMIPS_SYS(sys_rt_sigqueueinfo, 3)$

ERROR: code indent should never use tabs
#5582: FILE: linux-user/mips/cpu_loop.inc.c:203:
+^IMIPS_SYS(sys_rt_sigsuspend, 0)$

ERROR: code indent should never use tabs
#5583: FILE: linux-user/mips/cpu_loop.inc.c:204:
+^IMIPS_SYS(sys_pread64^I, 6)^I/* 4200 */$

ERROR: code indent should never use tabs
#5584: FILE: linux-user/mips/cpu_loop.inc.c:205:
+^IMIPS_SYS(sys_pwrite64^I, 6)$

ERROR: code indent should never use tabs
#5585: FILE: linux-user/mips/cpu_loop.inc.c:206:
+^IMIPS_SYS(sys_chown^I, 3)$

ERROR: code indent should never use tabs
#5586: FILE: linux-user/mips/cpu_loop.inc.c:207:
+^IMIPS_SYS(sys_getcwd^I, 2)$

ERROR: code indent should never use tabs
#5587: FILE: linux-user/mips/cpu_loop.inc.c:208:
+^IMIPS_SYS(sys_capget^I, 2)$

ERROR: code indent should never use tabs
#5588: FILE: linux-user/mips/cpu_loop.inc.c:209:
+^IMIPS_SYS(sys_capset^I, 2)^I/* 4205 */$

ERROR: code indent should never use tabs
#5589: FILE: linux-user/mips/cpu_loop.inc.c:210:
+^IMIPS_SYS(sys_sigaltstack^I, 2)$

ERROR: code indent should never use tabs
#5590: FILE: linux-user/mips/cpu_loop.inc.c:211:
+^IMIPS_SYS(sys_sendfile^I, 4)$

ERROR: code indent should never use tabs
#5591: FILE: linux-user/mips/cpu_loop.inc.c:212:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5592: FILE: linux-user/mips/cpu_loop.inc.c:213:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5593: FILE: linux-user/mips/cpu_loop.inc.c:214:
+^IMIPS_SYS(sys_mmap2^I, 6)^I/* 4210 */$

ERROR: code indent should never use tabs
#5594: FILE: linux-user/mips/cpu_loop.inc.c:215:
+^IMIPS_SYS(sys_truncate64^I, 4)$

ERROR: code indent should never use tabs
#5595: FILE: linux-user/mips/cpu_loop.inc.c:216:
+^IMIPS_SYS(sys_ftruncate64^I, 4)$

ERROR: code indent should never use tabs
#5596: FILE: linux-user/mips/cpu_loop.inc.c:217:
+^IMIPS_SYS(sys_stat64^I, 2)$

ERROR: code indent should never use tabs
#5597: FILE: linux-user/mips/cpu_loop.inc.c:218:
+^IMIPS_SYS(sys_lstat64^I, 2)$

ERROR: code indent should never use tabs
#5598: FILE: linux-user/mips/cpu_loop.inc.c:219:
+^IMIPS_SYS(sys_fstat64^I, 2)^I/* 4215 */$

ERROR: code indent should never use tabs
#5599: FILE: linux-user/mips/cpu_loop.inc.c:220:
+^IMIPS_SYS(sys_pivot_root^I, 2)$

ERROR: code indent should never use tabs
#5600: FILE: linux-user/mips/cpu_loop.inc.c:221:
+^IMIPS_SYS(sys_mincore^I, 3)$

ERROR: code indent should never use tabs
#5601: FILE: linux-user/mips/cpu_loop.inc.c:222:
+^IMIPS_SYS(sys_madvise^I, 3)$

ERROR: code indent should never use tabs
#5602: FILE: linux-user/mips/cpu_loop.inc.c:223:
+^IMIPS_SYS(sys_getdents64^I, 3)$

ERROR: code indent should never use tabs
#5603: FILE: linux-user/mips/cpu_loop.inc.c:224:
+^IMIPS_SYS(sys_fcntl64^I, 3)^I/* 4220 */$

ERROR: code indent should never use tabs
#5604: FILE: linux-user/mips/cpu_loop.inc.c:225:
+^IMIPS_SYS(sys_ni_syscall^I, 0)$

ERROR: code indent should never use tabs
#5605: FILE: linux-user/mips/cpu_loop.inc.c:226:
+^IMIPS_SYS(sys_gettid^I, 0)$

ERROR: code indent should never use tabs
#5606: FILE: linux-user/mips/cpu_loop.inc.c:227:
+^IMIPS_SYS(sys_readahead^I, 5)$

ERROR: code indent should never use tabs
#5607: FILE: linux-user/mips/cpu_loop.inc.c:228:
+^IMIPS_SYS(sys_setxattr^I, 5)$

ERROR: code indent should never use tabs
#5608: FILE: linux-user/mips/cpu_loop.inc.c:229:
+^IMIPS_SYS(sys_lsetxattr^I, 5)^I/* 4225 */$

ERROR: code indent should never use tabs
#5609: FILE: linux-user/mips/cpu_loop.inc.c:230:
+^IMIPS_SYS(sys_fsetxattr^I, 5)$

ERROR: code indent should never use tabs
#5610: FILE: linux-user/mips/cpu_loop.inc.c:231:
+^IMIPS_SYS(sys_getxattr^I, 4)$

ERROR: code indent should never use tabs
#5611: FILE: linux-user/mips/cpu_loop.inc.c:232:
+^IMIPS_SYS(sys_lgetxattr^I, 4)$

ERROR: code indent should never use tabs
#5612: FILE: linux-user/mips/cpu_loop.inc.c:233:
+^IMIPS_SYS(sys_fgetxattr^I, 4)$

ERROR: code indent should never use tabs
#5613: FILE: linux-user/mips/cpu_loop.inc.c:234:
+^IMIPS_SYS(sys_listxattr^I, 3)^I/* 4230 */$

ERROR: code indent should never use tabs
#5614: FILE: linux-user/mips/cpu_loop.inc.c:235:
+^IMIPS_SYS(sys_llistxattr^I, 3)$

ERROR: code indent should never use tabs
#5615: FILE: linux-user/mips/cpu_loop.inc.c:236:
+^IMIPS_SYS(sys_flistxattr^I, 3)$

ERROR: code indent should never use tabs
#5616: FILE: linux-user/mips/cpu_loop.inc.c:237:
+^IMIPS_SYS(sys_removexattr^I, 2)$

ERROR: code indent should never use tabs
#5617: FILE: linux-user/mips/cpu_loop.inc.c:238:
+^IMIPS_SYS(sys_lremovexattr, 2)$

ERROR: code indent should never use tabs
#5618: FILE: linux-user/mips/cpu_loop.inc.c:239:
+^IMIPS_SYS(sys_fremovexattr, 2)^I/* 4235 */$

ERROR: code indent should never use tabs
#5619: FILE: linux-user/mips/cpu_loop.inc.c:240:
+^IMIPS_SYS(sys_tkill^I, 2)$

ERROR: code indent should never use tabs
#5620: FILE: linux-user/mips/cpu_loop.inc.c:241:
+^IMIPS_SYS(sys_sendfile64^I, 5)$

ERROR: code indent should never use tabs
#5621: FILE: linux-user/mips/cpu_loop.inc.c:242:
+^IMIPS_SYS(sys_futex^I, 6)$

ERROR: code indent should never use tabs
#5622: FILE: linux-user/mips/cpu_loop.inc.c:243:
+^IMIPS_SYS(sys_sched_setaffinity, 3)$

ERROR: code indent should never use tabs #5623: FILE: linux-user/mips/cpu_loop.inc.c:244:
+^IMIPS_SYS(sys_sched_getaffinity, 3)^I/* 4240 */$

ERROR: code indent should never use tabs
#5624: FILE: linux-user/mips/cpu_loop.inc.c:245:
+^IMIPS_SYS(sys_io_setup^I, 2)$

ERROR: code indent should never use tabs
#5625: FILE: linux-user/mips/cpu_loop.inc.c:246:
+^IMIPS_SYS(sys_io_destroy^I, 1)$

ERROR: code indent should never use tabs
#5626: FILE: linux-user/mips/cpu_loop.inc.c:247:
+^IMIPS_SYS(sys_io_getevents, 5)$

ERROR: code indent should never use tabs
#5627: FILE: linux-user/mips/cpu_loop.inc.c:248:
+^IMIPS_SYS(sys_io_submit^I, 3)$

ERROR: code indent should never use tabs
#5628: FILE: linux-user/mips/cpu_loop.inc.c:249:
+^IMIPS_SYS(sys_io_cancel^I, 3)^I/* 4245 */$

ERROR: code indent should never use tabs
#5629: FILE: linux-user/mips/cpu_loop.inc.c:250:
+^IMIPS_SYS(sys_exit_group^I, 1)$

ERROR: code indent should never use tabs
#5630: FILE: linux-user/mips/cpu_loop.inc.c:251:
+^IMIPS_SYS(sys_lookup_dcookie, 3)$

ERROR: code indent should never use tabs
#5631: FILE: linux-user/mips/cpu_loop.inc.c:252:
+^IMIPS_SYS(sys_epoll_create, 1)$

ERROR: code indent should never use tabs
#5632: FILE: linux-user/mips/cpu_loop.inc.c:253:
+^IMIPS_SYS(sys_epoll_ctl^I, 4)$

ERROR: code indent should never use tabs
#5633: FILE: linux-user/mips/cpu_loop.inc.c:254:
+^IMIPS_SYS(sys_epoll_wait^I, 3)^I/* 4250 */$

ERROR: code indent should never use tabs
#5634: FILE: linux-user/mips/cpu_loop.inc.c:255:
+^IMIPS_SYS(sys_remap_file_pages, 5)$

ERROR: code indent should never use tabs
#5635: FILE: linux-user/mips/cpu_loop.inc.c:256:
+^IMIPS_SYS(sys_set_tid_address, 1)$

ERROR: code indent should never use tabs
#5636: FILE: linux-user/mips/cpu_loop.inc.c:257:
+^IMIPS_SYS(sys_restart_syscall, 0)$

ERROR: code indent should never use tabs
#5637: FILE: linux-user/mips/cpu_loop.inc.c:258:
+^IMIPS_SYS(sys_fadvise64_64, 7)$

ERROR: code indent should never use tabs
#5638: FILE: linux-user/mips/cpu_loop.inc.c:259:
+^IMIPS_SYS(sys_statfs64^I, 3)^I/* 4255 */$

ERROR: code indent should never use tabs
#5639: FILE: linux-user/mips/cpu_loop.inc.c:260:
+^IMIPS_SYS(sys_fstatfs64^I, 2)$

ERROR: code indent should never use tabs
#5640: FILE: linux-user/mips/cpu_loop.inc.c:261:
+^IMIPS_SYS(sys_timer_create, 3)$

ERROR: code indent should never use tabs
#5641: FILE: linux-user/mips/cpu_loop.inc.c:262:
+^IMIPS_SYS(sys_timer_settime, 4)$

ERROR: code indent should never use tabs
#5642: FILE: linux-user/mips/cpu_loop.inc.c:263:
+^IMIPS_SYS(sys_timer_gettime, 2)$

ERROR: code indent should never use tabs
#5643: FILE: linux-user/mips/cpu_loop.inc.c:264:
+^IMIPS_SYS(sys_timer_getoverrun, 1)^I/* 4260 */$

ERROR: code indent should never use tabs
#5644: FILE: linux-user/mips/cpu_loop.inc.c:265:
+^IMIPS_SYS(sys_timer_delete, 1)$

ERROR: code indent should never use tabs
#5645: FILE: linux-user/mips/cpu_loop.inc.c:266:
+^IMIPS_SYS(sys_clock_settime, 2)$

ERROR: code indent should never use tabs
#5646: FILE: linux-user/mips/cpu_loop.inc.c:267:
+^IMIPS_SYS(sys_clock_gettime, 2)$

ERROR: code indent should never use tabs
#5647: FILE: linux-user/mips/cpu_loop.inc.c:268:
+^IMIPS_SYS(sys_clock_getres, 2)$

ERROR: code indent should never use tabs
#5648: FILE: linux-user/mips/cpu_loop.inc.c:269:
+^IMIPS_SYS(sys_clock_nanosleep, 4)^I/* 4265 */$

ERROR: code indent should never use tabs
#5649: FILE: linux-user/mips/cpu_loop.inc.c:270:
+^IMIPS_SYS(sys_tgkill^I, 3)$

ERROR: code indent should never use tabs
#5650: FILE: linux-user/mips/cpu_loop.inc.c:271:
+^IMIPS_SYS(sys_utimes^I, 2)$

ERROR: code indent should never use tabs
#5651: FILE: linux-user/mips/cpu_loop.inc.c:272:
+^IMIPS_SYS(sys_mbind^I, 4)$

ERROR: code indent should never use tabs
#5652: FILE: linux-user/mips/cpu_loop.inc.c:273:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* sys_get_mempolicy */$

ERROR: code indent should never use tabs
#5653: FILE: linux-user/mips/cpu_loop.inc.c:274:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* 4270 sys_set_mempolicy */$

ERROR: code indent should never use tabs
#5654: FILE: linux-user/mips/cpu_loop.inc.c:275:
+^IMIPS_SYS(sys_mq_open^I, 4)$

ERROR: code indent should never use tabs
#5655: FILE: linux-user/mips/cpu_loop.inc.c:276:
+^IMIPS_SYS(sys_mq_unlink^I, 1)$

ERROR: code indent should never use tabs
#5656: FILE: linux-user/mips/cpu_loop.inc.c:277:
+^IMIPS_SYS(sys_mq_timedsend, 5)$

ERROR: code indent should never use tabs
#5657: FILE: linux-user/mips/cpu_loop.inc.c:278:
+^IMIPS_SYS(sys_mq_timedreceive, 5)$

ERROR: code indent should never use tabs
#5658: FILE: linux-user/mips/cpu_loop.inc.c:279:
+^IMIPS_SYS(sys_mq_notify^I, 2)^I/* 4275 */$

ERROR: code indent should never use tabs
#5659: FILE: linux-user/mips/cpu_loop.inc.c:280:
+^IMIPS_SYS(sys_mq_getsetattr, 3)$

ERROR: code indent should never use tabs #5660: FILE: linux-user/mips/cpu_loop.inc.c:281:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* sys_vserver */$

ERROR: code indent should never use tabs
#5661: FILE: linux-user/mips/cpu_loop.inc.c:282:
+^IMIPS_SYS(sys_waitid^I, 4)$

ERROR: code indent should never use tabs
#5662: FILE: linux-user/mips/cpu_loop.inc.c:283:
+^IMIPS_SYS(sys_ni_syscall^I, 0)^I/* available, was setaltroot */$

ERROR: code indent should never use tabs
#5663: FILE: linux-user/mips/cpu_loop.inc.c:284:
+^IMIPS_SYS(sys_add_key^I, 5)$

ERROR: code indent should never use tabs
#5664: FILE: linux-user/mips/cpu_loop.inc.c:285:
+^IMIPS_SYS(sys_request_key, 4)$

ERROR: code indent should never use tabs
#5665: FILE: linux-user/mips/cpu_loop.inc.c:286:
+^IMIPS_SYS(sys_keyctl^I, 5)$

ERROR: code indent should never use tabs
#5666: FILE: linux-user/mips/cpu_loop.inc.c:287:
+^IMIPS_SYS(sys_set_thread_area, 1)$

ERROR: code indent should never use tabs
#5667: FILE: linux-user/mips/cpu_loop.inc.c:288:
+^IMIPS_SYS(sys_inotify_init, 0)$

ERROR: code indent should never use tabs
#5668: FILE: linux-user/mips/cpu_loop.inc.c:289:
+^IMIPS_SYS(sys_inotify_add_watch, 3) /* 4285 */$

ERROR: code indent should never use tabs
#5669: FILE: linux-user/mips/cpu_loop.inc.c:290:
+^IMIPS_SYS(sys_inotify_rm_watch, 2)$

ERROR: code indent should never use tabs
#5670: FILE: linux-user/mips/cpu_loop.inc.c:291:
+^IMIPS_SYS(sys_migrate_pages, 4)$

ERROR: code indent should never use tabs
#5671: FILE: linux-user/mips/cpu_loop.inc.c:292:
+^IMIPS_SYS(sys_openat, 4)$

ERROR: code indent should never use tabs
#5672: FILE: linux-user/mips/cpu_loop.inc.c:293:
+^IMIPS_SYS(sys_mkdirat, 3)$

ERROR: code indent should never use tabs
#5673: FILE: linux-user/mips/cpu_loop.inc.c:294:
+^IMIPS_SYS(sys_mknodat, 4)^I/* 4290 */$

ERROR: code indent should never use tabs
#5674: FILE: linux-user/mips/cpu_loop.inc.c:295:
+^IMIPS_SYS(sys_fchownat, 5)$

ERROR: code indent should never use tabs
#5675: FILE: linux-user/mips/cpu_loop.inc.c:296:
+^IMIPS_SYS(sys_futimesat, 3)$

ERROR: code indent should never use tabs
#5676: FILE: linux-user/mips/cpu_loop.inc.c:297:
+^IMIPS_SYS(sys_fstatat64, 4)$

ERROR: code indent should never use tabs
#5677: FILE: linux-user/mips/cpu_loop.inc.c:298:
+^IMIPS_SYS(sys_unlinkat, 3)$

ERROR: code indent should never use tabs
#5678: FILE: linux-user/mips/cpu_loop.inc.c:299:
+^IMIPS_SYS(sys_renameat, 4)^I/* 4295 */$

ERROR: code indent should never use tabs
#5679: FILE: linux-user/mips/cpu_loop.inc.c:300:
+^IMIPS_SYS(sys_linkat, 5)$

ERROR: code indent should never use tabs
#5680: FILE: linux-user/mips/cpu_loop.inc.c:301:
+^IMIPS_SYS(sys_symlinkat, 3)$

ERROR: code indent should never use tabs
#5681: FILE: linux-user/mips/cpu_loop.inc.c:302:
+^IMIPS_SYS(sys_readlinkat, 4)$

ERROR: code indent should never use tabs
#5682: FILE: linux-user/mips/cpu_loop.inc.c:303:
+^IMIPS_SYS(sys_fchmodat, 3)$

ERROR: code indent should never use tabs
#5683: FILE: linux-user/mips/cpu_loop.inc.c:304:
+^IMIPS_SYS(sys_faccessat, 3)^I/* 4300 */$

ERROR: code indent should never use tabs
#5684: FILE: linux-user/mips/cpu_loop.inc.c:305:
+^IMIPS_SYS(sys_pselect6, 6)$

ERROR: code indent should never use tabs
#5685: FILE: linux-user/mips/cpu_loop.inc.c:306:
+^IMIPS_SYS(sys_ppoll, 5)$

ERROR: code indent should never use tabs
#5686: FILE: linux-user/mips/cpu_loop.inc.c:307:
+^IMIPS_SYS(sys_unshare, 1)$

ERROR: code indent should never use tabs
#5687: FILE: linux-user/mips/cpu_loop.inc.c:308:
+^IMIPS_SYS(sys_splice, 6)$

ERROR: code indent should never use tabs
#5688: FILE: linux-user/mips/cpu_loop.inc.c:309:
+^IMIPS_SYS(sys_sync_file_range, 7) /* 4305 */$

ERROR: code indent should never use tabs
#5689: FILE: linux-user/mips/cpu_loop.inc.c:310:
+^IMIPS_SYS(sys_tee, 4)$

ERROR: code indent should never use tabs
#5690: FILE: linux-user/mips/cpu_loop.inc.c:311:
+^IMIPS_SYS(sys_vmsplice, 4)$

ERROR: code indent should never use tabs
#5691: FILE: linux-user/mips/cpu_loop.inc.c:312:
+^IMIPS_SYS(sys_move_pages, 6)$

ERROR: code indent should never use tabs
#5692: FILE: linux-user/mips/cpu_loop.inc.c:313:
+^IMIPS_SYS(sys_set_robust_list, 2)$

ERROR: code indent should never use tabs
#5693: FILE: linux-user/mips/cpu_loop.inc.c:314:
+^IMIPS_SYS(sys_get_robust_list, 3) /* 4310 */$

ERROR: code indent should never use tabs
#5694: FILE: linux-user/mips/cpu_loop.inc.c:315:
+^IMIPS_SYS(sys_kexec_load, 4)$

ERROR: code indent should never use tabs
#5695: FILE: linux-user/mips/cpu_loop.inc.c:316:
+^IMIPS_SYS(sys_getcpu, 3)$

ERROR: code indent should never use tabs
#5696: FILE: linux-user/mips/cpu_loop.inc.c:317:
+^IMIPS_SYS(sys_epoll_pwait, 6)$

ERROR: code indent should never use tabs
#5697: FILE: linux-user/mips/cpu_loop.inc.c:318:
+^IMIPS_SYS(sys_ioprio_set, 3)$

ERROR: code indent should never use tabs
#5698: FILE: linux-user/mips/cpu_loop.inc.c:319:
+^IMIPS_SYS(sys_ioprio_get, 2)$

ERROR: space required before the open parenthesis '(' #5840: FILE: linux-user/mips/cpu_loop.inc.c:461:
+ for(;;) {

ERROR: space required before the open parenthesis '(' #5846: FILE: linux-user/mips/cpu_loop.inc.c:467:
+ switch(trapnr) {

ERROR: do not use assignment in if condition
#5863: FILE: linux-user/mips/cpu_loop.inc.c:484:
+ if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {

ERROR: do not use assignment in if condition
#5867: FILE: linux-user/mips/cpu_loop.inc.c:488:
+ if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {

ERROR: do not use assignment in if condition
#5871: FILE: linux-user/mips/cpu_loop.inc.c:492:
+ if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {

ERROR: do not use assignment in if condition
#5875: FILE: linux-user/mips/cpu_loop.inc.c:496:
+ if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) {

ERROR: that open brace { should be on the previous line #5939: FILE: linux-user/mips/cpu_loop.inc.c:560:
+ if (sig)
+ {

WARNING: line over 80 characters
#6069: FILE: linux-user/mips/cpu_loop.inc.c:690:
+ EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #6305: FILE: linux-user/ppc/cpu_loop.inc.c:27:
+__attribute__ (( alias ("cpu_ppc_load_tbu") ));

ERROR: space prohibited after that open parenthesis '(' #6305: FILE: linux-user/ppc/cpu_loop.inc.c:27:
+__attribute__ (( alias ("cpu_ppc_load_tbu") ));

ERROR: space prohibited before that close parenthesis ')' #6305: FILE: linux-user/ppc/cpu_loop.inc.c:27:
+__attribute__ (( alias ("cpu_ppc_load_tbu") ));

ERROR: space prohibited between function name and open parenthesis '(' #6313: FILE: linux-user/ppc/cpu_loop.inc.c:35:
+int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp)

ERROR: space prohibited between function name and open parenthesis '(' #6318: FILE: linux-user/ppc/cpu_loop.inc.c:40:
+int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)

ERROR: trailing statements should be on next line
#6345: FILE: linux-user/ppc/cpu_loop.inc.c:67:
+ case 1: segv = get_user_u8(val, addr); break;

ERROR: trailing statements should be on next line
#6346: FILE: linux-user/ppc/cpu_loop.inc.c:68:
+ case 2: segv = get_user_u16(val, addr); break;

ERROR: trailing statements should be on next line
#6347: FILE: linux-user/ppc/cpu_loop.inc.c:69:
+ case 4: segv = get_user_u32(val, addr); break;

ERROR: trailing statements should be on next line
#6349: FILE: linux-user/ppc/cpu_loop.inc.c:71:
+ case 8: segv = get_user_u64(val, addr); break;

ERROR: trailing statements should be on next line
#6358: FILE: linux-user/ppc/cpu_loop.inc.c:80:
+ default: abort();

ERROR: trailing statements should be on next line
#6363: FILE: linux-user/ppc/cpu_loop.inc.c:85:
+ case 1: segv = put_user_u8(val, addr); break;

ERROR: trailing statements should be on next line
#6364: FILE: linux-user/ppc/cpu_loop.inc.c:86:
+ case 2: segv = put_user_u16(val, addr); break;

ERROR: trailing statements should be on next line
#6365: FILE: linux-user/ppc/cpu_loop.inc.c:87:
+ case 4: segv = put_user_u32(val, addr); break;

ERROR: trailing statements should be on next line
#6367: FILE: linux-user/ppc/cpu_loop.inc.c:89:
+ case 8: segv = put_user_u64(val, addr); break;

ERROR: spaces required around that '+' (ctx:VxV)
#6372: FILE: linux-user/ppc/cpu_loop.inc.c:94:

+                            val = env->gpr[reg+1];
                                               ^

ERROR: spaces required around that '+' (ctx:VxV)
#6374: FILE: linux-user/ppc/cpu_loop.inc.c:96:

+                            val2 = env->gpr[reg+1];
                                                ^

ERROR: trailing statements should be on next line
#6384: FILE: linux-user/ppc/cpu_loop.inc.c:106:
+ default: abort();

ERROR: space required before the open parenthesis '(' #6409: FILE: linux-user/ppc/cpu_loop.inc.c:131:
+ for(;;) {

ERROR: space required before the open parenthesis '(' #6415: FILE: linux-user/ppc/cpu_loop.inc.c:137:
+ switch(trapnr) {

ERROR: space prohibited between function name and open parenthesis '(' #7047: FILE: linux-user/s390x/cpu_loop.inc.c:130:
+ process_pending_signals (env);

ERROR: code indent should never use tabs
#7106: FILE: linux-user/sh4/cpu_loop.inc.c:51:
+^Icase 0xa0:$

ERROR: code indent should never use tabs
#7107: FILE: linux-user/sh4/cpu_loop.inc.c:52:
+^Icase 0xc0:$

ERROR: code indent should never use tabs
#7113: FILE: linux-user/sh4/cpu_loop.inc.c:58:
+^I break;$

ERROR: space prohibited between function name and open parenthesis '(' #7119: FILE: linux-user/sh4/cpu_loop.inc.c:64:
+ printf ("Unhandled trap: 0x%x\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #7123: FILE: linux-user/sh4/cpu_loop.inc.c:68:
+ process_pending_signals (env);

ERROR: do not use C99 // comments
#7142: FILE: linux-user/sparc/cpu_loop.inc.c:3:
+//#define DEBUG_WIN

ERROR: braces {} are necessary for all arms of this statement #7151: FILE: linux-user/sparc/cpu_loop.inc.c:12:
+ if (index < 8 && env->cwp == env->nwindows - 1)
[...]

ERROR: braces {} are necessary for all arms of this statement #7164: FILE: linux-user/sparc/cpu_loop.inc.c:25:
+ if (sp_ptr & 3)
[...]

ERROR: space required before the open parenthesis '(' #7171: FILE: linux-user/sparc/cpu_loop.inc.c:32:
+ for(i = 0; i < 16; i++) {

ERROR: braces {} are necessary for all arms of this statement #7210: FILE: linux-user/sparc/cpu_loop.inc.c:71:
+ if (sp_ptr & 3)
[...]

ERROR: space required before the open parenthesis '(' #7217: FILE: linux-user/sparc/cpu_loop.inc.c:78:
+ for(i = 0; i < 16; i++) {

ERROR: braces {} are necessary for all arms of this statement #7224: FILE: linux-user/sparc/cpu_loop.inc.c:85:
+ if (env->cleanwin < env->nwindows - 1)
[...]

ERROR: space required before the open parenthesis '(' #7237: FILE: linux-user/sparc/cpu_loop.inc.c:98:
+ for(;;) {

ERROR: braces {} are necessary for all arms of this statement #7241: FILE: linux-user/sparc/cpu_loop.inc.c:102:
+ if (env->wim & (1 << cwp1))
[...]

ERROR: braces {} are necessary for all arms of this statement #7244: FILE: linux-user/sparc/cpu_loop.inc.c:105:
+ if (env->canrestore == 0)
[...]

ERROR: space prohibited between function name and open parenthesis '(' #7262: FILE: linux-user/sparc/cpu_loop.inc.c:123:
+void cpu_loop (CPUSPARCState *env)

ERROR: space prohibited between function name and open parenthesis '(' #7288: FILE: linux-user/sparc/cpu_loop.inc.c:149:
+ ret = do_syscall (env, env->gregs[1],

ERROR: braces {} are necessary for all arms of this statement #7356: FILE: linux-user/sparc/cpu_loop.inc.c:217:
+ if (trapnr == TT_DFAULT)
[...]
+ else
[...]

ERROR: that open brace { should be on the previous line #7391: FILE: linux-user/sparc/cpu_loop.inc.c:252:
+ if (sig)
+ {

ERROR: space prohibited between function name and open parenthesis '(' #7404: FILE: linux-user/sparc/cpu_loop.inc.c:265:
+ printf ("Unhandled trap: 0x%x\n", trapnr);

ERROR: space prohibited between function name and open parenthesis '(' #7408: FILE: linux-user/sparc/cpu_loop.inc.c:269:
+ process_pending_signals (env);

total: 433 errors, 5 warnings, 7776 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 5/5: linux-user: cleanup main()...
ERROR: space required before the open parenthesis '(' #48: FILE: linux-user/alpha/prologue.inc.c:4:
+ for(i = 0; i < 28; i++) {

ERROR: space required before the open parenthesis '(' #64: FILE: linux-user/arm/prologue.inc.c:5:
+ for(i = 0; i < 16; i++) {

ERROR: code indent should never use tabs
#90: FILE: linux-user/cris/prologue.inc.c:2:
+^I env->regs[0] = regs->r0;$

ERROR: code indent should never use tabs
#91: FILE: linux-user/cris/prologue.inc.c:3:
+^I env->regs[1] = regs->r1;$

ERROR: code indent should never use tabs
#92: FILE: linux-user/cris/prologue.inc.c:4:
+^I env->regs[2] = regs->r2;$

ERROR: code indent should never use tabs
#93: FILE: linux-user/cris/prologue.inc.c:5:
+^I env->regs[3] = regs->r3;$

ERROR: code indent should never use tabs
#94: FILE: linux-user/cris/prologue.inc.c:6:
+^I env->regs[4] = regs->r4;$

ERROR: code indent should never use tabs
#95: FILE: linux-user/cris/prologue.inc.c:7:
+^I env->regs[5] = regs->r5;$

ERROR: code indent should never use tabs
#96: FILE: linux-user/cris/prologue.inc.c:8:
+^I env->regs[6] = regs->r6;$

ERROR: code indent should never use tabs
#97: FILE: linux-user/cris/prologue.inc.c:9:
+^I env->regs[7] = regs->r7;$

ERROR: code indent should never use tabs
#98: FILE: linux-user/cris/prologue.inc.c:10:
+^I env->regs[8] = regs->r8;$

ERROR: code indent should never use tabs
#99: FILE: linux-user/cris/prologue.inc.c:11:
+^I env->regs[9] = regs->r9;$

ERROR: code indent should never use tabs
#100: FILE: linux-user/cris/prologue.inc.c:12:
+^I env->regs[10] = regs->r10;$

ERROR: code indent should never use tabs
#101: FILE: linux-user/cris/prologue.inc.c:13:
+^I env->regs[11] = regs->r11;$

ERROR: code indent should never use tabs
#102: FILE: linux-user/cris/prologue.inc.c:14:
+^I env->regs[12] = regs->r12;$

ERROR: code indent should never use tabs
#103: FILE: linux-user/cris/prologue.inc.c:15:
+^I env->regs[13] = regs->r13;$

ERROR: code indent should never use tabs
#104: FILE: linux-user/cris/prologue.inc.c:16:
+^I env->regs[14] = info->start_stack;$

ERROR: code indent should never use tabs
#105: FILE: linux-user/cris/prologue.inc.c:17:
+^I env->regs[15] = regs->acr;$

ERROR: code indent should never use tabs
#106: FILE: linux-user/cris/prologue.inc.c:18:
+^I env->pc = regs->erp;$

ERROR: spaces required around that '|' (ctx:VxV)
#178: FILE: linux-user/i386/prologue.inc.c:51:
+ PROT_READ|PROT_WRITE,

                                          ^

ERROR: spaces required around that '|' (ctx:VxV)
#179: FILE: linux-user/i386/prologue.inc.c:52:

+                                MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
                                              ^

ERROR: spaces required around that '|' (ctx:VxV)
#207: FILE: linux-user/i386/prologue.inc.c:80:
+ PROT_READ|PROT_WRITE,

                                              ^

ERROR: spaces required around that '|' (ctx:VxV)
#208: FILE: linux-user/i386/prologue.inc.c:81:

+                                    MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
                                                  ^

ERROR: space required before the open parenthesis '(' #734: FILE: linux-user/mips/prologue.inc.c:4:
+ for(i = 0; i < 32; i++) {

ERROR: space required before the open parenthesis '(' #831: FILE: linux-user/ppc/prologue.inc.c:13:
+ for(i = 0; i < 32; i++) {

ERROR: space required before the open parenthesis '(' #868: FILE: linux-user/sh4/prologue.inc.c:4:
+ for(i = 0; i < 16; i++) {

ERROR: code indent should never use tabs
#881: FILE: linux-user/sparc/prologue.inc.c:3:
+^Ienv->pc = regs->pc;$

ERROR: code indent should never use tabs
#882: FILE: linux-user/sparc/prologue.inc.c:4:
+^Ienv->npc = regs->npc;$

ERROR: space required before the open parenthesis '(' #884: FILE: linux-user/sparc/prologue.inc.c:6:
+ for(i = 0; i < 8; i++)

ERROR: braces {} are necessary for all arms of this statement #884: FILE: linux-user/sparc/prologue.inc.c:6:
+ for(i = 0; i < 8; i++)
[...]

ERROR: space required before the open parenthesis '(' #886: FILE: linux-user/sparc/prologue.inc.c:8:
+ for(i = 0; i < 8; i++)

ERROR: braces {} are necessary for all arms of this statement #886: FILE: linux-user/sparc/prologue.inc.c:8:
+ for(i = 0; i < 8; i++)
[...]

total: 32 errors, 0 warnings, 790 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#14 lore raw
In reply to Laurent Vivier
Quoted 11 lines · Laurent Vivier

Some files like signal.c are really hard to read because all architectures are mixed in the same file.

This series moves from signal.c these parts to the architecture dedicated directories in linux-user. Moerover, this allows to compare easier functions between architectures (it helps to debug problems). Adding new functions for a new architecture will be facilitated too.

Quoted 3 lines

As we are doing that for signal.c, we can also do that for main.c, for the cpu loop part
and the cpu loop prologue too.

Yeah, this is something I've kind of had on my backlog of "it would be nice to do this" for years. Thanks for putting in the work!

Quoted 3 lines

checkpatch.pl is not happy... but I only want to move code from a file to another. I don't want to change the content of the parts I move.

Yeah, that's reasonable. (Since the move will reduce the effectiveness of git blame anyway we might want to do a fix-coding-style pass afterwards, but we can do that as a separate patchset.)

thanks
-- PMM