From patchwork Tue Feb 25 12:38:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 25289 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC15320543 for ; Tue, 25 Feb 2014 12:41:17 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h3sf2360899igd.1 for ; Tue, 25 Feb 2014 04:41:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=mwI0BBVAmfcRFkE+XBt1Mugmln39qtrgn4OZrsTnVos=; b=NLwML/XgMjtUgLHXYH07LV8eUOYzKlgql8WxPDWYsIg9BknHfEo2jubENYHF+SXwXZ MdM7Z/A9aFkADN7eui9e9rJgGKaCeLzS42FxLHpfCmPOwkjRteTHPOy7a+qFMYPkIOG3 dxWRL+QpY7Zt6CYpc0TsXhAYuSVWS+ygqrYTG9MB7SUV26CErABLBCKeYdBp7dA8fw1B j80PMxoEXAseJuhQEz3IX3WY3fjkE+qAr6iAwTDjYJPuZjt3FMIOKvB00VH35PT6TnQh v2h6EcXceTi34WEdmGPLNmNZC7oyTmuhqvooIuERxfDrmzK/BpwRtJC9X3ndc1jl7BVi QkDA== X-Gm-Message-State: ALoCoQl88gJXK9HtjfyqwptStn1vKUPqnNE7Xl8gzLkZa8MLIbYE0vnj4+mdh9d88MAIuiVAHPlR X-Received: by 10.182.11.70 with SMTP id o6mr559247obb.19.1393332077214; Tue, 25 Feb 2014 04:41:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.33 with SMTP id c30ls1461091qge.9.gmail; Tue, 25 Feb 2014 04:41:17 -0800 (PST) X-Received: by 10.58.235.129 with SMTP id um1mr979804vec.17.1393332076958; Tue, 25 Feb 2014 04:41:16 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id or7si6765063vcb.61.2014.02.25.04.41.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 04:41:16 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 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.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so7130343vcb.20 for ; Tue, 25 Feb 2014 04:41:16 -0800 (PST) X-Received: by 10.221.40.10 with SMTP id to10mr988877vcb.22.1393332076866; Tue, 25 Feb 2014 04:41:16 -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.220.174.196 with SMTP id u4csp135971vcz; Tue, 25 Feb 2014 04:41:16 -0800 (PST) X-Received: by 10.180.103.227 with SMTP id fz3mr19319342wib.29.1393332075970; Tue, 25 Feb 2014 04:41:15 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id em8si17668314wjd.147.2014.02.25.04.41.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Feb 2014 04:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIHIi-00045B-5V; Tue, 25 Feb 2014 12:39:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIHIY-0000VI-0W; Tue, 25 Feb 2014 12:39:46 +0000 Received: from mail-wg0-f50.google.com ([74.125.82.50]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIHII-0000TO-OP for linux-arm-kernel@lists.infradead.org; Tue, 25 Feb 2014 12:39:31 +0000 Received: by mail-wg0-f50.google.com with SMTP id l18so348922wgh.9 for ; Tue, 25 Feb 2014 04:39:07 -0800 (PST) X-Received: by 10.180.98.35 with SMTP id ef3mr19546406wib.39.1393331947806; Tue, 25 Feb 2014 04:39:07 -0800 (PST) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id jw4sm50423292wjc.20.2014.02.25.04.39.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 04:39:07 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, peter.maydell@linaro.org Subject: [PATCH resend 3/3] arm64: advertise ARMv8 extensions to 32-bit compat ELF binaries Date: Tue, 25 Feb 2014 13:38:59 +0100 Message-Id: <1393331939-31289-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393331939-31289-1-git-send-email-ard.biesheuvel@linaro.org> References: <1393331939-31289-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140225_073930_888180_B51C1F23 X-CRM114-Status: GOOD ( 12.27 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.50 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: ryan.arnold@linaro.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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.175 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 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 Acked-by: Catalin Marinas --- 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 349c49260f09..67da30741a1b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -243,6 +243,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)