From patchwork Tue Aug 20 21:07:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171842 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp71660ily; Tue, 20 Aug 2019 14:09:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5t/vGTvJXkIoPdyAGWJoHnX2FYo0PSYvo3DL4DwfFrKLEr7qSt8Cl/LqQOSa0Wp2sRE4b X-Received: by 2002:a50:f708:: with SMTP id g8mr33166434edn.128.1566335358956; Tue, 20 Aug 2019 14:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566335358; cv=none; d=google.com; s=arc-20160816; b=lSm5iIVrO9KMC1BjXQ+m1wiQvGFRsLw5yPcGY4/m9tureLtXzYBUcj1uGMAITy4fCR aX9oC/bb9Kh1Dxz4Nz+KnNJSYYHDEX7CS7juyAXMhPbW0Rv9Ru6G7xDEDtUSw3l//5Lx yPO2sZmTHxd6CbfRIwGFkXNMwFl2OaTEJvEbv30Onxq3cQOhfZ4kfmpUGbROEW7SBLfm PgClhi8jEDgZ8Nihbi9IKBZAo3pwH5rWGGrGqOpEaNcM+lp2s3EHzCCTM7FgsIIu4O/y beOYtO1wR8V9dvKdxCLSro1/vc5HOC8c8jIY/v+pM1o997yZfVC1CSb7W8mf1QE+Nvrk iCKA== 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=PJKLZgNrZeIfcl9mOVKPSZ1nJWOZ0cTu6OQj4DvwKc4=; b=romMoAuRyx311iXzWZdfF9iX3FmX4WpB9NzESDgmuXKlbdSnx4S57tEspI00iAczJd bSf289VJThZOSsYIjdsxIpW3/5RO1WV5/emz6aCPi2cg9fFuot2N6cT7ccaLYWzGzjOX J1ETtIvziLEgqW4dBhhf3jVlhSEttig4Ne6pe0oVgC5MpWMnSXosSnBxyQupMG5FADfS GlSAo25Yuy7ws8lB4AbBMwihAApEhuLoNHvnCmADiddyjeicxeR9cEzrILutfnXrX99V 43bup5fYKp0+NdpD9PE7v+E9gA2nTC91qgvXQ+w1PFZ6adfL33InKmPrL4mXe+C6BjIs Ghlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A7LQhaTU; 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 h28si7459483ede.359.2019.08.20.14.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 14:09:18 -0700 (PDT) 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=A7LQhaTU; 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 ([::1]:41488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0BNV-0000Ft-PD for patch@linaro.org; Tue, 20 Aug 2019 17:09:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53638) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0BLj-0000By-6a for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0BLh-0008KU-OS for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:27 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:43111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i0BLh-0008Jq-Iy for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:25 -0400 Received: by mail-pg1-x541.google.com with SMTP id k3so2413pgb.10 for ; Tue, 20 Aug 2019 14:07:25 -0700 (PDT) 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=PJKLZgNrZeIfcl9mOVKPSZ1nJWOZ0cTu6OQj4DvwKc4=; b=A7LQhaTU8/N1jJ0gTMGQyzcaGPoEKpqeBGDEAgjZCDrGRxOYkbgUD2pIInVMHoNAg7 rZqfPky8OALWBMvvm752Gqp52J+TBaxhI1DoRrc8Z3SP/3gMXqBwFcfLJpqjfPQ1MftZ CRJTs7H8Axs2nBwoisdZyXWhWlSwPGYF01fEIklPs2sPXh9HAgueXhwlXO/8x+RP4Qb9 kkEh84w3afJIuwlyfvB6UKrIsfpZRw2hzmb6p4GgDCnMEfiW65kByBCuY8WwTaFFoNU0 S9x4sRVlfIqUnSKa3O3aGODCRG4NDU/7MVmHYJGwV1xNGUglPSnobXCw3k1udJjI+efp WUuw== 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=PJKLZgNrZeIfcl9mOVKPSZ1nJWOZ0cTu6OQj4DvwKc4=; b=tJZgUchX8o2Hd7Ei4wlCKSGohEH0OunDThTrQIlqAp1K90tsXxA5kYGrnmDrhRxUIK KBGiqJRunNhqijhNZAevdK4zk9oiLybPtWHC8Z0E6Y0MOm0PCa1VY0jLQdAkkfuwz39G YbIjfQaiCgU4GKen4urhFe0mWeUqnGXdbwyERrC5rLernzFpMsvpVVEbCaNVjp3Xt3mE GuNl6lmEpWjZtJOYL2l7G/GgJ3wD3Ju/csLqSXndXYcTFOjeWD2OkfXPmipeCQuS1Sos 2tGATszzN/Y5MmeFEjBtawhoxsNVvOmtZ4JTgRw0B3u0ajeRWXC/Xhq+01V7dTGlAWs7 Glaw== X-Gm-Message-State: APjAAAU7lS6fah+6zMWu+GCvuFh35soSW+OYk0bassl/j2/Nnx97yIMz VMoRJ67E8ZOLTJMAse6FUgdmffL5lZQ= X-Received: by 2002:a63:6a4a:: with SMTP id f71mr11071610pgc.409.1566335244166; Tue, 20 Aug 2019 14:07:24 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id k22sm21690743pfk.157.2019.08.20.14.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 14:07:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 14:07:04 -0700 Message-Id: <20190820210720.18976-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820210720.18976-1-richard.henderson@linaro.org> References: <20190820210720.18976-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::541 Subject: [Qemu-devel] [PATCH v5 01/17] target/arm: Split out rebuild_hflags_common X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create a function to compute the values of the TBFLAG_ANY bits that will be cached. For now, the env->hflags variable is not used, and the results are fed back to cpu_get_tb_cpu_state. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 29 ++++++++++++++++++----------- target/arm/helper.c | 26 +++++++++++++++++++------- 2 files changed, 37 insertions(+), 18 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0981303170..3dc52c032b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -231,6 +231,9 @@ typedef struct CPUARMState { uint32_t pstate; uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ + /* Cached TBFLAGS state. See below for which bits are included. */ + uint32_t hflags; + /* Frequently accessed CPSR bits are stored separately for efficiency. This contains all the other bits. Use cpsr_{read,write} to access the whole CPSR. */ @@ -3136,15 +3139,18 @@ typedef ARMCPU ArchCPU; #include "exec/cpu-all.h" -/* Bit usage in the TB flags field: bit 31 indicates whether we are +/* + * Bit usage in the TB flags field: bit 31 indicates whether we are * in 32 or 64 bit mode. The meaning of the other bits depends on that. * We put flags which are shared between 32 and 64 bit mode at the top * of the word, and flags which apply to only one mode at the bottom. + * + * Unless otherwise noted, these bits are cached in env->hflags. */ FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) FIELD(TBFLAG_ANY, MMUIDX, 28, 3) FIELD(TBFLAG_ANY, SS_ACTIVE, 27, 1) -FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) +FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) /* Not cached. */ /* Target EL if we take a floating-point-disabled exception */ FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) FIELD(TBFLAG_ANY, BE_DATA, 23, 1) @@ -3155,13 +3161,14 @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) /* Bit usage when in AArch32 state: */ -FIELD(TBFLAG_A32, THUMB, 0, 1) -FIELD(TBFLAG_A32, VECLEN, 1, 3) -FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) +FIELD(TBFLAG_A32, THUMB, 0, 1) /* Not cached. */ +FIELD(TBFLAG_A32, VECLEN, 1, 3) /* Not cached. */ +FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) /* Not cached. */ /* * We store the bottom two bits of the CPAR as TB flags and handle * checks on the other bits at runtime. This shares the same bits as * VECSTRIDE, which is OK as no XScale CPU has VFP. + * Not cached, because VECLEN+VECSTRIDE are not cached. */ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) /* @@ -3170,15 +3177,15 @@ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) * the same thing as the current security state of the processor! */ FIELD(TBFLAG_A32, NS, 6, 1) -FIELD(TBFLAG_A32, VFPEN, 7, 1) -FIELD(TBFLAG_A32, CONDEXEC, 8, 8) +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Not cached. */ +FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) /* For M profile only, set if FPCCR.LSPACT is set */ -FIELD(TBFLAG_A32, LSPACT, 18, 1) +FIELD(TBFLAG_A32, LSPACT, 18, 1) /* Not cached. */ /* For M profile only, set if we must create a new FP context */ -FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) /* Not cached. */ /* For M profile only, set if FPCCR.S does not match current security state */ -FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) /* Not cached. */ /* For M profile only, Handler (ie not Thread) mode */ FIELD(TBFLAG_A32, HANDLER, 21, 1) /* For M profile only, whether we should generate stack-limit checks */ @@ -3190,7 +3197,7 @@ FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) FIELD(TBFLAG_A64, BT, 9, 1) -FIELD(TBFLAG_A64, BTYPE, 10, 2) +FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ FIELD(TBFLAG_A64, TBID, 12, 2) static inline bool bswap_code(bool sctlr_b) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7e0d5398ab..f2c6419369 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11016,6 +11016,22 @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) } #endif +static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, + ARMMMUIdx mmu_idx, uint32_t flags) +{ + flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); + flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, + arm_to_core_mmu_idx(mmu_idx)); + + if (arm_cpu_data_is_big_endian(env)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); + } + if (arm_singlestep_active(env)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); + } + return flags; +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11107,7 +11123,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: @@ -11115,9 +11131,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, * 0 x Inactive (the TB flag for SS is always 0) * 1 0 Active-pending * 1 1 Active-not-pending + * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. */ - if (arm_singlestep_active(env)) { - flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); + if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE)) { if (is_a64(env)) { if (env->pstate & PSTATE_SS) { flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); @@ -11128,10 +11144,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } } - if (arm_cpu_data_is_big_endian(env)) { - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); - } - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); if (arm_v7m_is_handler_mode(env)) { flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1);