From patchwork Fri Dec 14 05:24:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 10730551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5C4A174F for ; Fri, 14 Dec 2018 05:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF4AA2CD6E for ; Fri, 14 Dec 2018 05:40:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEE492CDBE; Fri, 14 Dec 2018 05:40:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 657282CD6E for ; Fri, 14 Dec 2018 05:40:37 +0000 (UTC) Received: from localhost ([::1]:59506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXgDE-0001Iw-Iv for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Dec 2018 00:40:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXfxu-0004mY-5o for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXfxq-0005V2-7Z for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:46 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:35960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXfxo-0005T8-9D for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:40 -0500 Received: by mail-ot1-x344.google.com with SMTP id k98so4328312otk.3 for ; Thu, 13 Dec 2018 21:24:37 -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=QFHXVN9HoAm57mg/uppS1q9X/be1g/wjjh6mIB0wBzs=; b=RDYDnuzybaYYlWHaXFwkgC23+Z+H3tzXIX5R+/ROpiepGhQhq0HA2lKWCL7TzStTmY jlqz1+Blcq2mbz+OYfpD+joa6duR+fZfyuOPsp+q0NVB318cOm2yAWMQQuvziRakZf8a LINpZNPsKGCnnfWXeC5qc9/IZBQNnRoPfApNc= 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=QFHXVN9HoAm57mg/uppS1q9X/be1g/wjjh6mIB0wBzs=; b=U4Gi+AMJi5iiMto8JhQIV4bQ+pM7vSnMC6/eps338BdmRBXSlKaFsm8eA3701ITx/f i4TpgaISKLVxmYPGI1rhqS/+k6+lIrXA800oN3Mu64fvTzt0j8lXRdzzDbeupzErlrI8 zIk4vGHne2OCFzphjtpgeZBQYFNh1J5qTSrPGq5Dt81fS8xNajm2J4DceUZUCI5MxnrH 2DYvaKwUJcsPlXoR6UlZxGCF2jH1cQ/n0oiRGorBZxNMxwC50czSf4aBD9nrxies2dEd bQ3jmVxNmQVkz1/CB80eiFpS4Cz28V42lXF58uonGcjQ/6IlNCuZLn6Mp7MhcjX5u92D IOow== X-Gm-Message-State: AA+aEWZ6g4uuma+uelj6FDeky1et89LTzcX8481v9idHNIqVN4jCCIk9 GtzkgMT+Dm2btzL8vW/gW0kh+GEN39aEUA== X-Google-Smtp-Source: AFSGD/UIdx1VI3P+pLIY8VVr1zQWqjYeFCx4PfkKaGF47HLpMb1nam7moZV+JRMoX1+QgfU9mnnDTg== X-Received: by 2002:a9d:6b11:: with SMTP id g17mr1156616otp.70.1544765076909; Thu, 13 Dec 2018 21:24:36 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id r1sm1845379oti.44.2018.12.13.21.24.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 21:24:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 23:24:04 -0600 Message-Id: <20181214052410.11863-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214052410.11863-1-richard.henderson@linaro.org> References: <20181214052410.11863-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::344 Subject: [Qemu-devel] [PATCH v2 21/27] 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Peter Maydell --- target/arm/helper-a64.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 329af51232..87cff7d96a 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, ARMPACKey *key, bool data, int keynumber) { - g_assert_not_reached(); /* FIXME */ + ARMMMUIdx mmu_idx = arm_stage1_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); + 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)