From patchwork Thu Mar 12 19:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184541 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp973043ile; Thu, 12 Mar 2020 13:05:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtIB7kLG56aJwAymzdkKejAnqV+M8xAv+Rr9ed+NMgJ34XE7aXO9sqyh5YQABWcvjzZgPlV X-Received: by 2002:a05:620a:1092:: with SMTP id g18mr9483798qkk.80.1584043541679; Thu, 12 Mar 2020 13:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584043541; cv=none; d=google.com; s=arc-20160816; b=lvPWJnRJIybSBTbqJO4U511kDum6+AKQ31gl7GekuAr8z+067HyxbCm9PcV/1LknKz eWwHM2j/e2fvr+oI0dofxRqk/eHHAMYIRVusGq04rJdiuNNTzXIC4AK5C1s8+QhcC+Ms TACzMbjf/spdoGot0nW2DFVKuclkJpniHZ4HEEcnYIvloXrogHehahF1+4C8qj/shpuD riZRrMe4FcR7Y0Y6dCphp5LGLL+oZfiGSYaZTOtoUAHHwWDJo6CjbHhG2H2MGZQ++Z3H DoiqS4ZaH2ArRupSDbJIbcmjN73opzhtSMaecN4C7kpPdWiedtoMr4G4fJAStlYfieZ/ llUg== 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=QJvhSRp707cxdamQl0vVDLxpjNb38jwO6L+jNT02qis=; b=cyFO6XDh7KFjwMXjP03FxIkxLSoIpmaXIPVY1/BRNmggq4ANyAmcCvpCKjMkV7SX7w rT/9IgBT4Ov/yaxuJrO85lDzqRhi4sErj/6z5lK7ZQa0+0F6XxLhD9lErldsIBL7QU8F Y3TLkIVYwg6eHs4cm6tfAyowhHkBI9Kuk0kIuypOReyf7aQQbmHRWPaIA1rglwOokVuQ idHGubaY7NUeVzDFx9ZWfdPY/roFGnFVS+USVtW+CB1d3tIflp4aqMI03KMnxDWT230q p8vq2Em9fFPejQle1OPc3x8350htca7joLJlfodfSyAIajEnHPn1RzWDJc56FAxje8VA DFSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Htm7rd1q; 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=pass (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 z14si3250379qvy.197.2020.03.12.13.05.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Mar 2020 13:05:41 -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=pass header.i=@linaro.org header.s=google header.b=Htm7rd1q; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCU5M-0008Jc-5F for patch@linaro.org; Thu, 12 Mar 2020 16:05:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45779) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCTjT-0006C9-1E for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCTjR-0002Ht-JK for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:02 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:44657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCTjR-0002Ha-Do for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:01 -0400 Received: by mail-pg1-x543.google.com with SMTP id 37so3558674pgm.11 for ; Thu, 12 Mar 2020 12:43:01 -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=QJvhSRp707cxdamQl0vVDLxpjNb38jwO6L+jNT02qis=; b=Htm7rd1qhbD8wYpn5xGztYpEq7moH6Jqt1IzRBbiBRgtuNx6WRyILUK157ppeHE11z Ntq3SN/Mx+rNPDIH7aP7HoowgFWkZvaidtuf7SAyJ7gd7Duns+0n9KNCTJAwiAtMlmdT P2AuJ8hxcGowmVL0H+ZMvv5REOrgO5E+0vSgMKVTQ5R5LOalwjkw9MYBegqfUdGbvCIx n4BUVwtAnUMqp4gwyrr1xJwpWBc3ETjt0+MoXvkZgU41btzfrAD7tH93PxZGikxW/lxJ 6ViOLGedLDXtWkYtdHM9TsDZHJFfBTarLgN8ssPXDz8enlXnG/uZk1qR8WBYv1Pj98Zi Pekg== 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=QJvhSRp707cxdamQl0vVDLxpjNb38jwO6L+jNT02qis=; b=PB5xaJfuXBZy9zy+gCkhhL5TMgH+Tmjy01k3bTwOaYgVJad7xo1wpe1MpP1WMCBJYH KMluabD3g6n9gZTXonn7U9bBoEd6VtKrNVJWdXigYu5bAXlMen82lMwYDV+H7CjMrUDF V3vq/VB2Wzz5mYr9JSC5nrOQy0+XLzQIM7tsMnUTxGC3rdJTZRRlqjsYTUKjc0lzGfIc +TL/7WTkYdOKqlzPh5vgxqg+h7m1DoDhnpLAfQk2AorHFTkznc5q8eor6Sf3fXutZY9p dFjYxr4scgK74xHT+zNF4z1+vSB0XVBBL/bey93TywAen0qXmnuMdDeJrIDYCnRf56Bh 54uA== X-Gm-Message-State: ANhLgQ2BOxEVuTXqzhH5LWl/Z3j3C+jadvst4Aj/KwdL1du9G5W2CQRg GYPo4K0VgfyCRUhVfRfrVDu0XUYPH1U= X-Received: by 2002:a62:16d2:: with SMTP id 201mr7235600pfw.295.1584042180076; Thu, 12 Mar 2020 12:43:00 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id g69sm6824842pje.34.2020.03.12.12.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 12:42:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 29/42] target/arm: Use mte_checkN for sve unpredicated stores Date: Thu, 12 Mar 2020 12:42:06 -0700 Message-Id: <20200312194219.24406-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312194219.24406-1-richard.henderson@linaro.org> References: <20200312194219.24406-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::543 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, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper-sve.h | 1 + target/arm/sve_helper.c | 63 ++++++++++++++++++++++++++- target/arm/translate-sve.c | 88 ++++++++++++++------------------------ 3 files changed, 94 insertions(+), 58 deletions(-) -- 2.20.1 diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index 82ea70cf63..4e71501838 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -1124,6 +1124,7 @@ DEF_HELPER_FLAGS_5(sve_ftmad_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_ftmad_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(sve_ldr, TCG_CALL_NO_WG, void, env, ptr, tl, int) +DEF_HELPER_FLAGS_4(sve_str, TCG_CALL_NO_WG, void, env, ptr, tl, int) DEF_HELPER_FLAGS_4(sve_ld1bb_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ld2bb_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index ede72a2989..2396737420 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -4191,7 +4191,7 @@ static bool sve_probe_page(SVEHostPage *info, bool nofault, } /* - * Load contiguous data, unpredicated. + * Load/store contiguous data, unpredicated. * * Note that unpredicated load/store of vector/predicate registers * are defined as a stream of bytes, which equates to little-endian @@ -4261,6 +4261,67 @@ void HELPER(sve_ldr)(CPUARMState *env, void *vd, target_ulong addr, int size) } } +void HELPER(sve_str)(CPUARMState *env, void *vd, target_ulong addr, int size) +{ + int mem_idx = cpu_mmu_index(env, false); + int in_page = -((int)addr | TARGET_PAGE_MASK); + uintptr_t ra = GETPC(); + uint64_t val; + void *host; + int i; + + /* Small stores are expanded inline. */ + tcg_debug_assert(size > 2 * 8); + + if (likely(size <= in_page)) { + host = probe_write(env, addr, size, mem_idx, ra); + if (likely(host != NULL)) { + for (i = 0; i + 8 <= size; i += 8) { + stq_le_p(host + i, *(uint64_t *)(vd + i)); + } + + /* Predicate load length may be any multiple of 2. */ + if (unlikely(i != size)) { + val = *(uint64_t *)(vd + i); + if (size & 4) { + stl_le_p(host + i, val); + i += 4; + val >>= 32; + } + if (size & 2) { + stw_le_p(host + i, val); + } + } + return; + } + } else { + (void)probe_write(env, addr, in_page, mem_idx, ra); + (void)probe_write(env, addr + in_page, size - in_page, mem_idx, ra); + } + + /* + * Note there is no endian-specific target store function, so to handle + * aarch64_be-linux-user we need to bswap the big-endian store. + */ + for (i = 0; i + 8 <= size; i += 8) { + val = *(uint64_t *)(vd + i); + cpu_stq_data_ra(env, addr + i, le_bswap64(val), ra); + } + + /* Predicate load length may be any multiple of 2. */ + if (unlikely(i != size)) { + val = *(uint64_t *)(vd + i); + if (size & 4) { + cpu_stl_data_ra(env, addr + i, le_bswap32(val), ra); + i += 4; + val >>= 32; + } + if (size & 2) { + cpu_stw_data_ra(env, addr + i, le_bswap16(val), ra); + } + } +} + /* * Analyse contiguous data, protected by a governing predicate. */ diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index e55f8835bb..49d2e68564 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -4430,78 +4430,52 @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) int len_remain = len % 8; int nparts = len / 8 + ctpop8(len_remain); int midx = get_mem_index(s); - TCGv_i64 addr, t0; + TCGv_i64 dirty_addr, clean_addr, t0; + int i; + + dirty_addr = read_cpu_reg_sp(s, rn, true); + tcg_gen_addi_i64(dirty_addr, dirty_addr, imm); + + clean_addr = gen_mte_checkN(s, dirty_addr, true, rn != 31, len, MO_8); + + /* Limit tcg code expansion by doing large loads out of line. */ + if (nparts > 4) { + TCGv_ptr t_rd = tcg_temp_new_ptr(); + TCGv_i32 t_len = tcg_const_i32(len); + + tcg_gen_addi_ptr(t_rd, cpu_env, vofs); + gen_helper_sve_str(cpu_env, t_rd, clean_addr, t_len); + tcg_temp_free_ptr(t_rd); + tcg_temp_free_i32(t_len); + return; + } - addr = tcg_temp_new_i64(); t0 = tcg_temp_new_i64(); - - /* Note that unpredicated load/store of vector/predicate registers - * are defined as a stream of bytes, which equates to little-endian - * operations on larger quantities. There is no nice way to force - * a little-endian store for aarch64_be-linux-user out of line. - * - * Attempt to keep code expansion to a minimum by limiting the - * amount of unrolling done. - */ - if (nparts <= 4) { - int i; - - for (i = 0; i < len_align; i += 8) { - tcg_gen_ld_i64(t0, cpu_env, vofs + i); - tcg_gen_addi_i64(addr, cpu_reg_sp(s, rn), imm + i); - tcg_gen_qemu_st_i64(t0, addr, midx, MO_LEQ); - } - } else { - TCGLabel *loop = gen_new_label(); - TCGv_ptr t2, i = tcg_const_local_ptr(0); - - gen_set_label(loop); - - t2 = tcg_temp_new_ptr(); - tcg_gen_add_ptr(t2, cpu_env, i); - tcg_gen_ld_i64(t0, t2, vofs); - - /* Minimize the number of local temps that must be re-read from - * the stack each iteration. Instead, re-compute values other - * than the loop counter. - */ - tcg_gen_addi_ptr(t2, i, imm); - tcg_gen_extu_ptr_i64(addr, t2); - tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, rn)); - tcg_temp_free_ptr(t2); - - tcg_gen_qemu_st_i64(t0, addr, midx, MO_LEQ); - - tcg_gen_addi_ptr(i, i, 8); - - tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); - tcg_temp_free_ptr(i); + for (i = 0; i < len_align; i += 8) { + tcg_gen_ld_i64(t0, cpu_env, vofs + i); + tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEQ); + tcg_gen_addi_i64(clean_addr, clean_addr, 8); } /* Predicate register stores can be any multiple of 2. */ if (len_remain) { tcg_gen_ld_i64(t0, cpu_env, vofs + len_align); - tcg_gen_addi_i64(addr, cpu_reg_sp(s, rn), imm + len_align); - switch (len_remain) { - case 2: - case 4: - case 8: - tcg_gen_qemu_st_i64(t0, addr, midx, MO_LE | ctz32(len_remain)); - break; - case 6: - tcg_gen_qemu_st_i64(t0, addr, midx, MO_LEUL); - tcg_gen_addi_i64(addr, addr, 4); + tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUL); + tcg_gen_addi_i64(clean_addr, clean_addr, 4); tcg_gen_shri_i64(t0, t0, 32); - tcg_gen_qemu_st_i64(t0, addr, midx, MO_LEUW); + /* fall through */ + case 2: + tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUW); + break; + case 4: + tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUL); break; - default: g_assert_not_reached(); } } - tcg_temp_free_i64(addr); tcg_temp_free_i64(t0); }