Mailing List Archive

[PATCH 07/14] xen: balloon: do not update stage 1 pagetable for autotranslated guests
This is unnecessary (since the page will be removed from the p2m) and
can be tricky if the page is in the middle of a superpage, as it is on
ARM.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
Also effects PVH but in a benign way I think.
---
drivers/xen/balloon.c | 23 +++--------------------
1 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 7885a19..1b56ae0 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -357,15 +357,7 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap) &&
phys_to_machine_mapping_valid(pfn));

- if (xen_pv_domain() &&
- xen_feature(XENFEAT_auto_translated_physmap)) {
- /* PVH: we just need to update native page table */
- pte_t *ptep;
- unsigned int level;
- void *addr = __va(pfn << PAGE_SHIFT);
- ptep = lookup_address((unsigned long)addr, &level);
- set_pte(ptep, pfn_pte(pfn, PAGE_KERNEL));
- } else
+ if (!xen_feature(XENFEAT_auto_translated_physmap))
set_phys_to_machine(pfn, frame_list[i]);

/* Link back into the page tables if not highmem. */
@@ -427,21 +419,12 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)

scrub_page(page);

- if (xen_pv_domain() && !PageHighMem(page)) {
- if (xen_feature(XENFEAT_auto_translated_physmap)) {
- unsigned int level;
- pte_t *ptep;
- void *addr = __va(pfn << PAGE_SHIFT);
- ptep = lookup_address((unsigned long)addr,
- &level);
- set_pte(ptep, __pte(0));
-
- } else {
+ if (xen_pv_domain() && !PageHighMem(page) &&
+ !xen_feature(XENFEAT_auto_translated_physmap)) {
ret = HYPERVISOR_update_va_mapping(
(unsigned long)__va(pfn << PAGE_SHIFT),
__pte_ma(0), 0);
BUG_ON(ret);
- }
}
}

--
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH 07/14] xen: balloon: do not update stage 1 pagetable for autotranslated guests [ In reply to ]
On Thu, 4 Oct 2012, Ian Campbell wrote:
> This is unnecessary (since the page will be removed from the p2m) and
> can be tricky if the page is in the middle of a superpage, as it is on
> ARM.
>

I think that this patch is correct. I'll leave to Konrad whether we
should carry the original incorrect PVH patch and this separate fix or
just merge the two of them.


> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
> Also effects PVH but in a benign way I think.
>
> drivers/xen/balloon.c | 23 +++--------------------
> 1 files changed, 3 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index 7885a19..1b56ae0 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -357,15 +357,7 @@ static enum bp_state increase_reservation(unsigned long nr_pages)
> BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap) &&
> phys_to_machine_mapping_valid(pfn));
>
> - if (xen_pv_domain() &&
> - xen_feature(XENFEAT_auto_translated_physmap)) {
> - /* PVH: we just need to update native page table */
> - pte_t *ptep;
> - unsigned int level;
> - void *addr = __va(pfn << PAGE_SHIFT);
> - ptep = lookup_address((unsigned long)addr, &level);
> - set_pte(ptep, pfn_pte(pfn, PAGE_KERNEL));
> - } else
> + if (!xen_feature(XENFEAT_auto_translated_physmap))
> set_phys_to_machine(pfn, frame_list[i]);
>
> /* Link back into the page tables if not highmem. */
> @@ -427,21 +419,12 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
>
> scrub_page(page);
>
> - if (xen_pv_domain() && !PageHighMem(page)) {
> - if (xen_feature(XENFEAT_auto_translated_physmap)) {
> - unsigned int level;
> - pte_t *ptep;
> - void *addr = __va(pfn << PAGE_SHIFT);
> - ptep = lookup_address((unsigned long)addr,
> - &level);
> - set_pte(ptep, __pte(0));
> -
> - } else {
> + if (xen_pv_domain() && !PageHighMem(page) &&
> + !xen_feature(XENFEAT_auto_translated_physmap)) {
> ret = HYPERVISOR_update_va_mapping(
> (unsigned long)__va(pfn << PAGE_SHIFT),
> __pte_ma(0), 0);
> BUG_ON(ret);
> - }
> }
> }
>
> --
> 1.7.2.5
>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
Re: [PATCH 07/14] xen: balloon: do not update stage 1 pagetable for autotranslated guests [ In reply to ]
On Fri, 5 Oct 2012 13:05:01 +0100
Stefano Stabellini <stefano.stabellini@eu.citrix.com> wrote:

> On Thu, 4 Oct 2012, Ian Campbell wrote:
> > This is unnecessary (since the page will be removed from the p2m)
> > and can be tricky if the page is in the middle of a superpage, as
> > it is on ARM.
> >
>
> I think that this patch is correct. I'll leave to Konrad whether we
> should carry the original incorrect PVH patch and this separate fix or
> just merge the two of them.
>
>
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > ---
> > Also effects PVH but in a benign way I think.
> >
> > drivers/xen/balloon.c | 23 +++--------------------
> > 1 files changed, 3 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> > index 7885a19..1b56ae0 100644
> > --- a/drivers/xen/balloon.c
> > +++ b/drivers/xen/balloon.c
> > @@ -357,15 +357,7 @@ static enum bp_state
> > increase_reservation(unsigned long nr_pages)
> > BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap) &&
> > phys_to_machine_mapping_valid(pfn));
> > - if (xen_pv_domain() &&
> > - xen_feature(XENFEAT_auto_translated_physmap)) {
> > - /* PVH: we just need to update native page
> > table */
> > - pte_t *ptep;
> > - unsigned int level;
> > - void *addr = __va(pfn << PAGE_SHIFT);
> > - ptep = lookup_address((unsigned long)addr,
> > &level);
> > - set_pte(ptep, pfn_pte(pfn, PAGE_KERNEL));
> > - } else
> > + if (!xen_feature(XENFEAT_auto_translated_physmap))
> > set_phys_to_machine(pfn, frame_list[i]);
> >
> > /* Link back into the page tables if not highmem.
> > */ @@ -427,21 +419,12 @@ static enum bp_state
> > decrease_reservation(unsigned long nr_pages, gfp_t gfp)
> > scrub_page(page);
> >
> > - if (xen_pv_domain() && !PageHighMem(page)) {
> > - if
> > (xen_feature(XENFEAT_auto_translated_physmap)) {
> > - unsigned int level;
> > - pte_t *ptep;
> > - void *addr = __va(pfn <<
> > PAGE_SHIFT);
> > - ptep = lookup_address((unsigned
> > long)addr,
> > - &level);
> > - set_pte(ptep, __pte(0));
> > -
> > - } else {
> > + if (xen_pv_domain() && !PageHighMem(page) &&
> > + !xen_feature(XENFEAT_auto_translated_physmap))
> > { ret = HYPERVISOR_update_va_mapping(
> > (unsigned long)__va(pfn <<
> > PAGE_SHIFT), __pte_ma(0), 0);
> > BUG_ON(ret);
> > - }
> > }
> > }
> >
> > --
> > 1.7.2.5
> >


I've made this change in my tree also. So, its good for PVH also.

thanks
Mukesh


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel