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

[PATCH] do_multicall and MISRA Rule 8.3



Two out of three do_multicall definitions/declarations use uint32_t as
type for the "nr_calls" parameters. Change the third one to be
consistent with the other two. 

Link: 
https://lore.kernel.org/xen-devel/7e3abd4c0ef5127a07a60de1bf090a8aefac8e5c.1692717906.git.federico.serafini@xxxxxxxxxxx/
Link: 
https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2308251502430.6458@ubuntu-linux-20-04-desktop/
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
---
Note that a previous discussion showed disagreement between maintainers
on this topic. The source of disagreements are that we don't want to
change a guest-visible ABI and we haven't properly documented how to use
types for guest ABIs.

As an example, fixed-width types have the advantage of being explicit
about their size but sometimes register-size types are required (e.g.
unsigned long). The C specification says little about the size of
unsigned long and today, and we even use unsigned int in guest ABIs
without specifying the expected width of unsigned int on the various
arches. As Jan pointed out, in Xen we assume sizeof(int) >= 4, but
that's not written anywhere as far as I can tell.

I think the appropriate solution would be to document properly our
expectations of both fixed-width and non-fixed-width types, and how to
use them for guest-visible ABIs.

In this patch I used uint32_t for a couple of reasons:
- until we have better documentation, I feel more confident in using
  explicitly-sized integers in guest-visible ABIs
- 2/3 of the do_multicall definition/declaration are using uint32_t

diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index 6d361ddfce..8b8ee16074 100644
--- a/xen/include/hypercall-defs.c
+++ b/xen/include/hypercall-defs.c
@@ -172,7 +172,7 @@ console_io(unsigned int cmd, unsigned int count, char 
*buffer)
 vm_assist(unsigned int cmd, unsigned int type)
 event_channel_op(int cmd, void *arg)
 mmuext_op(mmuext_op_t *uops, unsigned int count, unsigned int *pdone, unsigned 
int foreigndom)
-multicall(multicall_entry_t *call_list, unsigned int nr_calls)
+multicall(multicall_entry_t *call_list, uint32_t nr_calls)
 #ifdef CONFIG_PV
 mmu_update(mmu_update_t *ureqs, unsigned int count, unsigned int *pdone, 
unsigned int foreigndom)
 stack_switch(unsigned long ss, unsigned long esp)



 


Rackspace

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