public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH 7/7] KVM: Push struct x86_exception into walk_addr()
Date: Mon, 22 Nov 2010 17:53:27 +0200	[thread overview]
Message-ID: <1290441207-4250-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1290441207-4250-1-git-send-email-avi@redhat.com>

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/paging_tmpl.h |   32 ++++++++++++++------------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index f448da5..aaed914 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -72,7 +72,7 @@ struct guest_walker {
 	unsigned pt_access;
 	unsigned pte_access;
 	gfn_t gfn;
-	u32 error_code;
+	struct x86_exception fault;
 };
 
 static gfn_t gpte_to_gfn_lvl(pt_element_t gpte, int lvl)
@@ -266,21 +266,23 @@ walk:
 	return 1;
 
 error:
-	walker->error_code = 0;
+	walker->fault.vector = PF_VECTOR;
+	walker->fault.error_code_valid = true;
+	walker->fault.error_code = 0;
 	if (present)
-		walker->error_code |= PFERR_PRESENT_MASK;
+		walker->fault.error_code |= PFERR_PRESENT_MASK;
 
-	walker->error_code |= write_fault | user_fault;
+	walker->fault.error_code |= write_fault | user_fault;
 
 	if (fetch_fault && mmu->nx)
-		walker->error_code |= PFERR_FETCH_MASK;
+		walker->fault.error_code |= PFERR_FETCH_MASK;
 	if (rsvd_fault)
-		walker->error_code |= PFERR_RSVD_MASK;
+		walker->fault.error_code |= PFERR_RSVD_MASK;
 
 	vcpu->arch.fault.address    = addr;
-	vcpu->arch.fault.error_code = walker->error_code;
+	vcpu->arch.fault.error_code = walker->fault.error_code;
 
-	trace_kvm_mmu_walker_error(walker->error_code);
+	trace_kvm_mmu_walker_error(walker->fault.error_code);
 	return 0;
 }
 
@@ -681,11 +683,8 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access,
 	if (r) {
 		gpa = gfn_to_gpa(walker.gfn);
 		gpa |= vaddr & ~PAGE_MASK;
-	} else if (exception) {
-		exception->vector = PF_VECTOR;
-		exception->error_code_valid = true;
-		exception->error_code = walker.error_code;
-	}
+	} else if (exception)
+		*exception = walker.fault;
 
 	return gpa;
 }
@@ -703,11 +702,8 @@ static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr,
 	if (r) {
 		gpa = gfn_to_gpa(walker.gfn);
 		gpa |= vaddr & ~PAGE_MASK;
-	} else if (exception) {
-		exception->vector = PF_VECTOR;
-		exception->error_code_valid = true;
-		exception->error_code = walker.error_code;
-	}
+	} else if (exception)
+		*exception = walker.fault;
 
 	return gpa;
 }
-- 
1.7.1


  parent reply	other threads:[~2010-11-22 15:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-22 15:53 [PATCH 0/7] Emulator exception improvements Avi Kivity
2010-11-22 15:53 ` [PATCH 1/7] KVM: x86 emulator: introduce struct x86_exception to communicate faults Avi Kivity
2010-11-22 15:53 ` [PATCH 2/7] KVM: x86 emulator: make emulator memory callbacks return full exception Avi Kivity
2010-11-22 15:53 ` [PATCH 3/7] KVM: x86 emulator: drop dead pf injection in emulate_popf() Avi Kivity
2010-11-22 15:53 ` [PATCH 4/7] KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checks Avi Kivity
2010-11-22 15:53 ` [PATCH 5/7] KVM: x86 emulator: simplify exception generation Avi Kivity
2010-11-22 15:53 ` [PATCH 6/7] KVM: Push struct x86_exception info the various gva_to_gpa variants Avi Kivity
2010-11-22 15:53 ` Avi Kivity [this message]
2010-11-30 14:47 ` [PATCH 0/7] Emulator exception improvements Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290441207-4250-8-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox