From patchwork Fri Jan 18 14:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1027436 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=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="N6ugvEti"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43h4170JlMz9sCh for ; Sat, 19 Jan 2019 02:02:19 +1100 (AEDT) Received: from localhost ([127.0.0.1]:41050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkVey-0005Rd-Sq for incoming@patchwork.ozlabs.org; Fri, 18 Jan 2019 10:02:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkVbR-0002jQ-Ux for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:58:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkVbP-0007Jz-TF for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:58:37 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:33776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkVbN-00078I-Vh for qemu-devel@nongnu.org; Fri, 18 Jan 2019 09:58:35 -0500 Received: by mail-wr1-x433.google.com with SMTP id c14so15472063wrr.0 for ; Fri, 18 Jan 2019 06:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hdIyZ3OR7owahs7bNQMPZXHZP1pdHEnpinPg10g91Kk=; b=N6ugvEtigWUd+rHW0qAMG6GnaatVtBtqAGMIzuyWPO8b8X431pqqvEIj/w4yOQiuZ/ HqsED2B4mhbZI73I9Kz/zfzXBB5taUAZotVNMVohrPkp+V8ywA+xDXt5ElxjRUtpncn0 99fzf+Ad19XD2zc73zIct7wNGafMNUXSjDFH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hdIyZ3OR7owahs7bNQMPZXHZP1pdHEnpinPg10g91Kk=; b=HRJ839Ue0jqchzFaJDI3PGcP+Qp/17Yq0z199/FTE7OK/WUgcniAYeRHI/kQl5wmup EeoERRk4ye7nivKZ32rBQpBMfcBSAM6z+5MwHQ4hitevMvO4vb3Rw/5NTVY8jyfNw29F gP8iHfFWXYASxjjK1IuaHvhyKcDhibBp0q/zHxW2lnr5WuRTHezdJIRQv7HPOn+04SuV +MdrFa/dvW1Jfzj/2V0c9KuL3AkhlP+lU2UaUMvwHg/751soJVtak1nDC8aaMk2vE6m3 BpFq7mPLuP3LD9yUzqhpCUTA9ciuYBpXw98b+TudPw6PbMTlCW35qjGg+YaJjXziRl6u 0hVA== X-Gm-Message-State: AJcUukee0UU1SxzgNM4DqpHqjh5jeXI4fy9ia6YOQEbOHdJKY46rNqJo 0+tdMI6zg0jNTiYwr6IfCNEj9HF1522pYw== X-Google-Smtp-Source: ALg8bN4yd0RFe24uea3QUyHqXZE5NUVbwY+KVST8+oLixyXEjfAcMRuI7qXYJU8/hcEqCTFbC/CfrQ== X-Received: by 2002:adf:8484:: with SMTP id 4mr16784483wrg.249.1547823496426; Fri, 18 Jan 2019 06:58:16 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id e27sm92094561wra.67.2019.01.18.06.58.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jan 2019 06:58:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 18 Jan 2019 14:57:24 +0000 Message-Id: <20190118145805.6852-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118145805.6852-1-peter.maydell@linaro.org> References: <20190118145805.6852-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 08/49] 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This path uses cpu_loop_exit_restore to unwind current processor state. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20190108223129.5570-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 7 +++++++ target/arm/op_helper.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 78e026d6e90..c01a3f8c968 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 ef72361a36d..8b31c6a13b8 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));