From patchwork Thu Nov 9 13:42:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 742571 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp845328wrw; Thu, 9 Nov 2023 05:48:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgLFvClWGEizdvaiDy960Y0dpGZlHEg0rf/Z9NnF66EpGt+HkwzI8k+a9tsvWwOQpLlHFH X-Received: by 2002:ac8:7d86:0:b0:419:4c70:c54e with SMTP id c6-20020ac87d86000000b004194c70c54emr4120785qtd.52.1699537713166; Thu, 09 Nov 2023 05:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699537713; cv=none; d=google.com; s=arc-20160816; b=IURAPNpEbA20R66ZveupQrS0A5C4UuAOY2g27640oTBRM+0tpEjTd9LVnfGneoVIcv xvJOtwHLQ87pto0q89fFtFvFMLjNH1cXN1WBy6gkUxpbn7tP7DlghrFv5e+0m/ZCikWo tb4f1NuO0x0T8qkeOkysSILSSp/7H9G9/wpmd8TruZQjP7q3vEJqZoTlwb04hqBb3EFd 2T38udJTuSEpS9XqQJokGRkk9t5w/XWEWtNr9Nw5BDO48ScKclB0zDpthEkRkkHruEi/ RUSp1zIDrnlvhSNaRqTKDiIvi3eRaKjYIB3t1bVEv659bT578TSOenYNQ8UbTvTcake+ 6bsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from; bh=PIAjhKVPypLaMwaijw/BpHhj/W3kfFRxPn6XV3SklU8=; fh=LpRsuFZ4Xrkq7gy4UTty7NeerQeaiM6FkYWG44Rdy8M=; b=AJmb4h06xZ9YXsx9O3FFuAxYfdVNQRO9EGP5Pxmtyi4g2owIJCxMsT1YOtzcH+/oXZ pwSV+BAaaZGcZm12eyVFUa1JFdI1DZTGgIrfomP/YhlWWX6Q2QlRxix5WPuLrwTFgM4D Y+LLRE2ayxDvHRSgVk8PoOyu6ERXkLaABzDpvyAr7ycTy74dXhE2JTRCZa6iTcg9Uyvq 4DNI3cuGIxYgDMuCUNv9SQXbGOgc+BFox91FrXzQsmFTWZSwi21QtfFgVhTlLFmnwM+7 3MG6beAfa12sCUVq1I/MSIXyakwA0SAbtsNBj3dIkOhrnPMvyMbWIgoR4f4FyezNLQIa KpDg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f18-20020ac85d12000000b0041cb522af7asi3027599qtx.199.2023.11.09.05.48.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 05:48:33 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r15Lp-0004qt-Ey; Thu, 09 Nov 2023 08:45:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r15Lg-0003si-Lg; Thu, 09 Nov 2023 08:45:32 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r15Le-0001fN-G9; Thu, 09 Nov 2023 08:45:32 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 25EAA31B11; Thu, 9 Nov 2023 16:43:13 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 270DB344B7; Thu, 9 Nov 2023 16:43:05 +0300 (MSK) Received: (nullmailer pid 1461836 invoked by uid 1000); Thu, 09 Nov 2023 13:43:02 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Michael Tokarev , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [Stable-8.1.3 25/55] target/arm: Fix SVE STR increment Date: Thu, 9 Nov 2023 16:42:29 +0300 Message-Id: <20231109134300.1461632-25-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson The previous change missed updating one of the increments and one of the MemOps. Add a test case for all vector lengths. Cc: qemu-stable@nongnu.org Fixes: e6dd5e782be ("target/arm: Use tcg_gen_qemu_{ld, st}_i128 in gen_sve_{ld, st}r") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20231031143215.29764-1-richard.henderson@linaro.org [PMM: fixed checkpatch nit] Signed-off-by: Peter Maydell (cherry picked from commit b11293c212c2927fcea1befc50dabec9baba4fcc) Signed-off-by: Michael Tokarev (Mjt: context fix in tests/tcg/aarch64/Makefile.target) Tested-by: Alex Bennée diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c index 2ba5efadfd..90865d8696 100644 --- a/target/arm/tcg/translate-sve.c +++ b/target/arm/tcg/translate-sve.c @@ -4294,7 +4294,7 @@ void gen_sve_str(DisasContext *s, TCGv_ptr base, int vofs, t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64(); t16 = tcg_temp_new_i128(); - for (i = 0; i < len_align; i += 8) { + for (i = 0; i < len_align; i += 16) { tcg_gen_ld_i64(t0, base, vofs + i); tcg_gen_ld_i64(t1, base, vofs + i + 8); tcg_gen_concat_i64_i128(t16, t0, t1); @@ -4320,7 +4320,8 @@ void gen_sve_str(DisasContext *s, TCGv_ptr base, int vofs, t16 = tcg_temp_new_i128(); tcg_gen_concat_i64_i128(t16, t0, t1); - tcg_gen_qemu_st_i128(t16, clean_addr, midx, MO_LEUQ); + tcg_gen_qemu_st_i128(t16, clean_addr, midx, + MO_LE | MO_128 | MO_ATOM_NONE); tcg_gen_addi_i64(clean_addr, clean_addr, 16); tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop); diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 49e1ffea93..6c2a6d6206 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -100,7 +100,11 @@ sha512-sve: CFLAGS=-O3 -march=armv8.1-a+sve sha512-sve: sha512.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) -TESTS += sha512-sve +sve-str: CFLAGS=-O1 -march=armv8.1-a+sve +sve-str: sve-str.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +TESTS += sha512-sve sve-str endif ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) diff --git a/tests/tcg/aarch64/sve-str.c b/tests/tcg/aarch64/sve-str.c new file mode 100644 index 0000000000..ae271c9d87 --- /dev/null +++ b/tests/tcg/aarch64/sve-str.c @@ -0,0 +1,49 @@ +#include +#include + +#define N (256 + 16) + +static int __attribute__((noinline)) test(int vl) +{ + unsigned char buf[N]; + int err = 0; + + for (int i = 0; i < N; ++i) { + buf[i] = (unsigned char)i; + } + + asm volatile ( + "mov z0.b, #255\n\t" + "str z0, %0" + : : "m" (buf) : "z0", "memory"); + + for (int i = 0; i < vl; ++i) { + if (buf[i] != 0xff) { + fprintf(stderr, "vl %d, index %d, expected 255, got %d\n", + vl, i, buf[i]); + err = 1; + } + } + + for (int i = vl; i < N; ++i) { + if (buf[i] != (unsigned char)i) { + fprintf(stderr, "vl %d, index %d, expected %d, got %d\n", + vl, i, (unsigned char)i, buf[i]); + err = 1; + } + } + + return err; +} + +int main() +{ + int err = 0; + + for (int i = 16; i <= 256; i += 16) { + if (prctl(PR_SVE_SET_VL, i, 0, 0, 0, 0) == i) { + err |= test(i); + } + } + return err; +}