From patchwork Tue Sep 12 10:36:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112292 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4986358qgf; Tue, 12 Sep 2017 03:38:45 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBadUKLtp5xF0opI5QHNIqZ9gEs6U04/hEGuIJ+iSnnPcoLq9RH2VrTL6BeMQNViDCroTgv X-Received: by 10.36.36.67 with SMTP id f64mr374336ita.10.1505212725868; Tue, 12 Sep 2017 03:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505212725; cv=none; d=google.com; s=arc-20160816; b=KJbDnS6ATP4c+Mn/g9zUS9XWX/OgihX3y2JV/xq1teuZlQOJBJ2yVgU4lR/KdGF8h8 DzrRt15K8p8Vkn43pEjzCK040F4tiZXjHmrYVD62lI+WMe2hRo2VwqrwUOhXEVUpkBhN //+hA4MQ5UNpllggfwhHTZNNRJp1/sDv3kAmdWFGaFeTvrZSCWhD8N8LPVOyN/CLclpY exnFtvE3V5/zI+vk3n1EYCgyArrA/FOIsIcp4mbPQ6ak+1MhpW9qgkzOHAdEUiQg1igc OOeXAKiwn6nO0FQtGHG5lZVi6tkpCIY1usDMFDVFLhToieELdEfQWQfZmWH8SiwwvubC AJng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=laPO2nbLoU127BbGlW3P7vygrLiWeCyLRdiN3v1e6H4=; b=EJiU0EDjXv1lmHNLyjgDtNRKuYLxCBkBptqdVuuk5hL+NOI0n0t6K4+6Q3WYzHp3j9 fCEqm3o+D1L994FbA1AxTIOgCwO0JvgbDREXuxMg7VWNI/66Grm/pDAAQ9p+BcPT4xJg S/Bp84/VvPziAE8De//EQLECe7VbctcMvIqfiXmBchl2UZVd4/HiprCYQAsNmpUl/8ir vGj2WTIJ4+3p3dnXh5aHG1iQOUGakh1GW1e3g9i1cb1/5K0atXwX5/vsCcxUMQ/8QkGO Gi+PG02URXSP0MrtCCgWoSTYSlQDTR+8EhUw4vEBuAvW8jYxbqZN1c+NI9c8Tx2W+BBe eh2g== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y11si10564117iod.293.2017.09.12.03.38.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 03:38:45 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1driYX-0001On-Ba; Tue, 12 Sep 2017 10:36:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1driYW-0001OO-1d for xen-devel@lists.xen.org; Tue, 12 Sep 2017 10:36:36 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 5D/EA-17770-3B8B7B95; Tue, 12 Sep 2017 10:36:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRWlGSWpSXmKPExsVysyfVTXfjju2 RBp8aDSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oydt7awFOwxqfi/axpLA+NV9S5GLg4hgc2M Eks3T2SBcE4zSnR/72HtYuTkYBPQlLjz+RMTiC0iIC1x7fNlRhCbWaBa4v/Ck2xdjBwcwgKhE md2h4KYLAKqEtdvqoBU8ApYSuxo+ckOYksIyEvsarsINpFTwEpi0asFLCDlQkA1lzZLTmDkXs DIsIpRvTi1qCy1SNdUL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LMMQLCDcfp l/0OMkhxMSqK8R9ZvjxTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwSuyHSgnWJSanlqRlpkDDDGY tAQHj5IIbzhImre4IDG3ODMdInWKUZej4+bdP0xCLHn5ealS4ry/tgEVCYAUZZTmwY2AhfslR lkpYV5GoKOEeApSi3IzS1DlXzGKczAqCfOagqziycwrgdv0CugIJqAjeC5tATmiJBEhJdXAeK QmtKXt15QWKVkBXt6m7ZXemc+3PoyuL1D4ofmYMcd43am1FStvSe4ws9n5e8vm/ObAg0oS4TN KbkxVNO7ep1anUeL3uuC9wrXqloWcn1+eeXjkQr386jfc577573p440nRLM2JaWF36x7x6zZt t3CSsdIWeSjlLDc/m7/whLTo5N55ddv9lFiKMxINtZiLihMBBTqGsnICAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1505212593!106800360!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11912 invoked from network); 12 Sep 2017 10:36:33 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 12 Sep 2017 10:36:33 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBDCD1529; Tue, 12 Sep 2017 03:36:32 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA0DE3F578; Tue, 12 Sep 2017 03:36:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Sep 2017 11:36:18 +0100 Message-Id: <20170912103622.18562-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170912103622.18562-1-julien.grall@arm.com> References: <20170912103622.18562-1-julien.grall@arm.com> Cc: bhupinder.thakur@linaro.org, Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com Subject: [Xen-devel] [PATCH v2 3/7] xen/arm: traps: Export a bunch of helpers to handle emulation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" A follow-up patch will move some parts of traps.c in separate files. The will require to use helpers that are currently statically defined. Export the following helpers: - inject_undef64_exception - inject_undef_exception - check_conditional_instr - advance_pc - handle_raz_wi - handle_wo_wi - handle_ro_raz Note that asm-arm/arm32/traps.h is empty but it is to keep parity with the arm64 counterpart. Signed-off-by: Julien Grall --- Cc: volodymyr_babchuk@epam.com Changes in v2: - Fixup guards - Add newline for clarity --- xen/arch/arm/traps.c | 43 +++++++++++++++++++-------------------- xen/include/asm-arm/arm32/traps.h | 13 ++++++++++++ xen/include/asm-arm/arm64/traps.h | 15 ++++++++++++++ xen/include/asm-arm/traps.h | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 xen/include/asm-arm/arm32/traps.h create mode 100644 xen/include/asm-arm/arm64/traps.h create mode 100644 xen/include/asm-arm/traps.h diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6f32f700e5..1c334a7b99 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -547,7 +548,7 @@ static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset) } /* Inject an undefined exception into a 64 bit guest */ -static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) { vaddr_t handler; const union hsr esr = { @@ -620,8 +621,7 @@ static void inject_iabt64_exception(struct cpu_user_regs *regs, #endif -static void inject_undef_exception(struct cpu_user_regs *regs, - const union hsr hsr) +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr) { if ( is_32bit_domain(current->domain) ) inject_undef32_exception(regs); @@ -1714,8 +1714,7 @@ static const unsigned short cc_map[16] = { 0 /* NV */ }; -static int check_conditional_instr(struct cpu_user_regs *regs, - const union hsr hsr) +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr) { unsigned long cpsr, cpsr_cond; int cond; @@ -1777,7 +1776,7 @@ static int check_conditional_instr(struct cpu_user_regs *regs, return 1; } -static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) { unsigned long itbits, cond, cpsr = regs->cpsr; @@ -1818,11 +1817,11 @@ static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) } /* Read as zero and write ignore */ -static void handle_raz_wi(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +void handle_raz_wi(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); @@ -1836,12 +1835,12 @@ static void handle_raz_wi(struct cpu_user_regs *regs, advance_pc(regs, hsr); } -/* Write only as write ignore */ -static void handle_wo_wi(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +/* write only as write ignore */ +void handle_wo_wi(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); @@ -1856,11 +1855,11 @@ static void handle_wo_wi(struct cpu_user_regs *regs, } /* Read only as read as zero */ -static void handle_ro_raz(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +void handle_ro_raz(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); diff --git a/xen/include/asm-arm/arm32/traps.h b/xen/include/asm-arm/arm32/traps.h new file mode 100644 index 0000000000..e3c4a8b473 --- /dev/null +++ b/xen/include/asm-arm/arm32/traps.h @@ -0,0 +1,13 @@ +#ifndef __ASM_ARM32_TRAPS__ +#define __ASM_ARM32_TRAPS__ + +#endif /* __ASM_ARM32_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ + diff --git a/xen/include/asm-arm/arm64/traps.h b/xen/include/asm-arm/arm64/traps.h new file mode 100644 index 0000000000..e5e5a4a036 --- /dev/null +++ b/xen/include/asm-arm/arm64/traps.h @@ -0,0 +1,15 @@ +#ifndef __ASM_ARM64_TRAPS__ +#define __ASM_ARM64_TRAPS__ + +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len); + +#endif /* __ASM_ARM64_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ + diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h new file mode 100644 index 0000000000..6d99d228e8 --- /dev/null +++ b/xen/include/asm-arm/traps.h @@ -0,0 +1,36 @@ +#ifndef __ASM_ARM_TRAPS__ +#define __ASM_ARM_TRAPS__ + +#include + +#if defined(CONFIG_ARM_32) +# include +#elif defined(CONFIG_ARM_64) +# include +#endif + +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr); + +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr); + +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr); + +void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +#endif /* __ASM_ARM_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ +