From 1b250720367ff0f716278784361b8e0e5f2c7c8a Mon Sep 17 00:00:00 2001 From: dv Date: Wed, 1 Sep 2021 11:08:21 +0000 Subject: [PATCH] remove unused functions and cleanup vmd.h Discussed with mlarkin@. These functions were implemented but never used. While in vmd.h, fix the order to match current vmd(8) reality. --- usr.sbin/vmd/vm.c | 62 +--------------------------------------------- usr.sbin/vmd/vmd.h | 14 ++++------- 2 files changed, 6 insertions(+), 70 deletions(-) diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index 1f451681f13..6323ecc3465 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $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 @@ -1776,29 +1776,6 @@ find_gpa_range(struct vm_create_params *vcp, paddr_t gpa, size_t len) 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 * @@ -1899,43 +1876,6 @@ read_mem(paddr_t src, void *buf, size_t len) 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 * diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h index 96afc3af2b6..824c48a4fc0 100644 --- a/usr.sbin/vmd/vmd.h +++ b/usr.sbin/vmd/vmd.h @@ -1,4 +1,4 @@ -/* $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 @@ -451,26 +451,22 @@ int vm_priv_addr6(struct vmd_config *, uint32_t, int, int, 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 *); -- 2.20.1