Wei Liu
2013-Aug-27 15:17 UTC
[PATCH] xen/balloon: don''t set P2M entry for auto translated guest
In commit cd9151e2: xen/balloon: set a mapping for ballooned out pages we have the ballooned out page''s mapping set to a scratch page. That commit also sets the P2M entry of ballooned out page to the scratch page''s MFN. This is necessary for PV guest but not for HVM guest. On the other hand, setting the P2M entry would trigger BUG_ON in __set_phys_to_machine. The correct thing to do here is to avoid calling __set_phys_to_machine for auto translated guest. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- drivers/xen/balloon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index a3dc75d..3101cf6 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -430,8 +430,13 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) /* No more mappings: invalidate P2M and add to balloon. */ for (i = 0; i < nr_pages; i++) { pfn = mfn_to_pfn(frame_list[i]); - __set_phys_to_machine(pfn, - pfn_to_mfn(page_to_pfn(__get_cpu_var(balloon_scratch_page)))); + if (!xen_feature(XENFEAT_auto_translated_physmap)) { + unsigned long p; + struct page *pg; + pg = __get_cpu_var(balloon_scratch_page); + p = page_to_pfn(pg); + __set_phys_to_machine(pfn, pfn_to_mfn(p)); + } balloon_append(pfn_to_page(pfn)); } -- 1.7.10.4
Stefano Stabellini
2013-Aug-28 12:54 UTC
Re: [PATCH] xen/balloon: don''t set P2M entry for auto translated guest
On Tue, 27 Aug 2013, Wei Liu wrote:> In commit cd9151e2: xen/balloon: set a mapping for ballooned out pages > we have the ballooned out page''s mapping set to a scratch page. > > That commit also sets the P2M entry of ballooned out page to the scratch > page''s MFN. This is necessary for PV guest but not for HVM guest. On the > other hand, setting the P2M entry would trigger BUG_ON in > __set_phys_to_machine. > > The correct thing to do here is to avoid calling __set_phys_to_machine > for auto translated guest. > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>> drivers/xen/balloon.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c > index a3dc75d..3101cf6 100644 > --- a/drivers/xen/balloon.c > +++ b/drivers/xen/balloon.c > @@ -430,8 +430,13 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) > /* No more mappings: invalidate P2M and add to balloon. */ > for (i = 0; i < nr_pages; i++) { > pfn = mfn_to_pfn(frame_list[i]); > - __set_phys_to_machine(pfn, > - pfn_to_mfn(page_to_pfn(__get_cpu_var(balloon_scratch_page)))); > + if (!xen_feature(XENFEAT_auto_translated_physmap)) { > + unsigned long p; > + struct page *pg; > + pg = __get_cpu_var(balloon_scratch_page); > + p = page_to_pfn(pg); > + __set_phys_to_machine(pfn, pfn_to_mfn(p)); > + } > balloon_append(pfn_to_page(pfn)); > } > > -- > 1.7.10.4 >
Possibly Parallel Threads
- [PATCH] xen/balloon: don't alloc page while non-preemptible
- [PATCH v4 1/2] xen: add an "highmem" parameter to alloc_xenballooned_pages
- [RFC 00/14] arm: implement ballooning and privcmd foreign mappings based on x86 PVH
- [PATCH 1/6] xen: balloon: allow PVMMU interfaces to be compiled out
- [PATCH] Arch-neutral balloon driver