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: 1040273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pgI8ttDa"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43z33l3jlKz9s4Z for ; Tue, 12 Feb 2019 11:11:31 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLfd-0002Ao-CW for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2019 19:11:29 -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-Google-Smtp-Source: AHgI3IaOGFAwPxZP+HikwoWg69Dyakm6rieiC0cquW3DV4Gi8hjACPOV/8ihZkTBeYgE5CEgUTOuLg== 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+incoming=patchwork.ozlabs.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 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)