From patchwork Tue Jan 8 22:31:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155025 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp40265jaa; Tue, 8 Jan 2019 14:44:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Fdo2C2zOcvZFNhQbVf/4S87CXNQRgaa0Ukp0qOrc2fMXXBdJA77PSbHzo1XFf0CLBsxU6 X-Received: by 2002:a5d:4e82:: with SMTP id e2mr2743275wru.291.1546987498796; Tue, 08 Jan 2019 14:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546987498; cv=none; d=google.com; s=arc-20160816; b=Kf2jnwZIKFwfG97CjIQUuoKkV9FRrukUrip2wPHWxDm9dcls7EQpU5CUV/i8d8aVRQ KYJJLfdz4o9EXolIy+DJKzztxB0BmaFBIyhC+8PxDw6P/TeJfCCU5jps5f1GN7S5w4f6 VtuK45pmxZLvZhFcGHZWEYvFKZTu/85l8wJgrKkOsr8nNH2zXjxj+RlnXdv9h0rTsKLG Z9rPGSDLu5I5V3ofuaghgkvBu2LVtugIy+ErCrzrYzvpJBims6v+yMr8jMIyAW4yXiJo RxRa+ZPhif70EaFAbTkTPS1klWY7RWMfXw7oWiNhrcmq4AhozOuNJKQWgZvytZ0Abr1h KVuA== 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=01IO6/Fjvs90ItdmEEqL8n0fmAXQds5N0LRFVoEcyAc=; b=mGdFIW5P2bb7oeYQ/zaHn6Hvn0lLL9sOQyXspdOwg+GpSVAqoa2UlGJ9l+OTWesLXZ sFexssiJkB1w/qmdgGtjvp6oiW8UscHV5YI8gIV+8OKM0sOn9dTP0AVdtMOlxavcjqh0 IhKc2oYrN5IYTQhWomzxTxHKMkKwe5UOKCMFl13kHtlQbBMHipqbEl9O6ZVfeJ1X502c 4QNhZi6maHsgBB4Sh1PPOtkBNH6DpH7QoS2uocg5oS6pBq53rBU9+7OWMGUI6LTA6emF O8UycVshko7wVTBZkYwxqv77vXi3xh748RlhoDJrFzot5rG30SJ2mTzHZV319Srd1F/h cQUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H2LfJane; 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 t63si7429488wma.109.2019.01.08.14.44.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:44:58 -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=H2LfJane; 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 ([127.0.0.1]:42731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh07F-0002qH-N8 for patch@linaro.org; Tue, 08 Jan 2019 17:44:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzvP-0000ZR-KX for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzvO-0005CT-Re for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:43 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzvO-0005BH-Jf for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:42 -0500 Received: by mail-pg1-x544.google.com with SMTP id z11so2376357pgu.0 for ; Tue, 08 Jan 2019 14:32:42 -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=01IO6/Fjvs90ItdmEEqL8n0fmAXQds5N0LRFVoEcyAc=; b=H2LfJaneF5DOwovLhZn4aPomZxKe+nds1fXmoL0ADWQbBLRPYtdL5NrxE/Rv7CCj2v IczOKLU/thgB1aj0L4PNvIqQrrnKu0i8720ESIrS/W6/4idfpt/7vNXE1W/PL+JlB8kt 1PUTifBFrjs33fFQb3mEYWwLpNRIdoR9TWLxU= 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=01IO6/Fjvs90ItdmEEqL8n0fmAXQds5N0LRFVoEcyAc=; b=Te1KFjx1txZ0mZLs/JpF6OTbU2Z41z+z2DlePMKK2ngVZ84V+NhADN9sSGaV/xkjBI Ii5FEKwEPXJ+03lSMSCXrvZQGY1oTp016WipT/ClJ8+lFGAEX62HAeNPQNWuySF5eStX iC+jgbZbnBHSYposjtMSDpEd5FIJPRW6/oEz+nC9mjncgcG2Fxqtxh7YmjROEGk66nnh qEh1aXK3q/G6dT4OTR114/v4vSe9MLQvXmYTbpJwUu2KvBS9+YE7HK911H9n9Tbf0KLg UM0MRJhVcDSyVaiMnrrnEKUBxxG16KlzcwSqrSEYOf9BJQkG1td/dkGuWrwan/cOkVGi T86w== X-Gm-Message-State: AJcUukfkHom/abEIlMUteCIagYtrPx9jLcllzVwIcLacggFEF5Ibv1YT pC9D7sc6uUy8YQa7apY4px7z6ZvlpUg= X-Received: by 2002:a63:580a:: with SMTP id m10mr3111075pgb.332.1546986761167; Tue, 08 Jan 2019 14:32:41 -0800 (PST) Received: from cloudburst.lan (2001-44b8-2176-c800-8cc6-2630-7d99-5ef1.static.ipv6.internode.on.net. [2001:44b8:2176:c800:8cc6:2630:7d99:5ef1]) by smtp.gmail.com with ESMTPSA id w128sm100686177pfw.79.2019.01.08.14.32.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:32:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:23 +1000 Message-Id: <20190108223129.5570-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190108223129.5570-1-richard.henderson@linaro.org> References: <20190108223129.5570-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::544 Subject: [Qemu-devel] [PATCH v3 25/31] 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/pauth_helper.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index e02376a2d0..fa7707e0bf 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -50,7 +50,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)