All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
@ 2014-02-05 14:16 Julien Grall
  2014-02-05 14:51 ` George Dunlap
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Julien Grall @ 2014-02-05 14:16 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, patches, Julien Grall, tim, George Dunlap,
	stefano.stabellini

The function domain_page_map_to_mfn can be used to translate a virtual
address mapped by both map_domain_page and map_domain_page_global.
The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
will always fail because the address is not in DOMHEAP range.

Check if the address is in vmap range and use __pa to translate it.

This patch fix guest shutdown when the event fifo is used.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: George Dunlap <george.dunlap@citrix.com>

---
    This is a bug fix for Xen 4.4. Without this patch, it's impossible to
use Linux 3.14 (and higher) as guest with the event fifo driver.
---
 xen/arch/arm/mm.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 127cce0..bdca68a 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -325,11 +325,15 @@ void unmap_domain_page(const void *va)
     local_irq_restore(flags);
 }
 
-unsigned long domain_page_map_to_mfn(const void *va)
+unsigned long domain_page_map_to_mfn(const void *ptr)
 {
+    unsigned long va = (unsigned long)ptr;
     lpae_t *map = this_cpu(xen_dommap);
-    int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
-    unsigned long offset = ((unsigned long)va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
+    int slot = (va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
+    unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
+
+    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
+        return virt_to_mfn(va);
 
     ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
     ASSERT(map[slot].pt.avail != 0);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-05 14:16 [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn Julien Grall
@ 2014-02-05 14:51 ` George Dunlap
  2014-02-06 12:02   ` Ian Campbell
  2014-02-05 16:27 ` Stefano Stabellini
  2014-02-06 12:26 ` Ian Campbell
  2 siblings, 1 reply; 7+ messages in thread
From: George Dunlap @ 2014-02-05 14:51 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: stefano.stabellini, George Dunlap, tim, ian.campbell, patches

On 02/05/2014 02:16 PM, Julien Grall wrote:
> The function domain_page_map_to_mfn can be used to translate a virtual
> address mapped by both map_domain_page and map_domain_page_global.
> The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
> will always fail because the address is not in DOMHEAP range.
>
> Check if the address is in vmap range and use __pa to translate it.
>
> This patch fix guest shutdown when the event fifo is used.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

I assume this brings the arm paths into line with the x86 functionality?

  -George


>
> ---
>      This is a bug fix for Xen 4.4. Without this patch, it's impossible to
> use Linux 3.14 (and higher) as guest with the event fifo driver.
> ---
>   xen/arch/arm/mm.c |   10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 127cce0..bdca68a 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -325,11 +325,15 @@ void unmap_domain_page(const void *va)
>       local_irq_restore(flags);
>   }
>   
> -unsigned long domain_page_map_to_mfn(const void *va)
> +unsigned long domain_page_map_to_mfn(const void *ptr)
>   {
> +    unsigned long va = (unsigned long)ptr;
>       lpae_t *map = this_cpu(xen_dommap);
> -    int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> -    unsigned long offset = ((unsigned long)va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +    int slot = (va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> +    unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +
> +    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
> +        return virt_to_mfn(va);
>   
>       ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
>       ASSERT(map[slot].pt.avail != 0);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-05 14:16 [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn Julien Grall
  2014-02-05 14:51 ` George Dunlap
@ 2014-02-05 16:27 ` Stefano Stabellini
  2014-02-06 12:26 ` Ian Campbell
  2 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2014-02-05 16:27 UTC (permalink / raw)
  To: Julien Grall
  Cc: ian.campbell, patches, tim, George Dunlap, stefano.stabellini, xen-devel

On Wed, 5 Feb 2014, Julien Grall wrote:
> The function domain_page_map_to_mfn can be used to translate a virtual
> address mapped by both map_domain_page and map_domain_page_global.
> The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
> will always fail because the address is not in DOMHEAP range.
> 
> Check if the address is in vmap range and use __pa to translate it.
> 
> This patch fix guest shutdown when the event fifo is used.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: George Dunlap <george.dunlap@citrix.com>

It looks good to me.

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> ---
>     This is a bug fix for Xen 4.4. Without this patch, it's impossible to
> use Linux 3.14 (and higher) as guest with the event fifo driver.
> ---
>  xen/arch/arm/mm.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 127cce0..bdca68a 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -325,11 +325,15 @@ void unmap_domain_page(const void *va)
>      local_irq_restore(flags);
>  }
>  
> -unsigned long domain_page_map_to_mfn(const void *va)
> +unsigned long domain_page_map_to_mfn(const void *ptr)
>  {
> +    unsigned long va = (unsigned long)ptr;
>      lpae_t *map = this_cpu(xen_dommap);
> -    int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> -    unsigned long offset = ((unsigned long)va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +    int slot = (va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> +    unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +
> +    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
> +        return virt_to_mfn(va);
>  
>      ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
>      ASSERT(map[slot].pt.avail != 0);
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-05 14:51 ` George Dunlap
@ 2014-02-06 12:02   ` Ian Campbell
  2014-02-06 12:03     ` George Dunlap
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2014-02-06 12:02 UTC (permalink / raw)
  To: George Dunlap
  Cc: patches, Julien Grall, tim, George Dunlap, stefano.stabellini, xen-devel

On Wed, 2014-02-05 at 14:51 +0000, George Dunlap wrote:
> On 02/05/2014 02:16 PM, Julien Grall wrote:
> > The function domain_page_map_to_mfn can be used to translate a virtual
> > address mapped by both map_domain_page and map_domain_page_global.
> > The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
> > will always fail because the address is not in DOMHEAP range.
> >
> > Check if the address is in vmap range and use __pa to translate it.
> >
> > This patch fix guest shutdown when the event fifo is used.
> >
> > Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> I assume this brings the arm paths into line with the x86 functionality?

Yes, functionality which is now expected by common code as well (FIFO
evthcn stuff).

> 
>   -George
> 
> 
> >
> > ---
> >      This is a bug fix for Xen 4.4. Without this patch, it's impossible to
> > use Linux 3.14 (and higher) as guest with the event fifo driver.
> > ---
> >   xen/arch/arm/mm.c |   10 +++++++---
> >   1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> > index 127cce0..bdca68a 100644
> > --- a/xen/arch/arm/mm.c
> > +++ b/xen/arch/arm/mm.c
> > @@ -325,11 +325,15 @@ void unmap_domain_page(const void *va)
> >       local_irq_restore(flags);
> >   }
> >   
> > -unsigned long domain_page_map_to_mfn(const void *va)
> > +unsigned long domain_page_map_to_mfn(const void *ptr)
> >   {
> > +    unsigned long va = (unsigned long)ptr;
> >       lpae_t *map = this_cpu(xen_dommap);
> > -    int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> > -    unsigned long offset = ((unsigned long)va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> > +    int slot = (va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> > +    unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> > +
> > +    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
> > +        return virt_to_mfn(va);
> >   
> >       ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
> >       ASSERT(map[slot].pt.avail != 0);
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-06 12:02   ` Ian Campbell
@ 2014-02-06 12:03     ` George Dunlap
  2014-02-06 13:07       ` Ian Campbell
  0 siblings, 1 reply; 7+ messages in thread
From: George Dunlap @ 2014-02-06 12:03 UTC (permalink / raw)
  To: Ian Campbell
  Cc: patches, Julien Grall, tim, George Dunlap, stefano.stabellini, xen-devel

On 02/06/2014 12:02 PM, Ian Campbell wrote:
> On Wed, 2014-02-05 at 14:51 +0000, George Dunlap wrote:
>> On 02/05/2014 02:16 PM, Julien Grall wrote:
>>> The function domain_page_map_to_mfn can be used to translate a virtual
>>> address mapped by both map_domain_page and map_domain_page_global.
>>> The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
>>> will always fail because the address is not in DOMHEAP range.
>>>
>>> Check if the address is in vmap range and use __pa to translate it.
>>>
>>> This patch fix guest shutdown when the event fifo is used.
>>>
>>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> I assume this brings the arm paths into line with the x86 functionality?
> Yes, functionality which is now expected by common code as well (FIFO
> evthcn stuff).

In that case:

Release-acked-by: George Dunlap <george.dunlap@eu.citrix.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-05 14:16 [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn Julien Grall
  2014-02-05 14:51 ` George Dunlap
  2014-02-05 16:27 ` Stefano Stabellini
@ 2014-02-06 12:26 ` Ian Campbell
  2 siblings, 0 replies; 7+ messages in thread
From: Ian Campbell @ 2014-02-06 12:26 UTC (permalink / raw)
  To: Julien Grall; +Cc: xen-devel, tim, George Dunlap, stefano.stabellini, patches

On Wed, 2014-02-05 at 14:16 +0000, Julien Grall wrote:
> The function domain_page_map_to_mfn can be used to translate a virtual
> address mapped by both map_domain_page and map_domain_page_global.
> The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
> will always fail because the address is not in DOMHEAP range.
> 
> Check if the address is in vmap range and use __pa to translate it.
> 
> This patch fix guest shutdown when the event fifo is used.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: George Dunlap <george.dunlap@citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> 
> ---
>     This is a bug fix for Xen 4.4. Without this patch, it's impossible to
> use Linux 3.14 (and higher) as guest with the event fifo driver.
> ---
>  xen/arch/arm/mm.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 127cce0..bdca68a 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -325,11 +325,15 @@ void unmap_domain_page(const void *va)
>      local_irq_restore(flags);
>  }
>  
> -unsigned long domain_page_map_to_mfn(const void *va)
> +unsigned long domain_page_map_to_mfn(const void *ptr)
>  {
> +    unsigned long va = (unsigned long)ptr;
>      lpae_t *map = this_cpu(xen_dommap);
> -    int slot = ((unsigned long) va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> -    unsigned long offset = ((unsigned long)va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +    int slot = (va - DOMHEAP_VIRT_START) >> SECOND_SHIFT;
> +    unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK;
> +
> +    if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END )
> +        return virt_to_mfn(va);
>  
>      ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES);
>      ASSERT(map[slot].pt.avail != 0);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn
  2014-02-06 12:03     ` George Dunlap
@ 2014-02-06 13:07       ` Ian Campbell
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Campbell @ 2014-02-06 13:07 UTC (permalink / raw)
  To: George Dunlap
  Cc: patches, Julien Grall, tim, George Dunlap, stefano.stabellini, xen-devel

On Thu, 2014-02-06 at 12:03 +0000, George Dunlap wrote:
> On 02/06/2014 12:02 PM, Ian Campbell wrote:
> > On Wed, 2014-02-05 at 14:51 +0000, George Dunlap wrote:
> >> On 02/05/2014 02:16 PM, Julien Grall wrote:
> >>> The function domain_page_map_to_mfn can be used to translate a virtual
> >>> address mapped by both map_domain_page and map_domain_page_global.
> >>> The former is using vmap to map the mfn, therefore domain_page_map_to_mfn
> >>> will always fail because the address is not in DOMHEAP range.
> >>>
> >>> Check if the address is in vmap range and use __pa to translate it.
> >>>
> >>> This patch fix guest shutdown when the event fifo is used.
> >>>
> >>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> >> I assume this brings the arm paths into line with the x86 functionality?
> > Yes, functionality which is now expected by common code as well (FIFO
> > evthcn stuff).
> 
> In that case:
> 
> Release-acked-by: George Dunlap <george.dunlap@eu.citrix.com>

Thanks, applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-06 13:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-05 14:16 [PATCH] xen/arm: Correctly implement domain_page_map_to_mfn Julien Grall
2014-02-05 14:51 ` George Dunlap
2014-02-06 12:02   ` Ian Campbell
2014-02-06 12:03     ` George Dunlap
2014-02-06 13:07       ` Ian Campbell
2014-02-05 16:27 ` Stefano Stabellini
2014-02-06 12:26 ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.