From patchwork Tue Jan 8 22:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155010 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp33058jaa; Tue, 8 Jan 2019 14:34:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN5MoP4xvdPalux/4b0pmLqxh8AxTwOR6Aym+Z+Ffq9YM4DAtCOwBSsj9Zb5xXTiFAzwB5XQ X-Received: by 2002:a5d:4202:: with SMTP id n2mr2789479wrq.260.1546986897499; Tue, 08 Jan 2019 14:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546986897; cv=none; d=google.com; s=arc-20160816; b=kq6u78S6qhrqbGwHkleWKT2UwnpQ4+CzZ+kXs9uUM3Sq4x9cNS+QM5c7j8heW+axuq BEvwMmpbVq8DVO9FAcH9TJGxWBv3iShFA5uhVHqhYti8IKLk2oHRZH4CyNSwfdmWTUN1 IqJPylVwpUkOqgrQ1dRN+Gk+s59FdXg6/AYTTy38r1uso8di+prX+n1Cur677XJegEkv SMfWKb6bQQqF5Oq/7DpUzZK5XRI1weCCBOjLD2GK+d3jq/8g1mExo2VdVcgD3Xw4vJyj BvtOnqHAlYN8IGyoQCmUbM6zjZKTsdq96vPqYF10mewS6HHz7LKB8CbNYslbOGWHHRJz 7mCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=DwJeWp+Qr2T2kEfXaMPGSK0wBAkLZExGSauaPxWOW3g=; b=jvg2EBvI/h/xHQ8h89tZyiMrqJWkeNbzohZi+t7xkCAw0V8lWuanllFVHB7mdoKbgY zVSxNro9PScGp93xKmDo52eLfQD7fwMHdJ/m+KrreFY8PRzqiSCqwU4xZ555BERk1aFp aFcggIP08TzI2p0qh5oWNHgcQHA1ef4F4JHvvNteYIKNJg6ZC4v5OZbhn8HZ/vxNv7Iq hTuiX3brcHDQ5Yr6WTidXrgcAWgFCFu3oUHNy4S8AP8YT1GHEgXSmVwRAZMRqfAsdxvA IbMmmBciSawmuGMjAieqR8kS7cDBzj8YM6BU3AGC4Pg6RJPvAE9Skp49ig1v7SMG75lz QP1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GOZXTnC4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d16si37200428wre.247.2019.01.08.14.34.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GOZXTnC4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:40034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzxY-0001Gg-AW for patch@linaro.org; Tue, 08 Jan 2019 17:34:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzuW-00081v-QK for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzuV-0004GH-S3 for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:48 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:35298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzuV-0004Ft-MH for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:47 -0500 Received: by mail-pl1-x642.google.com with SMTP id p8so2576110plo.2 for ; Tue, 08 Jan 2019 14:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DwJeWp+Qr2T2kEfXaMPGSK0wBAkLZExGSauaPxWOW3g=; b=GOZXTnC47VTuCQleB8WQDgwHVMls5Qx7z3vyNriSz7QBJexNOpBaTh5T7AFWOk5otE npSwyrVW6l1k1+N6PMHGWTSfo1EPOcPRx7bCAqJW8pMcSeL1qIxyvEgEQj2WEfgHUDeu GzYbGKIV+LWTbbJFWXnRenJVjSEENG/v3u+Cc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DwJeWp+Qr2T2kEfXaMPGSK0wBAkLZExGSauaPxWOW3g=; b=MrEE4nKscsh5CBr990A0Z/RYMkTx9avdo+iazTVjQawyHurQqKyJ47mdAPJ1/CkbCZ byUFQxWtI1pLy46UraOKVFq1yLvplb3qCIzdogN1Lq5QsS8sP/+sdpBYQC5pNG2gUUXN nUJRLtFPX+BqIJfWWgy1h3/8HS1pSJvb/g6ii1L2S1Z23azZsGI/HmsbIaXVbdNM/I8U uRYzclP8q1E+dTYe9VIPFKYBjKGQqwEkR76huOE0zzuyT4rzfmSceZUDg/6Qzdt5c0QC hIjE6jjV/ep3ji5v5XOZGGjSpwr3ZOkP1WImi5mb0zrgOqXym53yKEvNfkMUaCxKptVn vtpw== X-Gm-Message-State: AJcUukfG9LP/rsAG/DBYyAxpSy2zmM7XnaEoJmthOhpLFGE2ad8rgUz/ yXbgL2e/6GJ3uj9EuKkvxiTtkex+ThU= X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr3586368plz.110.1546986706294; Tue, 08 Jan 2019 14:31:46 -0800 (PST) Received: from cloudburst.lan (2001-44b8-2176-c800-8cc6-2630-7d99-5ef1.static.ipv6.internode.on.net. [2001:44b8:2176:c800:8cc6:2630:7d99:5ef1]) by smtp.gmail.com with ESMTPSA id w128sm100686177pfw.79.2019.01.08.14.31.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:31:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:02 +1000 Message-Id: <20190108223129.5570-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190108223129.5570-1-richard.henderson@linaro.org> References: <20190108223129.5570-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v3 04/31] target/arm: Introduce raise_exception_ra 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@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This path uses cpu_loop_exit_restore to unwind current processor state. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 7 +++++++ target/arm/op_helper.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) -- 2.17.2 Reviewed-by: Peter Maydell diff --git a/target/arm/internals.h b/target/arm/internals.h index 78e026d6e9..c01a3f8c96 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -103,6 +103,13 @@ FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */ void QEMU_NORETURN raise_exception(CPUARMState *env, uint32_t excp, uint32_t syndrome, uint32_t target_el); +/* + * Similarly, but also use unwinding to restore cpu state. + */ +void QEMU_NORETURN raise_exception_ra(CPUARMState *env, uint32_t excp, + uint32_t syndrome, uint32_t target_el, + uintptr_t ra); + /* * For AArch64, map a given EL to an index in the banked_spsr array. * Note that this mapping and the AArch32 mapping defined in bank_number() diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index ef72361a36..8b31c6a13b 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -28,8 +28,8 @@ #define SIGNBIT (uint32_t)0x80000000 #define SIGNBIT64 ((uint64_t)1 << 63) -void raise_exception(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_el) +static CPUState *do_raise_exception(CPUARMState *env, uint32_t excp, + uint32_t syndrome, uint32_t target_el) { CPUState *cs = CPU(arm_env_get_cpu(env)); @@ -50,9 +50,24 @@ void raise_exception(CPUARMState *env, uint32_t excp, cs->exception_index = excp; env->exception.syndrome = syndrome; env->exception.target_el = target_el; + + return cs; +} + +void raise_exception(CPUARMState *env, uint32_t excp, + uint32_t syndrome, uint32_t target_el) +{ + CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); cpu_loop_exit(cs); } +void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, + uint32_t target_el, uintptr_t ra) +{ + CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); + cpu_loop_exit_restore(cs, ra); +} + static int exception_target_el(CPUARMState *env) { int target_el = MAX(1, arm_current_el(env));