From patchwork Mon Dec 16 21:04:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 3356911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E84C9F380 for ; Mon, 16 Dec 2013 21:07:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BC1C2024D for ; Mon, 16 Dec 2013 21:07:41 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 939D52024C for ; Mon, 16 Dec 2013 21:07:40 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VsfMq-0002Dc-Oq; Mon, 16 Dec 2013 21:06:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VsfMZ-0006UB-W5; Mon, 16 Dec 2013 21:06:03 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VsfLz-0006P7-0i for linux-arm-kernel@lists.infradead.org; Mon, 16 Dec 2013 21:05:30 +0000 Received: by mail-wg0-f49.google.com with SMTP id x12so5259256wgg.16 for ; Mon, 16 Dec 2013 13:05:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zGvrw2S865U/tZQO+LnyQkLstQY9N9EcnV1zeo3ncN4=; b=A0ATxKu2RfGBwY78JnEE/yA0gjXjod9UBkMZYuK5HMYtPjIcT0x4Qj1CJQw3gqoMAr FzHrjuI1Bt53OzWDRT9CweUnr5281E3Y2oJ4Cmg40oaOpoYm6ZRdsw34A55JEnfi5IH/ bCW0jXwaQWCm3riLKnHYDnonaQfGqCp2CSnbtcg+gwlW4jguc6DFDBwSAD7w6Z0CKXLV t4D3M4+plP5YVCkjmq3sc5Qx2p46+vC5wwyMnaji0Hg44y+BZJLgCkacrWtKGJyX+ZY7 N0G84vkIkWevGdACkhii8z+HJ9YxJpIyeHFpjHSDbYbf/fjiawvpHovcZViPwGe0KFx0 WF5g== X-Gm-Message-State: ALoCoQlVMExvr3J2oi5m0cChINw/dp1EBj/uLZwageL/dFSIiyPd1Ueg3SNoNJ4UY1UFRsZdxWWv X-Received: by 10.194.243.70 with SMTP id ww6mr29897wjc.93.1387227903502; Mon, 16 Dec 2013 13:05:03 -0800 (PST) Received: from localhost.localdomain (82-169-5-66.ip.telfort.nl. [82.169.5.66]) by mx.google.com with ESMTPSA id fj8sm46381851wib.1.2013.12.16.13.05.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 13:05:02 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, steve.capper@linaro.org Subject: [PATCH 2/4] arm64: Add hwcaps for crypto and CRC32 extensions. Date: Mon, 16 Dec 2013 22:04:36 +0100 Message-Id: <1387227878-30438-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1387227878-30438-1-git-send-email-ard.biesheuvel@linaro.org> References: <1387227878-30438-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131216_160527_180297_63118850 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -2.6 (--) Cc: 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Capper Advertise the optional cryptographic and CRC32 instructions to user space where present. Several hwcap bits [3-7] are allocated. Signed-off-by: Steve Capper [bit 2 is taken now so use bits 3-7 instead] Signed-off-by: Ard Biesheuvel --- arch/arm64/include/uapi/asm/hwcap.h | 6 +++++- arch/arm64/kernel/setup.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h index 9b12476..73cf0f5 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -22,6 +22,10 @@ #define HWCAP_FP (1 << 0) #define HWCAP_ASIMD (1 << 1) #define HWCAP_EVTSTRM (1 << 2) - +#define HWCAP_AES (1 << 3) +#define HWCAP_PMULL (1 << 4) +#define HWCAP_SHA1 (1 << 5) +#define HWCAP_SHA2 (1 << 6) +#define HWCAP_CRC32 (1 << 7) #endif /* _UAPI__ASM_HWCAP_H */ diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 0bc5e4c..961c961 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -116,6 +116,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) static void __init setup_processor(void) { struct cpu_info *cpu_info; + u64 features, block; /* * locate processor in the list of supported processor @@ -136,6 +137,37 @@ static void __init setup_processor(void) sprintf(init_utsname()->machine, ELF_PLATFORM); elf_hwcap = 0; + + /* + * ID_AA64ISAR0_EL1 contains 4-bit wide signed feature blocks. + * The blocks we test below represent incremental functionality + * for non-negative values. Negative values are reserved. + */ + features = read_cpuid(ID_AA64ISAR0_EL1); + block = (features >> 4) & 0xf; + if (!(block & 0x8)) { + switch (block) { + default: + case 2: + elf_hwcap |= HWCAP_PMULL; + case 1: + elf_hwcap |= HWCAP_AES; + case 0: + break; + } + } + + block = (features >> 8) & 0xf; + if (block && !(block & 0x8)) + elf_hwcap |= HWCAP_SHA1; + + block = (features >> 12) & 0xf; + if (block && !(block & 0x8)) + elf_hwcap |= HWCAP_SHA2; + + block = (features >> 16) & 0xf; + if (block && !(block & 0x8)) + elf_hwcap |= HWCAP_CRC32; } static void __init setup_machine_fdt(phys_addr_t dt_phys) @@ -270,6 +302,11 @@ static const char *hwcap_str[] = { "fp", "asimd", "evtstrm", + "aes", + "pmull", + "sha1", + "sha2", + "crc32", NULL };