From patchwork Fri May 30 13:55:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 31192 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7279120E7C for ; Fri, 30 May 2014 13:55:30 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z6sf9223478yhz.5 for ; Fri, 30 May 2014 06:55:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=U3u2myJ4Q4C1Zw119Pvg9PF3SIVgaVd2ARBIFenb0kI=; b=QOkFu17S3d5RX8OPzmddH8u0QdLwGVUTPSJR5F0kfoAf5UtmuwsTidnjxH4oqo+nhu v2i27EyQMjtsuWa8xNmK12X7Ktl52ALI59UgSl5i0djAnQlfX4a+fQMjTl4vMVuRh3nJ UpJC5AvTnYjXNnTf9ot7tf93+0hsP9ybPnO/HNaK3ZDK6jQEGkfnBM4+0cbtVJPiuTsA cJsXRedctmoI+66U8e9ruAWWE1WbvhPVTH1VaC7b/OvtoD9E62ueSm9/rzE680OX4zLe NaRrXT1RxPxbUrFkaiZKwLQ+VpbHonpFVClo/HSR04SQC0o5dRkuwvCj/bg2ZZnQYIZI LVcA== X-Gm-Message-State: ALoCoQnJfI/PRfWL1ttYsNp7dQzrOGD7npqI4eEQtlcD/ZEQ/mzDAoaLeMiManLJWzLCPL2XfK2c X-Received: by 10.58.182.137 with SMTP id ee9mr6272522vec.37.1401458130098; Fri, 30 May 2014 06:55:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.201 with SMTP id k67ls1057597qge.22.gmail; Fri, 30 May 2014 06:55:29 -0700 (PDT) X-Received: by 10.220.159.4 with SMTP id h4mr13890782vcx.1.1401458129942; Fri, 30 May 2014 06:55:29 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id k4si3096061vch.63.2014.05.30.06.55.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 06:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jw12so2145665veb.19 for ; Fri, 30 May 2014 06:55:29 -0700 (PDT) X-Received: by 10.58.2.74 with SMTP id 10mr1303358ves.61.1401458129882; Fri, 30 May 2014 06:55:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp114273vcb; Fri, 30 May 2014 06:55:29 -0700 (PDT) X-Received: by 10.182.40.201 with SMTP id z9mr17386204obk.45.1401458128812; Fri, 30 May 2014 06:55:28 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id d8si7969548obq.49.2014.05.30.06.55.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 30 May 2014 06:55:28 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WqNHJ-0007ID-Eo; Fri, 30 May 2014 14:55:25 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Ard Biesheuvel , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 8/9] target-arm: A64: Implement 3-register SHA instructions Date: Fri, 30 May 2014 14:55:24 +0100 Message-Id: <1401458125-27977-9-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401458125-27977-1-git-send-email-peter.maydell@linaro.org> References: <1401458125-27977-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Implement the 3-register SHA instruction group from the optional Crypto Extensions. Signed-off-by: Peter Maydell --- target-arm/translate-a64.c | 59 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 544f20a..1b475cd 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -10608,7 +10608,64 @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) */ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + int size = extract32(insn, 22, 2); + int opcode = extract32(insn, 12, 3); + int rm = extract32(insn, 16, 5); + int rn = extract32(insn, 5, 5); + int rd = extract32(insn, 0, 5); + CryptoThreeOpEnvFn *genfn; + TCGv_i32 tcg_rd_regno, tcg_rn_regno, tcg_rm_regno; + int feature = ARM_FEATURE_V8_SHA256; + + if (size != 0) { + unallocated_encoding(s); + return; + } + + switch (opcode) { + case 0: /* SHA1C */ + case 1: /* SHA1P */ + case 2: /* SHA1M */ + case 3: /* SHA1SU0 */ + genfn = NULL; + feature = ARM_FEATURE_V8_SHA1; + break; + case 4: /* SHA256H */ + genfn = gen_helper_crypto_sha256h; + break; + case 5: /* SHA256H2 */ + genfn = gen_helper_crypto_sha256h2; + break; + case 6: /* SHA256SU1 */ + genfn = gen_helper_crypto_sha256su1; + break; + default: + unallocated_encoding(s); + return; + } + + if (!arm_dc_feature(s, feature)) { + unallocated_encoding(s); + return; + } + + tcg_rd_regno = tcg_const_i32(rd << 1); + tcg_rn_regno = tcg_const_i32(rn << 1); + tcg_rm_regno = tcg_const_i32(rm << 1); + + if (genfn) { + genfn(cpu_env, tcg_rd_regno, tcg_rn_regno, tcg_rm_regno); + } else { + TCGv_i32 tcg_opcode = tcg_const_i32(opcode); + + gen_helper_crypto_sha1_3reg(cpu_env, tcg_rd_regno, + tcg_rn_regno, tcg_rm_regno, tcg_opcode); + tcg_temp_free_i32(tcg_opcode); + } + + tcg_temp_free_i32(tcg_rd_regno); + tcg_temp_free_i32(tcg_rn_regno); + tcg_temp_free_i32(tcg_rm_regno); } /* C3.6.21 Crypto two-reg SHA