From patchwork Fri May 30 13:55:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 31197 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6B65720671 for ; Fri, 30 May 2014 14:10:17 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf2708709igq.2 for ; Fri, 30 May 2014 07:10:16 -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=DMe8gVcUyy1fpr3xqsZOTtQxSGONlZeCUFb11tPu+D0=; b=Bgmbz/oD7VnfeqJMmvUTrRJgqXowshiZ7bzNcwONMrsGR5Yw02ABghCrxJQqFOILgP hIPCyMAvtDEWOUS/rJYRrsF2QGdxY6NEyVTl1+uOCEuKroWpC3LUqUu5MPvMeNuhL5rY FfJ21bchNKRj+RfNY1AxHBevr5s6NaZBdkqcHrLqOoh6FIRd8CQwAznOSXQ2zcf/7+7H nrF2bD7JdZJQT1QSxLucmv08XPPGb2zaeA/SnBd+51IYylQJJvbgzgfXZXflmMPNlixh 1Uuc3K03ELN8mPJs5Is9veuGD9zsACMohRHWQ8BkqKn7nFOD0n3CUHA31L2gX3B7FVTm 10wg== X-Gm-Message-State: ALoCoQkFBnYmfPUv8DOjbkGdAQjzQSGIL/qlQqagKunriJ69IrvIMuz68vbcO6k7iTztk0Eb/J6F X-Received: by 10.182.105.41 with SMTP id gj9mr5890769obb.30.1401459016896; Fri, 30 May 2014 07:10:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.4 with SMTP id t4ls1132457qge.1.gmail; Fri, 30 May 2014 07:10:16 -0700 (PDT) X-Received: by 10.58.85.65 with SMTP id f1mr14270046vez.20.1401459016719; Fri, 30 May 2014 07:10:16 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id i19si3143014vdt.5.2014.05.30.07.10.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 07:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id db11so2158196veb.36 for ; Fri, 30 May 2014 07:10:16 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr832983vec.80.1401459016596; Fri, 30 May 2014 07:10:16 -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 ib8csp115419vcb; Fri, 30 May 2014 07:10:16 -0700 (PDT) X-Received: by 10.112.157.162 with SMTP id wn2mr12305443lbb.38.1401459015524; Fri, 30 May 2014 07:10:15 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id gh5si8691448wjd.145.2014.05.30.07.10.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 30 May 2014 07:10:09 -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-0007I9-DR; 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 7/9] target-arm: A64: Implement AES instructions Date: Fri, 30 May 2014 14:55:23 +0100 Message-Id: <1401458125-27977-8-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.177 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 AES instructions from the optional Crypto Extensions. Signed-off-by: Peter Maydell --- linux-user/elfload.c | 1 + target-arm/translate-a64.c | 51 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f2d5955..396a808 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -539,6 +539,7 @@ static uint32_t get_elf_hwcap(void) /* probe for the extra features */ #define GET_FEATURE(feat, hwcap) \ do { if (arm_feature(&cpu->env, feat)) { hwcaps |= hwcap; } } while (0) + GET_FEATURE(ARM_FEATURE_V8_AES, ARM_HWCAP_A64_AES); GET_FEATURE(ARM_FEATURE_V8_PMULL, ARM_HWCAP_A64_PMULL); GET_FEATURE(ARM_FEATURE_CRC, ARM_HWCAP_A64_CRC32); #undef GET_FEATURE diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 4eb1541..544f20a 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -84,6 +84,7 @@ typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); +typedef void CryptoThreeOpEnvFn(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); /* initialize TCG globals. */ void a64_translate_init(void) @@ -10548,7 +10549,55 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) */ static void disas_crypto_aes(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + int size = extract32(insn, 22, 2); + int opcode = extract32(insn, 12, 5); + int rn = extract32(insn, 5, 5); + int rd = extract32(insn, 0, 5); + int decrypt; + TCGv_i32 tcg_rd_regno, tcg_rn_regno, tcg_decrypt; + CryptoThreeOpEnvFn *genfn; + + if (!arm_dc_feature(s, ARM_FEATURE_V8_AES) + || size != 0) { + unallocated_encoding(s); + return; + } + + switch (opcode) { + case 0x4: /* AESE */ + decrypt = 0; + genfn = gen_helper_crypto_aese; + break; + case 0x6: /* AESMC */ + decrypt = 0; + genfn = gen_helper_crypto_aesmc; + break; + case 0x5: /* AESD */ + decrypt = 1; + genfn = gen_helper_crypto_aese; + break; + case 0x7: /* AESIMC */ + decrypt = 1; + genfn = gen_helper_crypto_aesmc; + break; + default: + unallocated_encoding(s); + return; + } + + /* Note that we convert the Vx register indexes into the + * index within the vfp.regs[] array, so we can share the + * helper with the AArch32 instructions. + */ + tcg_rd_regno = tcg_const_i32(rd << 1); + tcg_rn_regno = tcg_const_i32(rn << 1); + tcg_decrypt = tcg_const_i32(decrypt); + + genfn(cpu_env, tcg_rd_regno, tcg_rn_regno, tcg_decrypt); + + tcg_temp_free_i32(tcg_rd_regno); + tcg_temp_free_i32(tcg_rn_regno); + tcg_temp_free_i32(tcg_decrypt); } /* C3.6.20 Crypto three-reg SHA