From patchwork Fri Dec 7 10:36:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153122 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp342428ljp; Fri, 7 Dec 2018 02:46:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/UcDS/mtadLnvrywa5Cfevnbtq++bAQbU5HuXwOe5Vgr9J2e6GhCCkzLWct04QQE50p3jYB X-Received: by 2002:aed:2803:: with SMTP id r3mr1410510qtd.316.1544179614684; Fri, 07 Dec 2018 02:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544179614; cv=none; d=google.com; s=arc-20160816; b=Zl1wkYcntnhDHiLWwhZQHahb/TCFr9dVmaFoBB2z5zhTsymA0PJG1TmybudBZpnEUh FLVB+l5o6cT+njx4Q34lluQCwJW9876UjVQyYo6/hSUv6GPuQPOyzpR4nVMe/KrjNhDU +FLqqMJikVkawo0YVmERsb22cLUxD25sP2Jw/vtbOmcwdy97Dj7eAiK3xvOpoNk2fcwu JHa0r/+yXjtTbSSTEu2NFppJ8gKISF79L8eKfPXDHZcgvu0bcYElIpUAndrXBLQUaoEM jPDgstFbA+8slECVcW/t6i0IjjuOPMNdmX6myuStmyAITbQrssr9LrqxB01pocj3OudZ PMmg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=v40BxgpKv12FE0ZZ8FSnShn6GuP1goSUKV4ipG2SSGc=; b=HjwznvM56vvOHIvDIdlpXuexcLbfHdygo6ISPpJwOgEhM2lEV+4HiKxMeP9R3Ifm5i nAfQPb9eVl84om+2OmVxdHkDE29p5jOg5GqP2V2yGL0N0uwzSo5xJ2/bU/wdmqt4i6bQ XTYASAtZcLfs84dZspH3cZaUOYnlMPk04e4uUOLluERy+g7EJdgcYFKUrhXD0yfpbj1s e9bllkPeLqRTLYoQciqeyqrHli84V6kAJ4VD8cy/MYDIiF6C9JZvP7AMVGKD98nJyqrh rNbLMa4soQMKD4gLhyE2frMdOzRXVO34olEkZVkv8sbDTBAbBj7dhRpraaw6KUOe7oJe Q2KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Heq5uqRp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h191si2305711qka.21.2018.12.07.02.46.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 07 Dec 2018 02:46:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Heq5uqRp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:45304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDen-0003g6-FW for patch@linaro.org; Fri, 07 Dec 2018 05:46:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDVP-0008NO-L0 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVDVM-0007x0-Vx for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:11 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:44470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gVDVL-0007ud-Ny for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:37:07 -0500 Received: by mail-ot1-x343.google.com with SMTP id f18so3328706otl.11 for ; Fri, 07 Dec 2018 02:37:06 -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; bh=v40BxgpKv12FE0ZZ8FSnShn6GuP1goSUKV4ipG2SSGc=; b=Heq5uqRpMiNHc7xLJWKJcH42KfiSK8y6/ZGVa9fbtSevA9Gk05hAtVN/nEYPcmxFcH h6vgvb0XLTDNyFzEGWSGjwcXJNgHt4yuobpaF3ZN57cjZOOmUNY5J1yIXQkyN8c2wUrj +utIVMYFHA08lPWp6qeDO7PUM2c3u+rovshTM= 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; bh=v40BxgpKv12FE0ZZ8FSnShn6GuP1goSUKV4ipG2SSGc=; b=Wq/nRbDvQhl7O4bydpYX1utVoi7Q93Z15Ra80dbYLo3R82vB+83abfYyU2WtLShrOI dAUxy44uvUjWjwJgY+hcU4unNVXMCaME2wZVknRxTqoKuVPSK6s5+i3VgHfpuhCE1QwB vC8OaFv4LUktaYNZtvRz2NA0A9K8geDE1jQC5LamLiRf9r4O4fmH80zSrEFbD5nlK2Jf JD8vM/hxxowmZkBC7abmQEP0Oli33daduroR4+ATy/ZujM8xZyIJpWdYu/qUzJi8mxk1 wqfsw+AZIp7nzsgqNyn845/SA9x3g+WZME/wdWeE7BXGTyXHxrp5D8o9axKHypWeqLgU Dl0A== X-Gm-Message-State: AA+aEWYbF/XmBART+uxH3T+UHildGBePwGHGef8VBSVHK82Ejix/13k7 OafXIGgTsfwzj9389/4zbXbG1Z7by1g= X-Received: by 2002:a9d:5a81:: with SMTP id w1mr1126807oth.317.1544179025289; Fri, 07 Dec 2018 02:37:05 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id c19sm2037594otl.16.2018.12.07.02.37.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 02:37:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 04:36:25 -0600 Message-Id: <20181207103631.28193-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181207103631.28193-1-richard.henderson@linaro.org> References: <20181207103631.28193-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::343 Subject: [Qemu-devel] [PATCH 20/26] target/arm: Implement pauth_auth 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, ramana.radhakrishnan@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is not really functional yet, because the crypto is not yet implemented. This, however follows the Auth pseudo function. Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 8860704720..2c14a71f03 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1081,7 +1081,26 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, uint64_t *key, bool data, int keynumber) { - g_assert_not_reached(); /* FIXME */ + ARMMMUIdx mmu_idx = arm_mmu_idx(env); + ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); + int bot_bit, top_bit; + uint64_t pac, orig_ptr, test; + + orig_ptr = pauth_original_ptr(ptr, param); + pac = pauth_computepac(orig_ptr, modifier, key[1], key[0]); + bot_bit = 64 - param.tsz; + top_bit = 64 - 8 * param.tbi; + + test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); + if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { + int error_code = (keynumber << 1) | (keynumber ^ 1); + if (param.tbi) { + return deposit64(ptr, 53, 2, error_code); + } else { + return deposit64(ptr, 61, 2, error_code); + } + } + return orig_ptr; } static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data)