From patchwork Fri Oct 18 17:44:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176919 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1183163ill; Fri, 18 Oct 2019 10:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjgNfX7bCJ5Yw5hT89YJtS75KRLJl0JlFzW/NOP8SKkVanOCCojx69upB3wmBptZXIeK6v X-Received: by 2002:a37:a755:: with SMTP id q82mr9931323qke.394.1571420912788; Fri, 18 Oct 2019 10:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571420912; cv=none; d=google.com; s=arc-20160816; b=TI4xpeDgfNkokPGXa21XaB+ja0ubDo95NGeK+c+GtIxERu8cMdwMt+82h0yqcbBk0v OCwJpT6V7DuMhpgKY942mamR7uyQw+5aiRRIQ4wpWOCmpBn1sIRTiK5lKa0+7ciEf32b /yFAicO4kqmBleo2N5qFZA2ebG747MdYyXYT/Dd9sg1elsHVrTkCaEgYvABvXFncDH1z QpXxRhOAcad/1uHKhULEYpHtPppRYnqi4dA1DT8OzShh+tlIwsyi/7ZP2q4t3kNf5nMW RGju+PP3F5GvE4NfYTyyO/5x+b0O/tbybmQ9DKyqRnrPgOADWAUJghDLT686uKZ7azCx fY6w== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=V+xlzFuvLb5pgKpdhlHQ+6fMVNrPftAKplKJ/HYLHO0jxeiW5aGsyPJQTuL7GRHgJX IbWdwjU+JgNeff52iAxPmIRQX5qTWYMO/Kgp7pcVPEajTo+JsMTRfySr2yLKgzaKEL2L pSrfWZ6cq5RKBewkswPcl+mwYRNF1GZPQ7EkAxIBGYMeFctE+GkAtI2JxXOsZ42n70mJ jgqurCu2HTIWhLLZEKVQIPHWcgaaJ5dOeCyT01rcVbSMGI8NNzyqvVLBGjHhjUn8/RSH +liz+IeyP4q7kEqs/svAmQ4rCPAzpXSZlnY1JnMgqA4O2ckCEBQ1ojL3xWdLYkfdqhN9 ltvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TglGQ5w1; 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 h13si6411368qvc.156.2019.10.18.10.48.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Oct 2019 10:48:32 -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=TglGQ5w1; 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]:44226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWMZ-0001JA-8e for patch@linaro.org; Fri, 18 Oct 2019 13:48:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59069) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWIp-0006P8-O2 for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLWIn-0005LW-Ms for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:39 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:39393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLWIm-0005K3-3J for qemu-devel@nongnu.org; Fri, 18 Oct 2019 13:44:36 -0400 Received: by mail-pl1-x644.google.com with SMTP id s17so3181967plp.6 for ; Fri, 18 Oct 2019 10:44:36 -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 :mime-version:content-transfer-encoding; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=TglGQ5w1lkkBL0n1CzRUpYRAeD8WLHtjq70P5SsSvtLR6n6hjUvijmTXwTUjyWsZbk +symiKA08DnlmIdYa/oWymh5DEkzUl/IS3WkyUWvih2Gx4+bjsx/ErGPrynA3UE1DYBb XnlJ86eeSAMSZeML3gdLXdu+OTmo+rAHvzbxuocjLgjw97n74A2qFDI0MaQiiiJ7WAdg cCa6QVyEtPpeSZlRK7sCqH8ge9Ahv6z/Srz6umNSTct1nEs0Pb8xFloHKOggqVxPCn5z neqKoymVLwsMlQOq7FBtacOsdaN10Q0nk4Fy01qFD2nN5L+x66g8Zlq7URRmuaN8bNhp LTDA== 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:mime-version:content-transfer-encoding; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=K0O8KCW3s5n3og0Yt2DSy6jDVp6BsPaWU6s71E1y+pqbcBibZ4AQCaPflFwnqDVXza GFFlWRXfJYx1ohhu0eWqc5MOxCIYz9eBl7GP6esaHE/x9SvtldF7Gkoh4vMVDk9My6tP g1vns2I0uzOtXaUNr+ADeTv1/g4m7dPiPlLwucVTNKVmwhoSJs2oyMltYo+UoArQicKq tcKsJjNB5iJ9V7B0WecpgOKxiLbyMeU6hD+UXiQ3ikA/cMCP9crsdZJrvR2przfx8tAw 4f4LS+Q+cG1DCfEt5Nsn44OxfvspDOoFT8TM34MwPKO58JDoqgG8LMRYPOAnJTgGVcLF TBIA== X-Gm-Message-State: APjAAAXkQ8rVbrtvruPImttcOyO5EaYIg2ktW+q9L14udT7ShjXITt3d iummBy2ijliKeDSLRoyWt146MDrTbws= X-Received: by 2002:a17:902:d88c:: with SMTP id b12mr11323181plz.254.1571420674653; Fri, 18 Oct 2019 10:44:34 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d20sm7857534pfq.88.2019.10.18.10.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 10:44:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 02/22] target/arm: Split out rebuild_hflags_a64 Date: Fri, 18 Oct 2019 10:44:11 -0700 Message-Id: <20191018174431.1784-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191018174431.1784-1-richard.henderson@linaro.org> References: <20191018174431.1784-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 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_A64 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. Note that not all BTI related flags are cached, so we have to test the BTI feature twice -- once for those bits moved out to rebuild_hflags_a64 and once for those bits that remain in cpu_get_tb_cpu_state. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 131 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 62 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8829d91ae1..69da04786e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11070,6 +11070,71 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, return flags; } +static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, + ARMMMUIdx mmu_idx) +{ + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); + ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); + uint32_t flags = 0; + uint64_t sctlr; + int tbii, tbid; + + flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); + + /* FIXME: ARMv8.1-VHE S2 translation regime. */ + if (regime_el(env, stage1) < 2) { + ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); + tbid = (p1.tbi << 1) | p0.tbi; + tbii = tbid & ~((p1.tbid << 1) | p0.tbid); + } else { + tbid = p0.tbi; + tbii = tbid & !p0.tbid; + } + + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); + flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); + + if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { + int sve_el = sve_exception_el(env, el); + uint32_t zcr_len; + + /* + * 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 { + zcr_len = sve_zcr_len_for_el(env, el); + } + flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); + flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); + } + + sctlr = arm_sctlr(env, el); + + if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { + /* + * In order to save space in flags, we record only whether + * pauth is "inactive", meaning all insns are implemented as + * a nop, or "active" when some action must be performed. + * The decision of which action to take is left to a helper. + */ + if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { + flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); + } + } + + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { + /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ + if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { + flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); + } + } + + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11079,67 +11144,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, uint32_t flags = 0; if (is_a64(env)) { - ARMCPU *cpu = env_archcpu(env); - uint64_t sctlr; - *pc = env->pc; - flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - - /* Get control bits for tagged addresses. */ - { - ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); - ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); - int tbii, tbid; - - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { - ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); - tbid = (p1.tbi << 1) | p0.tbi; - tbii = tbid & ~((p1.tbid << 1) | p0.tbid); - } else { - tbid = p0.tbi; - tbii = tbid & !p0.tbid; - } - - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); - flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - int sve_el = sve_exception_el(env, current_el); - uint32_t zcr_len; - - /* 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 { - zcr_len = sve_zcr_len_for_el(env, current_el); - } - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); - } - - sctlr = arm_sctlr(env, current_el); - - if (cpu_isar_feature(aa64_pauth, cpu)) { - /* - * In order to save space in flags, we record only whether - * pauth is "inactive", meaning all insns are implemented as - * a nop, or "active" when some action must be performed. - * The decision of which action to take is left to a helper. - */ - if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { - flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); - } - } - - if (cpu_isar_feature(aa64_bti, cpu)) { - /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ - if (sctlr & (current_el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); - } + flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } } else { @@ -11159,9 +11166,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); } - } - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); + 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: