From patchwork Mon Jan 11 19:00:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 360530 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3134325jai; Mon, 11 Jan 2021 11:12:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJmdXHP5UNcqB5X1QJnHQ2vqh40dpG9lS/B0BceUn7fvgYh6uCYqsOnNcLCAOdJU+DNxxL X-Received: by 2002:a25:cf12:: with SMTP id f18mr1922816ybg.18.1610392323074; Mon, 11 Jan 2021 11:12:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610392323; cv=none; d=google.com; s=arc-20160816; b=UhwBElxodjv2LpXRgwzr5YXT5WQit6XXt/I6iqtKVNHt67TPiEIpv1qqhWqebHGg+U Ur83sKAaIOHOQkcdUBwDvFHrks/OM/EOtogf+zcBQqA7tQ74R+1eyZr2WECQvFdO30KQ LAffLZAUrhKHlQNz2eGm2Bm76iDbwClNckDBoKaHEyHkrUo8Zj0ru+AL3oZm9COiO25R JLuvk92ySQnDRUanp0HN4vPXSJilW4Js+K1jqP05cdlT6bBnbUDBOUqc9T2F77y4ob/v 8y3PEq9HQKt3ql2pDM/mkQjIQdqrUuBC7o0K8QwCaXqueC4c+hQ8qnB94j9Qpi/9EIEH VeIw== 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=5Gp5YJhUdu7O2iWG1ZDTCi/OY2TUbd2kY+8E+Hd/FJ4=; b=rPVbORdsQQRYXwD115Ubw0ZzRu5iZ9+xFOft0dFCkxfEJ1umEOg/mRHRlKB1uO0zFT Ep/9xt704Ke0FTZYvubmgJ+r7LAEwdODgY4d91bxch6oumjSrnUqOSYYn0r5VNxdcMsh YrQrEdG/rvkP8KQacl8pSApFeo9SyMhoyqDdZSkWig96Z6+XHIb7b3BR5mUTWGfJHIKr +9BwV24Tu6xpfitvPvpqAncLq36Fuou0yhDGOX9ClyxjWo89RkmFDSwzq/fOmjZRHwcX +e6vRgzh/1hWPJJKEl0ghUbKWVZ6hctC7aYBOiiJKjSWibdi3dHUGVatb8GaSycnBbKM ytqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Hrwh+m3a; 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 c127si653813yba.167.2021.01.11.11.12.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jan 2021 11:12:03 -0800 (PST) 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=Hrwh+m3a; 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]:41018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz2bi-0006s6-GQ for patch@linaro.org; Mon, 11 Jan 2021 14:12:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz2Rb-000637-Im for qemu-devel@nongnu.org; Mon, 11 Jan 2021 14:01:35 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:47091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kz2RZ-0006Ql-Pr for qemu-devel@nongnu.org; Mon, 11 Jan 2021 14:01:35 -0500 Received: by mail-pl1-x62d.google.com with SMTP id v3so314821plz.13 for ; Mon, 11 Jan 2021 11:01:33 -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 :mime-version:content-transfer-encoding; bh=5Gp5YJhUdu7O2iWG1ZDTCi/OY2TUbd2kY+8E+Hd/FJ4=; b=Hrwh+m3ahWF0A68aHzHCSsJcTJ2MdggXky1MWjQ8UbK/3xzqALsVjPcGEb6ua3AvAB mkEdcSaZFJI8+9YmuHmTtwWz5S55vTvRCH9MfmbMQ7El26sfzx1Gszl2WOItWlokFJkM efliDgDbuiJvMzT/CzUtCMDDTplqzw7Q0Sx1loMVYXRu0lXpZzsQJ28i5jdB9kEzCh3N Ab8GChSy/af0ly3xPFkw6o3AONctV2VgcnQ0kEm3kNxWZBVBk6b7s3z350QVihXBbXrb zUR/TZHkQkc5OIL3M3PF/+YdKl1QtFOHPMe9j6dMQtsnDUP7jOGHIsyRT2pR4KW6Tr9v wEmg== 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=5Gp5YJhUdu7O2iWG1ZDTCi/OY2TUbd2kY+8E+Hd/FJ4=; b=DoP9jFC6t8v9kmOITS6aM1ChY1qsAOe31Iiz76jEmL704t6tLzAsxZ7OdzzTwkDkiQ wuzk01v55XBcdiNTz9tIEr0MNoGGfjPkLyb6pF6+FLDbuesHG7vOSY/Rn3NTIHs0TiwN PPRhiHUAyKtuDvilPtCGykfyPTLU0DMMOTnm4EZ2mzWocoCcC0Yl8xdhz3Ex1dvqXbR1 xdvmg6HoJPGb0VebxI8HkYLSOvu4Sy+5eKE3ttpSX5tUAaMPs5+/wYigfcSBTR4Tk2wZ BaS4kFwaJDATXkPnuKmNIWb4JR8vMEorSu+jNF0FUyO93D0nuwKBvfquc1NJFEr20Cav DoDw== X-Gm-Message-State: AOAM530EFvBerIc76ErwTfbfeeSRBPOxGGNjZBMT+mDhKa1zWTlRBcUX K6JUItfSuu1z6vaQRj/vejTtSeKZ245Xtg== X-Received: by 2002:a17:90a:d70e:: with SMTP id y14mr288483pju.9.1610391692145; Mon, 11 Jan 2021 11:01:32 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id n195sm350395pfd.169.2021.01.11.11.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 11:01:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/30] target/arm: Add ALIGN_MEM to TBFLAG_ANY Date: Mon, 11 Jan 2021 09:00:52 -1000 Message-Id: <20210111190113.303726-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210111190113.303726-1-richard.henderson@linaro.org> References: <20210111190113.303726-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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" Use this to signal when memory access alignment is required. This value comes from the CCR register for M-profile, and from the SCTLR register for A-profile. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 2 ++ target/arm/translate.h | 2 ++ target/arm/helper.c | 19 +++++++++++++++++-- target/arm/translate-a64.c | 1 + target/arm/translate.c | 7 +++---- 5 files changed, 25 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index aa2f2d3a04..4adac2f193 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3284,6 +3284,8 @@ FIELD(TBFLAG_ANY, MMUIDX, 4, 4) FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2) /* For A-profile only, target EL for debug exceptions. */ FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2) +/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */ +FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1) /* * Bit usage when in AArch32 state, both A- and M-profile. diff --git a/target/arm/translate.h b/target/arm/translate.h index 50c2aba066..b185c14a03 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -87,6 +87,8 @@ typedef struct DisasContext { bool bt; /* True if any CP15 access is trapped by HSTR_EL2 */ bool hstr_active; + /* True if memory operations require alignment */ + bool align_mem; /* * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. * < 0, set by the current instruction. diff --git a/target/arm/helper.c b/target/arm/helper.c index 0d7c8817b6..fc38cc58aa 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12777,6 +12777,12 @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx) { CPUARMTBFlags flags = {}; + uint32_t ccr = env->v7m.ccr[env->v7m.secure]; + + /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */ + if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) { + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); + } if (arm_v7m_is_handler_mode(env)) { DP_TBFLAG_M32(flags, HANDLER, 1); @@ -12789,7 +12795,7 @@ rebuild_hflags_m32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx) */ if (arm_feature(env, ARM_FEATURE_V8) && !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { + (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) { DP_TBFLAG_M32(flags, STACKCHECK, 1); } @@ -12809,12 +12815,17 @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx) { CPUARMTBFlags flags = rebuild_hflags_aprofile(env); + int el = arm_current_el(env); + + if (arm_sctlr(env, el) & SCTLR_A) { + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); + } if (arm_el_is_aa64(env, 1)) { DP_TBFLAG_A32(flags, VFPEN, 1); } - if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && + if (el < 2 && env->cp15.hstr_el2 && (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1); } @@ -12859,6 +12870,10 @@ rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, ARMMMUIdx mmu_idx) sctlr = regime_sctlr(env, stage1); + if (sctlr & SCTLR_A) { + DP_TBFLAG_ANY(flags, ALIGN_MEM, 1); + } + if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { DP_TBFLAG_ANY(flags, BE_DATA, 1); } diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 010e81e0b4..69d401da21 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14712,6 +14712,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->user = (dc->current_el == 0); #endif dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); dc->sve_len = (EX_TBFLAG_A64(tb_flags, ZCR_LEN) + 1) * 16; dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); diff --git a/target/arm/translate.c b/target/arm/translate.c index 189b2ee3cb..3fc058e8d0 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -933,8 +933,7 @@ static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, { TCGv addr; - if (arm_dc_feature(s, ARM_FEATURE_M) && - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { + if (s->align_mem) { opc |= MO_ALIGN; } @@ -948,8 +947,7 @@ static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, { TCGv addr; - if (arm_dc_feature(s, ARM_FEATURE_M) && - !arm_dc_feature(s, ARM_FEATURE_M_MAIN)) { + if (s->align_mem) { opc |= MO_ALIGN; } @@ -8824,6 +8822,7 @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) dc->user = (dc->current_el == 0); #endif dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL); + dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); if (arm_feature(env, ARM_FEATURE_M)) { dc->vfp_enabled = 1;