From patchwork Thu Sep 15 11:28:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9333217 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 991416089F for ; Thu, 15 Sep 2016 11:31:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87F70295C6 for ; Thu, 15 Sep 2016 11:31:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CBA3295D1; Thu, 15 Sep 2016 11:31:17 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C10D9295D3 for ; Thu, 15 Sep 2016 11:31:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkUqa-0004aT-60; Thu, 15 Sep 2016 11:28:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkUqY-0004a3-KS for xen-devel@lists.xen.org; Thu, 15 Sep 2016 11:28:50 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id A3/54-23620-1F58AD75; Thu, 15 Sep 2016 11:28:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTfdj661 wg2tnFCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxrn94zFpwUrLi0aR57A2MnTxcjJ4eQwCZG ib6XLhD2aUaJi1OrQWw2AU2JO58/MYHYIgLSEtc+X2bsYuTiYBZoZ5RY29/L3MXIwSEsUCixZ I0mSA2LgKrEj+8z2UBsXgEXiWvHFoPZEgJyEiePTWYFKecUcJVY8lwUYpWLxLETO9kmMHIvYG RYxahRnFpUllqka2igl1SUmZ5RkpuYmQPkGevlphYXJ6an5iQmFesl5+duYgT6tp6BgXEH47Y u50OMkhxMSqK8bmm3woX4kvJTKjMSizPii0pzUosPMcpwcChJ8O5rAcoJFqWmp1akZeYAgwwm LcHBoyTC+wMkzVtckJhbnJkOkTrFqCglDtEnAJLIKM2Da4MF9iVGWSlhXkYGBgYhnoLUotzME lT5V4ziHIxKwrxHQKbwZOaVwE1/BbSYCWjxljXXQRaXJCKkpBoY299b5J669vDd2pyFBwW3Wc tqfX46VePRun+5fxebRfxVes+8ZzXDk8y4JSccT+z6fSns0K3Fx+Q6Psf+uaS75tHborcRVRH sj6sNp2/zkbGcsfVrXXQd6800TuHTFht/izgeL5hV+pR/S8cahxUF699X1Qm/sPlnWRz/71jk b58uz9Dq/QcauJVYijMSDbWYi4oTAbfozXlnAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1473938929!34559879!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65398 invoked from network); 15 Sep 2016 11:28:49 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 15 Sep 2016 11:28:49 -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 B99F314F; Thu, 15 Sep 2016 04:28:48 -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 B55E13F251; Thu, 15 Sep 2016 04:28:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 15 Sep 2016 12:28:17 +0100 Message-Id: <1473938919-31976-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473938919-31976-1-git-send-email-julien.grall@arm.com> References: <1473938919-31976-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] [for-4.8][PATCH v2 01/23] 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Stefano Stabellini --- Changes in v2: - Add Stefano's acked-by --- 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 39a05fd..a5a5384 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2404,35 +2404,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 */