From patchwork Wed Apr 11 18:56:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 897377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Lv4j4sZ5z9s1l for ; Thu, 12 Apr 2018 05:20:05 +1000 (AEST) Received: from localhost ([::1]:48966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6LHl-0000J2-3s for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2018 15:20:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6KwF-0006GF-N7 for qemu-devel@nongnu.org; Wed, 11 Apr 2018 14:57:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6KwD-00082N-5Q for qemu-devel@nongnu.org; Wed, 11 Apr 2018 14:57:47 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:52063) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6Kw5-0007sV-D6; Wed, 11 Apr 2018 14:57:37 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0Lp6ay-1eaYwn3RkS-00euk8; Wed, 11 Apr 2018 20:57:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2018 20:56:47 +0200 Message-Id: <20180411185651.21351-16-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180411185651.21351-1-laurent@vivier.eu> References: <20180411185651.21351-1-laurent@vivier.eu> X-Provags-ID: V03:K1:H2/GhzeZaEoyIb/556hMmEUadGr6CK5PVPhFdG2KrEwfk7ICxpy iJU4DvPluJLP7PMVDWa4ZclL4PUizWBzyZvCXGd6/PlQSsqQdrzP2hyixKLh6LISsJwu/+b QQUU03GR2DSXUQF4fCwCuC8hZYuZ/OSc5lqbxZrVmBPv5savAvzqE7kaE6w7IBpeXfAMHFE 8XBHNlC3Fmij3vESN2RcQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:XylAZH4r1Dg=:16tWAtgMJplw9Y6MgrxKLZ CzUnj3eCoGOn6DIbRnOgJuw7C/j5+K9DPN3EWg1haHbUteaqACq3o6FBxsgdi4ftcY+ec5fxM WXrNk9asQr+5IEaYj7m2QTVCjgEHJl/3agvBipUkVDb7wJu3MQawMwXa6QKiaR2iuKioNbf+l /ukHMAbdXUTmgsUUVEdV/f2yjMSORBxhexYlhGEEGJC1MZRQNyVdD8QPVacMn0JLfM9UJT0L3 /BVejl3XFBgid44sC2p8FN0zOm+d2+Evex9qJqSGyUrBD1IG86Ygaf4XuEqZ50gocMe2NKWtk ZyB/mN+WCxuwAq5IE9WqsQZmR2hPx3ENVg0WbGFVyUBT9Drji7PZ/a4rH++rNBTZGlMbMYhmx EU6OEioDDxtHw/eBzXVvtz7sm8/5oY9wNOK9pkkNm6CRR4dgaD+N+Qm5BKwHL7GnjEDCLFD/N rRsLnB0mxqDRPbuH644t4zUAJbPvZ7ZRuPBybqlLZ02HVN96Stmyg0LgdXYFeBx2yTDJsbtQp lukLU2lon0jxVSf2RRYN025e/E5rHUx231v4XvvwDOJcfTZ74hG0VwwZJ/sHDWjmLp3jXXC1r tUEfBZj7yDDGmeBUx1DVjhywaQdx6ccDBXAq68xAttxmFZcmJi3A2GnAUPlcpoOxdQqIJGcnH 3h3nNLYw1aUI/zAKHpDbAfBG35Xowpx4FOin9jL8W0tQlDwhx6dkEjoeioHWNo74ZNSLbBp5q /uRBYuo6YQKMxXZ7HVCRP/wyGx+2erGmrtEJXQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.74 Subject: [Qemu-devel] [PATCH for 2.13 v2 15/19] linux-user: move s390x cpu loop to s390x directory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cornelia Huck , Riku Voipio , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" No code change, only move code from main.c to s390x/cpu_loop.c. Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Acked-by: Cornelia Huck Reviewed-by: Philippe Mathieu-Daudé --- linux-user/main.c | 146 -------------------------------------------- linux-user/s390x/cpu_loop.c | 139 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 146 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 37cf3a7d6f..7f6cfa5548 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -149,143 +149,6 @@ void fork_end(int child) } } -#ifdef TARGET_S390X - -/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */ -#define S390X_FAIL_ADDR_MASK -4096LL - -void cpu_loop(CPUS390XState *env) -{ - CPUState *cs = CPU(s390_env_get_cpu(env)); - int trapnr, n, sig; - target_siginfo_t info; - target_ulong addr; - abi_long ret; - - while (1) { - cpu_exec_start(cs); - trapnr = cpu_exec(cs); - cpu_exec_end(cs); - process_queued_cpu_work(cs); - - switch (trapnr) { - case EXCP_INTERRUPT: - /* Just indicate that signals should be handled asap. */ - break; - - case EXCP_SVC: - n = env->int_svc_code; - if (!n) { - /* syscalls > 255 */ - n = env->regs[1]; - } - env->psw.addr += env->int_svc_ilen; - ret = do_syscall(env, n, env->regs[2], env->regs[3], - env->regs[4], env->regs[5], - env->regs[6], env->regs[7], 0, 0); - if (ret == -TARGET_ERESTARTSYS) { - env->psw.addr -= env->int_svc_ilen; - } else if (ret != -TARGET_QEMU_ESIGRETURN) { - env->regs[2] = ret; - } - break; - - case EXCP_DEBUG: - sig = gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - n = TARGET_TRAP_BRKPT; - goto do_signal_pc; - } - break; - case EXCP_PGM: - n = env->int_pgm_code; - switch (n) { - case PGM_OPERATION: - case PGM_PRIVILEGED: - sig = TARGET_SIGILL; - n = TARGET_ILL_ILLOPC; - goto do_signal_pc; - case PGM_PROTECTION: - case PGM_ADDRESSING: - sig = TARGET_SIGSEGV; - /* XXX: check env->error_code */ - n = TARGET_SEGV_MAPERR; - addr = env->__excp_addr & S390X_FAIL_ADDR_MASK; - goto do_signal; - case PGM_EXECUTE: - case PGM_SPECIFICATION: - case PGM_SPECIAL_OP: - case PGM_OPERAND: - do_sigill_opn: - sig = TARGET_SIGILL; - n = TARGET_ILL_ILLOPN; - goto do_signal_pc; - - case PGM_FIXPT_OVERFLOW: - sig = TARGET_SIGFPE; - n = TARGET_FPE_INTOVF; - goto do_signal_pc; - case PGM_FIXPT_DIVIDE: - sig = TARGET_SIGFPE; - n = TARGET_FPE_INTDIV; - goto do_signal_pc; - - case PGM_DATA: - n = (env->fpc >> 8) & 0xff; - if (n == 0xff) { - /* compare-and-trap */ - goto do_sigill_opn; - } else { - /* An IEEE exception, simulated or otherwise. */ - if (n & 0x80) { - n = TARGET_FPE_FLTINV; - } else if (n & 0x40) { - n = TARGET_FPE_FLTDIV; - } else if (n & 0x20) { - n = TARGET_FPE_FLTOVF; - } else if (n & 0x10) { - n = TARGET_FPE_FLTUND; - } else if (n & 0x08) { - n = TARGET_FPE_FLTRES; - } else { - /* ??? Quantum exception; BFP, DFP error. */ - goto do_sigill_opn; - } - sig = TARGET_SIGFPE; - goto do_signal_pc; - } - - default: - fprintf(stderr, "Unhandled program exception: %#x\n", n); - cpu_dump_state(cs, stderr, fprintf, 0); - exit(EXIT_FAILURE); - } - break; - - do_signal_pc: - addr = env->psw.addr; - do_signal: - info.si_signo = sig; - info.si_errno = 0; - info.si_code = n; - info._sifields._sigfault._addr = addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - - case EXCP_ATOMIC: - cpu_exec_step_atomic(cs); - break; - default: - fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); - exit(EXIT_FAILURE); - } - process_pending_signals (env); - } -} - -#endif /* TARGET_S390X */ - #ifdef TARGET_TILEGX static void gen_sigill_reg(CPUTLGState *env) @@ -1720,15 +1583,6 @@ int main(int argc, char **argv, char **envp) env->pc = regs->sepc; env->gpr[xSP] = regs->sp; } -#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; diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index b7700a5561..99f5f1594f 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -21,6 +21,145 @@ #include "qemu.h" #include "cpu_loop-common.h" +/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */ +#define S390X_FAIL_ADDR_MASK -4096LL + +void cpu_loop(CPUS390XState *env) +{ + CPUState *cs = CPU(s390_env_get_cpu(env)); + int trapnr, n, sig; + target_siginfo_t info; + target_ulong addr; + abi_long ret; + + while (1) { + cpu_exec_start(cs); + trapnr = cpu_exec(cs); + cpu_exec_end(cs); + process_queued_cpu_work(cs); + + switch (trapnr) { + case EXCP_INTERRUPT: + /* Just indicate that signals should be handled asap. */ + break; + + case EXCP_SVC: + n = env->int_svc_code; + if (!n) { + /* syscalls > 255 */ + n = env->regs[1]; + } + env->psw.addr += env->int_svc_ilen; + ret = do_syscall(env, n, env->regs[2], env->regs[3], + env->regs[4], env->regs[5], + env->regs[6], env->regs[7], 0, 0); + if (ret == -TARGET_ERESTARTSYS) { + env->psw.addr -= env->int_svc_ilen; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->regs[2] = ret; + } + break; + + case EXCP_DEBUG: + sig = gdb_handlesig(cs, TARGET_SIGTRAP); + if (sig) { + n = TARGET_TRAP_BRKPT; + goto do_signal_pc; + } + break; + case EXCP_PGM: + n = env->int_pgm_code; + switch (n) { + case PGM_OPERATION: + case PGM_PRIVILEGED: + sig = TARGET_SIGILL; + n = TARGET_ILL_ILLOPC; + goto do_signal_pc; + case PGM_PROTECTION: + case PGM_ADDRESSING: + sig = TARGET_SIGSEGV; + /* XXX: check env->error_code */ + n = TARGET_SEGV_MAPERR; + addr = env->__excp_addr & S390X_FAIL_ADDR_MASK; + goto do_signal; + case PGM_EXECUTE: + case PGM_SPECIFICATION: + case PGM_SPECIAL_OP: + case PGM_OPERAND: + do_sigill_opn: + sig = TARGET_SIGILL; + n = TARGET_ILL_ILLOPN; + goto do_signal_pc; + + case PGM_FIXPT_OVERFLOW: + sig = TARGET_SIGFPE; + n = TARGET_FPE_INTOVF; + goto do_signal_pc; + case PGM_FIXPT_DIVIDE: + sig = TARGET_SIGFPE; + n = TARGET_FPE_INTDIV; + goto do_signal_pc; + + case PGM_DATA: + n = (env->fpc >> 8) & 0xff; + if (n == 0xff) { + /* compare-and-trap */ + goto do_sigill_opn; + } else { + /* An IEEE exception, simulated or otherwise. */ + if (n & 0x80) { + n = TARGET_FPE_FLTINV; + } else if (n & 0x40) { + n = TARGET_FPE_FLTDIV; + } else if (n & 0x20) { + n = TARGET_FPE_FLTOVF; + } else if (n & 0x10) { + n = TARGET_FPE_FLTUND; + } else if (n & 0x08) { + n = TARGET_FPE_FLTRES; + } else { + /* ??? Quantum exception; BFP, DFP error. */ + goto do_sigill_opn; + } + sig = TARGET_SIGFPE; + goto do_signal_pc; + } + + default: + fprintf(stderr, "Unhandled program exception: %#x\n", n); + cpu_dump_state(cs, stderr, fprintf, 0); + exit(EXIT_FAILURE); + } + break; + + do_signal_pc: + addr = env->psw.addr; + do_signal: + info.si_signo = sig; + info.si_errno = 0; + info.si_code = n; + info._sifields._sigfault._addr = addr; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; + + case EXCP_ATOMIC: + cpu_exec_step_atomic(cs); + break; + default: + fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); + cpu_dump_state(cs, stderr, fprintf, 0); + exit(EXIT_FAILURE); + } + process_pending_signals (env); + } +} + void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { + 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; }