From patchwork Thu Feb 13 22:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 183449 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1093129ile; Thu, 13 Feb 2020 15:09:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyrHkKoftbsi4PsZD4SwP3eF0ONFXzHIe5EKNJfgJzXhvQSnAtFJ5SkTDFa36Ca+OWO7dib X-Received: by 2002:a0c:bd20:: with SMTP id m32mr13649267qvg.197.1581635343382; Thu, 13 Feb 2020 15:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581635343; cv=none; d=google.com; s=arc-20160816; b=qLNyJUDxljCr+cvXlMuTaZo16osL4Fg420VUDLtc23g5WEqRR0ORkrceaTNJH3zxy7 beIATyhCDqKFZp1fzLhbJCTDNZvPWiP9YKjhnAkk55MfmCK+7ZJ6N8Kum6d0lPeJdZBk qUlXPEZkIYb1+EytkYNDE0sU0QaNAZ55o0jGYkZpdvbXFOTPYveny3BcUk/5RyTzqAuk 0Cu/iH5AJ1XA+7G/SdOxjXkXF/B3G84NE7VtWz0XtkwjpP87xlJoLhhlmav5h68QCgKB 4Jh6UWKeRmNzs8k8W7j3o9rd4xsPgPrgsfDz8sE+OZocmgxbLlCFQITQw5XrxzVMwT/9 12TA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LM7CKlGDQQ+uKXRKtjMMvs0F+UsijFwZIGBIi2qQw/Q=; b=XtJQllGvVFvWFxNpxIo68feuA9gelmVKPafgjwSisQ8FjFGWmQbWdFstWE5TI6PoP7 OpQRUHP09IeWa0HjDH52yMuTKSgnAclcJVwCDJT5WHHPQClUIylBjHFu9a1jnmdBbWSS qdug6gs3ZoiwdRKM7rRuRkvldxeDqIm7KY9fZBjzA/tfscS7PuIvE+TK4ilJ1W3nBT07 8BZJzGG2SS/PZeYhXbvBmbea1RzA7N8u8l4OqQAm2n5P0oyEm7gtc3SITkUR7HV9cBt3 IgvmHX5ui0/Gnth7KO/uXpxL2T7GelX5AOgvx2Kuj6xw55cBbvz7yKpMd6QB0LCHO69A Ycpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qfVW2oUz; 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 x39si1857059qtj.125.2020.02.13.15.09.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2020 15:09:03 -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=qfVW2oUz; 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 ([::1]:60724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2NbR-0004N6-U2 for patch@linaro.org; Thu, 13 Feb 2020 18:09:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55494) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2NTZ-0002Y9-PR for qemu-devel@nongnu.org; Thu, 13 Feb 2020 18:00:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2NTY-0002cN-G8 for qemu-devel@nongnu.org; Thu, 13 Feb 2020 18:00:53 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:37339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2NTY-0002Yr-4n for qemu-devel@nongnu.org; Thu, 13 Feb 2020 18:00:52 -0500 Received: by mail-wm1-x331.google.com with SMTP id a6so8652046wme.2 for ; Thu, 13 Feb 2020 15:00:51 -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 :mime-version:content-transfer-encoding; bh=LM7CKlGDQQ+uKXRKtjMMvs0F+UsijFwZIGBIi2qQw/Q=; b=qfVW2oUzLqRug/aLV6Y9TNPG2a5TkiHjAHWnpxNSLz56sNjjDscu/WsAQp13sji8V9 E8bJAgsrTnpjozDWbzCw3VRopqX0xuCFlo8b3WjBSwAeLWcVrv4Fyj9yQfZVGA7ff3fu 9Cva+Df/8rx6xOwVq1uhrEm0dNbTXNqEJSX3Xy7DD8f5sUs8nWct3+lw5gbS/BqexWfQ n0BMedHsC8kx/asNpCshF5LLbv0XLaMEN73l1svNbY/0Bp2YF2gVFaGm3s9y4fHW9oNZ CyX03PUQoMm79c/MJFCZsWdC7E6IYTQlRiS44Ylm33CrHuQmlejAIDD4f1nu5IostMBH py/Q== 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:mime-version:content-transfer-encoding; bh=LM7CKlGDQQ+uKXRKtjMMvs0F+UsijFwZIGBIi2qQw/Q=; b=VwFZdl2k99zPE2ggOtt/JSgrokvwfNUtFpEpL+1fngdnAmcTELsYzzRDb2K9SUww7C TonHcudg60Yt4z5/FdWuA/l40YCgklt9J5ly0FdC9nw9M7LNS16SM+yCeXYDCpr7QZU1 E7a6SlLgF3EXWaW/qOexmKgcYPUh0o+1LQD/6YIyyQSlDwWcip2rB+p3rtx61CR2ppv2 pdui+BmjoJeQswF5oIyaTbgHUndb2G3LWfVVw8u6+uo8F0B/F9F+3kl/pOCHHgBE3VVw oGtUV9JDE5wKlQ8AqbTz24I02qSi/5Ncx+5HEIxRpbGnO9iD4vhIpTzQwLUNMfBiSW/j MUGQ== X-Gm-Message-State: APjAAAWgLTbScCgEcQrk4pp5KGaMXo55afRwXlwT69wKuRhUEu0dz/9F WbXo8r3aGraI52LbI0cwq2aVmg== X-Received: by 2002:a05:600c:214a:: with SMTP id v10mr358086wml.182.1581634850234; Thu, 13 Feb 2020 15:00:50 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g15sm4363854wro.65.2020.02.13.15.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 15:00:45 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4B08F1FFAA; Thu, 13 Feb 2020 22:51:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 19/19] tests/tcg: take into account expected clashes pauth-4 Date: Thu, 13 Feb 2020 22:51:09 +0000 Message-Id: <20200213225109.13120-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200213225109.13120-1-alex.bennee@linaro.org> References: <20200213225109.13120-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, Peter Maydell , berrange@redhat.com, robert.foley@linaro.org, pbonzini@redhat.com, stefanb@linux.vnet.ibm.com, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, marcandre.lureau@redhat.com, aaron@os.amperecomputing.com, cota@braap.org, stefanha@redhat.com, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, "open list:ARM TCG CPUs" , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Pointer authentication isn't perfect so measure the percentage of failed checks. As we want to vary the pointer that is authenticated we recurse down the stack. Signed-off-by: Alex Bennée --- tests/tcg/aarch64/pauth-4.c | 54 +++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 17 deletions(-) -- 2.20.1 Reviewed-by: Robert Foley Reviewed-by: Richard Henderson diff --git a/tests/tcg/aarch64/pauth-4.c b/tests/tcg/aarch64/pauth-4.c index 1040e92aec3..24a639e36ca 100644 --- a/tests/tcg/aarch64/pauth-4.c +++ b/tests/tcg/aarch64/pauth-4.c @@ -1,25 +1,45 @@ #include #include +#include +#include + +#define TESTS 1000 int main() { - uintptr_t x, y; + int i, count = 0; + float perc; + void *base = malloc(TESTS); + + for (i = 0; i < TESTS; i++) { + uintptr_t in, x, y; + + in = i + (uintptr_t) base; + + asm("mov %0, %[in]\n\t" + "pacia %0, sp\n\t" /* sigill if pauth not supported */ + "eor %0, %0, #4\n\t" /* corrupt single bit */ + "mov %1, %0\n\t" + "autia %1, sp\n\t" /* validate corrupted pointer */ + "xpaci %0\n\t" /* strip pac from corrupted pointer */ + : /* out */ "=r"(x), "=r"(y) + : /* in */ [in] "r" (in) + : /* clobbers */); - asm("mov %0, lr\n\t" - "pacia %0, sp\n\t" /* sigill if pauth not supported */ - "eor %0, %0, #4\n\t" /* corrupt single bit */ - "mov %1, %0\n\t" - "autia %1, sp\n\t" /* validate corrupted pointer */ - "xpaci %0\n\t" /* strip pac from corrupted pointer */ - : "=r"(x), "=r"(y)); + /* + * Once stripped, the corrupted pointer is of the form 0x0000...wxyz. + * We expect the autia to indicate failure, producing a pointer of the + * form 0x000e....wxyz. Use xpaci and != for the test, rather than + * extracting explicit bits from the top, because the location of the + * error code "e" depends on the configuration of virtual memory. + */ + if (x != y) { + count++; + } - /* - * Once stripped, the corrupted pointer is of the form 0x0000...wxyz. - * We expect the autia to indicate failure, producing a pointer of the - * form 0x000e....wxyz. Use xpaci and != for the test, rather than - * extracting explicit bits from the top, because the location of the - * error code "e" depends on the configuration of virtual memory. - */ - assert(x != y); - return 0; + } + perc = (float) count / (float) TESTS; + printf("Checks Passed: %0.2f%%", perc * 100.0); + assert(perc > 0.95); + return 0; }