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

Re: [PATCH v5 6/7] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages


  • To: Penny Zheng <penny.zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 24 Aug 2021 13:03:02 +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-SenderADCheck; bh=XgfXHDHphN2Fw8F8fIRnCOYdf0FiQrXZkVg4xMq3sr4=; b=EpzqLAJ65NvVUVGubmpsFchfPGcaYqZcsJAFnN9porIO+ugbz0skmyJ06ZybGs+L6EDWY0UsCeIJD9Ia1X4KApZw/FRHZFr4WT/PJXTFylcuczEMDVZew5u3ZcJ+or7yy3cmguCIcChjeBARBkvSucwblfohJTUAiKPDUgJlwwiZ2C6FsfxhuAbczuAwTpmlNuhjiRRGsXWDODqgEy/PBZLe9Gbkgv75sY1rlKNhUhNv9kzeDX9tOZlmVC+C7yL9uRnID0gbPN8XghzeEfO+Cst8t3ck1GEGja3k+egxnUxHyBLud53357H9W23fOIxI9QRshyvK3/YTjgTBNJNn4g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3ob61oHY291fkfEP1JaeR4ffCY39ndhQh62NTqUt66rwF6pD26FTGrTJGgzCQ90Z0ARWG9SgwE1UzT2SA4DSIKKWfwtB+8Og/brAK7qeC9i8BSX60ea/aY+5zKssH4viG7t30PfM417iagz1LlVz91Oo69f7+yvG9RNrhxnLYSbbf5IyP7lh/VkUIIqr0NUw9xjmqSgMTi0dxk6tWPplKm5xn8ObpcY1wB8y/cRJukqTAn4C3ZOYfMLI9RVpfQSpdpI67vXG1zBInUrDLBEU4abzcyHN3U8dRTHx5+OJ5FMjLSC7uF77RR1tu6wlVdXOIEnvhuoe0DliD7YacM6og==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand.Marquis@xxxxxxx, Wei.Chen@xxxxxxx, nd@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, julien@xxxxxxx
  • Delivery-date: Tue, 24 Aug 2021 11:11:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.08.2021 11:50, Penny Zheng wrote:
> +/*
> + * Acquire nr_mfns contiguous reserved pages, starting at #smfn, of
> + * static memory.
> + * This function needs to be reworked if used outside of boot.
> + */
> +static struct page_info * __init acquire_staticmem_pages(mfn_t smfn,
> +                                                         unsigned long 
> nr_mfns,
> +                                                         unsigned int 
> memflags)
> +{
> +    bool need_tlbflush = false;
> +    uint32_t tlbflush_timestamp = 0;
> +    unsigned long i;
> +    struct page_info *pg;
> +
> +    ASSERT(nr_mfns);
> +    for ( unsigned long i = 0; i < nr_mfns; i++ )

This form of variable declaration gets warned about by some compiler
versions and may only be used once we settle on C99 as the base line
language level. There's one more such instance below, and the one
here is even worse in that it shadows a function scope variable.

> +        if ( !mfn_valid(mfn_add(smfn, i)) )
> +            return NULL;
> +
> +    pg = mfn_to_page(smfn);
> +
> +    spin_lock(&heap_lock);
> +
> +    for ( i = 0; i < nr_mfns; i++ )
> +    {
> +        /* The page should be reserved and not yet allocated. */
> +        if ( pg[i].count_info != (PGC_state_free | PGC_reserved) )
> +        {
> +            printk(XENLOG_ERR
> +                   "pg[%lu] Static MFN %"PRI_mfn" c=%#lx t=%#x\n",
> +                   i, mfn_x(smfn) + i,
> +                   pg[i].count_info, pg[i].tlbflush_timestamp);
> +            goto out_err;
> +        }
> +
> +        if ( !(memflags & MEMF_no_tlbflush) )
> +            accumulate_tlbflush(&need_tlbflush, &pg[i],
> +                                &tlbflush_timestamp);
> +
> +        /*
> +         * Preserve flag PGC_reserved and change page state
> +         * to PGC_state_inuse.
> +         */
> +        pg[i].count_info = PGC_reserved | PGC_state_inuse;
> +        /* Initialise fields which have other uses for free pages. */
> +        pg[i].u.inuse.type_info = 0;
> +        page_set_owner(&pg[i], NULL);
>      }
> +
> +    spin_unlock(&heap_lock);
> +
> +    if ( need_tlbflush )
> +        filtered_flush_tlb_mask(tlbflush_timestamp);
> +
> +    /*
> +     * Ensure cache and RAM are consistent for platforms where the guest
> +     * can control its own visibility of/through the cache.
> +     */
> +    for ( i = 0; i < nr_mfns; i++ )
> +        flush_page_to_ram(mfn_x(smfn) + i, !(memflags & 
> MEMF_no_icache_flush));
> +
> +    return pg;
> +
> +out_err:

Please indent labels by at least one space.

> +    for ( unsigned long j = 0; j < i; j++ )

You don't need the extra variable here at all - simply use
"while ( i-- )".

Jan




 


Rackspace

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