public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] do not call gva_to_gpa on physical address
@ 2010-07-14 15:38 Gleb Natapov
  2010-07-14 15:44 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2010-07-14 15:38 UTC (permalink / raw)
  To: mtosatti, avi; +Cc: kvm

When tdp is enabled cr2 passed to emulator is pga not gva, so no need to
call gva_to_gpa on it.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fb08316..721bf0a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3944,10 +3944,13 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva)
 	if (kvm_mmu_unprotect_page_virt(vcpu, gva))
 		return true;
 
-	gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
+	if (!tdp_enabled) {
+		gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
 
-	if (gpa == UNMAPPED_GVA)
-		return true; /* let cpu generate fault */
+		if (gpa == UNMAPPED_GVA)
+			return true; /* let cpu generate fault */
+	} else
+		gpa = gva;
 
 	if (!kvm_is_error_hva(gfn_to_hva(vcpu->kvm, gpa >> PAGE_SHIFT)))
 		return true;
--
			Gleb.

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

* Re: [PATCH] do not call gva_to_gpa on physical address
  2010-07-14 15:38 [PATCH] do not call gva_to_gpa on physical address Gleb Natapov
@ 2010-07-14 15:44 ` Avi Kivity
  2010-07-14 15:52   ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2010-07-14 15:44 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: mtosatti, kvm

On 07/14/2010 06:38 PM, Gleb Natapov wrote:
> When tdp is enabled cr2 passed to emulator is pga not gva, so no need to
> call gva_to_gpa on it.
>
> Signed-off-by: Gleb Natapov<gleb@redhat.com>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index fb08316..721bf0a 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3944,10 +3944,13 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva)
>   	if (kvm_mmu_unprotect_page_virt(vcpu, gva))
>   		return true;
>
> -	gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
> +	if (!tdp_enabled) {
> +		gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
>
> -	if (gpa == UNMAPPED_GVA)
> -		return true; /* let cpu generate fault */
> +		if (gpa == UNMAPPED_GVA)
> +			return true; /* let cpu generate fault */
> +	} else
> +		gpa = gva;
>
>   	if (!kvm_is_error_hva(gfn_to_hva(vcpu->kvm, gpa>>  PAGE_SHIFT)))
>   		return true;
>    

Why not

     if (tdp_enabled)
               return false;

at the top?  Is there any reason ever to reexecute an instruction with 
tdp enabled?

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


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

* Re: [PATCH] do not call gva_to_gpa on physical address
  2010-07-14 15:44 ` Avi Kivity
@ 2010-07-14 15:52   ` Gleb Natapov
  2010-07-14 15:55     ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2010-07-14 15:52 UTC (permalink / raw)
  To: Avi Kivity; +Cc: mtosatti, kvm

On Wed, Jul 14, 2010 at 06:44:15PM +0300, Avi Kivity wrote:
> On 07/14/2010 06:38 PM, Gleb Natapov wrote:
> >When tdp is enabled cr2 passed to emulator is pga not gva, so no need to
> >call gva_to_gpa on it.
> >
> >Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >index fb08316..721bf0a 100644
> >--- a/arch/x86/kvm/x86.c
> >+++ b/arch/x86/kvm/x86.c
> >@@ -3944,10 +3944,13 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva)
> >  	if (kvm_mmu_unprotect_page_virt(vcpu, gva))
> >  		return true;
> >
> >-	gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
> >+	if (!tdp_enabled) {
> >+		gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
> >
> >-	if (gpa == UNMAPPED_GVA)
> >-		return true; /* let cpu generate fault */
> >+		if (gpa == UNMAPPED_GVA)
> >+			return true; /* let cpu generate fault */
> >+	} else
> >+		gpa = gva;
> >
> >  	if (!kvm_is_error_hva(gfn_to_hva(vcpu->kvm, gpa>>  PAGE_SHIFT)))
> >  		return true;
> 
> Why not
> 
>     if (tdp_enabled)
>               return false;
> 
> at the top?  Is there any reason ever to reexecute an instruction
> with tdp enabled?
> 
Can't think of one now. If in the future we will shadow some other data
structures in the guest except page tables (nested vmx/svm?) there may
be the reason.

--
			Gleb.

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

* Re: [PATCH] do not call gva_to_gpa on physical address
  2010-07-14 15:52   ` Gleb Natapov
@ 2010-07-14 15:55     ` Avi Kivity
  0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2010-07-14 15:55 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: mtosatti, kvm

On 07/14/2010 06:52 PM, Gleb Natapov wrote:
>
>> Why not
>>
>>      if (tdp_enabled)
>>                return false;
>>
>> at the top?  Is there any reason ever to reexecute an instruction
>> with tdp enabled?
>>
>>      
> Can't think of one now. If in the future we will shadow some other data
> structures in the guest except page tables (nested vmx/svm?) there may
> be the reason.
>    

Sure, we'll adjust it then.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


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

end of thread, other threads:[~2010-07-14 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 15:38 [PATCH] do not call gva_to_gpa on physical address Gleb Natapov
2010-07-14 15:44 ` Avi Kivity
2010-07-14 15:52   ` Gleb Natapov
2010-07-14 15:55     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox