From patchwork Mon Apr 19 20:22:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 424044 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp3047268jaf; Mon, 19 Apr 2021 13:47:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDqPK8mt967FP6k4zZpCNjdfQjs3MaXSTTJp3D4jw9EIOcF27PLgzdrTHBLhJd3unHx6ea X-Received: by 2002:a5e:990e:: with SMTP id t14mr2648950ioj.107.1618865276287; Mon, 19 Apr 2021 13:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618865276; cv=none; d=google.com; s=arc-20160816; b=nyVohJb1zbmLE4PpfbOZYYR/vsiYdlYM6Pj5mNudgGMaqBgIIneYl5dLdjGFejFOg6 CvRXF/o081iAhnXqtf+3mQELMKuITezb+biivUJ5xiRlb7JsQsVj9bf9NYKpqKzndkep OxTWg4P9KBWYkTKQVoCN5RDcWegUcraSmJzwhpwxg3L86ahHKu6f+hSCg8HGuXEHT+Jj O8aGwwupt05UwVNaNgJQ/aQAR7LQwB6xoI8iZxeEHDU0L+DyzpBM3zIkjJFAr7kqbEcN 7y0w9yaIVUO8SwZYiacn7FpayZ6eK7dsVr6MCYpRd0NK+WyNkfT1pSAO5zEMI2VWCOjb zy2Q== 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=Oh1qO2KUwgUkOK0Nb4wixyQnmsz7yfEm5+cSP3Pk7Zw=; b=vsShiAHJE9g8eBFfrRAI5OA6aNjn7Gs0w08FhqBaQx58Il+A+Sqm6ITTeLCU62Eafg OCst6mVwz3A4DM/6RDbxhZV5Lkd5JbEpLPzklqLSy5Dmcc9wr/5EPIZ/eBwguxPNKhiz JyuSXXWadzibQDBcb56sU4KdZTfcjBrkBdcSLSsxqvLoT12AT2ityWfssCWQrZzsMeOR WAHC4/d4b4KcMt99Abs8UJ6Usws9+CTJOGqjabX7lr2un0WvPv7XLDY2lArHq921lewp HDPDYRAZmMheJVxZihgHmptuPeO6Mp6Bt6qNPvEA1OY/QMoBiJjDlmeniX3NymYXmis0 swvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gW1eQkJR; 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 r21si8064676jab.74.2021.04.19.13.47.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Apr 2021 13:47:56 -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=gW1eQkJR; 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]:59422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYaoF-0000R2-Hc for patch@linaro.org; Mon, 19 Apr 2021 16:47:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYaQp-0007qd-9b for qemu-devel@nongnu.org; Mon, 19 Apr 2021 16:23:43 -0400 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]:35409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lYaQm-0002hy-F6 for qemu-devel@nongnu.org; Mon, 19 Apr 2021 16:23:43 -0400 Received: by mail-qv1-xf33.google.com with SMTP id x27so17572941qvd.2 for ; Mon, 19 Apr 2021 13:23:39 -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=Oh1qO2KUwgUkOK0Nb4wixyQnmsz7yfEm5+cSP3Pk7Zw=; b=gW1eQkJRaA21l6IlgDqT3n7EmOnqUBXn8VRuQinNy4vOeCxp/8uh1+mp85D1sxXETM qTtKThqX+nY/GlnoDMZvi2v1inAC9QlkVV9uSznjaOuEWCvay5yvhpv47TWgbdCf7TW5 +ExM040pCIluxruejoareVVxj3jFBUZU3Vs5SN2VnJIGPf3GOfHnUJvgTieK+CM0L8+g b06XLfrQNIh2NcsOfryyKuanVEBCYjxtfwFAMT5ej3hkmRlQchVxdhrKJrBVzlqmbJt8 kpnGCNyTooaZTdHttD/BZnO1Ggov/NsHfGdhNExDjV0gJGjmPg3ZVMaYUBNJvXXkyjb/ jkWg== 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=Oh1qO2KUwgUkOK0Nb4wixyQnmsz7yfEm5+cSP3Pk7Zw=; b=TxFjdFmY8cimNDn87LqET8Inr1DmZ33i6NafOHYuHTtfGUPLCPIYDKuygWWOhmYyZj D5sNjxlB8MvoNw4w8KUTZO4nFEaNjCQxwqnRCUmVFPPV1C9HQL2W55hc2oJxoNVJx8g8 RSCcTBw8VJ9XZRx4MEO0BlVEfroIKMNR2Yz/QrFM04/d75oc1gWo9XkDsyYgt2coPdaL o0DDaDvJ8/2gWnVdbQZXpxR+s9A/ouVa0QQxRoZ5iB/UsCQn30lPm2PIvEa4WeldUfVY xYaKM/oT2iVCvoDoBqHA1qvceBOSQuPECjZZEWL53uM31Z5InqAWTvHCqGTSirzcwvRF yizA== X-Gm-Message-State: AOAM530nzjW4X9+AWLrMh+jz9+QHAEUVzAB6N+cdGJCBBQmmtAKMmI82 hHGhcunb8wJlcc4fiT7PTzlHE/d6WQrpUFrf X-Received: by 2002:a0c:b348:: with SMTP id a8mr23368447qvf.7.1618863819254; Mon, 19 Apr 2021 13:23:39 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:80c7:aba4:3594:91a:8889:c77a]) by smtp.gmail.com with ESMTPSA id c23sm10007835qtm.46.2021.04.19.13.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 13:23:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 22/31] target/arm: Enforce alignment for VLDn (all lanes) Date: Mon, 19 Apr 2021 13:22:48 -0700 Message-Id: <20210419202257.161730-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210419202257.161730-1-richard.henderson@linaro.org> References: <20210419202257.161730-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf33.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 , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Fix alignment for n in {2, 4}. --- target/arm/translate.h | 1 + target/arm/translate.c | 15 +++++++++++++ target/arm/translate-neon.c.inc | 37 +++++++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/target/arm/translate.h b/target/arm/translate.h index 0c60b83b3d..ccf60c96d8 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -204,6 +204,7 @@ void arm_test_cc(DisasCompare *cmp, int cc); void arm_free_cc(DisasCompare *cmp); void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); void arm_gen_test_cc(int cc, TCGLabel *label); +MemOp pow2_align(unsigned i); /* Return state of Alternate Half-precision flag, caller frees result */ static inline TCGv_i32 get_ahp_flag(void) diff --git a/target/arm/translate.c b/target/arm/translate.c index 4decb2610e..0cf6da7e79 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -908,6 +908,21 @@ static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) #define IS_USER_ONLY 0 #endif +MemOp pow2_align(unsigned i) +{ + static const MemOp mop_align[] = { + 0, MO_ALIGN_2, MO_ALIGN_4, MO_ALIGN_8, MO_ALIGN_16, + /* + * FIXME: TARGET_PAGE_BITS_MIN affects TLB_FLAGS_MASK such + * that 256-bit alignment (MO_ALIGN_32) cannot be supported: + * see get_alignment_bits(). Enforce only 128-bit alignment for now. + */ + MO_ALIGN_16 + }; + g_assert(i < ARRAY_SIZE(mop_align)); + return mop_align[i]; +} + /* * Abstractions of "generate code to do a guest load/store for * AArch32", where a vaddr is always 32 bits (and is zero diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc index 18d9042130..9c2b076027 100644 --- a/target/arm/translate-neon.c.inc +++ b/target/arm/translate-neon.c.inc @@ -522,6 +522,7 @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) int size = a->size; int nregs = a->n + 1; TCGv_i32 addr, tmp; + MemOp mop, align; if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { return false; @@ -532,18 +533,33 @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) return false; } + align = 0; if (size == 3) { if (nregs != 4 || a->a == 0) { return false; } /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */ - size = 2; - } - if (nregs == 1 && a->a == 1 && size == 0) { - return false; - } - if (nregs == 3 && a->a == 1) { - return false; + size = MO_32; + align = MO_ALIGN_16; + } else if (a->a) { + switch (nregs) { + case 1: + if (size == 0) { + return false; + } + align = MO_ALIGN; + break; + case 2: + align = pow2_align(size + 1); + break; + case 3: + return false; + case 4: + align = pow2_align(size + 2); + break; + default: + g_assert_not_reached(); + } } if (!vfp_access_check(s)) { @@ -556,12 +572,12 @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) */ stride = a->t ? 2 : 1; vec_size = nregs == 1 ? stride * 8 : 8; - + mop = size | align; tmp = tcg_temp_new_i32(); addr = tcg_temp_new_i32(); load_reg_var(s, addr, a->rn); for (reg = 0; reg < nregs; reg++) { - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), size); + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), mop); if ((vd & 1) && vec_size == 16) { /* * We cannot write 16 bytes at once because the @@ -577,6 +593,9 @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) } tcg_gen_addi_i32(addr, addr, 1 << size); vd += stride; + + /* Subsequent memory operations inherit alignment */ + mop &= ~MO_AMASK; } tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr);