xen/arm: Correctly implement domain_page_map_to_mfn
PATCH 1/1 xen/arm: Correctly implement domain_page_map_to_mfn
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.
---
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(-)
xen/arch/arm/mm.c +7 -3
@@ -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 );
Signature · 1 line
1.7.10.4
Quoted 10 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Signed-off-by Julien Grall <[email protected]>
I assume this brings the arm paths into line with the x86 functionality?
-George
Quoted 31 lines
---
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(-)xen/arch/arm/mm.c +7
-3@@ -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 );
Quoted 6 lines · George Dunlap
Quoted 5 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.
Quoted 7 lines
Quoted 5 lines
Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Signed-off-by Julien Grall <[email protected]>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).
Quoted 36 lines
-George
Quoted 31 lines
---
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(-)xen/arch/arm/mm.c +7
-3@@ -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 );
Quoted 7 lines · Ian Campbell
Quoted 6 lines · George Dunlap
Quoted 5 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Signed-off-by Julien Grall <[email protected]>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:
Ian Campbell
AppliedQuoted 12 lines · George Dunlap
Quoted 11 lines · Ian Campbell
Quoted 10 lines · George Dunlap
Quoted 9 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Julien Grall <[email protected]>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 <[email protected]>
Thanks, applied.
Quoted 11 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>
It looks good to me.
Quoted 33 lines
---
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(-)xen/arch/arm/mm.c +7
-3@@ -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 );Signature · 1 line
1.7.10.4
Quoted 11 lines · Julien Grall
The function
domain_page_map_to_mfncan be used to translate a virtual address mapped by bothmap_domain_pageandmap_domain_page_global. The former is using vmap to map the mfn, thereforedomain_page_map_to_mfnwill always fail because the address is not in DOMHEAP range.Check if the address is in vmap range and use
__pato translate it.This patch fix guest shutdown when the event fifo is used.
Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>
Quoted 31 lines
---
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(-)xen/arch/arm/mm.c +7
-3@@ -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 );