From patchwork Tue Jan 23 03:53:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125474 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1519885ljf; Mon, 22 Jan 2018 19:58:34 -0800 (PST) X-Google-Smtp-Source: AH8x227qzIsKGZ9WeWb0xwtqSR9HZIfEAZLeUOK8I3xErS5Wpc/copZqSX/XCi1egvOEE8EDjAgn X-Received: by 10.13.255.133 with SMTP id p127mr1051389ywf.360.1516679914757; Mon, 22 Jan 2018 19:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516679914; cv=none; d=google.com; s=arc-20160816; b=0piMWTtUMxrkdjB4ZKHcIErzETRxNNsSnXK2jqBiMqKq+D+yLDHQ0bPMzsEXGpHmx4 iE7dOuSopDi4cjeGeoz7Z0eCxf9APX+2I/m+HRDpdUkdxwPMJmYzMDo3ijoskVMIEfq2 SGxskplybpzRnjvgY7ib/iChd+bE9uuoECheJPThS00L0Y/ipaDw5ZUUSuonQA85IAoi k5Nn++6eBEu2CC2AlNH9M3cVAOKVTDEhM50QswZQxlmizrb8dHmFCZEoOMu+BHf4Hq5B q9sycbAy3jygTtD0NN5VerDVXpbLozz8kkkybHNis32KMI57kuWdRFDNSGNHIdx7WfIi Gt3Q== 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:arc-authentication-results; bh=aOP5CpWP51onl5Hzyvxgad3yYqWLQMfjilJrKFLiPkU=; b=02VyZzLYY/PxLKFFME3OIyHoVDsVBOTTIMQX40LKzPNhRFy+tQyiglAzG6cXozkXV7 be1My5YhF7Kx5VrUQG45f7BGos3xAol5Pb3VAJt2OCE8zbeA20QGIYD5vnWG4ep99xFz Wm6kdon/Fx5gMaV3b4wCTJ5GF0wEcVw2baGDrk+G0XMJ3ukTdcWOIV6iOcYwRPwTSvV+ TDK/bzXvAngw8Ja6jocGyIytPH0abHDLGtTBPE+sarF1dGoa446vYubSlSiWX85z+cgf cE+ZS4K2nDeXHfXI0aOVQPGeSKTm0w7RhwPq7i28BIvQkr+UtBETCfFX3gLYmZgQD2ex 3Awg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BdqCt9Nh; 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 n14si1136778ybm.205.2018.01.22.19.58.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 22 Jan 2018 19:58:34 -0800 (PST) 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; dkim=fail header.i=@linaro.org header.s=google header.b=BdqCt9Nh; 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]:60826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edpjG-0005Ae-5w for patch@linaro.org; Mon, 22 Jan 2018 22:58:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edpes-0001vI-Et for qemu-devel@nongnu.org; Mon, 22 Jan 2018 22:54:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edper-0004BK-E0 for qemu-devel@nongnu.org; Mon, 22 Jan 2018 22:54:02 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:37286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edper-0004AW-6T for qemu-devel@nongnu.org; Mon, 22 Jan 2018 22:54:01 -0500 Received: by mail-pg0-x242.google.com with SMTP id z17so8768372pgc.4 for ; Mon, 22 Jan 2018 19:54:01 -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=aOP5CpWP51onl5Hzyvxgad3yYqWLQMfjilJrKFLiPkU=; b=BdqCt9NhofwJ7TCkTSw1tax0ch18dFc6/if3K4t5ZAi70jElowF5AIb/NllHvBN1TN cOcQwggf2/xGq2j/v9QmX6pF6uVLNjGM19ArKX+FAQJ4HwMywmeURvyc5ArSCcj7v0IX hm7McGVKK6dFmI1tf3zVf02gIJV0kZjo7Z1tk= 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=aOP5CpWP51onl5Hzyvxgad3yYqWLQMfjilJrKFLiPkU=; b=PLLKQhYy9Kkx2CN3/cpg560yCaMdG+Y+7ehVXt2rKFmp3XyDrr8OrAndDhMOoVr6Z6 VD4D41t7DHzf6e5f0yLON0LnHZBQ6M6p0GAlUUX7Pv1ckFDVF0drcIQGm8Dvix9Ul2qG h/4plYRzwC+3lvC17OvTRf83yPj9/fN0vy4JRg1qzz3Q4wfXTLMnNDd+HWjKI6tfhq2r 1H09ov0mwlqmm/JJ/BJ/BnpcyGFgWqX222NFMuPRz9TEOG63W2DfTiwwFHAWcZXBhOB+ Oxp1xpdu/eHkfLCTtCySA3DY0IS4OgfU2L1epGqKmKonKaKWO0QxH68SHAmU9kLhLkPI rC/w== X-Gm-Message-State: AKwxytf3Xf30ilMS7a2ejVjwK4tGPqbpuZMaCr62biAzrQmAVOh8zm3R 9ZzUeVrvW2pM4GjjZfUpHu0HA/KxtHk= X-Received: by 10.99.151.2 with SMTP id n2mr5791489pge.87.1516679639854; Mon, 22 Jan 2018 19:53:59 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id t1sm3444680pfj.21.2018.01.22.19.53.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 19:53:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 22 Jan 2018 19:53:49 -0800 Message-Id: <20180123035349.24538-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180123035349.24538-1-richard.henderson@linaro.org> References: <20180123035349.24538-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v3 5/5] target/arm: Add SVE state to TB->FLAGS 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, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add both SVE exception state and vector length. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 8 ++++++++ target/arm/translate.h | 2 ++ target/arm/helper.c | 25 ++++++++++++++++++++++++- target/arm/translate-a64.c | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 17955ad3ef..a311d4e327 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2648,6 +2648,10 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) #define ARM_TBFLAG_TBI0_MASK (0x1ull << ARM_TBFLAG_TBI0_SHIFT) #define ARM_TBFLAG_TBI1_SHIFT 1 /* TBI1 for EL0/1 */ #define ARM_TBFLAG_TBI1_MASK (0x1ull << ARM_TBFLAG_TBI1_SHIFT) +#define ARM_TBFLAG_SVEEXC_EL_SHIFT 2 +#define ARM_TBFLAG_SVEEXC_EL_MASK (0x3 << ARM_TBFLAG_SVEEXC_EL_SHIFT) +#define ARM_TBFLAG_ZCR_LEN_SHIFT 4 +#define ARM_TBFLAG_ZCR_LEN_MASK (0xf << ARM_TBFLAG_ZCR_LEN_SHIFT) /* some convenience accessor macros */ #define ARM_TBFLAG_AARCH64_STATE(F) \ @@ -2684,6 +2688,10 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) (((F) & ARM_TBFLAG_TBI0_MASK) >> ARM_TBFLAG_TBI0_SHIFT) #define ARM_TBFLAG_TBI1(F) \ (((F) & ARM_TBFLAG_TBI1_MASK) >> ARM_TBFLAG_TBI1_SHIFT) +#define ARM_TBFLAG_SVEEXC_EL(F) \ + (((F) & ARM_TBFLAG_SVEEXC_EL_MASK) >> ARM_TBFLAG_SVEEXC_EL_SHIFT) +#define ARM_TBFLAG_ZCR_LEN(F) \ + (((F) & ARM_TBFLAG_ZCR_LEN_MASK) >> ARM_TBFLAG_ZCR_LEN_SHIFT) static inline bool bswap_code(bool sctlr_b) { diff --git a/target/arm/translate.h b/target/arm/translate.h index 3f4df91e5e..c47febf99d 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -29,6 +29,8 @@ typedef struct DisasContext { bool tbi1; /* TBI1 for EL0/1, not used for EL2/3 */ bool ns; /* Use non-secure CPREG bank on access */ int fp_excp_el; /* FP exception EL or 0 if enabled */ + int sve_excp_el; /* SVE exception EL or 0 if enabled */ + int sve_len; /* SVE vector length in bytes */ /* Flag indicating that exceptions from secure mode are routed to EL3. */ bool secure_routed_to_el3; bool vfp_enabled; /* FP enabled via FPSCR.EN */ diff --git a/target/arm/helper.c b/target/arm/helper.c index db67e8ac72..d46d3622fc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11823,14 +11823,37 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false)); + int fp_el = fp_exception_el(env); uint32_t flags; if (is_a64(env)) { + int sve_el = sve_exception_el(env); + uint32_t zcr_len; + *pc = env->pc; flags = ARM_TBFLAG_AARCH64_STATE_MASK; /* Get control bits for tagged addresses */ flags |= (arm_regime_tbi0(env, mmu_idx) << ARM_TBFLAG_TBI0_SHIFT); flags |= (arm_regime_tbi1(env, mmu_idx) << ARM_TBFLAG_TBI1_SHIFT); + flags |= sve_el << ARM_TBFLAG_SVEEXC_EL_SHIFT; + + /* If SVE is disabled, but FP is enabled, + then the effective len is 0. */ + if (sve_el != 0 && fp_el == 0) { + zcr_len = 0; + } else { + int current_el = arm_current_el(env); + + zcr_len = env->vfp.zcr_el[current_el <= 1 ? 1 : current_el]; + zcr_len &= 0xf; + if (current_el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); + } + if (current_el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); + } + } + flags |= zcr_len << ARM_TBFLAG_ZCR_LEN_SHIFT; } else { *pc = env->regs[15]; flags = (env->thumb << ARM_TBFLAG_THUMB_SHIFT) @@ -11873,7 +11896,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, if (arm_cpu_data_is_big_endian(env)) { flags |= ARM_TBFLAG_BE_DATA_MASK; } - flags |= fp_exception_el(env) << ARM_TBFLAG_FPEXC_EL_SHIFT; + flags |= fp_el << ARM_TBFLAG_FPEXC_EL_SHIFT; if (arm_v7m_is_handler_mode(env)) { flags |= ARM_TBFLAG_HANDLER_MASK; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 10eef870fe..4c1eca7062 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11263,6 +11263,8 @@ static int aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->user = (dc->current_el == 0); #endif dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(dc->base.tb->flags); + dc->sve_excp_el = ARM_TBFLAG_SVEEXC_EL(dc->base.tb->flags); + dc->sve_len = (ARM_TBFLAG_ZCR_LEN(dc->base.tb->flags) + 1) * 16; dc->vec_len = 0; dc->vec_stride = 0; dc->cp_regs = arm_cpu->cp_regs;