All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Penny Zheng <Penny.Zheng@arm.com>
Cc: wei.chen@arm.com, Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v10 8/9] xen: retrieve reserved pages on populate_physmap
Date: Wed, 17 Aug 2022 12:04:51 +0200	[thread overview]
Message-ID: <691b68f0-db68-b400-5473-558583f8dbc1@suse.com> (raw)
In-Reply-To: <20220816023658.3551936-9-Penny.Zheng@arm.com>

On 16.08.2022 04:36, Penny Zheng wrote:
> @@ -2867,6 +2854,61 @@ int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn,
>  
>      return 0;
>  }
> +
> +/*
> + * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory,
> + * then assign them to one specific domain #d.
> + */
> +int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn,
> +                                   unsigned int nr_mfns, unsigned int memflags)
> +{
> +    struct page_info *pg;
> +
> +    ASSERT_ALLOC_CONTEXT();
> +
> +    pg = acquire_staticmem_pages(smfn, nr_mfns, memflags);
> +    if ( !pg )
> +        return -ENOENT;
> +
> +    if ( assign_domstatic_pages(d, pg, nr_mfns, memflags) )
> +        return -EINVAL;
> +
> +    return 0;
> +}
> +
> +/*
> + * Acquire a page from reserved page list(resv_page_list), when populating
> + * memory for static domain on runtime.
> + */
> +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags)
> +{
> +    struct page_info *page;
> +
> +    ASSERT_ALLOC_CONTEXT();
> +
> +    /* Acquire a page from reserved page list(resv_page_list). */
> +    spin_lock(&d->page_alloc_lock);
> +    page = page_list_remove_head(&d->resv_page_list);
> +    spin_unlock(&d->page_alloc_lock);
> +    if ( unlikely(!page) )
> +        return INVALID_MFN;
> +
> +    if ( !prepare_staticmem_pages(page, 1, memflags) )
> +        goto fail;
> +
> +    if ( assign_domstatic_pages(d, page, 1, memflags) )
> +        goto fail_assign;
> +
> +    return page_to_mfn(page);
> +
> + fail_assign:
> +    free_staticmem_pages(page, 1, memflags & MEMF_no_scrub);

Doesn't this need to be !(memflags & MEMF_no_scrub)? And then -
with assignment having failed and with it being just a single page
we're talking about, the page was not exposed to the guest at any
point afaict. So I don't see the need for scrubbing in the first
place.

Also I think the rename of the function would better be done first,
since then you wouldn't need to touch this line again right in the
next patch, and the prepare/unprepare pairing would also be visible
right here. This would then also better fit with the introduction
of prepare_*() in the previous patch (which, afaic, the name
change could also be merged into; FTAOD I don't mind it to be
separate).

Jan


  reply	other threads:[~2022-08-17 10:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  2:36 [PATCH v10 0/9] populate/unpopulate memory when domain on static allocation Penny Zheng
2022-08-16  2:36 ` [PATCH v10 1/9] xen/arm: rename PGC_reserved to PGC_static Penny Zheng
2022-08-16  2:36 ` [PATCH v10 2/9] xen: do not free reserved memory into heap Penny Zheng
2022-08-16  6:40   ` Jan Beulich
2022-08-24  9:03     ` Julien Grall
2022-08-24  9:27       ` Juergen Gross
2022-08-24  9:31         ` Julien Grall
2022-08-24  9:38           ` Juergen Gross
2022-08-24 10:42       ` Jan Beulich
2022-08-16  2:36 ` [PATCH v10 3/9] xen: do not merge reserved pages in free_heap_pages() Penny Zheng
2022-08-16  2:36 ` [PATCH v10 4/9] xen: add field "flags" to cover all internal CDF_XXX Penny Zheng
2022-08-16  2:36 ` [PATCH v10 5/9] xen/arm: introduce CDF_staticmem Penny Zheng
2022-08-16  2:36 ` [PATCH v10 6/9] xen: unpopulate memory when domain is static Penny Zheng
2022-08-17  8:51   ` Jan Beulich
2022-08-24  9:12   ` Julien Grall
2022-08-16  2:36 ` [PATCH v10 7/9] xen: introduce prepare_staticmem_pages Penny Zheng
2022-08-16  2:36 ` [PATCH v10 8/9] xen: retrieve reserved pages on populate_physmap Penny Zheng
2022-08-17 10:04   ` Jan Beulich [this message]
2022-09-05  7:08     ` Penny Zheng
2022-09-06  6:33       ` Jan Beulich
2022-09-06  7:14         ` Penny Zheng
2022-09-06  7:19           ` Jan Beulich
2022-08-16  2:36 ` [PATCH v10 9/9] xen: rename free_staticmem_pages to unprepare_staticmem_pages Penny Zheng
2022-08-17 10:07   ` Jan Beulich
2022-08-24  9:54 ` [PATCH v10 0/9] populate/unpopulate memory when domain on static allocation Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=691b68f0-db68-b400-5473-558583f8dbc1@suse.com \
    --to=jbeulich@suse.com \
    --cc=Penny.Zheng@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wei.chen@arm.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.