Message ID | 20180716172712.20294-6-julien.grall@arm.com |
---|---|
State | New |
Headers | show |
Series | xen/arm: Bunch of clean-up/improvement | expand |
On 07/16/2018 08:27 PM, Julien Grall wrote: > Mem access has only an impact on the hardware translation between a > guest virtual address and the machine physical address. So it is not > necessary to fallback to memaccess for all the other case (e.g when it > is not possible to acquire the page behind the MFN). > > Signed-off-by: Julien Grall <julien.grall@arm.com> Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com> Thanks, Razvan
On Mon, 16 Jul 2018, Julien Grall wrote: > Mem access has only an impact on the hardware translation between a > guest virtual address and the machine physical address. So it is not > necessary to fallback to memaccess for all the other case (e.g when it > is not possible to acquire the page behind the MFN). > > Signed-off-by: Julien Grall <julien.grall@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > > Cc: Razvan Cojocaru <rcojocaru@bitdefender.com> > Cc: Tamas K Lengyel <tamas@tklengyel.com> > --- > xen/arch/arm/p2m.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 5ca7ffe41b..ebf74760fa 100644 > --- a/xen/arch/arm/p2m.c > +++ b/xen/arch/arm/p2m.c > @@ -1425,17 +1425,24 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, > > if ( par ) > { > + /* > + * When memaccess is enabled, the translation GVA to MADDR may > + * have failed because of a permission fault. > + */ > + if ( p2m->mem_access_enabled ) > + return p2m_mem_access_check_and_get_page(va, flags, v); > + > dprintk(XENLOG_G_DEBUG, > "%pv: gvirt_to_maddr failed va=%#"PRIvaddr" flags=0x%lx par=%#"PRIx64"\n", > v, va, flags, par); > - goto err; > + return NULL; > } > > if ( !mfn_valid(maddr_to_mfn(maddr)) ) > { > dprintk(XENLOG_G_DEBUG, "%pv: Invalid MFN %#"PRI_mfn"\n", > v, mfn_x(maddr_to_mfn(maddr))); > - goto err; > + return NULL; > } > > page = mfn_to_page(maddr_to_mfn(maddr)); > @@ -1445,13 +1452,9 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, > { > dprintk(XENLOG_G_DEBUG, "%pv: Failing to acquire the MFN %#"PRI_mfn"\n", > v, mfn_x(maddr_to_mfn(maddr))); > - page = NULL; > + return NULL; > } > > -err: > - if ( !page && p2m->mem_access_enabled ) > - page = p2m_mem_access_check_and_get_page(va, flags, v); > - > return page; > } > > -- > 2.11.0 >
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 5ca7ffe41b..ebf74760fa 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1425,17 +1425,24 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( par ) { + /* + * When memaccess is enabled, the translation GVA to MADDR may + * have failed because of a permission fault. + */ + if ( p2m->mem_access_enabled ) + return p2m_mem_access_check_and_get_page(va, flags, v); + dprintk(XENLOG_G_DEBUG, "%pv: gvirt_to_maddr failed va=%#"PRIvaddr" flags=0x%lx par=%#"PRIx64"\n", v, va, flags, par); - goto err; + return NULL; } if ( !mfn_valid(maddr_to_mfn(maddr)) ) { dprintk(XENLOG_G_DEBUG, "%pv: Invalid MFN %#"PRI_mfn"\n", v, mfn_x(maddr_to_mfn(maddr))); - goto err; + return NULL; } page = mfn_to_page(maddr_to_mfn(maddr)); @@ -1445,13 +1452,9 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, { dprintk(XENLOG_G_DEBUG, "%pv: Failing to acquire the MFN %#"PRI_mfn"\n", v, mfn_x(maddr_to_mfn(maddr))); - page = NULL; + return NULL; } -err: - if ( !page && p2m->mem_access_enabled ) - page = p2m_mem_access_check_and_get_page(va, flags, v); - return page; }
Mem access has only an impact on the hardware translation between a guest virtual address and the machine physical address. So it is not necessary to fallback to memaccess for all the other case (e.g when it is not possible to acquire the page behind the MFN). Signed-off-by: Julien Grall <julien.grall@arm.com> --- Cc: Razvan Cojocaru <rcojocaru@bitdefender.com> Cc: Tamas K Lengyel <tamas@tklengyel.com> --- xen/arch/arm/p2m.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)