From patchwork Mon Feb 11 01:08:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 157946 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2059396jaa; Sun, 10 Feb 2019 17:15:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IZz6dqByGyLoRDB54p5LSwO28WhYb+LByIenO9vVm4gLYTBzqUOd7vXlSos6tjdx+D68TY7 X-Received: by 2002:adf:bc87:: with SMTP id g7mr24813163wrh.250.1549847740611; Sun, 10 Feb 2019 17:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549847740; cv=none; d=google.com; s=arc-20160816; b=0cQvJaI6oc/4fbYs+VC6LRTSY6N1oSViaCcdsaBIzItK6n2YFhC0zQk30v0eD8gUbx LOHFK+vchsvovaSvRP37yOGicuN2gqHtEmy2ubwx9Bt/RJDVhaBBMq1VdnVDPUaW6XML w+biBYWO6lr1dD0PlTVbBGvHqvmx7N/pJdr4GSZ0xnbafkRj9LjpRz3JkYFxkl5XPrsF k73fSSuyywDO743/rmO/zK7ueSgsjOI67DMjyjDoEMEiLh2D0qlDg84QYPgyEzl1a3ym BsC3tDEgJp3EWQWxWDc3y8uVHwVA9nQ4Ar8krUsMFogoshF7dcKzCP5L2R/MpNjY8D30 2l8g== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=UEnsVDtpBAmvsaSmrhCYvPqLmi/uP/YwCQYnlJNxoOc=; b=kVP5lcWxnZhqSI/p1UB0jmIQ0klc484B3t7qsoaUn59hTOLnHEjEB86rSC24kZI7mT hFeojXpoonqMrAz4XSntWmKN2JMuKby1kRL4kNEr4++puKZg1b73mM3z6t0BEo5Dqegf 9uQiag60Ly5OVBZIBWl9tk5w5ZRgv3bh7jEqSlQtK+ZMOIC9wSDz6E2Y1hYZSBBOOfnk ZZQSJJkX3/zMCGCJHjUSjONvKrGo35tsWnTItnYF+1RtBiLCsvAH0CmFedSKA98ymx2N YmKRUnECiUQJZOWycd4Bjylxxsdp4i+pKBuXeOCcXWoudU46ObtNni1+z+b+z1v2Ovrw 958A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bOaQpOpN; 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=fail (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 b193si3220901wme.47.2019.02.10.17.15.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Feb 2019 17:15:40 -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=fail header.i=@linaro.org header.s=google header.b=bOaQpOpN; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:42135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt0CB-0001nJ-Du for patch@linaro.org; Sun, 10 Feb 2019 20:15:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt05w-0005xT-8k for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gt05t-0000Bj-AV for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:12 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:42318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gt05s-0008WK-Tl for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:09 -0500 Received: by mail-pl1-x644.google.com with SMTP id s1so4492707plp.9 for ; Sun, 10 Feb 2019 17:09:06 -0800 (PST) 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; bh=UEnsVDtpBAmvsaSmrhCYvPqLmi/uP/YwCQYnlJNxoOc=; b=bOaQpOpNLY6zcJiw82mU4pcKXm3v94s4AVXRxplmL80v+w2cmLm/kprM+UOvezfQyf IO4KOzg6HBnabCIW5HpxVAFb9W0/hchMeX/c8ceyk8WCaNSCvs2iuiwdtibAMrcE2NNP qPtC6zCyGCHHxjAzxYFVUU7VzcQjFv4cNNFyL81MfHBwxZLRBOscilwvSEaP/dliFY90 yaHT1qJmBA7SHdpjM1pcmAA4N1Jk7PU53Y+fsGfQk1FlUuM4hGHp4vuNauqq49Kimpsd Phfhy4en2E/KHPnUWK5Lb+h3bcWFIo7+OvOl6nBJXju9E3aSEvRv7NGnjJASpIN+C6X2 q+xg== 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; bh=UEnsVDtpBAmvsaSmrhCYvPqLmi/uP/YwCQYnlJNxoOc=; b=OHS9Vn/UCGx1FFri2Ce/CebRHYSQqGNElkR6X4UDxSiL39IGVAUSKJE4wKGhW7XSCU sKTuvYJPkC4sW0cULXyiDFZNPZIqSUTFCs8QfzXhhnYRJFTjjHfY3zZDVJc76spe4HIS SX3YiiuWaXKf/F4G7H4fKVf516zzY3S/Gj3q/VidIHIgYKOI5SWxDQNG7DInxT0CEn4Y ehEOW+w/hLH7NMrQz7gfSKXfk/fR0I3NHGPLqc8waZFkx50XtnWz7JakfwFdEUZ1Hfg1 uZZYtIgs8IVJGW1PXlP27D0yyzrr4hA6dErM3ViD5noJXCWmn0s36Tw6+MbTkULni/HG mbeQ== X-Gm-Message-State: AHQUAuaCeWqvmw276Qo8CLyMwwXQD7THGNhwAS2XSmTq1BxjCpf6VcB1 dvAMYM96cROAqQrteC4/5xuE3kxP4x8= X-Received: by 2002:a17:902:e090:: with SMTP id cb16mr20567890plb.32.1549847345484; Sun, 10 Feb 2019 17:09:05 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id g14sm17177630pfg.27.2019.02.10.17.09.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Feb 2019 17:09:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 10 Feb 2019 17:08:29 -0800 Message-Id: <20190211010829.29869-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190211010829.29869-1-richard.henderson@linaro.org> References: <20190211010829.29869-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 26/26] tests/tcg/aarch64: Add mte smoke tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tests/tcg/aarch64/mte-1.c | 27 +++++++++++++++++++++ tests/tcg/aarch64/mte-2.c | 39 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 4 ++++ 3 files changed, 70 insertions(+) create mode 100644 tests/tcg/aarch64/mte-1.c create mode 100644 tests/tcg/aarch64/mte-2.c -- 2.17.2 diff --git a/tests/tcg/aarch64/mte-1.c b/tests/tcg/aarch64/mte-1.c new file mode 100644 index 0000000000..740bf506f1 --- /dev/null +++ b/tests/tcg/aarch64/mte-1.c @@ -0,0 +1,27 @@ +/* + * Memory tagging, basic pass cases. + */ + +#include + +asm(".arch armv8.5-a+memtag"); + +int data[16 / sizeof(int)] __attribute__((aligned(16))); + +int main(int ac, char **av) +{ + int *p0 = data; + int *p1, *p2; + long c; + + asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(1)); + assert(p1 != p0); + asm("subp %0,%1,%2" : "=r"(c) : "r"(p0), "r"(p1)); + assert(c == 0); + + asm("stg [%0]" : : "r"(p1)); + asm("ldg %0, [%1]" : "=r"(p2) : "r"(p0)); + assert(p1 == p2); + + return 0; +} diff --git a/tests/tcg/aarch64/mte-2.c b/tests/tcg/aarch64/mte-2.c new file mode 100644 index 0000000000..4d2004ab41 --- /dev/null +++ b/tests/tcg/aarch64/mte-2.c @@ -0,0 +1,39 @@ +/* + * Memory tagging, basic fail cases. + */ + +#include +#include +#include + +asm(".arch armv8.5-a+memtag"); + +int data[16 / sizeof(int)] __attribute__((aligned(16))); + +void pass(int sig) +{ + exit(0); +} + +int main(int ac, char **av) +{ + int *p0 = data; + int *p1, *p2; + long excl = 1; + + /* Create two differently tagged pointers. */ + asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl)); + asm("gmi %0,%1,%0" : "+r"(excl) : "r" (p1)); + assert(excl != 1); + asm("irg %0,%1,%2" : "=r"(p2) : "r"(p0), "r"(excl)); + assert(p1 != p2); + + /* Store the tag from the first pointer. */ + asm("stg [%0]" : : "r"(p1)); + + *p1 = 0; + signal(SIGSEGV, pass); + *p2 = 0; + + assert(0); +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 55420aeea6..614dfcd14d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -22,4 +22,8 @@ AARCH64_TESTS += bti-1 bti-1: LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib run-bti-1: QEMU += -cpu max,x-guarded-pages=on +AARCH64_TESTS += mte-1 mte-2 +mte-%: CFLAGS += -O -g +run-mte-%: QEMU += -cpu max,x-tagged-pages=on + TESTS:=$(AARCH64_TESTS)