From patchwork Thu Aug 4 17:50:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 73297 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1519313qga; Thu, 4 Aug 2016 10:52:31 -0700 (PDT) X-Received: by 10.107.137.150 with SMTP id t22mr74820612ioi.20.1470333151486; Thu, 04 Aug 2016 10:52:31 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o138si13676750ioo.211.2016.08.04.10.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 10:52:31 -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 1bVMmh-0004b5-1k; Thu, 04 Aug 2016 17:50:19 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVMmf-0004aT-Rk for xen-devel@lists.xen.org; Thu, 04 Aug 2016 17:50:17 +0000 Received: from [193.109.254.147] by server-9.bemta-14.messagelabs.com id 2B/F2-10182-95083A75; Thu, 04 Aug 2016 17:50:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTTeiYXG 4wcld+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8biP6cZCx5wVcz8uZG5gXESRxcjF4eQwCZG iYtzHrBAOKcZJVrfXGLrYuTkYBPQlLjz+RMTiC0iIC1x7fNlRhCbWcBB4s3HeywgtrBAiET3l Q6wOIuAqsS5vlXMIDavgIvEtjntYLaEgJzEyWOTWUFsTgFXiUmnfoDFhYBq1q27zDKBkXsBI8 MqRo3i1KKy1CJdI2O9pKLM9IyS3MTMHF1DQxO93NTi4sT01JzEpGK95PzcTYxAD9czMDDuYJx 13O8QoyQHk5Io76vqxeFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjd6oFygkWp6akVaZk5wFCD SUtw8CiJ8EaBpHmLCxJzizPTIVKnGBWlxHljQRICIImM0jy4Nlh4X2KUlRLmZWRgYBDiKUgty s0sQZV/xSjOwagkzFsOMoUnM68EbvoroMVMQItPGCwAWVySiJCSamBkiQrb8V4y0+2lWGpbV9 LtG8kCNzUv/t+77krm+Tu8T4q6H2nejX5/VfG2qpmgR9f1GS6mH5IXRL+WK3rLXykUOIUlRyz tRtPbItXAx6z3Ff/OiwzI92C5cawuao7SVvmbZ58amtxbcZZjrzDPkftyHg0nl0l4GK5pb/32 OtNZb8ojoa2xN18osRRnJBpqMRcVJwIAnw/pHGoCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1470333016!57891910!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 6332 invoked from network); 4 Aug 2016 17:50:16 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-27.messagelabs.com with SMTP; 4 Aug 2016 17:50:16 -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 6298930C; Thu, 4 Aug 2016 10:51:38 -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 5C1A63F51B; Thu, 4 Aug 2016 10:50:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 4 Aug 2016 18:50:02 +0100 Message-Id: <1470333007-25178-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470333007-25178-1-git-send-email-julien.grall@arm.com> References: <1470333007-25178-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 1/6] xen/arm: traps: Simplify the switch in do_trap_*_abort_guest 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" The fault status we care are in the form BBBBxx where xx is the lookup level that gave the fault. We can simplify the code by masking the 2 least significant bits. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- The switch has not been replaced by a simple if because more case will be added in follow-up patches. Changes in v2: - Fix typoes in the commit message --- xen/arch/arm/traps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 0f78d21..b11d2e5 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2387,9 +2387,9 @@ static void do_trap_instr_abort_guest(struct cpu_user_regs *regs, int rc; register_t gva = READ_SYSREG(FAR_EL2); - switch ( hsr.iabt.ifsc & 0x3f ) + switch ( hsr.iabt.ifsc & ~FSC_LL_MASK ) { - case FSC_FLT_PERM ... FSC_FLT_PERM + 3: + case FSC_FLT_PERM: { paddr_t gpa; const struct npfec npfec = { @@ -2450,9 +2450,9 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, return; /* Try again */ } - switch ( dabt.dfsc & 0x3f ) + switch ( dabt.dfsc & ~FSC_LL_MASK ) { - case FSC_FLT_PERM ... FSC_FLT_PERM + 3: + case FSC_FLT_PERM: { const struct npfec npfec = { .read_access = !dabt.write,