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

Re: [PATCH v10 8/9] xen: retrieve reserved pages on populate_physmap


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 17 Aug 2022 12:04:51 +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=AWdgy2/ltqh8Rqw5iGAIvSZaMw//DgtmkNlGaeRY+UQ=; b=mTnG55nA3BGSKfuH5KQ0pN4E5gObLqS7ZenjAkqdm6rxIzGywyK3o6+JPyIGwadPqhHuIeYJo//3s8sp9w7BfJaJ33qXbtm5jRi9MkD2oRMSmXtXMqqq9weVReoabw3il1UfCMjfX2ZUcY3qXawWEaIjC0Bh6cSd5WW0pApjdA3w5hFeYuzSjJkgszXJ1MoH5wJRx0nlDhsj6S4XbjhIl4lqJ39bzlT3a6zvHoI0PXq1PdTvV/IP8yCX/Ex3NoVpeZSeLkJlzccu6DQ6gyLZK23C1VYD5aFPxtdrjJwEQBUQnmYkWbUPYYMrgn9xm8WsDyjkP3wRCQbzXPCxRPtHig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DHTWZ66BTYH16ia5rdc2ejE2bz6e7Qm2R0aLhYByL7knHm6MKfzjDFQ3Q0n+uHT+KjNuUFzq/1bwyt2BS9GcG8bO+WZNs8DT5tA78i2YQEu0zSVrZJidaI5EDyTmg+QL7wsLdaMpX5G/cdj6z9Mw6jdebrl+R1ABBpOYoUYBdQFzrEOx/N45+8M/dbbwSz5xTTFMRLtU87P4oCjsUVfyiez4ZbgqwP36YVzRpMPggU+RsgwUG6Q/q0sC+H594mgWa/5UDot1H9mFe+jCDQSG1jLeQrwrLE8YQyX9lnfhkwKsGmrslnLEtN69CF0ifC4CTwY8JddGQxSee4JNyeXJQQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: wei.chen@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 17 Aug 2022 10:05:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

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