diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2007-12-20 19:18:23 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 11:01:20 -0500 |
commit | 7ec54588210df29ea637e6054489bc942c0ef371 (patch) | |
tree | a21f672f29965a7fa35d90b3c3fe034150ae9ec7 /virt | |
parent | 10589a4699bb978c781ce73bbae8ca942c5250c9 (diff) |
KVM: Add kvm_read_guest_atomic()
In preparation for a mmu spinlock, add kvm_read_guest_atomic()
and use it in fetch() and prefetch_page().
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'virt')
-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 678e80561b74..8d0b7c16c2f7 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -541,6 +541,26 @@ int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len) | |||
541 | } | 541 | } |
542 | EXPORT_SYMBOL_GPL(kvm_read_guest); | 542 | EXPORT_SYMBOL_GPL(kvm_read_guest); |
543 | 543 | ||
544 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, | ||
545 | unsigned long len) | ||
546 | { | ||
547 | int r; | ||
548 | unsigned long addr; | ||
549 | gfn_t gfn = gpa >> PAGE_SHIFT; | ||
550 | int offset = offset_in_page(gpa); | ||
551 | |||
552 | addr = gfn_to_hva(kvm, gfn); | ||
553 | if (kvm_is_error_hva(addr)) | ||
554 | return -EFAULT; | ||
555 | pagefault_disable(); | ||
556 | r = __copy_from_user_inatomic(data, (void __user *)addr + offset, len); | ||
557 | pagefault_enable(); | ||
558 | if (r) | ||
559 | return -EFAULT; | ||
560 | return 0; | ||
561 | } | ||
562 | EXPORT_SYMBOL(kvm_read_guest_atomic); | ||
563 | |||
544 | int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data, | 564 | int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data, |
545 | int offset, int len) | 565 | int offset, int len) |
546 | { | 566 | { |