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: 153761 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1681133ljp; Thu, 13 Dec 2018 21:41:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wo7XMLUmmQvP13pfQSY9aqZBHJoZlv8C20nHg7fUu9gL1V2KnJcqpsO6gVrL/PmXEplw2I X-Received: by 2002:ac8:2585:: with SMTP id e5mr1497014qte.233.1544766104558; Thu, 13 Dec 2018 21:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544766104; cv=none; d=google.com; s=arc-20160816; b=NzMtmIaZtxTfaJvbKw9wiTZWMuKVB3DN2CA4WZ054ARwse8n+QbMe947bbH202/YxQ X6vEydTdDAy+Td7hJ5pU3yf8KC17j7LIa2R3DlurIqd1ssqopq86km+U0gPlEQv6T8qi swrsXftrJ71CyiubE10NSOSnJb4Cc2+VLkJoSJw1Jwy5m39iNyHiMG/B+lRn7KLp4XJB 5dw2YLKD9u4rp3m5/5Lc9p1ZdG7/nnSOC7O0w9qUijc7zwvYQJsPIe67wQRRvVdoMnfx 3e4kU8i2FnTSh5sLYXI4v0iHVKHGCJItmNBjpeATiVZ5pRRyCzoHokpydLCETWhyBz+l IfdQ== 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=QFHXVN9HoAm57mg/uppS1q9X/be1g/wjjh6mIB0wBzs=; b=eoAIzesmKi6d2MfCtKe4szreDyVbz/b5G4HppoHxCBPf9dCHieqNeLQOCdiVZSfKZx QZ47fn8FrfQiIWwTqjqfbBb7t4gKAMcZMIAk1u4gO73JbXEWBODd+UA9qiMemSoLTUms UZ56wAzw4qMS9kz4HMqTt+kCeklCuIqykIzD0uX8dwXxcZUliAjcMOY+AW2kuTirHd65 2eZa7o303w9qf8qKb2d7KpTJFx3p+oR20SkTCVHKNsrX7NyNf8Nwb+bswCi9oM7GdDsV uawsFnOJT4tLfPzInkL7u27TUkqI3FKBvwZpcLgE4F5Vt5RIpjvPChEXb2ZFAgRV56my RD0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RDYDnuzy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.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. [208.118.235.17]) by mx.google.com with ESMTPS id a2si1859314qvj.165.2018.12.13.21.41.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Dec 2018 21:41:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RDYDnuzy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.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]:59515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXgEJ-0002Co-KF for patch@linaro.org; Fri, 14 Dec 2018 00:41:43 -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-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+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 Reviewed-by: Peter Maydell 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)