From patchwork Wed Feb 15 18:16:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 6802 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E9AB223DE1 for ; Wed, 15 Feb 2012 18:17:07 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id B1470A189E0 for ; Wed, 15 Feb 2012 18:17:07 +0000 (UTC) Received: by yenr11 with SMTP id r11so1028846yen.11 for ; Wed, 15 Feb 2012 10:17:07 -0800 (PST) Received: by 10.50.188.234 with SMTP id gd10mr13294525igc.29.1329329827076; Wed, 15 Feb 2012 10:17:07 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.80.19 with SMTP id r19cs2679ibk; Wed, 15 Feb 2012 10:17:06 -0800 (PST) Received: by 10.180.102.35 with SMTP id fl3mr36761417wib.22.1329329825679; Wed, 15 Feb 2012 10:17:05 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id r37si3115178weq.106.2012.02.15.10.17.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Feb 2012 10:17:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by wibhm14 with SMTP id hm14so957802wib.37 for ; Wed, 15 Feb 2012 10:17:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.24.7 with SMTP id q7mr37125247wif.14.1329329824690; Wed, 15 Feb 2012 10:17:04 -0800 (PST) Received: from localhost.localdomain ([213.123.120.124]) by mx.google.com with ESMTPS id dw7sm35106696wib.4.2012.02.15.10.16.48 (version=SSLv3 cipher=OTHER); Wed, 15 Feb 2012 10:17:04 -0800 (PST) From: Dave Martin To: Nicolas Pitre , Christoffer Dall , Marc Zyngier , Will Deacon Cc: patches@linaro.org, Dave Martin Subject: [PATCH 08/10] ARM: virt: Define helper macros for virtualisation instructions Date: Wed, 15 Feb 2012 18:16:01 +0000 Message-Id: <1329329763-31508-9-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1329329763-31508-1-git-send-email-dave.martin@linaro.org> References: <1329329763-31508-1-git-send-email-dave.martin@linaro.org> X-Gm-Message-State: ALoCoQme4HbOpqGPqzjikn2krEH7feiVaxmiieGxZq4B1u93AWGLIsQL89cWuUFK/V9E53h/4+dO In order to support booting in hyp mode as standard, it is useful to beable to compile the hyp stub installation code into all kernels, even if no hypervisor wlil actually be installed. If the version of gas in use doesn't support, this will fail. This patch defines some helper macros to emit the affected instructions if the tools don't support them natively. Note that there is no way to magically detect that this is necessary. Makefile rules can be used to define AS_NEEDS_HVC as appropriate: it probably does not make sense to define this everywhere. Signed-off-by: Dave Martin --- arch/arm/include/asm/assembler.h | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index fab3ca1..fcdc332 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -328,4 +328,38 @@ .size \name , . - \name .endm +/* + * Virtualisation instruction macros for tools which are too old to support + * them directly. + * + * Supporting Thumb-2 conditional forms via macros is tricky, so these are + * unconditional only. Code which will only be built using newer tools won't + * get these macros however, and should not need to worry about this + * restriction. + */ +#ifdef AS_NEEDS_HVC + .macro hvc i16 + ARM( .inst 0xE1400070 | (((\i16 )<<4)&0xFFF00) | ((\i16 )&0xF) ) + THUMB( .inst.w 0xF7E08000 | (((\i16 )<<4)&0xF0000) | ((\i16 )&0xFFF) ) + .endm + + .macro eret + ARM( .inst 0xE160006E ) /* for ARM, there is a separate encoding */ + THUMB( subs pc, lr, #0 ) /* for Thumb, this architecturally = ERET */ + .endm + +/* + * Note: to reduce the scariness of these macro definitions, regnum is the + * source register _number_ (e.g., specify 0, not r0). + */ + .macro msr_elr_hyp regnum:req + ARM( .inst 0xE12EF300 | (\regnum ) ) + THUMB( .inst 0xF3808A30 | (\regnum )<<16 ) + .endm +#else + .macro msr_elr_hyp regnum:req + msr elr_hyp, r\regnum + .endm +#endif + #endif /* __ASM_ASSEMBLER_H__ */