From patchwork Mon Feb 11 23:52:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158055 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3214859jaa; Mon, 11 Feb 2019 16:13:25 -0800 (PST) X-Google-Smtp-Source: AHgI3Iax0QToK/YHkS6n9DEYxpyu+fKUuV8Xw0UDYvnyGb8MLDt4691FKfk6Q5k6BhTC+ar77th+ X-Received: by 2002:a81:a355:: with SMTP id a82mr647313ywh.445.1549930405316; Mon, 11 Feb 2019 16:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549930405; cv=none; d=google.com; s=arc-20160816; b=KhkZdvLWMV5SZLuPCEpUGeWHfAsrh4jkubqLgByzGILVvJH4PVr1FRqITPIe7iAUB2 qCF3exCtt1gTchXuXlDu3EyaOJJdUx0AxJdV1V0UWSHTnDjmPvery074JEDU4AzY4Sgp MOvjpPtKOuMo2hcy54z8NNyWa4ZchVoJdqjUpGIaguckI3XOjx0TpWpGipdHK8OqiFIc mdzSgGmAahQ2StupkIawFYW8F7Tg0PaKZZUN5/yT313/lqvJuJljjoq4F0NQ9rGKKZVh KX9qxuRzHnWkkAONCuqI2vAQfZyckWaXGZ3/AKvK44UgS3flG8+z/QWbeXk1v1IE5Dgc uQ4Q== 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=D7zmCCEx4gtvzG1BwOiqP1rjcgbsuS/cyN2XMLs4c+Y=; b=wPFl+l1nSdfPeCWs16zn6+AgJH0Rc11Dxr38ZaIei8Fdt7s3Vy2yR3iwJQfj3oTEby iHY57mAihKvHUXNLzUbFbofiaTEGjgXbkwDioIHOBV61yqI2WkN2fumrt0y5x4j9eEQt RM3bBabD3sC4hXSSurydm4T25fdYUpKiQAGSJgJgVrWrfQHsrU03qXlKD/kin52qlTBg RxjUlWqw8gcXme0Vx4U/Glv3wfeXCdJr0zfDdOrJciOvny0pcLbpagQbCrfACurvAgzj TcdqQPv48r24nJF25k0dqqXuDvgsBdBFH08zepuuXFestSii0RUHZ3jOzheJFUb3s/S2 f/Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pgI8ttDa; 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 g123si6932822ywf.49.2019.02.11.16.13.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Feb 2019 16:13:25 -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=pgI8ttDa; 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]:58445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLhU-0003K2-Oi for patch@linaro.org; Mon, 11 Feb 2019 19:13:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLOj-0005to-5I for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:54:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtLOg-00053o-9p for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:54:00 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtLOf-0004kz-Ly for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:53:58 -0500 Received: by mail-pf1-x444.google.com with SMTP id z9so344965pfi.2 for ; Mon, 11 Feb 2019 15:53:39 -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=D7zmCCEx4gtvzG1BwOiqP1rjcgbsuS/cyN2XMLs4c+Y=; b=pgI8ttDajKS8JdLT5zP8lwNM99faP9uZ1tmJloLqdevbf17VZribCRNhvQEzHvSUrK FXIkhg5A7/eyj6+Vk7qZ/YvcUx/hwEEFkD6Du1re4JjZWNh2VaeQf/2O1IzZp+OCNMcn wNyo6AKgdBMyd8CQmzzMc4IMzxuHGFtaIXBaYEek94et2Y18yNKwfTH59AdMehqQ3s/L LnhysVhxbYEff0elORLV56DF4+33hdNvKlbzdJa8BV6wK7GoDprNctp9zcQo8nSOk100 idDVhTgCdjqf9tAAC/eszmIGnEDdfrEb47mY4YYypqnJtOh3peU6E3BviII3U8yCwMhL AnNw== 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=D7zmCCEx4gtvzG1BwOiqP1rjcgbsuS/cyN2XMLs4c+Y=; b=qGTwkP8vspnDXfKLuW9asqQFKvmZF5MZZoUvFNQ3nTtEugaSY9eT3dKSPDdMoktiEh lKiijdDwh20ouZ2pglTNUUh/NM4xVbfk/PGbe15KfgPbCMOr+6MzdwQqNgw/AzR7s31r wbqs+SSMapjB/rV2dVeY11YIHqStErBKTN5d+Ncz1ekaI9ryrb6tItfaEMsr+0ggTMnj r1dK58PPk5wCCamOvaRSh/m4yKM7OQVeXlXauHWoIuuD6W+SiPMoL3brq/Cflj4tWM7j ms6Ys7CiyR+X7VCvUtuygPBVlvKwnWa5Tv3kSvUK3ngblhBFiHvVE0MoXH5tsHfAw2Xa LxWQ== X-Gm-Message-State: AHQUAuaC8bC6q8gx9P/3T8xZnDG8dckx/cqXN3LnveeN02HkwxXzzKfe tUMCT759Y/uFc/BHNnwFNee+Ny9woFw= X-Received: by 2002:a63:5402:: with SMTP id i2mr805772pgb.79.1549929218052; Mon, 11 Feb 2019 15:53:38 -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 c4sm11861031pgq.85.2019.02.11.15.53.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 15:53:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 15:52:58 -0800 Message-Id: <20190211235258.542-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190211235258.542-1-richard.henderson@linaro.org> References: <20190211235258.542-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::444 Subject: [Qemu-devel] [PATCH v3 28/28] 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..18bfb1120f --- /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, [%0]" : : "r"(p1)); + asm("ldg %0, [%1]" : "=r"(p2) : "r"(p0), "0"(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..2991b7df69 --- /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, [%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)