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: 183904 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2794535ile; Tue, 25 Feb 2020 23:49:02 -0800 (PST) X-Google-Smtp-Source: APXvYqws6MZ3ihNKT1VuJEcLg9l3cWkQtY58P7wouYnG0doQlHhanY9kmvYYeyERfKo8ccLYWFYE X-Received: by 2002:a37:ad13:: with SMTP id f19mr3341436qkm.363.1582703342509; Tue, 25 Feb 2020 23:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582703342; cv=none; d=google.com; s=arc-20160816; b=nBGefPM7Kv8qbN0FNLT+Zw6Iqe4LxxC1A1vTs/ZNWUIP9O+WZqdkWlROBrzrzcezMI ExLauyRxLH+h3xn/Pz5Y8dUPSIOuyKbocHiz+xwxlT8JMn/O+YB7zIHMQPFn6GgP4nKr mxac0CRvjQXV9Rra43cYBTniCGXpCSM6uT4tBaY9XhU1Iu0prgszj0pApgwbdPO2bXDF z6pfuKVJ8yQGQERjl5OcMGQva9Qf6muj+0kQ1uUsdy7LCmRaPqZ7NN8jSKK0SKjJ5zFB 35gzOwz0XTP9wZs6HZF+plUNYtxVHoYKLCtkAKS1hAvr/55rwYQt6TSAuIwgj4LslAm2 Y3ag== 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=4olBGu/IQFOKY78lHg02hbFiHdwwHtqSc/rf9v7sw/0=; b=UER19tBYFmDzLJax/aMSXe0W7zWG0SsDRjKcK1DOV65dYWx35dIPgTuTmyN3V3IK3v 0I4NCYq1D/sTtY7tdEFU2HT9mlArf/KzJhF2R9KTz0nYX3RRm9jlBnWxvav6orGu6W4K ze6D2wbgv7AY65OvPaOraQLJ/39C5dvaULiU3q6pR6loBkXSeLDSGdHLUessSffKR2Gs n7cd+krMppHS9ZI07ughBRAaVUVG+SxOvkBKsDvMfgzRSgZ3TnioBQUJC3EQ6eLO8UFk tR5ium14ukMm269rZMDY3nsFE6SsJFs4ZG6eW9JnjSV+3ztDTxeitxIh5livIKZQwnnl yrbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LBVn+11j; 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 b16si703466qtr.155.2020.02.25.23.49.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 23:49:02 -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=LBVn+11j; 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]:39476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6rRG-0007xb-2j for patch@linaro.org; Wed, 26 Feb 2020 02:49:02 -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-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+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 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> -- 2.20.1 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; }