From nobody Tue Feb 10 05:46:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552409018936847.3070835043919; Tue, 12 Mar 2019 09:43:38 -0700 (PDT) Received: from localhost ([127.0.0.1]:55627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3kV4-0001EY-M3 for importer@patchew.org; Tue, 12 Mar 2019 12:43:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3ju9-0002dp-72 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 12:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3ju2-000382-8P for qemu-devel@nongnu.org; Tue, 12 Mar 2019 12:05:25 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:35469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3ju1-00033z-HD for qemu-devel@nongnu.org; Tue, 12 Mar 2019 12:05:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id t18so3337051wrx.2 for ; Tue, 12 Mar 2019 09:05:13 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d2sm10586222wrq.94.2019.03.12.09.05.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 09:05:09 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AC2501FF9D; Tue, 12 Mar 2019 15:59:48 +0000 (UTC) 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=IT6IQrPa2AyFdTkPjqWXoE9OsPUlkc9GeYuoBKZPqBs=; b=uxyALgzf4h8ixSlSNmDep3ptoWYsTJ9WL3PqVQl5g++PYvw8Aru+au/PVVQLmXpih/ LZIftnMEvpaeS8lzPD9iSTab1DAERSfa30w263KUCwN50kA6VEkdUVPnrw/mGeR5yDuZ wb9a3/483z4mzpc3qqVH5g+tZyas2ZIYhKy8M7zeZ1x4hrSVEkmAxfFxl6EuDrOsvhby srIOhJ0tUiyoV8w2mc5svF9ke1ae3ljZX2R7JykUeWXIpOK5XYmdQbeIWKPlEh5D3Bwk xcuOSTKSm5y7wJlyIOQDzaNoYFWuBbizbOhUsNDe0rc8of+gYNhpxlHr4Bsph8ttZk75 oY0A== 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=IT6IQrPa2AyFdTkPjqWXoE9OsPUlkc9GeYuoBKZPqBs=; b=ocSCJ+wjlEvrvMarcmSScXghr25IkBjOy3L68rCh32UY4o//utqVFQKp7uTk8h6lDd L5mXVxpKgnGEqXmk97mYgIo90GeNzK2sqiH/l1rLOm8uQ+pAhVeruvFT59pLjvEojWuv tlPtK9MidTso3PPDm7m3jE5sb9DP7zJQmMQExd63IA8UlM898C1fkhEp58f4ZdzRpv8g MslUwffbp/SPzG6zFfPr9ACFcj/xA2HSbQiOK4I6gtKnXITXzHBP6fzF4pR5uc4RR+ZG zk3cgfwanzPXOy3ovretS7ZHXFEW5C7DfpnCbTNAJRQ9NZLMdxphOnJ+b2Rxdq3Vy8Yw oqkw== X-Gm-Message-State: APjAAAWF/EHHqwaAWjWx3UqcVKd9zWf7q/SEtV56/F5M1YVaigetcVB1 1V+q7yBANQdjRlqWZOWmqnEaDA== X-Google-Smtp-Source: APXvYqz1C+yn7pNdWMY7CcXmB0sIn9ZV7C/SoyxvzTD0vhcHPZRcnr2LhBunQcHejlhsa4X4qgI27Q== X-Received: by 2002:adf:fd46:: with SMTP id h6mr23979252wrs.170.1552406712064; Tue, 12 Mar 2019 09:05:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 15:59:45 +0000 Message-Id: <20190312155947.14918-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312155947.14918-1-alex.bennee@linaro.org> References: <20190312155947.14918-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 Subject: [Qemu-devel] [PATCH v4 19/21] tests/tcg/arm: account for pauth randomness 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, famz@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, agraf@suse.de, cota@braap.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Pointer authentication isn't guaranteed to always detect a clash between different keys. Take this into account in the test by running several times and checking the percentage hit rate of the test. Cc: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/aarch64/pauth-1.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c index ae6dc05c2b..a3c1443cd0 100644 --- a/tests/tcg/aarch64/pauth-1.c +++ b/tests/tcg/aarch64/pauth-1.c @@ -1,5 +1,6 @@ #include #include +#include =20 asm(".arch armv8.4-a"); =20 @@ -8,16 +9,29 @@ asm(".arch armv8.4-a"); #define PR_PAC_APDAKEY (1 << 2) #endif =20 +#define TESTS 1000 + int main() { - int x; + int x, i, count =3D 0; void *p0 =3D &x, *p1, *p2; + float perc; + + for (i =3D 0; i < TESTS; i++) { + asm volatile("pacdza %0" : "=3Dr"(p1) : "0"(p0)); + prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0); + asm volatile("pacdza %0" : "=3Dr"(p2) : "0"(p0)); =20 - asm volatile("pacdza %0" : "=3Dr"(p1) : "0"(p0)); - prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0); - asm volatile("pacdza %0" : "=3Dr"(p2) : "0"(p0)); + if (p1 !=3D p0) { + count++; + } + if (p1 !=3D p2) { + count++; + } + } =20 - assert(p1 !=3D p0); - assert(p1 !=3D p2); + perc =3D (float) count / (float) (TESTS * 2); + printf("Ptr Check: %0.2f%%", perc * 100.0); + assert(perc > 0.95); return 0; } --=20 2.20.1