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

[xen staging] x86/P2M: split a read_atomic() invocation



commit 91ea85ec1213bf3dbc052bd8b3710f9be7a71000
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri May 22 08:19:34 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri May 22 08:19:34 2026 +0200

    x86/P2M: split a read_atomic() invocation
    
    Misra C:2012 rule 13.6 takes issue with pfn_to_pdx() and mfn_x() uses
    (deep) inside sizeof(), as used by read_atomic(). Break out the MFN ->
    struct page_info * translation.
    
    No difference in generated code, except for a line number change.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/mm/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index f5f9c0ac45..027b9ae69b 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1332,6 +1332,7 @@ int set_shared_p2m_entry(struct domain *d, unsigned long 
gfn_l, mfn_t mfn)
     p2m_access_t a;
     p2m_type_t ot;
     mfn_t omfn;
+    const struct page_info *pg;
     unsigned long pg_type;
 
     if ( !paging_mode_translate(p2m->domain) )
@@ -1345,7 +1346,8 @@ int set_shared_p2m_entry(struct domain *d, unsigned long 
gfn_l, mfn_t mfn)
     ASSERT(mfn_valid(omfn));
     /* Set the m2p entry to invalid only if there are no further type
      * refs to this page as shared */
-    pg_type = read_atomic(&(mfn_to_page(omfn)->u.inuse.type_info));
+    pg = mfn_to_page(omfn);
+    pg_type = read_atomic(&pg->u.inuse.type_info);
     if ( (pg_type & PGT_count_mask) == 0
          || (pg_type & PGT_type_mask) != PGT_shared_page )
         set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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