From patchwork Fri May 2 13:45:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 29551 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B3BD203F3 for ; Fri, 2 May 2014 13:45:20 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id j5sf9682888qga.6 for ; Fri, 02 May 2014 06:45:20 -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=L5IhoAL5DjK64JUP5NgaFTHNwh+S0cB4pwGDVGl1HQM=; b=WHs75ojAZV1Uh+IQzvCYaBIA4bCxJeF18tii4iB8f1DJYr0WJ7wWErI+EVGXQNBbPe K6uHcnvXldCVHFKA3lMcNba2Q2537INA9kTYVm2Ogql5uZyHaiaUoWg1RNGqnX2Z6gSy Zy6MZtqBWgX56wq/mLJ7E3YNh46ZQS5FiO8qZTyfJl0cfDoZLo6x3AnuGkzgiTJDc0p0 gz3yUpEugOjpvIE7ThQgpKW+FJpU392FH5fERqtt6+18utcxiYlqITJll2n5S7FYF/N0 aCJLFr278qIRKpEXvtza/6+2640W7ofN9Q3t+82yvFZG8pQJoCWVsZrTUXvJX0tAFQry Sghg== X-Gm-Message-State: ALoCoQk0n0yYxakEhJ8utBDPWyxbQ4yUL2PyhnJqXSw1+Kksc90yND3IwN6hsUAZPxDEFpX+gCrH X-Received: by 10.236.116.137 with SMTP id g9mr5216849yhh.14.1399038320399; Fri, 02 May 2014 06:45:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.180 with SMTP id w49ls1487440qge.3.gmail; Fri, 02 May 2014 06:45:20 -0700 (PDT) X-Received: by 10.58.195.202 with SMTP id ig10mr202292vec.33.1399038320195; Fri, 02 May 2014 06:45:20 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id m14si6719530vcn.17.2014.05.02.06.45.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 May 2014 06:45:20 -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.180; Received: by mail-ve0-f180.google.com with SMTP id db12so1879302veb.25 for ; Fri, 02 May 2014 06:45:20 -0700 (PDT) X-Received: by 10.220.105.130 with SMTP id t2mr13563077vco.18.1399038320128; Fri, 02 May 2014 06:45:20 -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 ib8csp104052vcb; Fri, 2 May 2014 06:45:19 -0700 (PDT) X-Received: by 10.67.14.98 with SMTP id ff2mr34574528pad.101.1399038318436; Fri, 02 May 2014 06:45:18 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id pn4si24235939pac.421.2014.05.02.06.45.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 02 May 2014 06:45:18 -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 1WgDm7-0002NT-Ek; Fri, 02 May 2014 14:45:15 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio Subject: [PATCH 4/4] linux-user/elfload.c: Support ARM HWCAP2 flags Date: Fri, 2 May 2014 14:45:15 +0100 Message-Id: <1399038315-9099-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399038315-9099-1-git-send-email-peter.maydell@linaro.org> References: <1399038315-9099-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=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 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: , 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 --- 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 e1ff346..5db67cf 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