From patchwork Tue Jun 6 09:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 689709 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp2540442wru; Tue, 6 Jun 2023 02:51:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BUus350I3AKMdnT4Kexjmxb2Wg+PpwtGbUktWFmxSPKLK0u5T8GgW6LPrSvFWgO/t23FF X-Received: by 2002:a05:620a:8c96:b0:75e:d0bf:5e4c with SMTP id ra22-20020a05620a8c9600b0075ed0bf5e4cmr665720qkn.16.1686045065351; Tue, 06 Jun 2023 02:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686045065; cv=none; d=google.com; s=arc-20160816; b=Ui0nK7arvF3ChsPXhx4D2CTWgZSeiHqiuUCKin9ZKyR6+qj/mMkXETvP0Ng7l+JWpD YZVX6svjPGFefysHPENlOY8J3Ha/XWixxduz5T+23z/QVoGR81EEcrdbQh3iurKBNOgh cAshkjbq/mrLuExCcT02U/6KCOBXYF+YXh9Ej+z9QxJ6ZvBfbB+lOlNdETdt/aCyu47a 1dt0qVZk8ufFwzAoGhAOXO/zj/9R3AApLXmgm4PQv1CF4IJTd57ZAyWDh9eyK5JoGd3o Z9O0twU2U2kYV7qqlJ1P/19Zt5DfUWXBsaEQIOFa0fRmxe8bTh+NFsH8P+xaAUPAwhOY B9uA== 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:to:from :dkim-signature; bh=xj/f+gH5uKmAixTu4UKEotEF3ZRZ6S/5RBdB+cJJN84=; b=ZtqRD4cLTfPA4KMzzjjt7zAKWu6jxCn2HobXN2+8HIMNihpeIMUiPTCSL5fDw3W0VM nenkzxBrokAdHXEA5WYvS4R9tRDBrp+YgW8k5+QnDRDeuW8xEZ5KCFcWru8rHS0IQxJx +HrWAZ/qiuUTEDyEmJva3Y9/pvH3MXjrkHyjb9O0cLTzbMWcprw1jzVwGezSF7OPN95A qYzIt6KTLYo0G16Vme9HXtCjTZv3+9D6B2r/eTtQucDH4eN9WeNwiIKGmtH8PWvpJZkD 8SCuLQHSSG+J6R2r6ascY+AfLGPhCa9vAIy6ijNS0IcvK88+x+1cIPHTAF5R6ZbiWW3c ZDSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bv0snAPD; 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 l18-20020ae9f012000000b0075c9b5d1a19si5514997qkg.548.2023.06.06.02.51.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jun 2023 02:51:05 -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=bv0snAPD; 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 1q6TJ1-0007s9-Cm; Tue, 06 Jun 2023 05:48:47 -0400 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 1q6TIu-0007ng-Pm for qemu-devel@nongnu.org; Tue, 06 Jun 2023 05:48:40 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6TIq-0004mT-Hl for qemu-devel@nongnu.org; Tue, 06 Jun 2023 05:48:40 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-30ae5f2ac94so5882792f8f.1 for ; Tue, 06 Jun 2023 02:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686044916; x=1688636916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xj/f+gH5uKmAixTu4UKEotEF3ZRZ6S/5RBdB+cJJN84=; b=bv0snAPDb8OAQUfPFCNaWIFM0G2bzAACs3uSnyp8afzDU1e82Lpp4lpCu9vTxnI6zL uG4WHn+i3++ZDA+iK+vIjLsixwZ/nOL7dUmJ1UIy8BIrRsw17oJjyjmmTcgQHEHt/z/C yIiF8Y7acwppXWv5k18BZBnl5ks0+zUpJ/5A94p3W+PKhWeyyCf6d5zMnMrJktPLCvPh RXnn6MavNJKsciVbbMDDYSXCl1Qpf7Lwnp9z+Te3lENgR4q66mNkhyjVAiZe412oZKyC RWax6ZL/yJsnyjkmOV1p30T5f6H6jIPikb5O/gOePAYCx7L3cep1hE2wJ/YI5kbytuEy oDAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686044916; x=1688636916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xj/f+gH5uKmAixTu4UKEotEF3ZRZ6S/5RBdB+cJJN84=; b=aKQiiozPX8emwXrhgehy2zwrlMKEbstERGOfq1OTLXJCN5aiL03FHy3ngfnBxUKlMA 7zDDLeK9dKioQG9bevwpOsC/dxnZsq9tCO7Y79Lv3phZGGU6QAOnMQspsw5G+s4I25WF wxQCmOnfccoKCIk2yCBqWqo9kOq7Kr8fFUgvTkCRTe+el2QukZAInekfC1By+RoQY0r7 JeIJBVwongh9tsTywVKVs+R2yGYIQ6cg0NtKN4T+lpZztiCQBOSqdDWIfpclnUpkkDqx bZKwMqS91mrdJxhiiFOf9zeq5EYtDFZ7I1oQdCdVHd2735IjaCg4iN59cOypwc7WFWtq dLVA== X-Gm-Message-State: AC+VfDxxI/jceDr0OCxNwJcsumS0MdmfSWBxUUQwl/Fzz2P99RQk8O7P tmiQhq2z9ZJqKDq9MPJvsxBwn6vYZqw1rrDtXM0= X-Received: by 2002:a5d:698f:0:b0:30a:f17e:e02e with SMTP id g15-20020a5d698f000000b0030af17ee02emr1523145wru.12.1686044915837; Tue, 06 Jun 2023 02:48:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v10-20020a5d4b0a000000b0030789698eebsm12134017wrq.89.2023.06.06.02.48.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:48:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 41/42] tests/tcg/aarch64: add DC CVA[D]P tests Date: Tue, 6 Jun 2023 10:48:13 +0100 Message-Id: <20230606094814.3581397-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230606094814.3581397-1-peter.maydell@linaro.org> References: <20230606094814.3581397-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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, 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: Zhuojia Shen Test execution of DC CVAP and DC CVADP instructions under user mode emulation. Signed-off-by: Zhuojia Shen Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- tests/tcg/aarch64/dcpodp.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/dcpop.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 11 ++++++ 3 files changed, 137 insertions(+) create mode 100644 tests/tcg/aarch64/dcpodp.c create mode 100644 tests/tcg/aarch64/dcpop.c diff --git a/tests/tcg/aarch64/dcpodp.c b/tests/tcg/aarch64/dcpodp.c new file mode 100644 index 00000000000..2cf7df2e073 --- /dev/null +++ b/tests/tcg/aarch64/dcpodp.c @@ -0,0 +1,63 @@ +/* + * Test execution of DC CVADP instruction. + * + * Copyright (c) 2023 Zhuojia Shen + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +#include +#include +#include +#include + +#ifndef HWCAP2_DCPODP +#define HWCAP2_DCPODP (1 << 0) +#endif + +bool should_fail = false; + +static void signal_handler(int sig, siginfo_t *si, void *data) +{ + ucontext_t *uc = (ucontext_t *)data; + + if (should_fail) { + uc->uc_mcontext.pc += 4; + } else { + exit(EXIT_FAILURE); + } +} + +static int do_dc_cvadp(void) +{ + struct sigaction sa = { + .sa_flags = SA_SIGINFO, + .sa_sigaction = signal_handler, + }; + + sigemptyset(&sa.sa_mask); + if (sigaction(SIGSEGV, &sa, NULL) < 0) { + perror("sigaction"); + return EXIT_FAILURE; + } + + asm volatile("dc cvadp, %0\n\t" :: "r"(&sa)); + + should_fail = true; + asm volatile("dc cvadp, %0\n\t" :: "r"(NULL)); + should_fail = false; + + return EXIT_SUCCESS; +} + +int main(void) +{ + if (getauxval(AT_HWCAP2) & HWCAP2_DCPODP) { + return do_dc_cvadp(); + } else { + printf("SKIP: no HWCAP2_DCPODP on this system\n"); + return EXIT_SUCCESS; + } +} diff --git a/tests/tcg/aarch64/dcpop.c b/tests/tcg/aarch64/dcpop.c new file mode 100644 index 00000000000..a332a804a41 --- /dev/null +++ b/tests/tcg/aarch64/dcpop.c @@ -0,0 +1,63 @@ +/* + * Test execution of DC CVAP instruction. + * + * Copyright (c) 2023 Zhuojia Shen + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +#include +#include +#include +#include + +#ifndef HWCAP_DCPOP +#define HWCAP_DCPOP (1 << 16) +#endif + +bool should_fail = false; + +static void signal_handler(int sig, siginfo_t *si, void *data) +{ + ucontext_t *uc = (ucontext_t *)data; + + if (should_fail) { + uc->uc_mcontext.pc += 4; + } else { + exit(EXIT_FAILURE); + } +} + +static int do_dc_cvap(void) +{ + struct sigaction sa = { + .sa_flags = SA_SIGINFO, + .sa_sigaction = signal_handler, + }; + + sigemptyset(&sa.sa_mask); + if (sigaction(SIGSEGV, &sa, NULL) < 0) { + perror("sigaction"); + return EXIT_FAILURE; + } + + asm volatile("dc cvap, %0\n\t" :: "r"(&sa)); + + should_fail = true; + asm volatile("dc cvap, %0\n\t" :: "r"(NULL)); + should_fail = false; + + return EXIT_SUCCESS; +} + +int main(void) +{ + if (getauxval(AT_HWCAP) & HWCAP_DCPOP) { + return do_dc_cvap(); + } else { + printf("SKIP: no HWCAP_DCPOP on this system\n"); + return EXIT_SUCCESS; + } +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 03157954871..3430fd3cd80 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -21,12 +21,23 @@ config-cc.mak: Makefile $(quiet-@)( \ $(call cc-option,-march=armv8.1-a+sve, CROSS_CC_HAS_SVE); \ $(call cc-option,-march=armv8.1-a+sve2, CROSS_CC_HAS_SVE2); \ + $(call cc-option,-march=armv8.2-a, CROSS_CC_HAS_ARMV8_2); \ $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \ + $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \ $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \ $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \ $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak -include config-cc.mak +ifneq ($(CROSS_CC_HAS_ARMV8_2),) +AARCH64_TESTS += dcpop +dcpop: CFLAGS += -march=armv8.2-a +endif +ifneq ($(CROSS_CC_HAS_ARMV8_5),) +AARCH64_TESTS += dcpodp +dcpodp: CFLAGS += -march=armv8.5-a +endif + # Pauth Tests ifneq ($(CROSS_CC_HAS_ARMV8_3),) AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5