From patchwork Wed Dec 15 10:40:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 524273 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp248711imb; Wed, 15 Dec 2021 03:36:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsuxCbdW7WoqbNPSafOmQocz367yxnkSgXSX63OATDPf7JZLScZD+GneC8sgIg51mM4CXs X-Received: by 2002:a25:cd47:: with SMTP id d68mr5619280ybf.537.1639568217365; Wed, 15 Dec 2021 03:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639568217; cv=none; d=google.com; s=arc-20160816; b=RLpNveh0Wkkcko0kq/YbJ4JeZmzeIuq7p/cOM9NKbf3C6rqcj85NrgyUYfkdQGSb0A wSjGnum8Crf/8+4qRivaLu0KW1P+nU3KyjxS2I6zji3LtFX8+VF95IXlQ5xv5Srayo4Y zPtCImPI4dR5BIZsyBSbQqswlyOrZT96Oho1zZjEsPzQDiHytZ2amMOocRpXSytm6s/M 0HyXBzpLsnSjuH6EX4k94zdgm7/OnXXfmUMJcyiSmvlOCUKqwpYYPmuMa9wiodV4d9Rq l0xJJTC0smNIC8NyEcX5sNkq++wTDFT3ORch3cDNLIDvjuEy6HtQlRgavRj0udZRYXh/ mKdA== 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=zsiqwW/bbQhFQjNkeayyIckoQIXuNagLEjNtbn8AkMM=; b=mhRciy4tVSSKASm0IfYc8LfMfTHBbovtpZjinYfAV9zv9KYHxNxag1+rrk54PsUJSE T0HW230mw27Bjeky1bAznBR/cXECEeFKFzLUj745EPDOPmQM6UkxbvljZouVK7LfAdzt e52ZTbZo1rvcM9DTSlhTho6vXHzwQI3QJ95AcSYbf7mNX414uXgCZOgHJLhuejECswd3 LIQ6K8DEVMklu/emloIXseVOZHCPrJk0zGCPkJOWsh4DP8e2w/SqpAeflOAjCFMRjtTq wU0ec8r9P3hwLBCYf5F9TKWotvicyNDwU0Et7aHkx2GX/9b9xvJ6CHtgkZdMlC15aSV7 E/eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VCWs+ANi; 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 j189si1647207ybb.719.2021.12.15.03.36.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Dec 2021 03:36: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=VCWs+ANi; 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]:47830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxSae-0001Xs-OX for patch@linaro.org; Wed, 15 Dec 2021 06:36:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxRid-00074h-P9 for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:07 -0500 Received: from [2a00:1450:4864:20::433] (port=37640 helo=mail-wr1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxRiY-0008S9-Cg for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:07 -0500 Received: by mail-wr1-x433.google.com with SMTP id t26so1056856wrb.4 for ; Wed, 15 Dec 2021 02:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zsiqwW/bbQhFQjNkeayyIckoQIXuNagLEjNtbn8AkMM=; b=VCWs+ANiK1Lp97KbWW2Tg5HZMfN5+/xylzcP1Dck06X0vtj1WJOOpevKVlrm/bHPXs 13Dzju8Mcsof8jzsudQtLYOUAYH/3cYhMOe6J5ZnXRKlZo1OdLh+qaDNLK/WXIexCEru LRggRl0HXiSRpUCW4uCl3OyT7UwRLN9K2l61xA29twT2AHabns9+dLAM2EkU6nkEZwQV qtOywAkbwmza+uIKIpFMozf+3Ixd9A+IU9Ike1zpKFvQoMwUBGaceieNB7LDX8XI9nBl 8rChqXExnHARBbpDfkSdIU6sQpR9OHPuKqDJt08W9IpBlIroBKuiMYW7Z9TbHw0GzLWu npfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zsiqwW/bbQhFQjNkeayyIckoQIXuNagLEjNtbn8AkMM=; b=RjKGxvkPeUZipj7qTOLCiSWjSAtWOjuAPnzimZhZeaVTDIlb2CRvbJYKYcF2WBrh+O czmiSlIQ85+n8eO9xvhk753eMvC9i2ItJ0Lek6hHvR4uOOiOdnkm6eRacgTMzQSQaUFU 2QoVUdX5UbHJbJ+rAxXkwGsBuNs1SmqU47upIOC0WOjimzdjEf1rVVer+RB1Ag5SjQuf 72Wn3eVC4nWHi9+kD0tModquUxCz3E+B/rz0G3gymreJarLGG8vTQYBS/NyDiAh8UxZq r3nm7Bl/npyDlKEye2ulSSl1cV2DAT47X1B/ZlbcLgHisV0MuD+dZRBTKIeg6bpeEEvg wIdg== X-Gm-Message-State: AOAM532URONkmeu3yAzbLzldpoz2opLEKfRO8HSfZ7DlgbXdIDBLwqZQ 87kIUA0YmB4tXLfVlC2GcqlH0vxAWunsuQ== X-Received: by 2002:adf:a48e:: with SMTP id g14mr3753616wrb.474.1639564861077; Wed, 15 Dec 2021 02:41:01 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e18sm1600815wrs.48.2021.12.15.02.41.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 02:41:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/33] tests/tcg: Add arm and aarch64 pc alignment tests Date: Wed, 15 Dec 2021 10:40:34 +0000 Message-Id: <20211215104049.2030475-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215104049.2030475-1-peter.maydell@linaro.org> References: <20211215104049.2030475-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::433 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" From: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- tests/tcg/aarch64/pcalign-a64.c | 37 +++++++++++++++++++++++++ tests/tcg/arm/pcalign-a32.c | 46 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 4 +-- tests/tcg/arm/Makefile.target | 4 +++ 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/aarch64/pcalign-a64.c create mode 100644 tests/tcg/arm/pcalign-a32.c diff --git a/tests/tcg/aarch64/pcalign-a64.c b/tests/tcg/aarch64/pcalign-a64.c new file mode 100644 index 00000000000..6b9277f919f --- /dev/null +++ b/tests/tcg/aarch64/pcalign-a64.c @@ -0,0 +1,37 @@ +/* Test PC misalignment exception */ + +#include +#include +#include +#include + +static void *expected; + +static void sigbus(int sig, siginfo_t *info, void *vuc) +{ + assert(info->si_code == BUS_ADRALN); + assert(info->si_addr == expected); + exit(EXIT_SUCCESS); +} + +int main() +{ + void *tmp; + + struct sigaction sa = { + .sa_sigaction = sigbus, + .sa_flags = SA_SIGINFO + }; + + if (sigaction(SIGBUS, &sa, NULL) < 0) { + perror("sigaction"); + return EXIT_FAILURE; + } + + asm volatile("adr %0, 1f + 1\n\t" + "str %0, %1\n\t" + "br %0\n" + "1:" + : "=&r"(tmp), "=m"(expected)); + abort(); +} diff --git a/tests/tcg/arm/pcalign-a32.c b/tests/tcg/arm/pcalign-a32.c new file mode 100644 index 00000000000..3c9c8cc97b1 --- /dev/null +++ b/tests/tcg/arm/pcalign-a32.c @@ -0,0 +1,46 @@ +/* Test PC misalignment exception */ + +#ifdef __thumb__ +#error "This test must be compiled for ARM" +#endif + +#include +#include +#include +#include + +static void *expected; + +static void sigbus(int sig, siginfo_t *info, void *vuc) +{ + assert(info->si_code == BUS_ADRALN); + assert(info->si_addr == expected); + exit(EXIT_SUCCESS); +} + +int main() +{ + void *tmp; + + struct sigaction sa = { + .sa_sigaction = sigbus, + .sa_flags = SA_SIGINFO + }; + + if (sigaction(SIGBUS, &sa, NULL) < 0) { + perror("sigaction"); + return EXIT_FAILURE; + } + + asm volatile("adr %0, 1f + 2\n\t" + "str %0, %1\n\t" + "bx %0\n" + "1:" + : "=&r"(tmp), "=m"(expected)); + + /* + * From v8, it is CONSTRAINED UNPREDICTABLE whether BXWritePC aligns + * the address or not. If so, we can legitimately fall through. + */ + return EXIT_SUCCESS; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 2c05c90d170..1d967901bd2 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -8,8 +8,8 @@ VPATH += $(ARM_SRC) AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 VPATH += $(AARCH64_SRC) -# Float-convert Tests -AARCH64_TESTS=fcvt +# Base architecture tests +AARCH64_TESTS=fcvt pcalign-a64 fcvt: LDFLAGS+=-lm diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 5ab59ed6ce1..f509d823d4f 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -29,6 +29,10 @@ run-fcvt: fcvt $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) +# PC alignment test +ARM_TESTS += pcalign-a32 +pcalign-a32: CFLAGS+=-marm + ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) # Semihosting smoke test for linux-user