From patchwork Sat Feb 4 16:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 650669 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp1447359pva; Sat, 4 Feb 2023 08:37:57 -0800 (PST) X-Google-Smtp-Source: AK7set92tqG6icbB31YD1UWGmdJTx0mWXPU2adx/7y5kNrTS6ZGlbEPziKcJsqCD1zQvRW8yixJP X-Received: by 2002:a05:6214:b69:b0:568:d79c:7a70 with SMTP id ey9-20020a0562140b6900b00568d79c7a70mr11847376qvb.1.1675528677190; Sat, 04 Feb 2023 08:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675528677; cv=none; d=google.com; s=arc-20160816; b=v8zd7UnF4XLlZ8NEioTylKUnuaYFXE/nZoecipI4b6dBs//qIaFWzJMafCH7rpek+d Ptdrjj+yXIz13rPo7ZgFi3rIu/gp+w6+TMOylzjC221F1FXy2RMVtwOfP8HMWC3PYTgq RjgTElyimM549FyREeSN2d5VyIA1sjW/l9LPb4tItQUuyZl9g70sViJ8l2VjCSQMCeQW fm6HBTJPvC45riLo0qs/GckKcd6jB/7VdyyNKOzogTJD3Kfgwz2StqB5mU9qTP8U2kiB FC21P2okkgN1I941o/zKL/zgdjKFawgmvxqm7cpQIl4AUJf9WZqDjPhJR5d2phMF/onV OJrA== 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:dkim-signature; bh=eZTavF7es3O2ujG9mYHigJTrObpuqrsvusel8D8p0rM=; b=bEwT4aQG6x8zk0skDE1g3IyS+hLlTpOie6GvjN/ZluD24nI4HbC8Mqmb086klU+94Q GZNuXz5E04KluK209tXjU7EM8sY6NmYAt4st3hGNFHNfCrzGpqFLQnb/LGfli/0N7n6T GKeGBhVnAljd4IBFfe4+Eq9HdCjA3Gqmd7SaSYfKmHMAMsYIA8BWj96dPGBFXFlMTb4e SnMK3++Wr3klJD/26uGmNG9VboTvWFiyc1xfZ84oZeYpZcFDd3j3jB/XoCpfeszJ3yr2 MsI19O4V/52bpAljW+cr5p9DWYceDK7NYTkR6RLtF7ee5fEdZBRMIZMwwAQ19ewO9i9K bBNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r3Td0hma; 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 nt9-20020a0562143c0900b005354625dc8bsi3943428qvb.532.2023.02.04.08.37.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Feb 2023 08:37:57 -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=pass header.i=@linaro.org header.s=google header.b=r3Td0hma; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOLUD-0005D3-Hs; Sat, 04 Feb 2023 11:33:57 -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 1pOLUC-0005Cs-HX for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:56 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOLUA-0002X0-UH for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:56 -0500 Received: by mail-pj1-x102e.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so7622430pjb.1 for ; Sat, 04 Feb 2023 08:33:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eZTavF7es3O2ujG9mYHigJTrObpuqrsvusel8D8p0rM=; b=r3Td0hmalNK4UiMvKaWHjRYm9pv5EZsRMZ/gTWeX2ttFPylk1RofXrYjUUSkTs7+wP +vI/w9iqYUwRPspuaIC6dW0iiOlX2J1YsUjkDSvKPn+e3mLz3QRpAltAJiTlO3+5KcXT Tn6mFAxbxTRQsxbWzFIlO9J3/kYYDsw6uz7U5BGfnfzQeLJjqPRR42GgFUwgUWwE85TX k72PaRw+/8S/JJ7eJGRnZ2ix3E+1klUg61Itz6jM0zT/R6viFFLs28k69io+IcqW73Rj zpAQqRuTABBlnlEWIzNw5429CPHQqnZH/5YxL+qMkQlqMtP9R4XBywynk4fWV7J/rWiJ d52w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eZTavF7es3O2ujG9mYHigJTrObpuqrsvusel8D8p0rM=; b=v1hOhUBa9cEHbZpwqlLVwNL/RbEyicaES+FJ43/s3b0MwTedcKbV8GosKD90Iu0r37 bNbH+xX/3YDvlPokg4sazLLqg6hhIiXkng9vUpcuXAnqa9uBpO0hlfgF38R1x3raldz2 34Y9x0yQk9WpCCAN6N5CtlajraFRJa7MLbMrmdNwCg3Egpv/O0StgNVJMUz6ZpKS/vC8 bKxRAxtWqn+KF0h7LqGYbXaIkJYmGAT1HgERghY5AjieA/e9XFq8AY2iG5CVyhTq8ET5 FcjQz0O9217KAD6kX9SnqFLXD1DUqTSPPBsmexu2deQYtjImCYDBZCbT78/2x9iLyR3H AG9Q== X-Gm-Message-State: AO0yUKXl36ckHeMgeyOD3Xez3vjv+/0rhI3gLmFTSNldKCPzce7b6wM2 /8KTshGEGLVQ8u/0Gx2SZR6EWozCXIdI/H+L X-Received: by 2002:a17:902:d093:b0:198:ee12:ce93 with SMTP id v19-20020a170902d09300b00198ee12ce93mr2585510plv.46.1675528434063; Sat, 04 Feb 2023 08:33:54 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id w19-20020a1709029a9300b00186b69157ecsm3660859plp.202.2023.02.04.08.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 08:33:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich Subject: [PULL 26/40] tests/tcg/s390x: Add cdsg.c Date: Sat, 4 Feb 2023 06:32:56 -1000 Message-Id: <20230204163310.815536-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204163310.815536-1-richard.henderson@linaro.org> References: <20230204163310.815536-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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=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: Ilya Leoshkevich Add a simple test to prevent regressions. Signed-off-by: Ilya Leoshkevich Message-Id: <20230201133257.3223115-1-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/s390x/cdsg.c | 93 +++++++++++++++++++++++++++++++++ tests/tcg/s390x/Makefile.target | 4 ++ 2 files changed, 97 insertions(+) create mode 100644 tests/tcg/s390x/cdsg.c diff --git a/tests/tcg/s390x/cdsg.c b/tests/tcg/s390x/cdsg.c new file mode 100644 index 0000000000..800618ff4b --- /dev/null +++ b/tests/tcg/s390x/cdsg.c @@ -0,0 +1,93 @@ +/* + * Test CDSG instruction. + * + * Increment the first half of aligned_quadword by 1, and the second half by 2 + * from 2 threads. Verify that the result is consistent. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include + +static volatile bool start; +typedef unsigned long aligned_quadword[2] __attribute__((__aligned__(16))); +static aligned_quadword val; +static const int n_iterations = 1000000; + +static inline int cdsg(unsigned long *orig0, unsigned long *orig1, + unsigned long new0, unsigned long new1, + aligned_quadword *mem) +{ + register unsigned long r0 asm("r0"); + register unsigned long r1 asm("r1"); + register unsigned long r2 asm("r2"); + register unsigned long r3 asm("r3"); + int cc; + + r0 = *orig0; + r1 = *orig1; + r2 = new0; + r3 = new1; + asm("cdsg %[r0],%[r2],%[db2]\n" + "ipm %[cc]" + : [r0] "+r" (r0) + , [r1] "+r" (r1) + , [db2] "+m" (*mem) + , [cc] "=r" (cc) + : [r2] "r" (r2) + , [r3] "r" (r3) + : "cc"); + *orig0 = r0; + *orig1 = r1; + + return (cc >> 28) & 3; +} + +void *cdsg_loop(void *arg) +{ + unsigned long orig0, orig1, new0, new1; + int cc; + int i; + + while (!start) { + } + + orig0 = val[0]; + orig1 = val[1]; + for (i = 0; i < n_iterations;) { + new0 = orig0 + 1; + new1 = orig1 + 2; + + cc = cdsg(&orig0, &orig1, new0, new1, &val); + + if (cc == 0) { + orig0 = new0; + orig1 = new1; + i++; + } else { + assert(cc == 1); + } + } + + return NULL; +} + +int main(void) +{ + pthread_t thread; + int ret; + + ret = pthread_create(&thread, NULL, cdsg_loop, NULL); + assert(ret == 0); + start = true; + cdsg_loop(NULL); + ret = pthread_join(thread, NULL); + assert(ret == 0); + + assert(val[0] == n_iterations * 2); + assert(val[1] == n_iterations * 4); + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 1d454270c0..72ad309b27 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -27,6 +27,10 @@ TESTS+=noexec TESTS+=div TESTS+=clst TESTS+=long-double +TESTS+=cdsg + +cdsg: CFLAGS+=-pthread +cdsg: LDFLAGS+=-pthread Z13_TESTS=vistr $(Z13_TESTS): CFLAGS+=-march=z13 -O2