Skip to contentSkip to conversation

x86: More misc MISRA fixes

PATCH In review Andrew Cooper 3 participants 10 messages Dec 12, 2025 – Dec 15, 2025

lore
Share & tools
lore
#0 lore raw

cover x86: More misc MISRA fixes

Andrew Cooper (5):
x86/pv: Address MISRA C:2012 Rule 4.1
x86/pv: Change type of do_update_descriptor()'s desc parameter
x86: Address MIRSA R8.3 (declaration/definition mismatch) issues
x86: Address MIRSA R8.4 (declaration visibility) issues RFC x86/shadow: Deviate multi.h as being included multiple times

 xen/arch/x86/include/asm/hypercall.h |  4 ++--
 xen/arch/x86/include/asm/pv/mm.h     |  4 ++--
 xen/arch/x86/include/asm/shadow.h    |  2 +-
 xen/arch/x86/mm.c                    |  4 ++--
 xen/arch/x86/mm/shadow/common.c      |  8 ++++----
 xen/arch/x86/mm/shadow/multi.h       |  6 ++++--
 xen/arch/x86/mm/shadow/private.h     | 10 +++++-----
 xen/arch/x86/pv/descriptor-tables.c  | 10 ++++------
 xen/arch/x86/pv/emul-inv-op.c        |  2 +-
 xen/arch/x86/pv/traps.c              |  4 ++--
 xen/arch/x86/setup.c                 |  4 ++--
 xen/common/kimage.c                  |  2 +-
 xen/common/livepatch.c               | 14 +++++++-------
 xen/include/hypercall-defs.c         |  2 +-
 xen/include/xen/livepatch.h          |  2 +-
 15 files changed, 39 insertions(+), 39 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/5 x86/pv: Address MISRA C:2012 Rule 4.1

MISRA doesn't like mixing hexadecimal escape sequences with ASCII text. Use the same workaround as in commit cd5048353725 ("xen: address MISRA C:2012 Rule 4.1").

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/pv/emul-inv-op.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/pv/emul-inv-op.c +1 -1
index 314ebd01cb34..346ac1124d7b 100644
@@ -26,7 +26,7 @@ static int emulate_forced_invalid_op(struct cpu_user_regs *regs)
         pv_inject_page_fault(0, eip + sizeof(sig) - rc);
         return EXCRET_fault_fixed;
     }
-    if ( memcmp(sig, "\xf\xbxen", sizeof(sig)) )
+    if ( memcmp(sig, "\xf\xb" "xen", sizeof(sig)) )
         return 0;
     eip += sizeof(sig);
 
Signature · 1 line
2.39.5
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] x86/pv: Address MISRA C:2012 Rule 4.1

Quoted 8 lines · Andrew Cooper

MISRA doesn't like mixing hexadecimal escape sequences with ASCII text.
Use
the same workaround as in commit cd5048353725 ("xen: address MISRA C:2012 Rule 4.1").

No functional change.

Quoted 23 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/pv/emul-inv-op.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/pv/emul-inv-op.c +1 -1
index 314ebd01cb34..346ac1124d7b 100644
@@ -26,7 +26,7 @@ static int emulate_forced_invalid_op(struct 
 cpu_user_regs *regs)
         pv_inject_page_fault(0, eip + sizeof(sig) - rc);
         return EXCRET_fault_fixed;
     }
-    if ( memcmp(sig, "\xf\xbxen", sizeof(sig)) )
+    if ( memcmp(sig, "\xf\xb" "xen", sizeof(sig)) )
         return 0;
     eip += sizeof(sig);
Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#3 lore raw

PATCH 2/5 x86/pv: Change type of do_update_descriptor()'s desc parameter

In reply to Andrew Cooper

The automatically generated hypercall dispatch logic looks like:

    case __HYPERVISOR_update_descriptor: \
        ret = do_update_descriptor((uint64_t)(a1), (seg_desc_t)(a2)); \
        break; \

but seg_desc_t is a union and Eclair considers this to be a violation of MISRA Rule 1.1. There's also a Rule 8.3 violation for the parameter name mismatch.

Instead of playing games trying to change seg_desc_t to be a struct, or to alter the AWK generator to know that seg_desc_t is magic and needs braces rather than brackets, just switch the type to be a plain uint64_t.

The size is fixed by the x86 architecture, so it is never going to change. This even lets us simplify compat_update_descriptor() a little.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/pv/descriptor-tables.c | 10 ++++------
 xen/include/hypercall-defs.c        |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)
xen/arch/x86/pv/descriptor-tables.c +4 -6
index 26f7d18b11b5..8a32b9ae5ced 100644
@@ -179,11 +179,8 @@ int compat_set_gdt(
 int compat_update_descriptor(
     uint32_t pa_lo, uint32_t pa_hi, uint32_t desc_lo, uint32_t desc_hi)
 {
-    seg_desc_t d;
-
-    d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
-
-    return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
+    return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32),
+                                desc_lo | ((uint64_t)desc_hi << 32));
 }
 
 #endif /* CONFIG_PV32 */
@@ -288,9 +285,10 @@ int validate_segdesc_page(struct page_info *page)
     return i == 512 ? 0 : -EINVAL;
 }
 
-long do_update_descriptor(uint64_t gaddr, seg_desc_t d)
+long do_update_descriptor(uint64_t gaddr, uint64_t desc)
 {
     struct domain *currd = current->domain;
+    seg_desc_t d = { .raw = desc };
     gfn_t gfn = gaddr_to_gfn(gaddr);
     mfn_t mfn;
     seg_desc_t *entry;
xen/include/hypercall-defs.c +1 -1
index cef08eeec1b8..5782cdfd1496 100644
@@ -184,7 +184,7 @@ mca(xen_mc_t *u_xen_mc)
 set_trap_table(const_trap_info_t *traps)
 set_gdt(xen_ulong_t *frame_list, unsigned int entries)
 set_callbacks(unsigned long event_address, unsigned long failsafe_address, unsigned long syscall_address)
-update_descriptor(uint64_t gaddr, seg_desc_t desc)
+update_descriptor(uint64_t gaddr, uint64_t desc)
 update_va_mapping(unsigned long va, uint64_t val64, unsigned long flags)
 update_va_mapping_otherdomain(unsigned long va, uint64_t val64, unsigned long flags, domid_t domid)
 #endif
Signature · 1 line
2.39.5
#4 lore raw

PATCH 3/5 x86: Address MIRSA R8.3 (declaration/definition mismatch) issues

In reply to Andrew Cooper

These are mostly name mismatches, but a couple have type alias mismatches too.

For shadow_put_top_level() and is_patch(), the declaration name is the better choice so change the name in the function.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/include/asm/hypercall.h |  4 ++--
 xen/arch/x86/include/asm/pv/mm.h     |  4 ++--
 xen/arch/x86/include/asm/shadow.h    |  2 +-
 xen/arch/x86/mm.c                    |  4 ++--
 xen/arch/x86/mm/shadow/common.c      |  8 ++++----
 xen/arch/x86/mm/shadow/multi.h       |  4 ++--
 xen/arch/x86/mm/shadow/private.h     | 10 +++++-----
 xen/common/kimage.c                  |  2 +-
 xen/common/livepatch.c               | 14 +++++++-------
 xen/include/xen/livepatch.h          |  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)
xen/arch/x86/include/asm/hypercall.h +2 -2
index f6e9e2313b3c..bf2f0e169aef 100644
@@ -22,8 +22,8 @@
 void pv_hypercall(struct cpu_user_regs *regs);
 #endif
 
-void pv_ring1_init_hypercall_page(void *ptr);
-void pv_ring3_init_hypercall_page(void *ptr);
+void pv_ring1_init_hypercall_page(void *p);
+void pv_ring3_init_hypercall_page(void *p);
 
 /*
  * Both do_mmuext_op() and do_mmu_update():
xen/arch/x86/include/asm/pv/mm.h +2 -2
index 182764542c1f..a5745908206a 100644
@@ -18,7 +18,7 @@ int pv_set_gdt(struct vcpu *v, const unsigned long frames[],
                unsigned int entries);
 void pv_destroy_gdt(struct vcpu *v);
 
-bool pv_map_ldt_shadow_page(unsigned int off);
+bool pv_map_ldt_shadow_page(unsigned int offset);
 bool pv_destroy_ldt(struct vcpu *v);
 
 int validate_segdesc_page(struct page_info *page);
@@ -40,7 +40,7 @@ static inline int pv_set_gdt(struct vcpu *v, const unsigned long frames[],
 { ASSERT_UNREACHABLE(); return -EINVAL; }
 static inline void pv_destroy_gdt(struct vcpu *v) { ASSERT_UNREACHABLE(); }
 
-static inline bool pv_map_ldt_shadow_page(unsigned int off) { return false; }
+static inline bool pv_map_ldt_shadow_page(unsigned int offset) { return false; }
 static inline bool pv_destroy_ldt(struct vcpu *v)
 { ASSERT_UNREACHABLE(); return false; }
 
xen/arch/x86/include/asm/shadow.h +1 -1
index 9a8d1b8353cd..60589c3cacee 100644
@@ -63,7 +63,7 @@ int shadow_enable(struct domain *d, u32 mode);
 
 /* Enable VRAM dirty bit tracking. */
 int shadow_track_dirty_vram(struct domain *d,
-                            unsigned long first_pfn,
+                            unsigned long begin_pfn,
                             unsigned int nr_frames,
                             XEN_GUEST_HANDLE(void) guest_dirty_bitmap);
 
xen/arch/x86/mm.c +2 -2
index b929d15d0050..0d0d5292953b 100644
@@ -4566,7 +4566,7 @@ static int __do_update_va_mapping(
 }
 
 long do_update_va_mapping(
-    unsigned long va, u64 val64, unsigned long flags)
+    unsigned long va, uint64_t val64, unsigned long flags)
 {
     int rc = __do_update_va_mapping(va, val64, flags, current->domain);
 
@@ -4578,7 +4578,7 @@ long do_update_va_mapping(
 }
 
 long do_update_va_mapping_otherdomain(
-    unsigned long va, u64 val64, unsigned long flags, domid_t domid)
+    unsigned long va, uint64_t val64, unsigned long flags, domid_t domid)
 {
     struct domain *pg_owner;
     int rc;
xen/arch/x86/mm/shadow/common.c +4 -4
index f2aee5be46a7..f9310d008de6 100644
@@ -751,7 +751,7 @@ void shadow_promote(struct domain *d, mfn_t gmfn, unsigned int type)
     TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_PROMOTE);
 }
 
-void shadow_demote(struct domain *d, mfn_t gmfn, u32 type)
+void shadow_demote(struct domain *d, mfn_t gmfn, unsigned int type)
 {
     struct page_info *page = mfn_to_page(gmfn);
 
@@ -2615,11 +2615,11 @@ pagetable_t sh_set_toplevel_shadow(struct vcpu *v,
  * Helper invoked when releasing of a top-level shadow's reference was
  * deferred in sh_set_toplevel_shadow() above.
  */
-void shadow_put_top_level(struct domain *d, pagetable_t old_entry)
+void shadow_put_top_level(struct domain *d, pagetable_t old)
 {
-    ASSERT(!pagetable_is_null(old_entry));
+    ASSERT(!pagetable_is_null(old));
     paging_lock(d);
-    sh_put_ref(d, pagetable_get_mfn(old_entry), 0);
+    sh_put_ref(d, pagetable_get_mfn(old), 0);
     paging_unlock(d);
 }
 
xen/arch/x86/mm/shadow/multi.h +2 -2
index 0e938594345a..fc86d7a8d9cd 100644
@@ -89,11 +89,11 @@ SHADOW_INTERNAL_NAME(sh_paging_mode, GUEST_LEVELS);
 #if SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC
 extern void
 SHADOW_INTERNAL_NAME(sh_resync_l1, GUEST_LEVELS)
-     (struct vcpu *v, mfn_t gmfn, mfn_t snpmfn);
+     (struct vcpu *v, mfn_t gl1mfn, mfn_t snpmfn);
 
 extern int
 SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, GUEST_LEVELS)
-     (struct vcpu*v, mfn_t gmfn);
+     (struct vcpu*v, mfn_t gl1mfn);
 
 extern int
 SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, GUEST_LEVELS)
xen/arch/x86/mm/shadow/private.h +5 -5
index bc99e00100f7..12cfb52f095b 100644
@@ -364,11 +364,11 @@ bool  shadow_hash_delete(struct domain *d,
                          unsigned long n, unsigned int t, mfn_t smfn);
 
 /* shadow promotion */
-void shadow_promote(struct domain *d, mfn_t gmfn, u32 type);
-void shadow_demote(struct domain *d, mfn_t gmfn, u32 type);
+void shadow_promote(struct domain *d, mfn_t gmfn, unsigned int type);
+void shadow_demote(struct domain *d, mfn_t gmfn, unsigned int type);
 
 /* Shadow page allocation functions */
-bool __must_check shadow_prealloc(struct domain *d, unsigned int shadow_type,
+bool __must_check shadow_prealloc(struct domain *d, unsigned int type,
                                   unsigned int count);
 mfn_t shadow_alloc(struct domain *d,
                     u32 shadow_type,
@@ -392,11 +392,11 @@ int sh_validate_guest_entry(struct vcpu *v, mfn_t gmfn, void *entry, u32 size);
  * Returns non-zero if we need to flush TLBs.
  * level and fault_addr desribe how we found this to be a pagetable;
  * level==0 means we have some other reason for revoking write access. */
-extern int sh_remove_write_access(struct domain *d, mfn_t readonly_mfn,
+extern int sh_remove_write_access(struct domain *d, mfn_t gmfn,
                                   unsigned int level,
                                   unsigned long fault_addr);
 #else
-static inline int sh_remove_write_access(struct domain *d, mfn_t readonly_mfn,
+static inline int sh_remove_write_access(struct domain *d, mfn_t gmfn,
                                          unsigned int level,
                                          unsigned long fault_addr)
 {
xen/common/kimage.c +1 -1
index 9961eac187e9..e1aec5a18a54 100644
@@ -66,7 +66,7 @@
 static int kimage_is_destination_range(struct kexec_image *image,
                                        paddr_t start, paddr_t end);
 static struct page_info *kimage_alloc_page(struct kexec_image *image,
-                                           paddr_t dest);
+                                           paddr_t destination);
 
 static struct page_info *kimage_alloc_zeroed_page(unsigned memflags)
 {
xen/common/livepatch.c +7 -7
index d0da2aa28132..7446533c8cfb 100644
@@ -107,7 +107,7 @@ static int verify_payload(const struct xen_sysctl_livepatch_upload *upload, char
     return 0;
 }
 
-bool is_patch(const void *ptr)
+bool is_patch(const void *addr)
 {
     const struct payload *data;
     bool r = false;
@@ -115,12 +115,12 @@ bool is_patch(const void *ptr)
     rcu_read_lock(&rcu_payload_lock);
     list_for_each_entry_rcu ( data, &payload_list, list )
     {
-        if ( (ptr >= data->rw_addr &&
-              ptr < (data->rw_addr + data->rw_size)) ||
-             (ptr >= data->ro_addr &&
-              ptr < (data->ro_addr + data->ro_size)) ||
-             (ptr >= data->text_addr &&
-              ptr < (data->text_addr + data->text_size)) )
+        if ( (addr >= data->rw_addr &&
+              addr < (data->rw_addr + data->rw_size)) ||
+             (addr >= data->ro_addr &&
+              addr < (data->ro_addr + data->ro_size)) ||
+             (addr >= data->text_addr &&
+              addr < (data->text_addr + data->text_size)) )
         {
             r = 1;
             break;
xen/include/xen/livepatch.h +1 -1
index 3f5ad01f1bdd..45c8924f3412 100644
@@ -89,7 +89,7 @@ enum va_type {
  * Function to secure the allocate pages (from arch_livepatch_alloc_payload)
  * with the right page permissions.
  */
-int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type types);
+int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type type);
 
 void arch_livepatch_init(void);
 
Signature · 1 line
2.39.5
#5 lore raw

Re: [PATCH 3/5] x86: Address MIRSA R8.3 (declaration/definition mismatch) issues

s/MIRSA/MISRA/ in the subject, here and in patch 4

Quoted 254 lines · Andrew Cooper

These are mostly name mismatches, but a couple have type alias mismatches too.

For shadow_put_top_level() and is_patch(), the declaration name is the better choice so change the name in the function.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/include/asm/hypercall.h |  4 ++--
 xen/arch/x86/include/asm/pv/mm.h     |  4 ++--
 xen/arch/x86/include/asm/shadow.h    |  2 +-
 xen/arch/x86/mm.c                    |  4 ++--
 xen/arch/x86/mm/shadow/common.c      |  8 ++++----
 xen/arch/x86/mm/shadow/multi.h       |  4 ++--
 xen/arch/x86/mm/shadow/private.h     | 10 +++++-----
 xen/common/kimage.c                  |  2 +-
 xen/common/livepatch.c               | 14 +++++++-------
 xen/include/xen/livepatch.h          |  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)
xen/arch/x86/include/asm/hypercall.h +2 -2
index f6e9e2313b3c..bf2f0e169aef 100644
@@ -22,8 +22,8 @@
 void pv_hypercall(struct cpu_user_regs *regs);
 #endif
 
-void pv_ring1_init_hypercall_page(void *ptr);
-void pv_ring3_init_hypercall_page(void *ptr);
+void pv_ring1_init_hypercall_page(void *p);
+void pv_ring3_init_hypercall_page(void *p);
 
 /*
  * Both do_mmuext_op() and do_mmu_update():
xen/arch/x86/include/asm/pv/mm.h +1 -1
index 182764542c1f..a5745908206a 100644
@@ -18,7 +18,7 @@ int pv_set_gdt(struct vcpu *v, const unsigned long 
 frames[],
                unsigned int entries);
 void pv_destroy_gdt(struct vcpu *v);
 
-bool pv_map_ldt_shadow_page(unsigned int off);
+bool pv_map_ldt_shadow_page(unsigned int offset);
 bool pv_destroy_ldt(struct vcpu *v);
 

int validate_segdesc_page(struct page_info *page);

xen/arch/x86/include/asm/pv/mm.h +1 -1
@@ -40,7 +40,7 @@ static inline int pv_set_gdt(struct vcpu *v, const 
 unsigned long frames[],
 { ASSERT_UNREACHABLE(); return -EINVAL; }
 static inline void pv_destroy_gdt(struct vcpu *v) { 
 ASSERT_UNREACHABLE(); }
 
-static inline bool pv_map_ldt_shadow_page(unsigned int off) { return 
 false; }
+static inline bool pv_map_ldt_shadow_page(unsigned int offset) { 

return false; }
static inline bool pv_destroy_ldt(struct vcpu *v) { ASSERT_UNREACHABLE(); return false; }

xen/arch/x86/include/asm/shadow.h +1 -1
index 9a8d1b8353cd..60589c3cacee 100644
@@ -63,7 +63,7 @@ int shadow_enable(struct domain *d, u32 mode);
 
 /* Enable VRAM dirty bit tracking. */
 int shadow_track_dirty_vram(struct domain *d,
-                            unsigned long first_pfn,
+                            unsigned long begin_pfn,
                             unsigned int nr_frames,
                             XEN_GUEST_HANDLE(void) 
 guest_dirty_bitmap);
xen/arch/x86/mm.c +2 -2
index b929d15d0050..0d0d5292953b 100644
@@ -4566,7 +4566,7 @@ static int __do_update_va_mapping(
 }
 
 long do_update_va_mapping(
-    unsigned long va, u64 val64, unsigned long flags)
+    unsigned long va, uint64_t val64, unsigned long flags)
 {
     int rc = __do_update_va_mapping(va, val64, flags, 
 current->domain);
@@ -4578,7 +4578,7 @@ long do_update_va_mapping(
 }
 
 long do_update_va_mapping_otherdomain(
-    unsigned long va, u64 val64, unsigned long flags, domid_t domid)
+    unsigned long va, uint64_t val64, unsigned long flags, domid_t 
 domid)
 {
     struct domain *pg_owner;
     int rc;
xen/arch/x86/mm/shadow/common.c +4 -4
index f2aee5be46a7..f9310d008de6 100644
@@ -751,7 +751,7 @@ void shadow_promote(struct domain *d, mfn_t gmfn, 
 unsigned int type)
     TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_PROMOTE);
 }
 
-void shadow_demote(struct domain *d, mfn_t gmfn, u32 type)
+void shadow_demote(struct domain *d, mfn_t gmfn, unsigned int type)
 {
     struct page_info *page = mfn_to_page(gmfn);
@@ -2615,11 +2615,11 @@ pagetable_t sh_set_toplevel_shadow(struct vcpu 
 *v,
  * Helper invoked when releasing of a top-level shadow's reference was
  * deferred in sh_set_toplevel_shadow() above.
  */
-void shadow_put_top_level(struct domain *d, pagetable_t old_entry)
+void shadow_put_top_level(struct domain *d, pagetable_t old)
 {
-    ASSERT(!pagetable_is_null(old_entry));
+    ASSERT(!pagetable_is_null(old));
     paging_lock(d);
-    sh_put_ref(d, pagetable_get_mfn(old_entry), 0);
+    sh_put_ref(d, pagetable_get_mfn(old), 0);
     paging_unlock(d);
 }
xen/arch/x86/mm/shadow/multi.h +2 -2
index 0e938594345a..fc86d7a8d9cd 100644
@@ -89,11 +89,11 @@ SHADOW_INTERNAL_NAME(sh_paging_mode, GUEST_LEVELS);
 #if SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC
 extern void
 SHADOW_INTERNAL_NAME(sh_resync_l1, GUEST_LEVELS)
-     (struct vcpu *v, mfn_t gmfn, mfn_t snpmfn);
+     (struct vcpu *v, mfn_t gl1mfn, mfn_t snpmfn);
 
 extern int
 SHADOW_INTERNAL_NAME(sh_safe_not_to_sync, GUEST_LEVELS)
-     (struct vcpu*v, mfn_t gmfn);
+     (struct vcpu*v, mfn_t gl1mfn);
 
 extern int
 SHADOW_INTERNAL_NAME(sh_rm_write_access_from_sl1p, GUEST_LEVELS)
xen/arch/x86/mm/shadow/private.h +3 -3
index bc99e00100f7..12cfb52f095b 100644
@@ -364,11 +364,11 @@ bool  shadow_hash_delete(struct domain *d,
                          unsigned long n, unsigned int t, mfn_t smfn);
 
 /* shadow promotion */
-void shadow_promote(struct domain *d, mfn_t gmfn, u32 type);
-void shadow_demote(struct domain *d, mfn_t gmfn, u32 type);
+void shadow_promote(struct domain *d, mfn_t gmfn, unsigned int type);
+void shadow_demote(struct domain *d, mfn_t gmfn, unsigned int type);
 
 /* Shadow page allocation functions */
-bool __must_check shadow_prealloc(struct domain *d, unsigned int 
 shadow_type,
+bool __must_check shadow_prealloc(struct domain *d, unsigned int type,
                                   unsigned int count);
 mfn_t shadow_alloc(struct domain *d,

u32 shadow_type,

xen/arch/x86/mm/shadow/private.h +1 -2
@@ -392,11 +392,11 @@ int sh_validate_guest_entry(struct vcpu *v, mfn_t 
 gmfn, void *entry, u32 size);
  * Returns non-zero if we need to flush TLBs.
  * level and fault_addr desribe how we found this to be a pagetable;
  * level==0 means we have some other reason for revoking write access. 
 */
-extern int sh_remove_write_access(struct domain *d, mfn_t 
 readonly_mfn,
+extern int sh_remove_write_access(struct domain *d, mfn_t gmfn,
                                   unsigned int level,
                                   unsigned long fault_addr);
 #else
-static inline int sh_remove_write_access(struct domain *d, mfn_t 

readonly_mfn,

xen/arch/x86/mm/shadow/private.h +1 -0
+static inline int sh_remove_write_access(struct domain *d, mfn_t gmfn,
                                          unsigned int level,
                                          unsigned long fault_addr)
 {
xen/common/kimage.c +1 -1
index 9961eac187e9..e1aec5a18a54 100644
@@ -66,7 +66,7 @@
 static int kimage_is_destination_range(struct kexec_image *image,
                                        paddr_t start, paddr_t end);
 static struct page_info *kimage_alloc_page(struct kexec_image *image,
-                                           paddr_t dest);
+                                           paddr_t destination);
 
 static struct page_info *kimage_alloc_zeroed_page(unsigned memflags)
 {
xen/common/livepatch.c +0 -0
index d0da2aa28132..7446533c8cfb 100644
@@ -107,7 +107,7 @@ static int verify_payload(const struct 

xen_sysctl_livepatch_upload *upload, char

     return 0;

}

xen/common/livepatch.c +7 -7
-bool is_patch(const void *ptr)
+bool is_patch(const void *addr)
 {
     const struct payload *data;
     bool r = false;
@@ -115,12 +115,12 @@ bool is_patch(const void *ptr)
     rcu_read_lock(&rcu_payload_lock);
     list_for_each_entry_rcu ( data, &payload_list, list )
     {
-        if ( (ptr >= data->rw_addr &&
-              ptr < (data->rw_addr + data->rw_size)) ||
-             (ptr >= data->ro_addr &&
-              ptr < (data->ro_addr + data->ro_size)) ||
-             (ptr >= data->text_addr &&
-              ptr < (data->text_addr + data->text_size)) )
+        if ( (addr >= data->rw_addr &&
+              addr < (data->rw_addr + data->rw_size)) ||
+             (addr >= data->ro_addr &&
+              addr < (data->ro_addr + data->ro_size)) ||
+             (addr >= data->text_addr &&
+              addr < (data->text_addr + data->text_size)) )
         {
             r = 1;
             break;
xen/include/xen/livepatch.h +1 -1
index 3f5ad01f1bdd..45c8924f3412 100644
@@ -89,7 +89,7 @@ enum va_type {
  * Function to secure the allocate pages (from 
 arch_livepatch_alloc_payload)
  * with the right page permissions.
  */
-int arch_livepatch_secure(const void *va, unsigned int pages, enum 
 va_type types);
+int arch_livepatch_secure(const void *va, unsigned int pages, enum 
 va_type type);

void arch_livepatch_init(void);

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#6 lore raw

PATCH 4/5 x86: Address MIRSA R8.4 (declaration visibility) issues

In reply to Andrew Cooper

set_guest_*_trapbounce() are only called from assembly so gain asmlinkage to identify them.

xen_msr_s_cet_value() is called by assembly and C, so asmlinkage isn't appropriate. Make the declaration unconditional, which silences the complaint.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/arch/x86/pv/traps.c | 4 ++--
 xen/arch/x86/setup.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/pv/traps.c +2 -2
index c3c0976c440f..26a468108a77 100644
@@ -99,7 +99,7 @@ void pv_inject_event(const struct x86_event *event)
  * Called from asm to set up the MCE trapbounce info.
  * Returns false no callback is set up, else true.
  */
-bool set_guest_machinecheck_trapbounce(void)
+bool asmlinkage set_guest_machinecheck_trapbounce(void)
 {
     struct vcpu *curr = current;
     struct trap_bounce *tb = &curr->arch.pv.trap_bounce;
@@ -114,7 +114,7 @@ bool set_guest_machinecheck_trapbounce(void)
  * Called from asm to set up the NMI trapbounce info.
  * Returns false if no callback is set up, else true.
  */
-bool set_guest_nmi_trapbounce(void)
+bool asmlinkage set_guest_nmi_trapbounce(void)
 {
     struct vcpu *curr = current;
     struct trap_bounce *tb = &curr->arch.pv.trap_bounce;
xen/arch/x86/setup.c +2 -2
index 44da5efa1d20..27c63d1d97c9 100644
@@ -877,6 +877,8 @@ static void noreturn init_done(void)
     startup_cpu_idle_loop();
 }
 
+unsigned int xen_msr_s_cet_value(void); /* To avoid ifdefary, and placate MISRA */
+
 #if defined(CONFIG_XEN_SHSTK) || defined(CONFIG_XEN_IBT)
 /*
  * Used by AP and S3 asm code to calcualte the appropriate MSR_S_CET setting.
@@ -888,8 +890,6 @@ unsigned int xen_msr_s_cet_value(void)
     return ((cpu_has_xen_shstk ? CET_SHSTK_EN | CET_WRSS_EN : 0) |
             (cpu_has_xen_ibt   ? CET_ENDBR_EN : 0));
 }
-#else
-unsigned int xen_msr_s_cet_value(void); /* To avoid ifdefary */
 #endif
 
 /* Reinitalise all state referring to the old virtual address of the stack. */
Signature · 1 line
2.39.5
#7 lore raw

RFC PATCH 5/5 x86/shadow: Deviate multi.h as being included multiple times

In reply to Andrew Cooper

This resolves the Eclair complaint about a MISRA D4.10 violation.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

RFC - this doesn't actually squash the violation, despite being the requisite magic string. I suspect the Eclair config needs tweaking to allow the magic anchor string to be after the SDPX tag.

---
 xen/arch/x86/mm/shadow/multi.h | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/mm/shadow/multi.h +2 -0
index fc86d7a8d9cd..b4a6cf1362a6 100644
@@ -2,6 +2,8 @@
 /******************************************************************************
  * arch/x86/mm/shadow/multi.h
  *
+ * This file is intended to be included multiple times.
+ *
  * Shadow declarations which will be multiply compiled.
  * Parts of this code are Copyright (c) 2006 by XenSource Inc.
  * Parts of this code are Copyright (c) 2006 by Michael A Fetterman
Signature · 1 line
2.39.5
#8 lore raw

Re: [PATCH RFC 5/5] x86/shadow: Deviate multi.h as being included multiple times

Quoted 10 lines · Andrew Cooper

This resolves the Eclair complaint about a MISRA D4.10 violation.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 4 lines

RFC - this doesn't actually squash the violation, despite being the requisite magic string. I suspect the Eclair config needs tweaking to allow the magic anchor string to be after the SDPX tag.
---

I think it's just a matter of positioning. The location of the violation is at line 11 (the first non-comment statement of the file, and the string is matched in a range of -4 lines from that point:

-config=MC3A2.D4.10,reports+={safe, "first_area(text(^/\\* This file is intended to be included multiple times\\. \\*/$, begin-4))"}

so I think moving it just below the copyright lines or increasing the range should do the trick.

Quoted 17 lines
 xen/arch/x86/mm/shadow/multi.h | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/mm/shadow/multi.h +2 -0
index fc86d7a8d9cd..b4a6cf1362a6 100644
@@ -2,6 +2,8 @@
 
 /******************************************************************************
  * arch/x86/mm/shadow/multi.h
  *
+ * This file is intended to be included multiple times.
+ *
  * Shadow declarations which will be multiply compiled.
  * Parts of this code are Copyright (c) 2006 by XenSource Inc.

* Parts of this code are Copyright (c) 2006 by Michael A Fetterman

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
Acked-by on the v1 series
#9 lore raw
In reply to Andrew Cooper
Quoted 5 lines · Andrew Cooper

Andrew Cooper (5):
x86/pv: Address MISRA C:2012 Rule 4.1
x86/pv: Change type of do_update_descriptor()'s desc parameter
x86: Address MIRSA R8.3 (declaration/definition mismatch) issues
x86: Address MIRSA R8.4 (declaration visibility) issues

(with the title typos taken care of, preferably)

Jan