Skip to contentSkip to conversation

x86: address some violations of MISRA C:2012 Rule 8.2

PATCH In review Federico Serafini 2 participants 15 messages Oct 18, 2023 – Oct 23, 2023

lore
Share & tools
lore
#0 lore raw

cover x86: address some violations of MISRA C:2012 Rule 8.2

This patch series addresses some of the violations of Rule 8.2 adding the missing parameter names.

Federico Serafini (7):
x86/mctelem: address violations of MISRA C:2012 Rule 8.2 x86/mtrr: address violation of MISRA C:2012 Rule 8.2 x86/domain: address violations of MISRA C:2012 Rule 8.2 x86/cpuidle: address violations of MISRA C:2012 Rule 8.2 x86/mcaction: address a violation of MISRA C:2012 Rule 8.2 x86/vmce: address violations of MISRA C:2012 Rule 8.2 x86/hpet: address violations of MISRA C:2012 Rule 8.2

 xen/arch/x86/cpu/mcheck/mcaction.h |  2 +-
 xen/arch/x86/cpu/mcheck/mctelem.c  |  2 +-
 xen/arch/x86/cpu/mcheck/mctelem.h  | 25 +++++++++++++------------
 xen/arch/x86/cpu/mcheck/vmce.h     |  8 ++++----
 xen/arch/x86/hpet.c                |  2 +-
 xen/arch/x86/include/asm/cpuidle.h | 11 ++++++-----
 xen/arch/x86/include/asm/domain.h  | 26 +++++++++++++-------------
 xen/arch/x86/include/asm/hpet.h    |  2 +-
 xen/arch/x86/include/asm/mtrr.h    | 10 +++++-----
 9 files changed, 45 insertions(+), 43 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/7 x86/mctelem: address violations of MISRA C:2012 Rule 8.2

Add missing parameter names. No functional change.

---
 xen/arch/x86/cpu/mcheck/mctelem.c |  2 +-
 xen/arch/x86/cpu/mcheck/mctelem.h | 25 +++++++++++++------------
 2 files changed, 14 insertions(+), 13 deletions(-)
xen/arch/x86/cpu/mcheck/mctelem.c +1 -1
index 77a4d1d5ff..b8d0368a7d 100644
@@ -208,7 +208,7 @@ void mctelem_defer(mctelem_cookie_t cookie, bool lmce)
  *  @lmce: indicate which pending list on @cpu is handled
  */
 void mctelem_process_deferred(unsigned int cpu,
-			      int (*fn)(mctelem_cookie_t),
+			      int (*fn)(mctelem_cookie_t mctc),
 			      bool lmce)
 {
 	struct mctelem_ent *tep;
xen/arch/x86/cpu/mcheck/mctelem.h +13 -12
index 21b251847b..f4c5ff848d 100644
@@ -60,18 +60,19 @@ typedef enum mctelem_class {
     MC_NCLASSES
 } mctelem_class_t;
 
-extern void mctelem_init(unsigned int);
-extern mctelem_cookie_t mctelem_reserve(mctelem_class_t);
-extern void *mctelem_dataptr(mctelem_cookie_t);
-extern void mctelem_commit(mctelem_cookie_t);
-extern void mctelem_dismiss(mctelem_cookie_t);
-extern mctelem_cookie_t mctelem_consume_oldest_begin(mctelem_class_t);
-extern void mctelem_consume_oldest_end(mctelem_cookie_t);
-extern void mctelem_ack(mctelem_class_t, mctelem_cookie_t);
-extern void mctelem_defer(mctelem_cookie_t, bool lmce);
-extern void mctelem_process_deferred(unsigned int,
-                                     int (*)(mctelem_cookie_t), bool lmce);
-bool mctelem_has_deferred(unsigned int);
+extern void mctelem_init(unsigned int datasz);
+extern mctelem_cookie_t mctelem_reserve(mctelem_class_t which);
+extern void *mctelem_dataptr(mctelem_cookie_t cookie);
+extern void mctelem_commit(mctelem_cookie_t cookie);
+extern void mctelem_dismiss(mctelem_cookie_t cookie);
+extern mctelem_cookie_t mctelem_consume_oldest_begin(mctelem_class_t which);
+extern void mctelem_consume_oldest_end(mctelem_cookie_t cookie);
+extern void mctelem_ack(mctelem_class_t which, mctelem_cookie_t cookie);
+extern void mctelem_defer(mctelem_cookie_t cookie, bool lmce);
+extern void mctelem_process_deferred(unsigned int cpu,
+                                     int (*fn)(mctelem_cookie_t mctc),
+                                     bool lmce);
+bool mctelem_has_deferred(unsigned int cpu);
 bool mctelem_has_deferred_lmce(unsigned int cpu);
 
 #endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH 2/7 x86/mtrr: address violation of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter names. No functional change.

---
 xen/arch/x86/include/asm/mtrr.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/include/asm/mtrr.h +5 -5
index 14246e3387..1d2744eceb 100644
@@ -48,7 +48,7 @@ struct mtrr_state {
 };
 extern struct mtrr_state mtrr_state;
 
-extern void cf_check mtrr_save_fixed_ranges(void *);
+extern void cf_check mtrr_save_fixed_ranges(void *info);
 extern void mtrr_save_state(void);
 extern int mtrr_add(unsigned long base, unsigned long size,
                     unsigned int type, char increment);
@@ -68,14 +68,14 @@ extern void mtrr_aps_sync_begin(void);
 extern void mtrr_aps_sync_end(void);
 extern void mtrr_bp_restore(void);
 
-extern bool_t mtrr_var_range_msr_set(struct domain *, struct mtrr_state *,
+extern bool_t mtrr_var_range_msr_set(struct domain *d, struct mtrr_state *m,
                                      uint32_t msr, uint64_t msr_content);
-extern bool_t mtrr_fix_range_msr_set(struct domain *, struct mtrr_state *,
+extern bool_t mtrr_fix_range_msr_set(struct domain *d, struct mtrr_state *m,
                                      uint32_t row, uint64_t msr_content);
-extern bool_t mtrr_def_type_msr_set(struct domain *, struct mtrr_state *,
+extern bool_t mtrr_def_type_msr_set(struct domain *d, struct mtrr_state *m,
                                     uint64_t msr_content);
 #ifdef CONFIG_HVM
-extern void memory_type_changed(struct domain *);
+extern void memory_type_changed(struct domain *d);
 #else
 static inline void memory_type_changed(struct domain *d) {}
 #endif
Signature · 1 line
2.34.1
#5 lore raw

PATCH 3/7 x86/domain: address violations of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter names. No functional change.

---
 xen/arch/x86/include/asm/domain.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
xen/arch/x86/include/asm/domain.h +13 -13
index 619e667938..d033224d2b 100644
@@ -74,20 +74,20 @@ struct mapcache_domain {
     unsigned long *garbage;
 };
 
-int mapcache_domain_init(struct domain *);
-int mapcache_vcpu_init(struct vcpu *);
-void mapcache_override_current(struct vcpu *);
+int mapcache_domain_init(struct domain *d);
+int mapcache_vcpu_init(struct vcpu *v);
+void mapcache_override_current(struct vcpu *v);
 
 /* x86/64: toggle guest between kernel and user modes. */
-void toggle_guest_mode(struct vcpu *);
+void toggle_guest_mode(struct vcpu *v);
 /* x86/64: toggle guest page tables between kernel and user modes. */
-void toggle_guest_pt(struct vcpu *);
+void toggle_guest_pt(struct vcpu *v);
 
 /*
  * Initialise a hypercall-transfer page. The given pointer must be mapped
  * in Xen virtual address space (accesses are not validated or checked).
  */
-void init_hypercall_page(struct domain *d, void *);
+void init_hypercall_page(struct domain *d, void *ptr);
 
 /************************************************/
 /*          shadow paging extension             */
@@ -342,8 +342,8 @@ struct arch_domain
     struct page_list_head relmem_list;
 
     const struct arch_csw {
-        void (*from)(struct vcpu *);
-        void (*to)(struct vcpu *);
+        void (*from)(struct vcpu *v);
+        void (*to)(struct vcpu *v);
         void noreturn (*tail)(void);
     } *ctxt_switch;
 
@@ -690,12 +690,12 @@ void update_guest_memory_policy(struct vcpu *v,
 
 void domain_cpu_policy_changed(struct domain *d);
 
-bool update_secondary_system_time(struct vcpu *,
-                                  struct vcpu_time_info *);
-void force_update_secondary_system_time(struct vcpu *,
-                                        struct vcpu_time_info *);
+bool update_secondary_system_time(struct vcpu *v,
+                                  struct vcpu_time_info *u);
+void force_update_secondary_system_time(struct vcpu *v,
+                                        struct vcpu_time_info *map);
 
-void vcpu_show_registers(const struct vcpu *);
+void vcpu_show_registers(const struct vcpu *v);
 
 static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void)
 {
Signature · 1 line
2.34.1
#7 lore raw

PATCH 4/7 x86/cpuidle: address violations of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter names. No functional change.

---
 xen/arch/x86/include/asm/cpuidle.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
xen/arch/x86/include/asm/cpuidle.h +6 -5
index 3edd7a75d2..707b3e948d 100644
@@ -15,16 +15,17 @@ extern void (*lapic_timer_on)(void);
 
 extern uint64_t (*cpuidle_get_tick)(void);
 
-int mwait_idle_init(struct notifier_block *);
+int mwait_idle_init(struct notifier_block *nfb);
 int cpuidle_init_cpu(unsigned int cpu);
 void cf_check default_dead_idle(void);
 void cf_check acpi_dead_idle(void);
 void play_dead(void);
 void trace_exit_reason(u32 *irq_traced);
-void update_idle_stats(struct acpi_processor_power *,
-                       struct acpi_processor_cx *, uint64_t, uint64_t);
-void update_last_cx_stat(struct acpi_processor_power *,
-                         struct acpi_processor_cx *, uint64_t);
+void update_idle_stats(struct acpi_processor_power *power,
+                       struct acpi_processor_cx *cx,
+                       uint64_t before, uint64_t after);
+void update_last_cx_stat(struct acpi_processor_power *power,
+                         struct acpi_processor_cx *cx, uint64_t ticks);
 
 bool errata_c6_workaround(void);
 
Signature · 1 line
2.34.1
#9 lore raw

PATCH 5/7 x86/mcaction: address a violation of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter name. No functional change.

---
 xen/arch/x86/cpu/mcheck/mcaction.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/mcheck/mcaction.h +1 -1
index 5cbe558fb0..9cb2ad6c9f 100644
@@ -13,7 +13,7 @@ mc_memerr_dhandler(struct mca_binfo *binfo,
 #define MC_ADDR_VIRTUAL   1
 
 typedef bool (*mce_check_addr_t)(uint64_t status, uint64_t misc, int addr_type);
-extern void mce_register_addrcheck(mce_check_addr_t);
+extern void mce_register_addrcheck(mce_check_addr_t cbfunc);
 
 extern mce_check_addr_t mc_check_addr;
 
Signature · 1 line
2.34.1
#11 lore raw

PATCH 6/7 x86/vmce: address violations of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter names. No functional change.

---
 xen/arch/x86/cpu/mcheck/vmce.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/cpu/mcheck/vmce.h +4 -4
index 2e9b32a9bd..a9a325f776 100644
@@ -11,10 +11,10 @@ int vmce_init(struct cpuinfo_x86 *c);
 
 int unmmap_broken_page(struct domain *d, mfn_t mfn, unsigned long gfn);
 
-int vmce_intel_rdmsr(const struct vcpu *, uint32_t msr, uint64_t *val);
-int vmce_intel_wrmsr(struct vcpu *, uint32_t msr, uint64_t val);
-int vmce_amd_rdmsr(const struct vcpu *, uint32_t msr, uint64_t *val);
-int vmce_amd_wrmsr(struct vcpu *, uint32_t msr, uint64_t val);
+int vmce_intel_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val);
+int vmce_intel_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val);
+int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val);
+int vmce_amd_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val);
 
 int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
                    uint64_t gstatus, int vmce_vcpuid);
Signature · 1 line
2.34.1
#13 lore raw

PATCH 7/7 x86/hpet: address violations of MISRA C:2012 Rule 8.2

In reply to Federico Serafini

Add missing parameter names. No functional change.

---
 xen/arch/x86/hpet.c             | 2 +-
 xen/arch/x86/include/asm/hpet.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hpet.c +1 -1
index 79c07f6a9e..63d4158f0f 100644
@@ -37,7 +37,7 @@ struct hpet_event_channel
     s_time_t      next_event;
     cpumask_var_t cpumask;
     spinlock_t    lock;
-    void          (*event_handler)(struct hpet_event_channel *);
+    void          (*event_handler)(struct hpet_event_channel *ch);
 
     unsigned int idx;   /* physical channel idx */
     unsigned int cpu;   /* msi target */
xen/arch/x86/include/asm/hpet.h +1 -1
index 9919f74730..b342a154e6 100644
@@ -60,7 +60,7 @@ extern int8_t opt_hpet_legacy_replacement;
  * Return value is zero if HPET is unavailable.
  */
 u64 hpet_setup(void);
-void hpet_resume(u32 *);
+void hpet_resume(u32 *boot_cfg);
 
 /*
  * Disable HPET hardware: restore it to boot time state.
Signature · 1 line
2.34.1
Acked-by on v1 7/7
#14 lore raw

Re: [XEN PATCH 7/7] x86/hpet: address violations of MISRA C:2012 Rule 8.2

xen/arch/x86/include/asm/hpet.h extern int8_t opt_hpet_legacy_replacement; · line 63

Quoted 8 lines · Federico Serafini
xen/arch/x86/include/asm/hpet.h +1 -1
@@ -60,7 +60,7 @@ extern int8_t opt_hpet_legacy_replacement;
  * Return value is zero if HPET is unavailable.
  */
 u64 hpet_setup(void);
-void hpet_resume(u32 *);
+void hpet_resume(u32 *boot_cfg);

Ideally also switching to uint32_t while touching this:

Jan