From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] xen/balloon: set ballooned out pages as invalid in p2m Date: Tue, 1 Jul 2014 09:58:14 -0400 Message-ID: <20140701135814.GC19711@laptop.dumpdata.com> References: <1404221868-10704-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X1yZs-0003GL-Gw for xen-devel@lists.xenproject.org; Tue, 01 Jul 2014 13:58:32 +0000 Content-Disposition: inline In-Reply-To: <1404221868-10704-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On Tue, Jul 01, 2014 at 02:37:48PM +0100, David Vrabel wrote: > Since cd9151e26d31048b2b5e00fd02e110e07d2200c9 (xen/balloon: set a > mapping for ballooned out pages), a ballooned out page had its entry > in the p2m set to the MFN of one of the scratch pages. This means > that the p2m will contain many entries pointing to the same MFN. > > During a domain save, these many-to-one entries are not identified as > such and the scratch page is saved multiple times. On restore the > ballooned pages are populated with new frames and the domain may use > up its allocation before all pages can be restored. > > Set ballooned out pages as INVALID_P2M_ENTRY in the p2m (as they were > before), preventing them from being saved and re-populated on restore. > Won't that invalide the primal purpose of the scratch page code? That is cd9151e26d31048b2b5e00fd02e110e07d2200c9 xen/balloon: set a mapping for ballooned out pages " Allocate a page per cpu and map all the ballooned out pages to the corresponding mfn. Set the p2m accordingly. This way reading from a ballooned out page won't cause a kernel crash (see http://lists.xen.org/archives/html/xen-devel/2012-12/msg01154.html). " ? > Signed-off-by: David Vrabel > Reported-by: Marek Marczykowski > Tested-by: Marek Marczykowski > --- > drivers/xen/balloon.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c > index b7a506f..5c660c7 100644 > --- a/drivers/xen/balloon.c > +++ b/drivers/xen/balloon.c > @@ -426,20 +426,18 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) > * p2m are consistent. > */ > if (!xen_feature(XENFEAT_auto_translated_physmap)) { > - unsigned long p; > - struct page *scratch_page = get_balloon_scratch_page(); > - > if (!PageHighMem(page)) { > + struct page *scratch_page = get_balloon_scratch_page(); > + > ret = HYPERVISOR_update_va_mapping( > (unsigned long)__va(pfn << PAGE_SHIFT), > pfn_pte(page_to_pfn(scratch_page), > PAGE_KERNEL_RO), 0); > BUG_ON(ret); > - } > - p = page_to_pfn(scratch_page); > - __set_phys_to_machine(pfn, pfn_to_mfn(p)); > > - put_balloon_scratch_page(); > + put_balloon_scratch_page(); > + } > + __set_phys_to_machine(pfn, INVALID_P2M_ENTRY); > } > #endif > > -- > 1.7.10.4 >