diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-09-10 11:30:51 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:52:37 -0400 |
commit | ec92fe44e7ff94d04d8305e49efcffd8773e1cf6 (patch) | |
tree | a1f3c9e47e5c05a83d0d507d0616f810234c80a4 /arch/x86/kvm/x86.c | |
parent | 6539e738f65a8f1fc7806295d5d701fba4008343 (diff) |
KVM: X86: Add kvm_read_guest_page_mmu function
This patch adds a function which can read from the guests
physical memory or from the guest's guest physical memory.
This will be used in the two-dimensional page table walker.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4196fc719142..a2efb70f4cc8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -370,6 +370,29 @@ bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl) | |||
370 | EXPORT_SYMBOL_GPL(kvm_require_cpl); | 370 | EXPORT_SYMBOL_GPL(kvm_require_cpl); |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * This function will be used to read from the physical memory of the currently | ||
374 | * running guest. The difference to kvm_read_guest_page is that this function | ||
375 | * can read from guest physical or from the guest's guest physical memory. | ||
376 | */ | ||
377 | int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, | ||
378 | gfn_t ngfn, void *data, int offset, int len, | ||
379 | u32 access) | ||
380 | { | ||
381 | gfn_t real_gfn; | ||
382 | gpa_t ngpa; | ||
383 | |||
384 | ngpa = gfn_to_gpa(ngfn); | ||
385 | real_gfn = mmu->translate_gpa(vcpu, ngpa, access); | ||
386 | if (real_gfn == UNMAPPED_GVA) | ||
387 | return -EFAULT; | ||
388 | |||
389 | real_gfn = gpa_to_gfn(real_gfn); | ||
390 | |||
391 | return kvm_read_guest_page(vcpu->kvm, real_gfn, data, offset, len); | ||
392 | } | ||
393 | EXPORT_SYMBOL_GPL(kvm_read_guest_page_mmu); | ||
394 | |||
395 | /* | ||
373 | * Load the pae pdptrs. Return true is they are all valid. | 396 | * Load the pae pdptrs. Return true is they are all valid. |
374 | */ | 397 | */ |
375 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3) | 398 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3) |