Re: [Xen-devel] [PATCH 05/15] xen/arm: p2m: Limit call to mem access code use in get_page_from_gva

2018-08-14 Thread Stefano Stabellini
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 

Reviewed-by: Stefano Stabellini 


> ---
> 
> Cc: Razvan Cojocaru 
> Cc: Tamas K Lengyel 
> ---
>  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
> 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 05/15] xen/arm: p2m: Limit call to mem access code use in get_page_from_gva

2018-07-17 Thread Razvan Cojocaru
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 

Acked-by: Razvan Cojocaru 


Thanks,
Razvan

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 05/15] xen/arm: p2m: Limit call to mem access code use in get_page_from_gva

2018-07-16 Thread Julien Grall
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 

---

Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
---
 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


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel