From patchwork Wed Nov 16 14:38:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 9431753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A96260476 for ; Wed, 16 Nov 2016 14:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C77D28713 for ; Wed, 16 Nov 2016 14:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7142A28727; Wed, 16 Nov 2016 14:38:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2487228713 for ; Wed, 16 Nov 2016 14:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753589AbcKPOio (ORCPT ); Wed, 16 Nov 2016 09:38:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932664AbcKPOim (ORCPT ); Wed, 16 Nov 2016 09:38:42 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 665EAC0641E8; Wed, 16 Nov 2016 14:38:41 +0000 (UTC) Received: from kamzik.brq.redhat.com (kamzik.brq.redhat.com [10.34.1.143]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAGEccS2030614; Wed, 16 Nov 2016 09:38:39 -0500 From: Andrew Jones To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: wei@redhat.com, cov@codeaurora.org, shannon.zhao@linaro.org, marc.zyngier@arm.com, peter.maydell@linaro.org, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH] arm/arm64: introduce is_aarch32 Date: Wed, 16 Nov 2016 15:38:36 +0100 Message-Id: <1479307116-6355-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 16 Nov 2016 14:38:41 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ARMv7-A isn't exactly the same as ARMv8-A32 (AArch32). This function allows unit tests to make the distinction. Signed-off-by: Andrew Jones --- I'm actually unsure if there's a feature bit or not that I could probe instead. It'd be nice if somebody can confirm. Thanks, drew lib/arm/asm/processor.h | 20 ++++++++++++++++++++ lib/arm64/asm/processor.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/lib/arm/asm/processor.h b/lib/arm/asm/processor.h index f25e7eee3666..223e54beb72a 100644 --- a/lib/arm/asm/processor.h +++ b/lib/arm/asm/processor.h @@ -5,6 +5,7 @@ * * This work is licensed under the terms of the GNU LGPL, version 2. */ +#include #include enum vector { @@ -46,4 +47,23 @@ static inline unsigned int get_mpidr(void) extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr); extern bool is_user(void); +/* + * ARMv7-A isn't exactly the same as ARMv8-A32 (AArch32). This + * function allows unit tests to make the distinction. + */ +static inline bool is_aarch32(void) +{ + /* + * XXX: Unfortunately there's no feature bit we can probe for + * this, so we do a hacky check for the processor type not being + * a Cortex-A15, which is the only v7 type we currently use. + */ + unsigned long midr; + + asm volatile("MRC p15, 0, %0, c0, c0, 0" : "=r" (midr)); + midr &= GENMASK(31, 24) | GENMASK(15, 4); + + return midr != ((0x41 << 24) | (0xc0f << 4)); +} + #endif /* _ASMARM_PROCESSOR_H_ */ diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h index 84d5c7ce752b..b602e1fbbc2d 100644 --- a/lib/arm64/asm/processor.h +++ b/lib/arm64/asm/processor.h @@ -81,5 +81,10 @@ DEFINE_GET_SYSREG32(mpidr) extern void start_usr(void (*func)(void *arg), void *arg, unsigned long sp_usr); extern bool is_user(void); +static inline bool is_aarch32(void) +{ + return false; +} + #endif /* !__ASSEMBLY__ */ #endif /* _ASMARM64_PROCESSOR_H_ */