diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-09-10 11:30:46 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:52:33 -0400 |
commit | 8df25a328a6ca3bd0f048278f4d5ae0a1f6fadc1 (patch) | |
tree | 613b4e3c09fa90a7a52b4283cc0687ce547bd5c7 /arch/x86/include | |
parent | 3241f22da85d26505b39f525a88f52ebd1235975 (diff) |
KVM: MMU: Track page fault data in struct vcpu
This patch introduces a struct with two new fields in
vcpu_arch for x86:
* fault.address
* fault.error_code
This will be used to correctly propagate page faults back
into the guest when we could have either an ordinary page
fault or a nested page fault. In the case of a nested page
fault the fault-address is different from the original
address that should be walked. So we need to keep track
about the real fault-address.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 17 |
2 files changed, 12 insertions, 6 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 1bf11400ae99..5187dd88019b 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -229,7 +229,6 @@ struct x86_emulate_ctxt { | |||
229 | int exception; /* exception that happens during emulation or -1 */ | 229 | int exception; /* exception that happens during emulation or -1 */ |
230 | u32 error_code; /* error code for exception */ | 230 | u32 error_code; /* error code for exception */ |
231 | bool error_code_valid; | 231 | bool error_code_valid; |
232 | unsigned long cr2; /* faulted address in case of #PF */ | ||
233 | 232 | ||
234 | /* decode cache */ | 233 | /* decode cache */ |
235 | struct decode_cache decode; | 234 | struct decode_cache decode; |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 009a4a1b370e..3fde5b322534 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -239,9 +239,7 @@ struct kvm_mmu { | |||
239 | void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root); | 239 | void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root); |
240 | unsigned long (*get_cr3)(struct kvm_vcpu *vcpu); | 240 | unsigned long (*get_cr3)(struct kvm_vcpu *vcpu); |
241 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); | 241 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); |
242 | void (*inject_page_fault)(struct kvm_vcpu *vcpu, | 242 | void (*inject_page_fault)(struct kvm_vcpu *vcpu); |
243 | unsigned long addr, | ||
244 | u32 error_code); | ||
245 | void (*free)(struct kvm_vcpu *vcpu); | 243 | void (*free)(struct kvm_vcpu *vcpu); |
246 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, | 244 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, |
247 | u32 *error); | 245 | u32 *error); |
@@ -288,6 +286,16 @@ struct kvm_vcpu_arch { | |||
288 | bool tpr_access_reporting; | 286 | bool tpr_access_reporting; |
289 | 287 | ||
290 | struct kvm_mmu mmu; | 288 | struct kvm_mmu mmu; |
289 | |||
290 | /* | ||
291 | * This struct is filled with the necessary information to propagate a | ||
292 | * page fault into the guest | ||
293 | */ | ||
294 | struct { | ||
295 | u64 address; | ||
296 | unsigned error_code; | ||
297 | } fault; | ||
298 | |||
291 | /* only needed in kvm_pv_mmu_op() path, but it's hot so | 299 | /* only needed in kvm_pv_mmu_op() path, but it's hot so |
292 | * put it here to avoid allocation */ | 300 | * put it here to avoid allocation */ |
293 | struct kvm_pv_mmu_op_buffer mmu_op_buffer; | 301 | struct kvm_pv_mmu_op_buffer mmu_op_buffer; |
@@ -624,8 +632,7 @@ void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr); | |||
624 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); | 632 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); |
625 | void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); | 633 | void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); |
626 | void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); | 634 | void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); |
627 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, | 635 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu); |
628 | u32 error_code); | ||
629 | bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); | 636 | bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); |
630 | 637 | ||
631 | int kvm_pic_set_irq(void *opaque, int irq, int level); | 638 | int kvm_pic_set_irq(void *opaque, int irq, int level); |