-/* $OpenBSD: vm.c,v 1.64 2021/07/16 16:21:22 dv Exp $ */
+/* $OpenBSD: vm.c,v 1.65 2021/09/01 11:08:21 dv Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
return (vmr);
}
-void *
-vaddr_mem(paddr_t gpa, size_t len)
-{
- struct vm_create_params *vcp = ¤t_vm->vm_params.vmc_params;
- size_t i;
- struct vm_mem_range *vmr;
- paddr_t gpend = gpa + len;
-
- /* Find the first vm_mem_range that contains gpa */
- for (i = 0; i < vcp->vcp_nmemranges; i++) {
- vmr = &vcp->vcp_memranges[i];
- if (gpa < vmr->vmr_gpa)
- continue;
-
- if (gpend >= vmr->vmr_gpa + vmr->vmr_size)
- continue;
-
- return ((char *)vmr->vmr_va + (gpa - vmr->vmr_gpa));
- }
-
- return (NULL);
-}
-
/*
* write_mem
*
return (0);
}
-int
-iovec_mem(paddr_t src, size_t len, struct iovec *iov, int iovcnt)
-{
- size_t n, off;
- struct vm_mem_range *vmr;
- int niov = 0;
-
- vmr = find_gpa_range(¤t_vm->vm_params.vmc_params, src, len);
- if (vmr == NULL) {
- errno = EINVAL;
- return (-1);
- }
-
- off = src - vmr->vmr_gpa;
- while (len > 0) {
- if (niov == iovcnt) {
- errno = ENOMEM;
- return (-1);
- }
-
- n = vmr->vmr_size - off;
- if (len < n)
- n = len;
-
- iov[niov].iov_base = (char *)vmr->vmr_va + off;
- iov[niov].iov_len = n;
-
- niov++;
-
- len -= n;
- off = 0;
- vmr++;
- }
-
- return (niov);
-}
-
/*
* vcpu_assert_pic_irq
*
-/* $OpenBSD: vmd.h,v 1.105 2021/04/11 14:12:42 dv Exp $ */
+/* $OpenBSD: vmd.h,v 1.106 2021/09/01 11:08:21 dv Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
struct in6_addr *);
/* vmm.c */
-struct iovec;
-
void vmm(struct privsep *, struct privsep_proc *);
void vmm_shutdown(void);
-void *vaddr_mem(paddr_t, size_t);
-int write_mem(paddr_t, const void *buf, size_t);
-int read_mem(paddr_t, void *buf, size_t);
-int iovec_mem(paddr_t, size_t, struct iovec *, int);
int opentap(char *);
int fd_hasdata(int);
-void mutex_lock(pthread_mutex_t *);
-void mutex_unlock(pthread_mutex_t *);
int vmm_pipe(struct vmd_vm *, int, void (*)(int, short, void *));
/* vm.c */
+void mutex_lock(pthread_mutex_t *);
+void mutex_unlock(pthread_mutex_t *);
+int read_mem(paddr_t, void *buf, size_t);
int start_vm(struct vmd_vm *, int);
__dead void vm_shutdown(unsigned int);
void vm_pipe_init(struct vm_dev_pipe *, void (*)(int, short, void *));
void vm_pipe_send(struct vm_dev_pipe *, enum pipe_msg_type);
enum pipe_msg_type vm_pipe_recv(struct vm_dev_pipe *);
+int write_mem(paddr_t, const void *buf, size_t);
/* config.c */
int config_init(struct vmd *);