diff options
author | Gleb Natapov <gleb@redhat.com> | 2011-07-11 15:28:11 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 06:17:01 -0400 |
commit | e03b644fe68b1c6401465b02724d261538dba10f (patch) | |
tree | 9bb12d9ca9a74865618919e10922b2483a8cacdb /virt/kvm/kvm_main.c | |
parent | 29d03158f9d400450c17bb25ee0533b52f651d04 (diff) |
KVM: introduce kvm_read_guest_cached
Introduce kvm_read_guest_cached() function in addition to write one we
already have.
[ by glauber: export function signature in kvm header ]
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
Acked-by: Rik van Riel <riel@redhat.com>
Tested-by: Eric Munson <emunson@mgebm.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 11d2783eb9df..d5ef9ebcaff7 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1418,6 +1418,26 @@ int kvm_write_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc, | |||
1418 | } | 1418 | } |
1419 | EXPORT_SYMBOL_GPL(kvm_write_guest_cached); | 1419 | EXPORT_SYMBOL_GPL(kvm_write_guest_cached); |
1420 | 1420 | ||
1421 | int kvm_read_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc, | ||
1422 | void *data, unsigned long len) | ||
1423 | { | ||
1424 | struct kvm_memslots *slots = kvm_memslots(kvm); | ||
1425 | int r; | ||
1426 | |||
1427 | if (slots->generation != ghc->generation) | ||
1428 | kvm_gfn_to_hva_cache_init(kvm, ghc, ghc->gpa); | ||
1429 | |||
1430 | if (kvm_is_error_hva(ghc->hva)) | ||
1431 | return -EFAULT; | ||
1432 | |||
1433 | r = __copy_from_user(data, (void __user *)ghc->hva, len); | ||
1434 | if (r) | ||
1435 | return -EFAULT; | ||
1436 | |||
1437 | return 0; | ||
1438 | } | ||
1439 | EXPORT_SYMBOL_GPL(kvm_read_guest_cached); | ||
1440 | |||
1421 | int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len) | 1441 | int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len) |
1422 | { | 1442 | { |
1423 | return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page, | 1443 | return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page, |