diff mbox

[v3,1/6] xen/arm: traps: Simplify the switch in do_trap_*_abort_guest

Message ID 1470333007-25178-2-git-send-email-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Julien Grall Aug. 4, 2016, 5:50 p.m. UTC
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 <julien.grall@arm.com>

---
    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(-)

Comments

Julien Grall Aug. 4, 2016, 5:52 p.m. UTC | #1
Hi,

On 04/08/16 18:50, Julien Grall wrote:
> 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 <julien.grall@arm.com>

I forgot to retain the reviewed-by from Stefano given on the last version:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

>
> ---
>     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,
>
diff mbox

Patch

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,