WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] do_memory_op: cleanup if copy_to_guest fails

To: Olaf Hering <olaf@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] do_memory_op: cleanup if copy_to_guest fails
From: Keir Fraser <keir@xxxxxxx>
Date: Thu, 16 Dec 2010 18:32:14 +0000
Cc:
Delivery-date: Thu, 16 Dec 2010 10:33:00 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:user-agent:date :subject:from:to:message-id:thread-topic:thread-index:in-reply-to :mime-version:content-type:content-transfer-encoding; bh=BOKh0T+auqxaUvoH7gyuv7wsDz7CBt+9wi3P53/lDMM=; b=FlikBQHenhiKeA3IsM3GHxhdHPfkSQADUC2olQs1DhTo7KFzLNz3GXCeOKiLAAx+7+ hfXyEWnTkdDjAZxyO3usFLed324RYsjXYHQf5cfESIwdfLCcksXH3fazFqPCb8yENYlr 47KNJvsW2iXyAZxRcBZXQ1AxjQ5kHFem9tiJo=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:user-agent:date:subject:from:to:message-id:thread-topic :thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; b=C/Fv/ltysYWm3hyAUbUtQADaTyHRgZiSQA4DghufnKyqWWVXahg48Mrh1y31XVBZFv 8/Y0anFzDkWgjR35h2t+nyC2aZbM/t0E7oT+IUy9xJe9HL4EfwpESgkeGcf6WWwL1LGw WLNRWzQwGR7rMB2BcSCqff5DvBsRtFOQtzQjs=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20101216175910.GA24006@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcudT48pJnnP2+5NW0e9vFawrKTDAw==
Thread-topic: [Xen-devel] [PATCH] do_memory_op: cleanup if copy_to_guest fails
User-agent: Microsoft-Entourage/12.27.0.100910
On 16/12/2010 17:59, "Olaf Hering" <olaf@xxxxxxxxx> wrote:

> Undo the page allocation in the ulikely event the copy_to_guest fails.

You can't really clean up in this case. Once a page has been alloc'ed to a
domain, it can immediately see it and map it. Trying to then
free_domheap_page() ignoring the current page reference count is actually
introducing a bug.

Leaving a bit of a mess on failed copy_to_guest is okay imo, as that is
usually a pretty fatal sign anyway. If there were good reason for cleaning
up better, we should at least be doing if (test_and_clear(PGC_allocated))
put_page().

 -- Keir

> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> 
> ---
> 
> I have not exercised this code path, it was found during code inspection in
> 4.0
> 
>  xen/common/memory.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> --- xen-unstable.hg-4.1.22548.orig/xen/common/memory.c
> +++ xen-unstable.hg-4.1.22548/xen/common/memory.c
> @@ -82,7 +82,10 @@ static void increase_reservation(struct
>          {
>              mfn = page_to_mfn(page);
>              if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn, 1))
> )
> +            {
> +                free_domheap_pages(page, a->extent_order);
>                  goto out;
> +            }
>          }
>      }
>  
> @@ -144,7 +147,13 @@ static void populate_physmap(struct memo
>  
>                  /* Inform the domain of the new page's machine address. */
>                  if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn,
> 1)) )
> +                {
> +                    for ( j = 0; j < (1 << a->extent_order); j++ )
> +                        set_gpfn_from_mfn(mfn + j, INVALID_M2P_ENTRY);
> +                    guest_physmap_remove_page(d, gpfn, mfn, a->extent_order);
> +                    free_domheap_pages(page, a->extent_order);
>                      goto out;
> +                }
>              }
>          }
>      }
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>