From patchwork Mon Jul 1 17:35:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18221 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DF18D27751 for ; Mon, 1 Jul 2013 17:35:41 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id w16sf7016940vbb.8 for ; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=tsuEq8Wydw8HYUirVNVUPYkJMMwCCFmfkDuK4KgVUzo=; b=LApIAL2mbY9orHavsx8fM81up5Lu2Xsrjz7ZND45Ymt+4P2B6E6WLegLpDG6q0pzsG 9ZGrDva4b4eLNsPycAKHhRKoa/5MkbLZvNCAit3M6iqCyO098skBSE4leRkw4WKKa20J k/uZNKxW4vnZ9GLRJWcOPkm2c6ZpCYkCQivgFi6Ttf4hwCLPLmPbDEeRfcO+rIRfwgt0 +KIBvguE8R7jh4cUVU5ybm6hxi/FVspJ4MPUOtNxDN5+XLgi3FPYkOjPXJXXzBfN3tBA wDAFOw1HJaVLQtmXh9xPEQg5qgxWBrlVL3Hg7U6OAE2ekq45+C7v+9qOY7nHQb8lFSa5 +itA== X-Received: by 10.236.92.7 with SMTP id i7mr15241275yhf.52.1372700141432; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.200 with SMTP id j8ls2314652qer.42.gmail; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) X-Received: by 10.58.86.70 with SMTP id n6mr10123683vez.8.1372700141334; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id l10si2203242vdw.87.2013.07.01.10.35.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jul 2013 10:35:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id gd11so2154230vcb.30 for ; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) X-Received: by 10.220.203.197 with SMTP id fj5mr10077109vcb.60.1372700141211; Mon, 01 Jul 2013 10:35:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp289818veb; Mon, 1 Jul 2013 10:35:40 -0700 (PDT) X-Received: by 10.205.21.9 with SMTP id qq9mr3434523bkb.145.1372700132517; Mon, 01 Jul 2013 10:35:32 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id up9si1750472bkb.183.2013.07.01.10.35.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 01 Jul 2013 10:35:32 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Uti0Y-0002Ks-Ar; Mon, 01 Jul 2013 18:35:22 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Andreas Schwab , "Mian M. Hamayun" Subject: [PATCH v5 10/21] linux-user: Add cpu loop for AArch64 Date: Mon, 1 Jul 2013 18:35:09 +0100 Message-Id: <1372700120-8896-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372700120-8896-1-git-send-email-peter.maydell@linaro.org> References: <1372700120-8896-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmivif6KBaavbVBb1Jlb/k9hk8/ZkJ3jp2xT0ks+2BF/gYsioHQxJ87KCJ0HuAzQqXYAFir X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add the main linux-user cpu loop for AArch64. Since AArch64 has a different system call interface, doesn't need to worry about FPA emulation and may in the future keep the prefetch/data abort information in different system registers, it's simplest just to use a completely separate loop from the 32 bit ARM target, rather than peppering it with ifdefs. Signed-off-by: Peter Maydell --- linux-user/main.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index af82db8..8aba817 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -484,6 +484,9 @@ void cpu_loop(CPUX86State *env) __r; \ }) +#ifdef TARGET_ABI32 +/* Commpage handling -- there is no commpage for AArch64 */ + /* * See the Linux kernel's Documentation/arm/kernel_user_helpers.txt * Input: @@ -617,6 +620,7 @@ do_kernel_trap(CPUARMState *env) return 0; } +#endif static int do_strex(CPUARMState *env) { @@ -696,6 +700,7 @@ done: return segv; } +#ifdef TARGET_ABI32 void cpu_loop(CPUARMState *env) { CPUState *cs = CPU(arm_env_get_cpu(env)); @@ -908,6 +913,83 @@ void cpu_loop(CPUARMState *env) } } +#else + +/* AArch64 main loop */ +void cpu_loop(CPUARMState *env) +{ + CPUState *cs = CPU(arm_env_get_cpu(env)); + int trapnr, sig; + target_siginfo_t info; + uint32_t addr; + + for (;;) { + cpu_exec_start(cs); + trapnr = cpu_arm_exec(env); + cpu_exec_end(cs); + + switch (trapnr) { + case EXCP_SWI: + env->xregs[0] = 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); + break; + case EXCP_INTERRUPT: + /* just indicate that signals should be handled asap */ + break; + case EXCP_UDEF: + info.si_signo = SIGILL; + info.si_errno = 0; + info.si_code = TARGET_ILL_ILLOPN; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, &info); + break; + case EXCP_PREFETCH_ABORT: + addr = env->cp15.c6_insn; + goto do_segv; + case EXCP_DATA_ABORT: + addr = env->cp15.c6_data; + do_segv: + info.si_signo = 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, &info); + break; + case EXCP_DEBUG: + case EXCP_BKPT: + sig = gdb_handlesig(env, TARGET_SIGTRAP); + if (sig) { + info.si_signo = sig; + info.si_errno = 0; + info.si_code = TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, &info); + } + break; + case EXCP_STREX: + if (do_strex(env)) { + addr = env->cp15.c6_data; + goto do_segv; + } + break; + default: + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + trapnr); + cpu_dump_state(cs, stderr, fprintf, 0); + abort(); + } + process_pending_signals(env); + } +} +#endif /* ndef TARGET_ABI32 */ + #endif #ifdef TARGET_UNICORE32