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

[xen master] x86/shadow: rename a parameter of shadow_l<N>_index()



commit ef69700ea0c979eadb5e67eefabe312160bd5304
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri May 22 13:18:38 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri May 22 13:18:38 2026 +0200

    x86/shadow: rename a parameter of shadow_l<N>_index()
    
    ... shadowing a file scope one, thus violating Misra C:2012 rule 5.3
    ("An identifier declared in an inner scope shall not hide an identifier
    declared in an outer scope").
    
    While there,
    - replace u32 by uint32_t,
    - reduce the number of cf_check by aliasing shadow_l<N>_index() to
      shadow_l1_index() for N > 1 and GUEST_PAGING_LEVELS > 2.
    
    No difference in generated code, except of course the removal of the
    duplicate function instances.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/mm/shadow/multi.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 9e4992c6b1..2990cee869 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -402,46 +402,39 @@ guest_index(const void *ptr)
     return (u32)((unsigned long)ptr & ~PAGE_MASK) / sizeof(guest_l1e_t);
 }
 
-static u32 cf_check shadow_l1_index(mfn_t *smfn, u32 guest_index)
+static uint32_t cf_check shadow_l1_index(mfn_t *smfn, uint32_t gidx)
 {
 #if (GUEST_PAGING_LEVELS == 2)
     ASSERT(mfn_to_page(*smfn)->u.sh.head);
-    if ( guest_index >= SHADOW_L1_PAGETABLE_ENTRIES )
+    if ( gidx >= SHADOW_L1_PAGETABLE_ENTRIES )
         *smfn = sh_next_page(*smfn);
-    return (guest_index % SHADOW_L1_PAGETABLE_ENTRIES);
+    return (gidx % SHADOW_L1_PAGETABLE_ENTRIES);
 #else
-    return guest_index;
+    return gidx;
 #endif
 }
 
-static u32 cf_check shadow_l2_index(mfn_t *smfn, u32 guest_index)
-{
 #if (GUEST_PAGING_LEVELS == 2)
+static uint32_t cf_check shadow_l2_index(mfn_t *smfn, uint32_t gidx)
+{
     int i;
     ASSERT(mfn_to_page(*smfn)->u.sh.head);
     // Because we use 2 shadow l2 entries for each guest entry, the number of
     // guest entries per shadow page is SHADOW_L2_PAGETABLE_ENTRIES/2
-    for ( i = 0; i < guest_index / (SHADOW_L2_PAGETABLE_ENTRIES / 2); i++ )
+    for ( i = 0; i < gidx / (SHADOW_L2_PAGETABLE_ENTRIES / 2); i++ )
         *smfn = sh_next_page(*smfn);
     // We multiply by two to get the index of the first of the two entries
     // used to shadow the specified guest entry.
-    return (guest_index % (SHADOW_L2_PAGETABLE_ENTRIES / 2)) * 2;
+    return (gidx % (SHADOW_L2_PAGETABLE_ENTRIES / 2)) * 2;
+}
 #else
-    return guest_index;
+#define shadow_l2_index shadow_l1_index
 #endif
-}
 
 #if GUEST_PAGING_LEVELS >= 4
 
-static u32 cf_check shadow_l3_index(mfn_t *smfn, u32 guest_index)
-{
-    return guest_index;
-}
-
-static u32 cf_check shadow_l4_index(mfn_t *smfn, u32 guest_index)
-{
-    return guest_index;
-}
+#define shadow_l3_index shadow_l1_index
+#define shadow_l4_index shadow_l1_index
 
 #endif // GUEST_PAGING_LEVELS >= 4
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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