From nobody Tue May 14 12:55:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1695298332660137.18612849124554; Thu, 21 Sep 2023 05:12:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.606333.944183 (Exim 4.92) (envelope-from ) id 1qjIX1-0005Aw-Dl; Thu, 21 Sep 2023 12:11:43 +0000 Received: by outflank-mailman (output) from mailman id 606333.944183; Thu, 21 Sep 2023 12:11:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qjIX1-0005Ap-9p; Thu, 21 Sep 2023 12:11:43 +0000 Received: by outflank-mailman (input) for mailman id 606333; Thu, 21 Sep 2023 12:11:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qjIX0-0004uB-0F for xen-devel@lists.xenproject.org; Thu, 21 Sep 2023 12:11:42 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 055763e4-5878-11ee-878a-cb3800f73035; Thu, 21 Sep 2023 14:11:40 +0200 (CEST) Received: from Dell.homenet.telecomitalia.it (host-82-50-59-70.retail.telecomitalia.it [82.50.59.70]) by support.bugseng.com (Postfix) with ESMTPSA id A9FFB4EE073F; Thu, 21 Sep 2023 14:11:39 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 055763e4-5878-11ee-878a-cb3800f73035 From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [XEN PATCH v3] xen/hypercalls: address violations of MISRA C:2012 Rule 8.3 Date: Thu, 21 Sep 2023 14:11:24 +0200 Message-Id: <2c3e9469b3e59c7c4d0128320515f2b3df2b4c1c.1695297383.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1695298335341100001 Content-Type: text/plain; charset="utf-8" Make function declarations and definitions consistent. No functional change. Signed-off-by: Federico Serafini Reviewed-by: Stefano Stabellini --- Changes in v3: - removed changes involving types with fixed/unfixed width; - uniformed parameter names of compat_memory_op() with {do,hvm}_memory_op(). --- Changes in v2: - change compat_grant_table_op() definition instead of the declaration; - use unsigned int for multicall()'s parameter in accordance with XEN coding style. --- --- xen/common/compat/grant_table.c | 22 +++++++++--------- xen/common/compat/memory.c | 40 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/xen/common/compat/grant_table.c b/xen/common/compat/grant_tabl= e.c index f8177c84c0..e00bc24a34 100644 --- a/xen/common/compat/grant_table.c +++ b/xen/common/compat/grant_table.c @@ -57,7 +57,7 @@ CHECK_gnttab_cache_flush; #undef xen_gnttab_cache_flush =20 int compat_grant_table_op( - unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) cmp_uop, unsigned int c= ount) + unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop, unsigned int count) { int rc =3D 0; unsigned int i, cmd_op; @@ -71,7 +71,7 @@ int compat_grant_table_op( { #define CASE(name) \ case GNTTABOP_##name: \ - if ( unlikely(!guest_handle_okay(guest_handle_cast(cmp_uop, \ + if ( unlikely(!guest_handle_okay(guest_handle_cast(uop, \ gnttab_##name##= _compat_t), \ count)) ) \ rc =3D -EFAULT; \ @@ -119,7 +119,7 @@ int compat_grant_table_op( =20 #undef CASE default: - return do_grant_table_op(cmd, cmp_uop, count); + return do_grant_table_op(cmd, uop, count); } =20 if ( (int)count < 0 ) @@ -148,7 +148,7 @@ int compat_grant_table_op( case GNTTABOP_setup_table: if ( unlikely(count > 1) ) rc =3D -EINVAL; - else if ( unlikely(__copy_from_guest(&cmp.setup, cmp_uop, 1)) ) + else if ( unlikely(__copy_from_guest(&cmp.setup, uop, 1)) ) rc =3D -EFAULT; else if ( unlikely(!compat_handle_okay(cmp.setup.frame_list, c= mp.setup.nr_frames)) ) rc =3D -EFAULT; @@ -193,7 +193,7 @@ int compat_grant_table_op( } while (0) XLAT_gnttab_setup_table(&cmp.setup, nat.setup); #undef XLAT_gnttab_setup_table_HNDL_frame_list - if ( unlikely(__copy_to_guest(cmp_uop, &cmp.setup, 1)) ) + if ( unlikely(__copy_to_guest(uop, &cmp.setup, 1)) ) rc =3D -EFAULT; else i =3D 1; @@ -203,7 +203,7 @@ int compat_grant_table_op( case GNTTABOP_transfer: for ( n =3D 0; n < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.xfer) &&= i < count && rc =3D=3D 0; ++i, ++n ) { - if ( unlikely(__copy_from_guest_offset(&cmp.xfer, cmp_uop,= i, 1)) ) + if ( unlikely(__copy_from_guest_offset(&cmp.xfer, uop, i, = 1)) ) rc =3D -EFAULT; else { @@ -222,7 +222,7 @@ int compat_grant_table_op( { XEN_GUEST_HANDLE_PARAM(gnttab_transfer_compat_t) xfer; =20 - xfer =3D guest_handle_cast(cmp_uop, gnttab_transfer_compat= _t); + xfer =3D guest_handle_cast(uop, gnttab_transfer_compat_t); guest_handle_add_offset(xfer, i); cnt_uop =3D guest_handle_cast(xfer, void); while ( n-- ) @@ -237,7 +237,7 @@ int compat_grant_table_op( case GNTTABOP_copy: for ( n =3D 0; n < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.copy) &&= i < count && rc =3D=3D 0; ++i, ++n ) { - if ( unlikely(__copy_from_guest_offset(&cmp.copy, cmp_uop,= i, 1)) ) + if ( unlikely(__copy_from_guest_offset(&cmp.copy, uop, i, = 1)) ) rc =3D -EFAULT; else { @@ -267,7 +267,7 @@ int compat_grant_table_op( { XEN_GUEST_HANDLE_PARAM(gnttab_copy_compat_t) copy; =20 - copy =3D guest_handle_cast(cmp_uop, gnttab_copy_compat_t); + copy =3D guest_handle_cast(uop, gnttab_copy_compat_t); guest_handle_add_offset(copy, i); cnt_uop =3D guest_handle_cast(copy, void); while ( n-- ) @@ -285,7 +285,7 @@ int compat_grant_table_op( rc =3D -EINVAL; break; } - if ( unlikely(__copy_from_guest(&cmp.get_status, cmp_uop, 1) || + if ( unlikely(__copy_from_guest(&cmp.get_status, uop, 1) || !compat_handle_okay(cmp.get_status.frame_list, cmp.get_status.nr_frames)) ) { @@ -303,7 +303,7 @@ int compat_grant_table_op( if ( rc >=3D 0 ) { XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_compat_t) = get =3D - guest_handle_cast(cmp_uop, + guest_handle_cast(uop, gnttab_get_status_frames_compat_t); =20 if ( unlikely(__copy_field_to_guest(get, nat.get_status, diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index 8c34f201c2..45e5fb0e5d 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -54,7 +54,7 @@ static int cf_check get_reserved_device_memory( } #endif =20 -int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) +int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct vcpu *curr =3D current; struct domain *currd =3D curr->domain; @@ -96,7 +96,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_P= ARAM(void) compat) case XENMEM_increase_reservation: case XENMEM_decrease_reservation: case XENMEM_populate_physmap: - if ( copy_from_guest(&cmp.rsrv, compat, 1) ) + if ( copy_from_guest(&cmp.rsrv, arg, 1) ) return start_extent; =20 /* Is size too large for us to encode a continuation? */ @@ -158,7 +158,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) { int order_delta; =20 - if ( copy_from_guest(&cmp.xchg, compat, 1) ) + if ( copy_from_guest(&cmp.xchg, arg, 1) ) return -EFAULT; =20 order_delta =3D cmp.xchg.out.extent_order - cmp.xchg.in.extent= _order; @@ -241,14 +241,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HAND= LE_PARAM(void) compat) case XENMEM_maximum_reservation: case XENMEM_maximum_gpfn: case XENMEM_maximum_ram_page: - nat.hnd =3D compat; + nat.hnd =3D arg; break; =20 case XENMEM_add_to_physmap: BUILD_BUG_ON((typeof(cmp.atp.size))-1 > (UINT_MAX >> MEMOP_EXTENT_SHIFT)); =20 - if ( copy_from_guest(&cmp.atp, compat, 1) ) + if ( copy_from_guest(&cmp.atp, arg, 1) ) return -EFAULT; =20 XLAT_add_to_physmap(nat.atp, &cmp.atp); @@ -271,7 +271,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) enum XLAT_add_to_physmap_batch_u u =3D XLAT_add_to_physmap_batch_u_res0; =20 - if ( copy_from_guest(&cmp.atpb, compat, 1) ) + if ( copy_from_guest(&cmp.atpb, arg, 1) ) return -EFAULT; size =3D cmp.atpb.size; if ( !compat_handle_okay(cmp.atpb.idxs, size) || @@ -322,7 +322,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) =20 case XENMEM_remove_from_physmap: { - if ( copy_from_guest(&cmp.xrfp, compat, 1) ) + if ( copy_from_guest(&cmp.xrfp, arg, 1) ) return -EFAULT; =20 XLAT_remove_from_physmap(nat.xrfp, &cmp.xrfp); @@ -331,7 +331,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) } =20 case XENMEM_access_op: - if ( copy_from_guest(&cmp.mao, compat, 1) ) + if ( copy_from_guest(&cmp.mao, arg, 1) ) return -EFAULT; =20 #define XLAT_mem_access_op_HNDL_pfn_list(_d_, _s_) \ @@ -355,7 +355,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) enum XLAT_vnuma_topology_info_vmemrange vmemrange =3D XLAT_vnuma_topology_info_vmemrange_h; =20 - if ( copy_from_guest(&cmp.vnuma, compat, 1) ) + if ( copy_from_guest(&cmp.vnuma, arg, 1) ) return -EFAULT; =20 #define XLAT_vnuma_topology_info_HNDL_vdistance_h(_d_, _s_) \ @@ -381,7 +381,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) if ( unlikely(start_extent) ) return -EINVAL; =20 - if ( copy_from_guest(&grdm.map, compat, 1) || + if ( copy_from_guest(&grdm.map, arg, 1) || !compat_handle_okay(grdm.map.buffer, grdm.map.nr_entries)= ) return -EFAULT; =20 @@ -395,7 +395,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) if ( !rc && grdm.map.nr_entries < grdm.used_entries ) rc =3D -ENOBUFS; grdm.map.nr_entries =3D grdm.used_entries; - if ( __copy_to_guest(compat, &grdm.map, 1) ) + if ( __copy_to_guest(arg, &grdm.map, 1) ) rc =3D -EFAULT; =20 return rc; @@ -406,7 +406,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) { xen_pfn_t *xen_frame_list =3D NULL; =20 - if ( copy_from_guest(&cmp.mar, compat, 1) ) + if ( copy_from_guest(&cmp.mar, arg, 1) ) return -EFAULT; =20 /* Marshal the frame list in the remainder of the xlat space. = */ @@ -470,7 +470,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) break; } default: - return compat_arch_memory_op(cmd, compat); + return compat_arch_memory_op(cmd, arg); } =20 rc =3D do_memory_op(cmd, nat.hnd); @@ -481,14 +481,14 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HAND= LE_PARAM(void) compat) cmp.vnuma.nr_vnodes =3D nat.vnuma->nr_vnodes; cmp.vnuma.nr_vcpus =3D nat.vnuma->nr_vcpus; cmp.vnuma.nr_vmemranges =3D nat.vnuma->nr_vmemranges; - if ( __copy_to_guest(compat, &cmp.vnuma, 1) ) + if ( __copy_to_guest(arg, &cmp.vnuma, 1) ) rc =3D -EFAULT; } break; } =20 cmd =3D 0; - if ( hypercall_xlat_continuation(&cmd, 2, 0x02, nat.hnd, compat) ) + if ( hypercall_xlat_continuation(&cmd, 2, 0x02, nat.hnd, arg) ) { BUG_ON(rc !=3D __HYPERVISOR_memory_op); BUG_ON((cmd & MEMOP_CMD_MASK) !=3D op); @@ -573,7 +573,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) } =20 cmp.xchg.nr_exchanged =3D nat.xchg->nr_exchanged; - if ( __copy_field_to_guest(guest_handle_cast(compat, + if ( __copy_field_to_guest(guest_handle_cast(arg, compat_memory_exc= hange_t), &cmp.xchg, nr_exchanged) ) rc =3D -EFAULT; @@ -605,7 +605,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) cmp.vnuma.nr_vnodes =3D nat.vnuma->nr_vnodes; cmp.vnuma.nr_vcpus =3D nat.vnuma->nr_vcpus; cmp.vnuma.nr_vmemranges =3D nat.vnuma->nr_vmemranges; - if ( __copy_to_guest(compat, &cmp.vnuma, 1) ) + if ( __copy_to_guest(arg, &cmp.vnuma, 1) ) rc =3D -EFAULT; break; =20 @@ -618,7 +618,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) { ASSERT(split =3D=3D 0 && rc =3D=3D 0); if ( __copy_field_to_guest( - guest_handle_cast(compat, + guest_handle_cast(arg, compat_mem_acquire_resource_t), nat.mar, nr_frames) ) return -EFAULT; @@ -707,7 +707,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) if ( done < nat.mar->nr_frames ) return hypercall_create_continuation( __HYPERVISOR_memory_op, "ih", - op | (start_extent << MEMOP_EXTENT_SHIFT), compat); + op | (start_extent << MEMOP_EXTENT_SHIFT), arg); =20 /* * Well... Somethings gone wrong with the two levels of chunki= ng. @@ -728,7 +728,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE= _PARAM(void) compat) cmd =3D op | (start_extent << MEMOP_EXTENT_SHIFT); if ( split > 0 && hypercall_preempt_check() ) return hypercall_create_continuation( - __HYPERVISOR_memory_op, "ih", cmd, compat); + __HYPERVISOR_memory_op, "ih", cmd, arg); } while ( split > 0 ); =20 if ( unlikely(rc > INT_MAX) ) --=20 2.34.1