From patchwork Fri May 2 19:15:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 29585 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E6A3E203F3 for ; Fri, 2 May 2014 19:26:44 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id i17sf6640794qcy.2 for ; Fri, 02 May 2014 12:26:44 -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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=WqFsECgLdapE81nEgfPtibsJE9he/Y4m4gdfLw4laRs=; b=F5fBj6YiJqJLVnmUeGmQ5oXqXwXYH22SCXs0aB01w7QsbRJ9PsA7tjO5EXm1IE6p0U idDq4iXpMLq+Ci+/vbF5kAmBtcCKkOe0BKuWmmvvfWgD94n5lcumxDUYEV342IBo1FN5 3r7LMVl2XgvgMTif5iCmk4SuLjQ/U95uokCRWyZkI40ojQ5YFSbaD33qR4SN9HZuV/oS FGaYki3tPnt7J/pG8S7gMWz7zVFjZAjWSLc1v+iujcq1iIq+6K9wQBEsQvpVrs0Rrt3m 4GaT2YI+FcTf6t1EQeNjy5QUzbciO6PUw2b8pES/p4t5VXH8ED9IBihiuiviZpU4t4OI HSsg== X-Gm-Message-State: ALoCoQlGRJH1tSWgXiadLV2KiUbhEZvXwHuwlDxxFAPIy2N1tgNnbah9jU3z4vP8IUwTq5z6nCcS X-Received: by 10.236.32.236 with SMTP id o72mr8274563yha.42.1399058804729; Fri, 02 May 2014 12:26:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.54 with SMTP id b51ls1720829qgf.48.gmail; Fri, 02 May 2014 12:26:44 -0700 (PDT) X-Received: by 10.221.36.73 with SMTP id sz9mr1022369vcb.62.1399058804442; Fri, 02 May 2014 12:26:44 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id u18si1188993vew.84.2014.05.02.12.26.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 May 2014 12:26:44 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so4947124veb.32 for ; Fri, 02 May 2014 12:26:44 -0700 (PDT) X-Received: by 10.52.128.231 with SMTP id nr7mr11964929vdb.17.1399058804377; Fri, 02 May 2014 12:26:44 -0700 (PDT) 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.221.72 with SMTP id ib8csp126287vcb; Fri, 2 May 2014 12:26:44 -0700 (PDT) X-Received: by 10.140.48.13 with SMTP id n13mr23768542qga.90.1399058804001; Fri, 02 May 2014 12:26:44 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a7si1015090qcf.45.2014.05.02.12.26.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 May 2014 12:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:45961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgIyZ-0003WN-Ss for patch@linaro.org; Fri, 02 May 2014 15:18:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgIwE-00082p-BY for qemu-devel@nongnu.org; Fri, 02 May 2014 15:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgIw5-0000C8-GX for qemu-devel@nongnu.org; Fri, 02 May 2014 15:16:02 -0400 Received: from afflict.kos.to ([92.243.29.197]:48087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgIw5-0000AH-8Z for qemu-devel@nongnu.org; Fri, 02 May 2014 15:15:53 -0400 Received: from localhost.localdomain (afflict [92.243.29.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 4274E264D6; Fri, 2 May 2014 21:15:51 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 2 May 2014 22:15:49 +0300 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 14/14] linux-user/elfload.c: Support ARM HWCAP2 flags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 From: Peter Maydell The ARM kernel has chosen to spill into the HWCAP2 ELF feature bit flags early, even though it hasn't yet exhausted all 32 bits of the HWCAP word. Add support for setting this in the same way we do for HWCAP. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- include/elf.h | 1 + linux-user/elfload.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/elf.h b/include/elf.h index 667af6f..1599ab2 100644 --- a/include/elf.h +++ b/include/elf.h @@ -254,6 +254,7 @@ typedef int64_t Elf64_Sxword; #define AT_SECURE 23 /* boolean, was exec suid-like? */ #define AT_BASE_PLATFORM 24 /* string identifying real platforms */ #define AT_RANDOM 25 /* address of 16 random bytes */ +#define AT_HWCAP2 26 /* extension of AT_HWCAP */ #define AT_EXECFN 31 /* filename of the executable */ #define AT_SYSINFO 32 /* address of kernel entry point */ #define AT_SYSINFO_EHDR 33 /* address of kernel vdso */ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ad07c43..995f999 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -20,6 +20,7 @@ #undef ARCH_DLINFO #undef ELF_PLATFORM #undef ELF_HWCAP +#undef ELF_HWCAP2 #undef ELF_CLASS #undef ELF_DATA #undef ELF_ARCH @@ -353,6 +354,14 @@ enum ARM_HWCAP_ARM_EVTSTRM = 1 << 21, }; +enum { + ARM_HWCAP2_ARM_AES = 1 << 0, + ARM_HWCAP2_ARM_PMULL = 1 << 1, + ARM_HWCAP2_ARM_SHA1 = 1 << 2, + ARM_HWCAP2_ARM_SHA2 = 1 << 3, + ARM_HWCAP2_ARM_CRC32 = 1 << 4, +}; + /* The commpage only exists for 32 bit kernels */ #define TARGET_HAS_VALIDATE_GUEST_SPACE @@ -416,6 +425,7 @@ static int validate_guest_space(unsigned long guest_base, } #define ELF_HWCAP get_elf_hwcap() +#define ELF_HWCAP2 get_elf_hwcap2() static uint32_t get_elf_hwcap(void) { @@ -448,11 +458,22 @@ static uint32_t get_elf_hwcap(void) */ GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPD32); GET_FEATURE(ARM_FEATURE_LPAE, ARM_HWCAP_ARM_LPAE); -#undef GET_FEATURE return hwcaps; } +static uint32_t get_elf_hwcap2(void) +{ + ARMCPU *cpu = ARM_CPU(thread_cpu); + uint32_t hwcaps = 0; + + GET_FEATURE(ARM_FEATURE_V8_AES, ARM_HWCAP2_ARM_AES); + GET_FEATURE(ARM_FEATURE_CRC, ARM_HWCAP2_ARM_CRC32); + return hwcaps; +} + +#undef GET_FEATURE + #else /* 64 bit ARM definitions */ #define ELF_START_MMAP 0x80000000 @@ -1486,6 +1507,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, #ifdef DLINFO_ARCH_ITEMS size += DLINFO_ARCH_ITEMS * 2; #endif +#ifdef ELF_HWCAP2 + size += 2; +#endif size += envc + argc + 2; size += 1; /* argc itself */ size *= n; @@ -1519,6 +1543,10 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK)); NEW_AUX_ENT(AT_RANDOM, (abi_ulong) u_rand_bytes); +#ifdef ELF_HWCAP2 + NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2); +#endif + if (k_platform) NEW_AUX_ENT(AT_PLATFORM, u_platform); #ifdef ARCH_DLINFO