From patchwork Thu Jan 16 23:08:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1224520 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=DHbB57yk; 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 47zKvH5KT6z9sRl for ; Fri, 17 Jan 2020 10:21:13 +1100 (AEDT) Received: from localhost ([::1]:49708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isERp-000488-Sp for incoming@patchwork.ozlabs.org; Thu, 16 Jan 2020 18:21:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51396) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEFV-0002fa-IK for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isEFU-000834-2y for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:25 -0500 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:54154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isEFT-00081v-SC for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:24 -0500 Received: by mail-pj1-x1043.google.com with SMTP id n96so2277576pjc.3 for ; Thu, 16 Jan 2020 15:08:20 -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=/Jxac41ScZ9wklqoaoJ1ujuvSIgK3pa8BvU4q8iE/qg=; b=DHbB57ykUvSpDmrZzJBQzelX/Q4mRPA0rkl9wlyr6Dbbn5Swd19bcjKOcquJO5bwMi EWZi4us5RfWM3PNg4C5hgS8l2j9x2LESi0HfNVIIDpzfaiqbEpGL+U6rCwH8DZ8LZhhZ VCkvemRaQd93b80ZS/f31nSZdwYb3OULptLLd4Zy/UEzNuc9/3olXCAsAT/Ghy3Y1+ek vjEcSxFYnbqRCMuTNMsQRUlL/vL4QDnGpsDJVN6G2tX4G6aVofuwWy4oVjq2Ev8exb5W yhyVXUdWLidb55BEf28JV/XMXYcp6YlufYxCWI6Gm9Y7aBpanha0hRxHgaa4gdmsKY48 ieCg== 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=/Jxac41ScZ9wklqoaoJ1ujuvSIgK3pa8BvU4q8iE/qg=; b=VPdo7bmUsFQutVKVE+ZjFH7gTX9jal81i7dMmJexyCMy9lTY/gjORarYOBxHtXhGd7 LaNH3yNZCWQdFcqACon9GE7tjoXbu7iLVqFYKLNpvBC4l89VMJrvwWcppJ2aP3Cug46i PA14GiKYIrWn8dZlt6eGJ9qlomdNbUfPbyTku6qimut3yjME/Oo4u6i9YNSSpRncXAdG om89lLb57HbJKJCa3yBEIIql4hs+chqK2lxMzYYqHOtFkpd1TvtMbUdCzQYMML9ixPO9 zXOmLMea+jWxBOSd+5qnJ5gWGYRPAHM+sJskoi/UzpDHoT9l5L9N2cSNtFg8HvZxWfO7 O39g== X-Gm-Message-State: APjAAAVQ6k4I29/CGyXKsJngaIC6X53u6Z99Bw92SeYVju+6tUQa/4yw IIIpgSHvAE4g99q9YLkB/SxQ04AUX5c= X-Google-Smtp-Source: APXvYqxenawD/zo7RWmeGAEuzpcNrQDUOQTMILLR2z+Zg/h+GrnMY0AumNfnwgJahG6Kt1f6i8aIcw== X-Received: by 2002:a17:90a:950b:: with SMTP id t11mr1987656pjo.79.1579216099560; Thu, 16 Jan 2020 15:08:19 -0800 (PST) Received: from cloudburst.ASUS (rrcs-66-91-136-155.west.biz.rr.com. [66.91.136.155]) by smtp.gmail.com with ESMTPSA id s7sm5111578pjk.22.2020.01.16.15.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 15:08:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/4] target/arm: Fix PAuth sbox functions Date: Thu, 16 Jan 2020 13:08:06 -1000 Message-Id: <20200116230809.19078-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116230809.19078-1-richard.henderson@linaro.org> References: <20200116230809.19078-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1043 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: peter.maydell@linaro.org, vincent.dehors@smile.fr, alex.bennee@linaro.org, adrien.grassein@smile.fr Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vincent Dehors In the PAC computation, sbox was applied over wrong bits. As this is a 4-bit sbox, bit index should be incremented by 4 instead of 16. Test vector from QARMA paper (https://eprint.iacr.org/2016/444.pdf) was used to verify one computation of the pauth_computepac() function which uses sbox2. Launchpad: https://bugs.launchpad.net/bugs/1859713 Reviewed-by: Richard Henderson Signed-off-by: Vincent DEHORS Signed-off-by: Adrien GRASSEIN --- target/arm/pauth_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index d3194f2043..0a5f41e10c 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -89,7 +89,7 @@ static uint64_t pac_sub(uint64_t i) uint64_t o = 0; int b; - for (b = 0; b < 64; b += 16) { + for (b = 0; b < 64; b += 4) { o |= (uint64_t)sub[(i >> b) & 0xf] << b; } return o; @@ -104,7 +104,7 @@ static uint64_t pac_inv_sub(uint64_t i) uint64_t o = 0; int b; - for (b = 0; b < 64; b += 16) { + for (b = 0; b < 64; b += 4) { o |= (uint64_t)inv_sub[(i >> b) & 0xf] << b; } return o; From patchwork Thu Jan 16 23:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1224515 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=zsizWUve; 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 47zKfl0Lnjz9s1x for ; Fri, 17 Jan 2020 10:10:23 +1100 (AEDT) Received: from localhost ([::1]:49598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEHM-0004TR-T9 for incoming@patchwork.ozlabs.org; Thu, 16 Jan 2020 18:10:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEFb-0002lf-1g for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isEFa-00086c-19 for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:30 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:37208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isEFZ-00082W-Rm for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:29 -0500 Received: by mail-pl1-x644.google.com with SMTP id c23so9018679plz.4 for ; Thu, 16 Jan 2020 15:08:22 -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=NVbq1Jag2Ekov4ET8qNdfiaIvA8EZAKN4xv0TeisvTw=; b=zsizWUveFCD+JR7XI8QiMaGtfBljiK39Fy4uai3KKQ5ijeft74PT/v0THXRAA+ow+W 75MlADDz3qG5mc5VMeziRgrsGXCkX/NFo74Ra+xBUWUkDkBeEcs32pfzAikXabRDpuD5 DII0IMMHQ7Q1fZzF/SMmgD4+TSuGH9NE20g+vEN4lixsfs4gOS2fan87XylRPK90eeyR MLtuUt5sZbYcXWFzH3XWJfC31hHJoCGYRAURIEEw7fscpllTvAVy8RclV76Dmw7VIjLr 44Y5Rot6hrGnjEWg1S5x1m2NGXYoj6RSizvEKyfXCsRcZ+GcLfzpxzQb6GcO/S5AtalS 9n0w== 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=NVbq1Jag2Ekov4ET8qNdfiaIvA8EZAKN4xv0TeisvTw=; b=gDtokNNKTwDvTGAVCPZXr6QhWwlqiDH8ncdF+4sVdr6qShp8Y45AwSr9eJ+rIL8p9L djoibDwWxSFceARHLUoCpWrGJjSFuE3SX2mU3MDZy6BP/UUKs6y/y3CPjNe20jv7pztP ninsRS3YFRk8oNdJMwujiW9dLQCs0GbZLtcfsQumwgI3CACg7+kaQ1vziDc2MEcegD6O xefByvUY/NDrleKlPXGpfmHXm1X4TkofMht0cZjCCvZ1ugMzLCLuyT08/TQBfVeynVkv XOiHHeRASEwo6pBIxY5Gq6m+1+7Cj4CpZwgdXjdx2RNgpf4CDUowbu5kQLvOgdSdZTht 0vwQ== X-Gm-Message-State: APjAAAXzHPUb3aMYMMbbYzxRtEnceVWFRsbPYYE8CBuYA+yLasXrbYc4 U1PmTMvvmarhR0fHw3iuyFVuxv9XqeU= X-Google-Smtp-Source: APXvYqzs5na07qLW5vghc3yt+NlTJJxnxj3J6IP4MxGdEP+NtR2U5HRPDU0A0da9Z27/35M4b7Gnug== X-Received: by 2002:a17:90b:2289:: with SMTP id kx9mr2058984pjb.94.1579216101221; Thu, 16 Jan 2020 15:08:21 -0800 (PST) Received: from cloudburst.ASUS (rrcs-66-91-136-155.west.biz.rr.com. [66.91.136.155]) by smtp.gmail.com with ESMTPSA id s7sm5111578pjk.22.2020.01.16.15.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 15:08:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/4] tests/tcg/aarch64: Fix compilation parameters for pauth-% Date: Thu, 16 Jan 2020 13:08:07 -1000 Message-Id: <20200116230809.19078-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116230809.19078-1-richard.henderson@linaro.org> References: <20200116230809.19078-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 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: peter.maydell@linaro.org, vincent.dehors@smile.fr, alex.bennee@linaro.org, adrien.grassein@smile.fr Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Hiding the required architecture within asm() is not correct. Add it to the cflags of the (cross-) compiler. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tests/tcg/aarch64/pauth-1.c | 2 -- tests/tcg/aarch64/pauth-2.c | 2 -- tests/tcg/aarch64/Makefile.target | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c index a3c1443cd0..ea0984ea82 100644 --- a/tests/tcg/aarch64/pauth-1.c +++ b/tests/tcg/aarch64/pauth-1.c @@ -2,8 +2,6 @@ #include #include -asm(".arch armv8.4-a"); - #ifndef PR_PAC_RESET_KEYS #define PR_PAC_RESET_KEYS 54 #define PR_PAC_APDAKEY (1 << 2) diff --git a/tests/tcg/aarch64/pauth-2.c b/tests/tcg/aarch64/pauth-2.c index 2fe030ba3d..9bba0beb63 100644 --- a/tests/tcg/aarch64/pauth-2.c +++ b/tests/tcg/aarch64/pauth-2.c @@ -1,8 +1,6 @@ #include #include -asm(".arch armv8.4-a"); - void do_test(uint64_t value) { uint64_t salt1, salt2; diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index df3fe8032c..374c8d6830 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -20,6 +20,7 @@ run-fcvt: fcvt # Pauth Tests AARCH64_TESTS += pauth-1 pauth-2 run-pauth-%: QEMU_OPTS += -cpu max +pauth-%: CFLAGS += -march=armv8.3-a # Semihosting smoke test for linux-user AARCH64_TESTS += semihosting From patchwork Thu Jan 16 23:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1224513 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=D0oqySV8; 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 47zKd85PQVz9s29 for ; Fri, 17 Jan 2020 10:08:59 +1100 (AEDT) Received: from localhost ([::1]:49570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEG0-0002gZ-S8 for incoming@patchwork.ozlabs.org; Thu, 16 Jan 2020 18:08:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEFV-0002fi-Uo for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isEFU-00083V-JX for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:25 -0500 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:38482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isEFU-000830-E8 for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:24 -0500 Received: by mail-pj1-x1044.google.com with SMTP id l35so2386452pje.3 for ; Thu, 16 Jan 2020 15:08:24 -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=stg+e2AWftdtGimCGELoLi5XJTSvE6Z/YM/75Jku7WI=; b=D0oqySV8LJ8grKcCh5HHIZ2ipDkwodX3bQlK0laaOctxQ5U6BqQZZfzXITL5mrT5j1 ASlEjCj2DoEt0Lu7mEyZZDidGEglfh13jp7Lz+1qf225Js5Y9R3ALB1/1ltt5YQNXoQB N8dUvS+IE55tpw0oU9A5qr2hCKu1QrSyTIEyb/gEdW+zSMCIJzkssmWqm89tZmInJuw8 5GUSj5o9Zx4PK6B47VYrZw0cqQvXHjnarD/vsXpYfegdCmux+D4p0zn+uPJDBFZJ/EU4 ViDct44a411BXPH/N5On/yMuwTK6k6xhkEx18FfJ/kuRKN6y42ji448RBvwLD7ARnTV3 D2dg== 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=stg+e2AWftdtGimCGELoLi5XJTSvE6Z/YM/75Jku7WI=; b=NXfdL/LTGRJchHHQDKW48wWa8nI+towV2DZaulWuEsR0W+F+Xwok6/sctGohrYsPXD MyJsvDD3PsujmQ/XivYtj0BGSeYT2mvqyZ6NLOdB3p56F8aY9Susbkym3tiLDGvoFHcO ZdmNEkwYmI2pofVN+YV7PyP/mKsMrlHWDuRA8b59nqYPApSNVNvsEiYaiV737GB6Nx3q 11hDkSVSkyvIgcMi6+cAvzJWC/OBBX2RPCGTef1qxnP9D1jAMOS2ThVrtIwDiTblXP7P Eoy6Dkb0Wmkp03R9Ojp5pX5PDQQxS8CMEWfE+ytuA50L1Nad/qM1fYBy6xbEHAGpI2zW X0pQ== X-Gm-Message-State: APjAAAXgCkGbSxsdd8JG3+O/rWtDxnSLAkYS716UXiyjj9qLKRAo/h8M LSMHEAAE3EEgOWYGBlitWAgl7wYovNQ= X-Google-Smtp-Source: APXvYqwzbTV0eZ0wMahPSoFM7fxp8Iq9TwQet1uF7AvOKQTxheDl7XpaRv/NbcA4RFXQWx6V/UL1/A== X-Received: by 2002:a17:90b:258:: with SMTP id fz24mr2002106pjb.6.1579216103138; Thu, 16 Jan 2020 15:08:23 -0800 (PST) Received: from cloudburst.ASUS (rrcs-66-91-136-155.west.biz.rr.com. [66.91.136.155]) by smtp.gmail.com with ESMTPSA id s7sm5111578pjk.22.2020.01.16.15.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 15:08:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/4] tests/tcg/aarch64: Add pauth-3 Date: Thu, 16 Jan 2020 13:08:08 -1000 Message-Id: <20200116230809.19078-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116230809.19078-1-richard.henderson@linaro.org> References: <20200116230809.19078-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1044 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: peter.maydell@linaro.org, vincent.dehors@smile.fr, alex.bennee@linaro.org, adrien.grassein@smile.fr Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is the test vector from the QARMA paper, run through PACGA. Suggested-by: Vincent Dehors Signed-off-by: Richard Henderson --- tests/tcg/aarch64/system/pauth-3.c | 40 +++++++++++++++++++++++ tests/tcg/aarch64/Makefile.softmmu-target | 5 ++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/system/pauth-3.c diff --git a/tests/tcg/aarch64/system/pauth-3.c b/tests/tcg/aarch64/system/pauth-3.c new file mode 100644 index 0000000000..42eff4d5ea --- /dev/null +++ b/tests/tcg/aarch64/system/pauth-3.c @@ -0,0 +1,40 @@ +#include +#include + +int main() +{ + /* + * Test vector from QARMA paper (https://eprint.iacr.org/2016/444.pdf) + * to verify one computation of the pauth_computepac() function, + * which uses sbox2. + * + * Use PACGA, because it returns the most bits from ComputePAC. + * We still only get the most significant 32-bits of the result. + */ + + static const uint64_t d[5] = { + 0xfb623599da6e8127ull, + 0x477d469dec0b8762ull, + 0x84be85ce9804e94bull, + 0xec2802d4e0a488e9ull, + 0xc003b93999b33765ull & 0xffffffff00000000ull + }; + uint64_t r; + + asm("msr apgakeyhi_el1, %[w0]\n\t" + "msr apgakeylo_el1, %[k0]\n\t" + "pacga %[r], %[P], %[T]" + : [r] "=r"(r) + : [P] "r" (d[0]), + [T] "r" (d[1]), + [w0] "r" (d[2]), + [k0] "r" (d[3])); + + if (r == d[4]) { + ml_printf("OK\n"); + return 0; + } else { + ml_printf("FAIL: %lx != %lx\n", r, d[4]); + return 1; + } +} diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target index 7b4eede3f0..f6b5121f5c 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -61,4 +61,7 @@ run-memory-replay: memory-replay run-memory-record $(QEMU_OPTS) memory, \ "$< on $(TARGET_NAME)") -EXTRA_TESTS+=memory-record memory-replay +run-pauth-3: pauth-3 +pauth-3: CFLAGS += -march=armv8.3-a + +EXTRA_TESTS+=memory-record memory-replay pauth-3 From patchwork Thu Jan 16 23:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1224516 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=PXBXpD55; 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 47zKfr6pXGz9s1x for ; Fri, 17 Jan 2020 10:10:28 +1100 (AEDT) Received: from localhost ([::1]:49606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEHS-0004dI-HG for incoming@patchwork.ozlabs.org; Thu, 16 Jan 2020 18:10:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51429) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isEFZ-0002ix-Dd for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isEFY-00085Y-BM for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:29 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:45625) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isEFY-00085G-6L for qemu-devel@nongnu.org; Thu, 16 Jan 2020 18:08:28 -0500 Received: by mail-pg1-x535.google.com with SMTP id b9so10655000pgk.12 for ; Thu, 16 Jan 2020 15:08:28 -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=Tr0oxdmAfzE1nW8KiWlCJDKgMy/qK0eB4ARHFT7qrQI=; b=PXBXpD555MuimMsvzvUvu/yFuV61mYbPW7BErCgkYo3m1v/dm2qfjmbOxxUKK2z48f umWOyCx0NQDytwBwcHui2OUCkTv9ojUpDu7YuxVcd0IdRkcs0tkNtYfUM0ZQMXawBUBq 9ctitZkvBBfvAkAH3GpJAyS94ObiaGfq/HyknG8kpX+j56Ae78Ud3wExDo6ziVEV35hu lawwzkcRsVqObrQJk/4kUpVDf7fFfbWyLZzG8DeaIrUzE1D+/HNhC99CKkrTXElU8eBC ALUWY5O4sFNSx9dCTVnkoJ9JGllHXioA90+7oIzYwgE0DcPocV8FfKjy/O3L0BEU3hoW GxSQ== 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=Tr0oxdmAfzE1nW8KiWlCJDKgMy/qK0eB4ARHFT7qrQI=; b=hDjr6cfOgJoBI+ymzNp/DgXDX2ZMyhAoNfAfALwGApKkztraePxp0vFAh9JG24jW2c yAK5Aq0TqTU+gXpLH3tnid9ltJAcpbVUbRYC4zwxX+xNd+2+x9BHtIH3Wn5rUeKGbr6w 3sDp1yupoYmvumivOhC652zNEEAwuWIFMQ8aXLE428j4Aaezhaxv2S3EPCQZDQQxAGos PpIVKlw5zUJ3mfz2JR93mFXsX5Hfx1ZKA52r5iO5DddoGMZAe0f2g/g2JIwI73jgbJYa OhBYQM9H/+4MRToMb16ArD/XI+qtMSN0i+XGirvCbFE5LtiwwaLBsnXujpUN28T6YHB4 gEHA== X-Gm-Message-State: APjAAAWMhEHsWyCUtH4+GHcpHSqJwEpvnh6bE2AxGe1rUWVnPiHqXJKW zrb+jVuBf+CEF9OQibaEMvk2aoGx6Wo= X-Google-Smtp-Source: APXvYqyOiXAOqTSky9MAEDwVv2DNq+yVeywQx46rb51Rq45g6S9fOYx3D/pDtzN4qU/saIvfpBWgtA== X-Received: by 2002:a63:5964:: with SMTP id j36mr42477266pgm.225.1579216106685; Thu, 16 Jan 2020 15:08:26 -0800 (PST) Received: from cloudburst.ASUS (rrcs-66-91-136-155.west.biz.rr.com. [66.91.136.155]) by smtp.gmail.com with ESMTPSA id s7sm5111578pjk.22.2020.01.16.15.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 15:08:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/4] tests/tcg/aarch64: Add pauth-4 Date: Thu, 16 Jan 2020 13:08:09 -1000 Message-Id: <20200116230809.19078-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116230809.19078-1-richard.henderson@linaro.org> References: <20200116230809.19078-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 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: peter.maydell@linaro.org, vincent.dehors@smile.fr, alex.bennee@linaro.org, adrien.grassein@smile.fr Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Perform the set of operations and test described in LP 1859713. Suggested-by: Adrien GRASSEIN Signed-off-by: Richard Henderson --- tests/tcg/aarch64/pauth-4.c | 25 +++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64/pauth-4.c diff --git a/tests/tcg/aarch64/pauth-4.c b/tests/tcg/aarch64/pauth-4.c new file mode 100644 index 0000000000..4b22e6e282 --- /dev/null +++ b/tests/tcg/aarch64/pauth-4.c @@ -0,0 +1,25 @@ +#include +#include + +int main() +{ + uintptr_t x, y; + + 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. + */ + assert(x != y); + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 374c8d6830..efa67cf1e9 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -18,7 +18,7 @@ run-fcvt: fcvt $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) # Pauth Tests -AARCH64_TESTS += pauth-1 pauth-2 +AARCH64_TESTS += pauth-1 pauth-2 pauth-4 run-pauth-%: QEMU_OPTS += -cpu max pauth-%: CFLAGS += -march=armv8.3-a