[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v3 32/38] arm/p2m: Code movement in instr/data abort handlers



This commit moves code in the functions
"do_trap_data_(instr|abort)_guest" without changing the original
functionality. The code movement is limited to moving the struct npfec
out of the switch statements in both functions. This commit acts as a
basis for the following commit implementing the altp2m paging mechanism.

Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Julien Grall <julien.grall@xxxxxxx>
---
 xen/arch/arm/traps.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index da56cc0..0bf1653 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2406,6 +2406,12 @@ static void do_trap_instr_abort_guest(struct 
cpu_user_regs *regs,
     paddr_t gpa;
     mfn_t mfn;
 
+    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
@@ -2431,20 +2437,12 @@ static void do_trap_instr_abort_guest(struct 
cpu_user_regs *regs,
     switch ( fsc )
     {
     case FSC_FLT_PERM:
-    {
-        const struct npfec npfec = {
-            .insn_fetch = 1,
-            .gla_valid = 1,
-            .kind = hsr.iabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla
-        };
-
         rc = p2m_mem_access_check(gpa, gva, npfec);
 
         /* Trap was triggered by mem_access, work here is done */
         if ( !rc )
             return;
         break;
-    }
     case FSC_FLT_TRANS:
         /*
          * The PT walk may have failed because someone was playing
@@ -2500,6 +2498,13 @@ static void do_trap_data_abort_guest(struct 
cpu_user_regs *regs,
     uint8_t fsc = hsr.dabt.dfsc & ~FSC_LL_MASK;
     mfn_t mfn;
 
+    const struct npfec npfec = {
+        .read_access = !dabt.write,
+        .write_access = dabt.write,
+        .gla_valid = 1,
+        .kind = dabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla
+    };
+
     info.dabt = dabt;
 #ifdef CONFIG_ARM_32
     info.gva = READ_CP32(HDFAR);
@@ -2524,21 +2529,12 @@ static void do_trap_data_abort_guest(struct 
cpu_user_regs *regs,
     switch ( fsc )
     {
     case FSC_FLT_PERM:
-    {
-        const struct npfec npfec = {
-            .read_access = !dabt.write,
-            .write_access = dabt.write,
-            .gla_valid = 1,
-            .kind = dabt.s1ptw ? npfec_kind_in_gpt : npfec_kind_with_gla
-        };
-
         rc = p2m_mem_access_check(info.gpa, info.gva, npfec);
 
         /* Trap was triggered by mem_access, work here is done */
         if ( !rc )
             return;
         break;
-    }
     case FSC_FLT_TRANS:
         /*
          * Attempt first to emulate the MMIO has the data abort will
-- 
2.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.