Re: [RFC PATCH 2/3] KVM: x86: use memory_prepare in fetch helper function

From: Paolo Bonzini
Date: Tue May 06 2014 - 05:46:18 EST


Il 06/05/2014 02:40, Bandan Das ha scritto:
+ ret = ctxt->ops->memory_prepare(ctxt, addr, toread,
+ exception, false,
+ NULL, &uaddr);
+ if (ret != X86EMUL_CONTINUE)
+ return ret;
+
+ if (unlikely(kvm_is_error_hva(uaddr))) {
+ r = X86EMUL_PROPAGATE_FAULT;
+ return r;
+ }

What you are doing here is basically optimizing kvm_read_guest_virt_helper because you know that all reads will be single-page and you do not need the "next_segment" in kvm_read_guest.
Good catch, but you can use kvm_read_guest_page instead of going through ctxt->ops->memory_prepare. :)

Paolo

+ ret = __copy_from_user(data, (void __user *)uaddr, toread);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/