From patchwork Fri Oct 19 16:57:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 149302 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3558467lji; Fri, 19 Oct 2018 10:09:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV6268cfeSa69cn2zqj5RHRFiC5Maej4/Sn9KSO7tUNOJxhOAfamAgNjMP00fC+4ANhIvClgk X-Received: by 2002:a0c:ad31:: with SMTP id u46mr26161633qvc.60.1539968984523; Fri, 19 Oct 2018 10:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539968984; cv=none; d=google.com; s=arc-20160816; b=Ex0dcnAhWlQnpPmXIxIo5YyanHHi9poP9TnqRmpLo0RK9RR3d/xK7qKknU+Vq4D0Zu 3NNfgyCLENTMVtiPIc6mMRw4ilD6BZYh9sfiMDMu+z/XDSJZbv+767hd2DVlnIc0m7Yk 4MNNVlY4mjyujiBmhr/17OnJCRlQp7gU/uBKy5/rBwNpck3VaVCHSxvqyGp9qnaI6Cu7 9Hac9OeB/dqywH/Qevpk2ntN+oMCK4jLL1b7fre1XrzFPtWZt6lv0vBkuEn49jiO01gz /nFu+m8J+/hL7OC9dUTU13kTMlPRpDfZnvVo0ve5Zic/r179k6AmKvMwl50gIW8QSnCe XEKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=0zu0WzrCTyckYWUv+eCO1f1d9+0rFEgehrr+4LWr0OE=; b=gLG5nt8j2FugrVGGCKP1N5rtXJDn/X8AP1/XU9cs0SfhgMBDuDUUf/QnOqHdJ51hCV hZXFdGVDlYRPi/dl10O7TH8crlwtJQQ+13sCg51xLW0Is03jqr+nNFX0QKXQc1r4/gOK BHFM78tRbkO9/13Z3veqTuPxF6tfQv7QqEBVYJgrrpnlzKxXtoNf60Zdg7I1LGoETmTK JIUvfUcQ/rifR2ccOs2AUya7fPQltwYfI8AbFGcWEwVV7yfG3YPU2oK0IQHXWSS0SYwd QdMsrxyJFlW040T6YK4kmw8VX+1i27B2bLM2AFNmZ5CqhX8mJ6V4jOKVDohBpjSRKAvw oBxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o49-v6si845062qtk.150.2018.10.19.10.09.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 10:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:51751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDYHP-0005aP-Ui for patch@linaro.org; Fri, 19 Oct 2018 13:09:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDY6J-0001of-FM for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:58:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDY6H-0002Yf-FK for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:58:15 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:51980) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gDY6F-00020Y-IJ for qemu-devel@nongnu.org; Fri, 19 Oct 2018 12:58:12 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gDY62-0006jx-Al for qemu-devel@nongnu.org; Fri, 19 Oct 2018 17:57:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2018 17:57:10 +0100 Message-Id: <20181019165735.22511-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181019165735.22511-1-peter.maydell@linaro.org> References: <20181019165735.22511-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: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 20/45] target/arm: Report correct syndrome for FP/SIMD traps to Hyp mode 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For traps of FP/SIMD instructions to AArch32 Hyp mode, the syndrome provided in HSR has more information than is reported to AArch64. Specifically, there are extra fields TA and coproc which indicate whether the trapped instruction was FP or SIMD. Add this extra information to the syndromes we construct, and mask it out when taking the exception to AArch64. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20181012144235.19646-11-peter.maydell@linaro.org --- target/arm/internals.h | 14 +++++++++++++- target/arm/helper.c | 9 +++++++++ target/arm/translate.c | 8 ++++---- 3 files changed, 26 insertions(+), 5 deletions(-) -- 2.19.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index 6b9387ba97e..6c2bb2deebd 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -288,6 +288,9 @@ static inline uint32_t syn_get_ec(uint32_t syn) * few cases the value in HSR for exceptions taken to AArch32 Hyp * mode differs slightly, and we fix this up when populating HSR in * arm_cpu_do_interrupt_aarch32_hyp(). + * The exception is FP/SIMD access traps -- these report extra information + * when taking an exception to AArch32. For those we include the extra coproc + * and TA fields, and mask them out when taking the exception to AArch64. */ static inline uint32_t syn_uncategorized(void) { @@ -387,9 +390,18 @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit) { + /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */ return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) | (is_16bit ? 0 : ARM_EL_IL) - | (cv << 24) | (cond << 20); + | (cv << 24) | (cond << 20) | 0xa; +} + +static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit) +{ + /* AArch32 SIMD trap: TA == 1 coproc == 0 */ + return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT) + | (is_16bit ? 0 : ARM_EL_IL) + | (cv << 24) | (cond << 20) | (1 << 5); } static inline uint32_t syn_sve_access_trap(void) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5db76df758b..bf4f50196de 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8546,6 +8546,15 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) case EXCP_HVC: case EXCP_HYP_TRAP: case EXCP_SMC: + if (syn_get_ec(env->exception.syndrome) == EC_ADVSIMDFPACCESSTRAP) { + /* + * QEMU internal FP/SIMD syndromes from AArch32 include the + * TA and coproc fields which are only exposed if the exception + * is taken to AArch32 Hyp mode. Mask them out to get a valid + * AArch64 format syndrome. + */ + env->exception.syndrome &= ~MAKE_64BIT_MASK(0, 20); + } env->cp15.esr_el[new_el] = env->exception.syndrome; break; case EXCP_IRQ: diff --git a/target/arm/translate.c b/target/arm/translate.c index 46c4b86bf52..1bf339a98b6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4948,7 +4948,7 @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) */ if (s->fp_excp_el) { gen_exception_insn(s, 4, EXCP_UDEF, - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); return 0; } @@ -5727,7 +5727,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) */ if (s->fp_excp_el) { gen_exception_insn(s, 4, EXCP_UDEF, - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); return 0; } @@ -7838,7 +7838,7 @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) if (s->fp_excp_el) { gen_exception_insn(s, 4, EXCP_UDEF, - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); return 0; } if (!s->vfp_enabled) { @@ -7924,7 +7924,7 @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) if (s->fp_excp_el) { gen_exception_insn(s, 4, EXCP_UDEF, - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); + syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); return 0; } if (!s->vfp_enabled) {