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

[Xen-devel] [PATCH 2/5] x86/shadow: Tweak some initialisation in sh_page_fault()



sh_page_fault() is a complicated function.  It aids clarity for the reader if
constant data is declared as such.

Declare struct npfec access and fetch_type_t ft as const, which requires
initialising them during declaration.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 xen/arch/x86/mm/shadow/multi.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index f494f7b..67c98b9 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -2860,15 +2860,17 @@ static int sh_page_fault(struct vcpu *v,
     struct sh_emulate_ctxt emul_ctxt;
     const struct x86_emulate_ops *emul_ops;
     int r;
-    fetch_type_t ft = 0;
     p2m_type_t p2mt;
     uint32_t rc;
     int version;
-    struct npfec access = {
+    const struct npfec access = {
          .read_access = 1,
+         .write_access = !!(regs->error_code & PFEC_write_access),
          .gla_valid = 1,
          .kind = npfec_kind_with_gla
     };
+    const fetch_type_t ft =
+        access.write_access ? ft_demand_write : ft_demand_read;
 #if SHADOW_OPTIMIZATIONS & SHOPT_FAST_EMULATION
     int fast_emul = 0;
 #endif
@@ -2878,9 +2880,6 @@ static int sh_page_fault(struct vcpu *v,
 
     perfc_incr(shadow_fault);
 
-    if ( regs->error_code & PFEC_write_access )
-        access.write_access = 1;
-
 #if SHADOW_OPTIMIZATIONS & SHOPT_FAST_EMULATION
     /* If faulting frame is successfully emulated in last shadow fault
      * it's highly likely to reach same emulation action for this frame.
@@ -3050,10 +3049,6 @@ static int sh_page_fault(struct vcpu *v,
         goto propagate;
     }
 
-    /* What kind of access are we dealing with? */
-    ft = ((regs->error_code & PFEC_write_access)
-          ? ft_demand_write : ft_demand_read);
-
     /* What mfn is the guest trying to access? */
     gfn = guest_l1e_get_gfn(gw.l1e);
     gmfn = get_gfn(d, gfn, &p2mt);
-- 
2.1.4


_______________________________________________
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®.