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

Re: [PATCH v1 3/5] xen/arm: unpopulate memory when domain on static allocation


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 30 Mar 2022 11:52:37 +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=YDomwYr5S80vYsrW9hNDuagVEoGbHJX4KMvKzQMyXqY=; b=F318oR9tqfj3j4lis8kdOY0slWQoHXxxT2gn5kCUh5+elB1kPQ1WyJAL3R5nVvASb58PQMeGT1R6t2fYCJuIOwciNkK/WwbcSBWrRUcEPd57PEIDmy/gE8HnJ06KYvrtAIKUZBpAnI9m0HxmSTQKbo7MjADgNKGFkxx4QGiMIxEXxnEoMBt5FSi6ihNdgNmjKcKlWd+07zhmvVVSQk5KiPoYCZ/JTLwb7a3hI6H80pH2lvDyIAwPT2Txd7BqS/Qkm/zVwWRP8TLOUhYPTL6dZqiEoyUh5DNtNOzqrPJ0AtNgD0WL19LPPiInZVTVpl6dmyQptrxzrZ7CNvwTKg3suQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J//gBLVHM+Zh0sv4cQEJ2SQbyWKOGX/+xdVdt/lSFN5nhtHXJ64NNcTKTw3QqKSIObSpYpXETkkbg957wwhCcQyvwIPC9ktAtOPFQWBa7ZRxfAJiScAHGjIHGT1NTFTfAQtn/pyCryCkUT/KyFHhxRtxu5Q7m5OGjsLQ3m+9Ou8uJN60C5w1jm+/Qo1PJ9xCMCJl7yHhNMWMavZvtLCLsFSgKfpy2K9+xvbTHcxtiJP92bOacb3WHO4IHWE+18p/Wuk6SRmntxm/+avNt3mLJMml/z0kEU1/PovV2hiIUh7pJffCOlrT6rAr4YMoFI7W+7SZYKiJzBSrtZENc9eaRw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: wei.chen@xxxxxxx, henry.wang@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, 30 Mar 2022 09:52:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30.03.2022 11:36, Penny Zheng wrote:
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -35,6 +35,10 @@
>  #include <asm/guest.h>
>  #endif
>  
> +#ifndef is_domain_on_static_allocation
> +#define is_domain_on_static_allocation(d) 0

Nit: "false", not "0".

> @@ -405,13 +409,29 @@ int guest_remove_page(struct domain *d, unsigned long 
> gmfn)
>       * device must retrieve the same pfn when the hypercall populate_physmap
>       * is called.
>       *
> +     * When domain on static allocation, they should always get pages from 
> the
> +     * reserved static region when the hypercall populate_physmap is called.
> +     *
>       * For this purpose (and to match populate_physmap() behavior), the page
>       * is kept allocated.
>       */
> -    if ( !rc && !is_domain_direct_mapped(d) )
> +    if ( !rc && !(is_domain_direct_mapped(d) ||
> +                  is_domain_on_static_allocation(d)) )
>          put_page_alloc_ref(page);
>  
>      put_page(page);
> +#ifdef CONFIG_STATIC_MEMORY
> +    /*
> +     * When domain on static allocation, we shall store pages to 
> resv_page_list,
> +     * so the hypercall populate_physmap could retrieve pages from it,
> +     * rather than allocating from heap.
> +     */
> +    if ( is_domain_on_static_allocation(d) )
> +    {
> +        page_list_add_tail(page, &d->resv_page_list);
> +        d->resv_pages++;
> +    }
> +#endif

I think this is wrong, as a result of not integrating with put_page().
The page should only go on that list once its last ref was dropped. I
don't recall for sure, but iirc staticmem pages are put on the
domain's page list just like other pages would be. But then you also
corrupt the list when this isn't the last ref which is put.

As a result I also think that you shouldn't need to touch the earlier
if().

Jan




 


Rackspace

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