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

Re: [XEN PATCH] x86/domain_page: address violations of MISRA C:2012 Rule 8.3


  • To: Federico Serafini <federico.serafini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 28 Sep 2023 08:25:50 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sKQTNh+YhOkIo/Whcq7H0tmI5hZxy65obV9kR55ubmA=; b=Zeh/B4ZmiD2p4nsS3xE51vQy8FPXcujEsSORT8ncyyv9dT5ry9o3J/cYVsYM6KpBJlK8dRdk9gAph9N2xsIkqIIPLTDYgpkkxtrXPNdU+TfuGmQmDcc2a2uLbGb4ykv8cc/xb7OwfDhLW8fR5yzPgFrJznfBff5+gNO/4DJ+qXj8W8PJO6gR/+QOL+jRQG2a6P7ZrnItrw5SWIHi1DSAywq4lugKMii+p8cieLiMnksYm7jnNaLU5LnF7gfttHhzakPJOb6kJGVtWotaQkw6ANd7BkZ4Q1Uexi29kN29iRo/QFab1ooH4F08nSkcDvA/TxhpmsBp/HniQ5+5xH/zvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQNPgjnV6tUhpm7vo47/qxAFAqSH0DYTtcJEpxvNNa4ZMDjjgIduKadKZTC4NDW2B/TjR+mKgvTcLO7urFscOL/ZaO9tOJLlB+mbgoZg8h2A3bl0CxZS+nVCjQLR4hhzpiFo0yi2Jex+oClScboRkkQp6TAsqinfa+tXhd3m4a2eis7CP/gwvCXql+2U5lHl13tbbL/hq4uNHbUqjvxpLdjPpugigbEEnn25c5AW1SL/8+B7gF79V3hk7ITZhZthRRKozHsNyKDhBZTHZm+vOOPdajk7ugV8im2HbFOzdzu5yByj93RXY0NowH/FRLaZ9IDt6Q21ZY8bfApuJPZ/QA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <henry.wang@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 28 Sep 2023 06:26:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.09.2023 17:09, Federico Serafini wrote:
> Make function declarations and definitions consistent.
> No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
> ---
>  xen/arch/x86/domain_page.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
> index eac5e3304f..1cfa992a02 100644
> --- a/xen/arch/x86/domain_page.c
> +++ b/xen/arch/x86/domain_page.c
> @@ -173,18 +173,18 @@ void *map_domain_page(mfn_t mfn)
>      return (void *)MAPCACHE_VIRT_START + pfn_to_paddr(idx);
>  }
>  
> -void unmap_domain_page(const void *ptr)
> +void unmap_domain_page(const void *va)
>  {
>      unsigned int idx;
>      struct vcpu *v;
>      struct mapcache_domain *dcache;
> -    unsigned long va = (unsigned long)ptr, mfn, flags;
> +    unsigned long addr = (unsigned long)va, mfn, flags;
>      struct vcpu_maphash_entry *hashent;
>  
> -    if ( !va || va >= DIRECTMAP_VIRT_START )
> +    if ( !addr || addr >= DIRECTMAP_VIRT_START )
>          return;
>  
> -    ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END);
> +    ASSERT(addr >= MAPCACHE_VIRT_START && addr < MAPCACHE_VIRT_END);
>  
>      v = mapcache_current_vcpu();
>      ASSERT(v && is_pv_vcpu(v));
> @@ -192,7 +192,7 @@ void unmap_domain_page(const void *ptr)
>      dcache = &v->domain->arch.pv.mapcache;
>      ASSERT(dcache->inuse);
>  
> -    idx = PFN_DOWN(va - MAPCACHE_VIRT_START);
> +    idx = PFN_DOWN(addr - MAPCACHE_VIRT_START);
>      mfn = l1e_get_pfn(MAPCACHE_L1ENT(idx));
>      hashent = &v->arch.pv.mapcache.hash[MAPHASH_HASHFN(mfn)];
>  
> @@ -317,30 +317,30 @@ void *map_domain_page_global(mfn_t mfn)
>      return vmap(&mfn, 1);
>  }
>  
> -void unmap_domain_page_global(const void *ptr)
> +void unmap_domain_page_global(const void *va)
>  {
> -    unsigned long va = (unsigned long)ptr;
> +    unsigned long addr = (unsigned long)va;
>  
> -    if ( va >= DIRECTMAP_VIRT_START )
> +    if ( addr >= DIRECTMAP_VIRT_START )
>          return;
>  
> -    ASSERT(va >= VMAP_VIRT_START && va < VMAP_VIRT_END);
> +    ASSERT(addr >= VMAP_VIRT_START && addr < VMAP_VIRT_END);
>  
> -    vunmap(ptr);
> +    vunmap(va);
>  }

Up to here a statement in the description is needed why this apparently
much heavier code churn (compared to changing the declaration) is still
the (likely) better approach. (It may still be worthwhile to consider
changing declaration and Arm code, for "ptr" being the imo better name
for a const void * parameter, and "va" being more specific than just
"addr" as a local variable.)

>  /* Translate a map-domain-page'd address to the underlying MFN */
> -mfn_t domain_page_map_to_mfn(const void *ptr)
> +mfn_t domain_page_map_to_mfn(const void *va)
>  {
> -    unsigned long va = (unsigned long)ptr;
> +    unsigned long addr = (unsigned long)va;
>  
> -    if ( va >= DIRECTMAP_VIRT_START )
> -        return _mfn(virt_to_mfn(ptr));
> +    if ( addr >= DIRECTMAP_VIRT_START )
> +        return _mfn(virt_to_mfn(va));
>  
> -    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
> -        return vmap_to_mfn(va);
> +    if ( addr >= VMAP_VIRT_START && addr < VMAP_VIRT_END )
> +        return vmap_to_mfn(addr);
>  
> -    ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END);
> +    ASSERT(addr >= MAPCACHE_VIRT_START && addr < MAPCACHE_VIRT_END);
>  
> -    return l1e_get_mfn(__linear_l1_table[l1_linear_offset(va)]);
> +    return l1e_get_mfn(__linear_l1_table[l1_linear_offset(addr)]);
>  }

This change, otoh, moves the violation from x86 to Arm, afaict. IOW
this likely wants taking care of by changing the declaration. Then,
for consistency, the consideration above gains one more supporting
factor.

Jan



 


Rackspace

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