From patchwork Thu Jul 28 14:51:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72985 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp894844qga; Thu, 28 Jul 2016 07:54:48 -0700 (PDT) X-Received: by 10.36.25.202 with SMTP id b193mr106040183itb.29.1469717688326; Thu, 28 Jul 2016 07:54:48 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 203si13464637ioz.136.2016.07.28.07.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:54:48 -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 1bSmfE-0002mN-TF; Thu, 28 Jul 2016 14:51:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmfD-0002m9-Vh for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:51:56 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id DA/DA-06589-B0C1A975; Thu, 28 Jul 2016 14:51:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTZdLZla 4wdPVWhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bU19tYC24JVBw4d5q1gXEzdxcjF4eQwCZG icVb/7BBOKcZJXZeWsPexcjJwSagKXHn8ycmEFtEQFri2ufLjCBFzALtjBJr+3uZQRLCAskS9 661AhVxcLAIqEr82JkBEuYVcJY4duIDI4gtISAncfLYZFaQEk4BF4nX3UIgYSGgkukzlzJOYO RewMiwilG9OLWoLLVI10IvqSgzPaMkNzEzR9fQ0EQvN7W4ODE9NScxqVgvOT93EyPQuwxAsIN x4yTnQ4ySHExKorxhoTPDhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw+kvNChcSLEpNT61Iy8wB hhlMWoKDR0mEVw8kzVtckJhbnJkOkTrFqCglzlsDkhAASWSU5sG1wUL7EqOslDAvI9AhQjwFq UW5mSWo8q8YxTkYlYR5d4BM4cnMK4Gb/gpoMRPQ4uLYGSCLSxIRUlINjBqzKu68+6ub9PfLHd lJO9evqPaZzRZ65dpUgR3XX/345POW6e/s6hVRa7zeRjMXPjd8yRH3tqHJQMm/ezN/xdQZX/Y zLWbr+rzr5O3UfK9FE2oik7Wsz+7Tt7D396mXPl/6Iub7bsd3LbvUhG39V5RO9LPgFHD2cjdh SvzwMMBvwZyJMZu+XFViKc5INNRiLipOBACTEu9EaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1469717514!3969173!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42366 invoked from network); 28 Jul 2016 14:51:54 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 28 Jul 2016 14:51:54 -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 15FD930C; Thu, 28 Jul 2016 07:53:11 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D5DED3F21A; Thu, 28 Jul 2016 07:51:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:51:24 +0100 Message-Id: <1469717505-8026-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469717505-8026-1-git-send-email-julien.grall@arm.com> References: <1469717505-8026-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [RFC 01/22] xen/arm: do_trap_instr_abort_guest: Move the IPA computation out of the switch 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 add more case to the switch that will require the IPA. So move the computation out of the switch. Signed-off-by: Julien Grall --- xen/arch/arm/traps.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 683bcb2..46e0663 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2403,35 +2403,35 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, int rc; register_t gva = READ_SYSREG(FAR_EL2); uint8_t fsc = hsr.iabt.ifsc & ~FSC_LL_MASK; + paddr_t gpa; + + if ( hpfar_is_valid(hsr.iabt.s1ptw, fsc) ) + gpa = get_faulting_ipa(gva); + else + { + /* + * Flush the TLB to make sure the DTLB is clear before + * doing GVA->IPA translation. If we got here because of + * an entry only present in the ITLB, this translation may + * still be inaccurate. + */ + flush_tlb_local(); + + rc = gva_to_ipa(gva, &gpa, GV2M_READ); + if ( rc == -EFAULT ) + return; /* Try again */ + } switch ( fsc ) { case FSC_FLT_PERM: { - paddr_t gpa; const struct npfec npfec = { .insn_fetch = 1, .gla_valid = 1, .kind = hsr.iabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla }; - if ( hpfar_is_valid(hsr.iabt.s1ptw, fsc) ) - gpa = get_faulting_ipa(gva); - else - { - /* - * Flush the TLB to make sure the DTLB is clear before - * doing GVA->IPA translation. If we got here because of - * an entry only present in the ITLB, this translation may - * still be inaccurate. - */ - flush_tlb_local(); - - rc = gva_to_ipa(gva, &gpa, GV2M_READ); - if ( rc == -EFAULT ) - return; /* Try again */ - } - rc = p2m_mem_access_check(gpa, gva, npfec); /* Trap was triggered by mem_access, work here is done */