From patchwork Fri Jan 17 09:23:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 23311 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1AD420540 for ; Fri, 17 Jan 2014 09:24:03 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id e9sf5819729qcy.11 for ; Fri, 17 Jan 2014 01:24:02 -0800 (PST) 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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=w12un2T7UZixXTYaJ5wLhFCxH8IjFNE2NBsOSHxODPc=; b=KpSXJn6MYRWFTOCNiwPQ1WPx2WtYguSwAy0uPPVBoEkiyVUytq8Ui4kgkP5bKRGHjl e1oyDEwEjcy6hDC2k9S2MQgZ60N+uTaKMvgAXAfX+xclvl0/eRfIewP1SQfSh3W3LWsN JooIoGPsCI0kFg9qfDlJf5nYijajWnzn0L2YK40xtL8TrYzIhR9NHl3CGauRgjrOkOFK xuco35kkJe19VXSmyLTOtad6mWtgfjeTIw6c4CCzLyfS74Gjcy96y3vcaLWnvO0R0GrF aHgZNmbNvcK0u4Lu6kWIdW5wf6bqN3+7AmaJrpPoY9zFLIn1cTMX7z4UInmRNvZ2gLc/ CHGQ== X-Gm-Message-State: ALoCoQlK49ZWW0Ko+4uOYRtDqRj+MiBnwHJShzq+c2bz6RwF4xnPab8GMxgAmqOKKOgFUebbumkG X-Received: by 10.236.139.116 with SMTP id b80mr254221yhj.30.1389950642667; Fri, 17 Jan 2014 01:24:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.4 with SMTP id d4ls462897qga.20.gmail; Fri, 17 Jan 2014 01:24:02 -0800 (PST) X-Received: by 10.58.118.36 with SMTP id kj4mr413954veb.2.1389950642497; Fri, 17 Jan 2014 01:24:02 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id e9si4623636vct.109.2014.01.17.01.24.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 01:24:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hu8so1463082vcb.15 for ; Fri, 17 Jan 2014 01:24:02 -0800 (PST) X-Received: by 10.52.172.133 with SMTP id bc5mr314257vdc.11.1389950642391; Fri, 17 Jan 2014 01:24:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp5874ved; Fri, 17 Jan 2014 01:24:01 -0800 (PST) X-Received: by 10.68.134.130 with SMTP id pk2mr791479pbb.167.1389950641465; Fri, 17 Jan 2014 01:24:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si9624685pbb.114.2014.01.17.01.23.59; Fri, 17 Jan 2014 01:23:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752518AbaAQJXk (ORCPT + 26 others); Fri, 17 Jan 2014 04:23:40 -0500 Received: from mail-we0-f173.google.com ([74.125.82.173]:41592 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752443AbaAQJXY (ORCPT ); Fri, 17 Jan 2014 04:23:24 -0500 Received: by mail-we0-f173.google.com with SMTP id t60so4259335wes.18 for ; Fri, 17 Jan 2014 01:23:23 -0800 (PST) X-Received: by 10.194.176.163 with SMTP id cj3mr881305wjc.8.1389950602991; Fri, 17 Jan 2014 01:23:22 -0800 (PST) Received: from ards-mac-mini.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id 5sm8736569wjw.17.2014.01.17.01.23.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Jan 2014 01:23:22 -0800 (PST) From: Ard Biesheuvel To: linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, viro@zeniv.linux.org.uk, dave.martin@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: peter.maydell@linaro.org, Ard Biesheuvel Subject: [PATCH v2 resend 5/5] arm64: advertise ARMv8 extensions to 32-bit compat ELF binaries Date: Fri, 17 Jan 2014 10:23:11 +0100 Message-Id: <1389950591-4212-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389950591-4212-1-git-send-email-ard.biesheuvel@linaro.org> References: <1389950591-4212-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds support for advertising the presence of ARMv8 Crypto Extensions in the Aarch32 execution state to 32-bit ELF binaries running in 32-bit compat mode under the arm64 kernel. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/hwcap.h | 6 ++++++ arch/arm64/kernel/setup.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index 9a4cbd60c88e..024c46183c3c 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -32,6 +32,12 @@ #define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) #define COMPAT_HWCAP_EVTSTRM (1 << 21) +#define COMPAT_HWCAP2_AES (1 << 0) +#define COMPAT_HWCAP2_PMULL (1 << 1) +#define COMPAT_HWCAP2_SHA1 (1 << 2) +#define COMPAT_HWCAP2_SHA2 (1 << 3) +#define COMPAT_HWCAP2_CRC32 (1 << 4) + #ifndef __ASSEMBLY__ /* * This yields a mask that user programs can use to figure out what diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 15f3bd207981..c36cab831932 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -174,6 +174,38 @@ static void __init setup_processor(void) block = (features >> 16) & 0xf; if (block && !(block & 0x8)) elf_hwcap |= HWCAP_CRC32; + +#ifdef CONFIG_COMPAT + /* + * ID_ISAR5_EL1 carries similar information as above, but pertaining to + * the Aarch32 32-bit execution state. + */ + features = read_cpuid(ID_ISAR5_EL1); + block = (features >> 4) & 0xf; + if (!(block & 0x8)) { + switch (block) { + default: + case 2: + compat_elf_hwcap2 |= COMPAT_HWCAP2_PMULL; + case 1: + compat_elf_hwcap2 |= COMPAT_HWCAP2_AES; + case 0: + break; + } + } + + block = (features >> 8) & 0xf; + if (block && !(block & 0x8)) + compat_elf_hwcap2 |= COMPAT_HWCAP2_SHA1; + + block = (features >> 12) & 0xf; + if (block && !(block & 0x8)) + compat_elf_hwcap2 |= COMPAT_HWCAP2_SHA2; + + block = (features >> 16) & 0xf; + if (block && !(block & 0x8)) + compat_elf_hwcap2 |= COMPAT_HWCAP2_CRC32; +#endif } static void __init setup_machine_fdt(phys_addr_t dt_phys)