diff mbox

[2/6] ARM: kvm: Use virt_to_idmap instead of virt_to_phys for idmap mappings

Message ID 1384457866-16135-3-git-send-email-santosh.shilimkar@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Santosh Shilimkar Nov. 14, 2013, 7:37 p.m. UTC
KVM initialisation fails on architectures implementing virt_to_idmap() because
virt_to_phys() on such architectures won't fetch you the correct idmap page.

So update the KVM ARM code to use the virt_to_idmap() to fix the issue.

Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
 arch/arm/kvm/mmu.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Christoffer Dall Nov. 15, 2013, 12:12 a.m. UTC | #1
On Thu, Nov 14, 2013 at 02:37:42PM -0500, Santosh Shilimkar wrote:
> KVM initialisation fails on architectures implementing virt_to_idmap() because
> virt_to_phys() on such architectures won't fetch you the correct idmap page.
> 
> So update the KVM ARM code to use the virt_to_idmap() to fix the issue.
> 
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> 
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> ---
>  arch/arm/kvm/mmu.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
> index b0de86b..3bd652f 100644
> --- a/arch/arm/kvm/mmu.c
> +++ b/arch/arm/kvm/mmu.c
> @@ -747,9 +747,9 @@ int kvm_mmu_init(void)
>  {
>  	int err;
>  
> -	hyp_idmap_start = virt_to_phys(__hyp_idmap_text_start);
> -	hyp_idmap_end = virt_to_phys(__hyp_idmap_text_end);
> -	hyp_idmap_vector = virt_to_phys(__kvm_hyp_init);
> +	hyp_idmap_start = virt_to_idmap(__hyp_idmap_text_start);
> +	hyp_idmap_end = virt_to_idmap(__hyp_idmap_text_end);
> +	hyp_idmap_vector = virt_to_idmap(__kvm_hyp_init);
>  
>  	if ((hyp_idmap_start ^ hyp_idmap_end) & PAGE_MASK) {
>  		/*
> @@ -775,8 +775,7 @@ int kvm_mmu_init(void)
>  		 * caches off at that point.
>  		 */
>  		kvm_flush_dcache_to_poc(init_bounce_page, len);
> -
> -		phys_base = virt_to_phys(init_bounce_page);
> +		phys_base = virt_to_idmap(init_bounce_page);
>  		hyp_idmap_vector += phys_base - hyp_idmap_start;
>  		hyp_idmap_start = phys_base;
>  		hyp_idmap_end = phys_base + len;
> -- 
> 1.7.9.5
> 
Looks good to me.

Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
diff mbox

Patch

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index b0de86b..3bd652f 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -747,9 +747,9 @@  int kvm_mmu_init(void)
 {
 	int err;
 
-	hyp_idmap_start = virt_to_phys(__hyp_idmap_text_start);
-	hyp_idmap_end = virt_to_phys(__hyp_idmap_text_end);
-	hyp_idmap_vector = virt_to_phys(__kvm_hyp_init);
+	hyp_idmap_start = virt_to_idmap(__hyp_idmap_text_start);
+	hyp_idmap_end = virt_to_idmap(__hyp_idmap_text_end);
+	hyp_idmap_vector = virt_to_idmap(__kvm_hyp_init);
 
 	if ((hyp_idmap_start ^ hyp_idmap_end) & PAGE_MASK) {
 		/*
@@ -775,8 +775,7 @@  int kvm_mmu_init(void)
 		 * caches off at that point.
 		 */
 		kvm_flush_dcache_to_poc(init_bounce_page, len);
-
-		phys_base = virt_to_phys(init_bounce_page);
+		phys_base = virt_to_idmap(init_bounce_page);
 		hyp_idmap_vector += phys_base - hyp_idmap_start;
 		hyp_idmap_start = phys_base;
 		hyp_idmap_end = phys_base + len;