public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 1/3] KVM: x86: clean up reexecute_instruction
@ 2013-01-13 15:44 Xiao Guangrong
  2013-01-13 15:46 ` [PATCH v6 2/3] KVM: x86: let reexecute_instruction work for tdp Xiao Guangrong
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Xiao Guangrong @ 2013-01-13 15:44 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Gleb Natapov, LKML, KVM

Little cleanup for reexecute_instruction, also use gpa_to_gfn in
retry_instruction

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/x86.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1c9c834..08cacd9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4761,19 +4761,18 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva)
 	if (tdp_enabled)
 		return false;

+	gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
+	if (gpa == UNMAPPED_GVA)
+		return true; /* let cpu generate fault */
+
 	/*
 	 * if emulation was due to access to shadowed page table
 	 * and it failed try to unshadow page and re-enter the
 	 * guest to let CPU execute the instruction.
 	 */
-	if (kvm_mmu_unprotect_page_virt(vcpu, gva))
+	if (kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(gpa)))
 		return true;

-	gpa = kvm_mmu_gva_to_gpa_system(vcpu, gva, NULL);
-
-	if (gpa == UNMAPPED_GVA)
-		return true; /* let cpu generate fault */
-
 	/*
 	 * Do not retry the unhandleable instruction if it faults on the
 	 * readonly host memory, otherwise it will goto a infinite loop:
@@ -4828,7 +4827,7 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt,
 	if (!vcpu->arch.mmu.direct_map)
 		gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2, NULL);

-	kvm_mmu_unprotect_page(vcpu->kvm, gpa >> PAGE_SHIFT);
+	kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(gpa));

 	return true;
 }
-- 
1.7.7.6

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

end of thread, other threads:[~2013-01-22  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13 15:44 [PATCH v6 1/3] KVM: x86: clean up reexecute_instruction Xiao Guangrong
2013-01-13 15:46 ` [PATCH v6 2/3] KVM: x86: let reexecute_instruction work for tdp Xiao Guangrong
2013-01-13 15:49 ` [PATCH v6 3/3] KVM: x86: improve reexecute_instruction Xiao Guangrong
2013-01-16 23:20 ` [PATCH v6 1/3] KVM: x86: clean up reexecute_instruction Xiao Guangrong
2013-01-17 13:06 ` Gleb Natapov
2013-01-17 21:00 ` Marcelo Tosatti
2013-01-22  0:59 ` Marcelo Tosatti

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