From patchwork Wed Feb 26 07:39:29 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: 1244751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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.a=rsa-sha256 header.s=google header.b=LBVn+11j; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48S7Fc03THz9sPR for ; Wed, 26 Feb 2020 18:48:04 +1100 (AEDT) Received: from localhost ([::1]:39456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6rQH-00065M-Sa for incoming@patchwork.ozlabs.org; Wed, 26 Feb 2020 02:48:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6rO6-0003Xa-2O for qemu-devel@nongnu.org; Wed, 26 Feb 2020 02:45:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6rO4-0005fz-Oa for qemu-devel@nongnu.org; Wed, 26 Feb 2020 02:45:45 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6rO4-0005dJ-Aq for qemu-devel@nongnu.org; Wed, 26 Feb 2020 02:45:44 -0500 Received: by mail-wm1-x336.google.com with SMTP id a9so1862962wmj.3 for ; Tue, 25 Feb 2020 23:45:43 -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=4olBGu/IQFOKY78lHg02hbFiHdwwHtqSc/rf9v7sw/0=; b=LBVn+11jSt/rgqati9jKTTkr+6S6qLVA4H5fnfVOnjokVuQZPXWAhTLO4oRm/mGfUB F9BNoEuzPV8qa26U6/sarOUpz2MOo9QljYkU6aGKhUrBOXSV/m+bmmK8oIyP9Z3wshdG Jf3Z5mOChQ6VHsRvGREYGNnXTpHaWdRl1UG/g5QIIHJ0daPtYwojuuR++55ccfQveDiI 1pJwGyx+ntpNhkRM0fjwBy4uTTgT30iasv4smU6UVuZojmKfMeaVSOYxXhN4LIhOKdjV jYx+liz3bQyU4w1svUNY2QHhH7+YQFcdV8QoSJKQFwZ4UYo/SWRgoBeiWCB+aQli48O6 q+Ag== 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=4olBGu/IQFOKY78lHg02hbFiHdwwHtqSc/rf9v7sw/0=; b=r9R1mwNSHz+xgVdY1tfFs4x8EHJqtWlMYhunQof0dNU4NfgLOH6cDJJ9yebr2LvODC c3ja5s3JIE8nCGAqIAQKmk+J9qsnwgcf5rdZdyE08B22cFmtZ5hd/vxH54VkkKIVmXHJ c3yjDXIr/c5NTKfegX0ZEIcXZDhUzWZCHZrIO8PnqymiiSC9Dt9CsxONip5aBNAVP/wu gFzIiiJBSXsCHDW4bu8Pc75rc2UQyvkWYkfwsGb8al+y5lGMAYTgzlyvivNpCPDcQJ4+ QtTgSva8CsAgwHebmMW0SYi8SOtDXOXIkNF+umwcC1fuGWjnkg1mu7CJW0gFu3rtKJ+z yh8A== X-Gm-Message-State: APjAAAUIeDRNDJywJ6MJ7o+ekBQzqPeEGwHWyWI8iKViFv5bBVS+uAq7 iW39CHt7pfW9qc3EoHD/CE6bcA== X-Google-Smtp-Source: APXvYqzsBiOTFMqVaBFBeJyN8XdkU8Fj1PwwPds0hw5RBZuCpfFVM9/Z5Q8fAidZTPGE0nwdgq3IpQ== X-Received: by 2002:a7b:c3cd:: with SMTP id t13mr3824115wmj.88.1582703142994; Tue, 25 Feb 2020 23:45:42 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b21sm1797732wmd.37.2020.02.25.23.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 23:45:40 -0800 (PST) Received: from zen.home.arpa (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E6B5C1FFAA; Wed, 26 Feb 2020 07:39:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 19/19] tests/tcg: take into account expected clashes pauth-4 Date: Wed, 26 Feb 2020 07:39:29 +0000 Message-Id: <20200226073929.28237-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200226073929.28237-1-alex.bennee@linaro.org> References: <20200226073929.28237-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::336 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: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Robert Foley Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 we work through a bunch of different addresses. Signed-off-by: Alex Bennée Reviewed-by: Robert Foley Reviewed-by: Richard Henderson Message-Id: <20200225124710.14152-20-alex.bennee@linaro.org> 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; }