From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>
Subject: [PATCH 5/5] x86/shadow: rename a parameter of shadow_l<N>_index()
Date: Wed, 13 May 2026 13:46:59 +0200 [thread overview]
Message-ID: <8aca671a-eb6f-475d-87cb-7a738ecd0793@suse.com> (raw)
In-Reply-To: <5eaaf72a-850c-4535-9f20-13b4feed38d1@suse.com>
... 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@suse.com>
--- 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
prev parent reply other threads:[~2026-05-13 11:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 11:43 [PATCH 0/5] x86: Misra rule 5.3 Jan Beulich
2026-05-13 11:44 ` [PATCH 1/5] x86/guest: rename a local variable Jan Beulich
2026-05-13 21:17 ` Nicola Vetrini
2026-05-15 11:00 ` Andrew Cooper
2026-05-13 11:44 ` [PATCH 2/5] x86/PV: rename a local variable in pv_emulate_gate_op() Jan Beulich
2026-05-13 11:45 ` [PATCH 3/5] x86/shadow: conditionalize / rename local variables Jan Beulich
2026-05-13 11:46 ` [PATCH 4/5] x86/shadow: split a nested max() invocation Jan Beulich
2026-05-14 5:08 ` Nicola Vetrini
2026-05-15 6:15 ` Jan Beulich
2026-05-13 11:46 ` Jan Beulich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8aca671a-eb6f-475d-87cb-7a738ecd0793@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.