aboutsummaryrefslogtreecommitdiff
path: root/lib/libvmmapi
diff options
context:
space:
mode:
authorNeel Natu <neel@FreeBSD.org>2015-01-19 06:51:04 +0000
committerNeel Natu <neel@FreeBSD.org>2015-01-19 06:51:04 +0000
commit009e2acba6c14814b896cc0527bda97697d9c8f5 (patch)
treeec0e6478798b2f3e8ba401635c575d542ef3be88 /lib/libvmmapi
parente15138e5740afa089b01612329b30b82e236737a (diff)
Notes
Diffstat (limited to 'lib/libvmmapi')
-rw-r--r--lib/libvmmapi/vmmapi.c22
-rw-r--r--lib/libvmmapi/vmmapi.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 5660f3b7bc50..982887688664 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -987,6 +987,7 @@ int
vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt)
{
+ void *va;
uint64_t gpa;
int error, fault, i, n, off;
@@ -1006,7 +1007,11 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
off = gpa & PAGE_MASK;
n = min(len, PAGE_SIZE - off);
- iov->iov_base = (void *)gpa;
+ va = vm_map_gpa(ctx, gpa, n);
+ if (va == NULL)
+ return (-1);
+
+ iov->iov_base = va;
iov->iov_len = n;
iov++;
iovcnt--;
@@ -1018,19 +1023,24 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
}
void
+vm_copy_teardown(struct vmctx *ctx, int vcpu, struct iovec *iov, int iovcnt)
+{
+
+ return;
+}
+
+void
vm_copyin(struct vmctx *ctx, int vcpu, struct iovec *iov, void *vp, size_t len)
{
const char *src;
char *dst;
- uint64_t gpa;
size_t n;
dst = vp;
while (len) {
assert(iov->iov_len);
- gpa = (uint64_t)iov->iov_base;
n = min(len, iov->iov_len);
- src = vm_map_gpa(ctx, gpa, n);
+ src = iov->iov_base;
bcopy(src, dst, n);
iov++;
@@ -1045,15 +1055,13 @@ vm_copyout(struct vmctx *ctx, int vcpu, const void *vp, struct iovec *iov,
{
const char *src;
char *dst;
- uint64_t gpa;
size_t n;
src = vp;
while (len) {
assert(iov->iov_len);
- gpa = (uint64_t)iov->iov_base;
n = min(len, iov->iov_len);
- dst = vm_map_gpa(ctx, gpa, n);
+ dst = iov->iov_base;
bcopy(src, dst, n);
iov++;
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 8634762d0065..06b29302640d 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -137,6 +137,8 @@ void vm_copyin(struct vmctx *ctx, int vcpu, struct iovec *guest_iov,
void *host_dst, size_t len);
void vm_copyout(struct vmctx *ctx, int vcpu, const void *host_src,
struct iovec *guest_iov, size_t len);
+void vm_copy_teardown(struct vmctx *ctx, int vcpu, struct iovec *iov,
+ int iovcnt);
/* RTC */
int vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value);