From nobody Thu Jan 26 22:11:50 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P2w0l0tZMz3c85S; Thu, 26 Jan 2023 22:11:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P2w0k5hRJz3vhf; Thu, 26 Jan 2023 22:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674771111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bn3ktIKqUMR4DrpRMiNk28KpO15R84GbNEnu5fM0+R4=; b=sdT0jYGK/+AWrBLAYUMHgPHk6e3YS99KcRHwFox7bF4GVjHUz37iTGJShydSbf0e+7EB5/ RvvVbPK2HkiP5oWbeQ8tZpRZvTULchTfdaEd3X23uA/z3V4ZeF775s8eRCWDDh6Mo9UrAJ 8qrXfGnsVNTYM5HpbORXZYQDmIDgluyAE71aJzlgC7bxBpwb487HhG/dA+sIA9Wwb0qm22 5HyVCFVgEcHfIYt0fOwPWUgucF6VO7BgBdEZ2Fdhf3N10FtzQrhVbc0L4xf/Wbwig4C75m 1lPmvjFdz8RSgSVLYF6oIglR2CqdYqbnnX1UvIafhCvu+4mKxG1SsQ69MjAgsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674771110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bn3ktIKqUMR4DrpRMiNk28KpO15R84GbNEnu5fM0+R4=; b=QjRIPTj19yIQORJdl0SNdPPEhoaIr3Mvgsqf7qTpCQZqvtql9Hu8wxnyvIII4sU7xwxED2 Xyyz/him4qjy6OE9LO68NjVxbu7Wa/fh0nYLomMKXF/vLqgnxENZtoM4na9KzNhVMbfnrw wSiEtEl4hKex3AnFLwdqM1SDUJuQ4afMDELCBQ47Bg4t+R3O1oCDxHZTtPpIEb+mfyqk/X R9b8Kaq9Fv5ZZXzh71XL6Hr0QkXWbEpCBVceRldvtnoRzBZRZNcME0RDcPifRtC9SqHFrv id1zUitxepRNE3HcyyJ4AAxTEvP9qZEiKxGXjk+35gJ8CjCk6MyS72h+AFO5Kw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674771110; a=rsa-sha256; cv=none; b=kgKWsZPoexxO5CjoncyUY0Z0ljICPU2tbwQeQarzmuSw3P4Nece6NP71gpAXbtSO5d3k9L aw5iAbT1FqSaRqbOEI7vZhweqfd/yvsYHyOoIjcIoYLUFZd4FxLQzWL6lu5AzV4onbxujB IHB9hO52LGfn0fqOtFaIyF/E7g5ZdMJvB8kSNILOa99mZ7NUKz0jlneIFparNQ5rQaN/SY 4qZQ6sgMWqg0GFYreP640ApLGvfA9P5QdBKSjt1H67rN9wpJYCvZxllyCPLfQCcOMShwlk ezm/T1nVtBzXB0v52feTVZBEEOFbp+rCrKIqrBwpiJQfIQcbFisnUcOL1A7ogg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P2w0k4Pp7zlm7; Thu, 26 Jan 2023 22:11:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30QMBoNC021868; Thu, 26 Jan 2023 22:11:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QMBoSR021867; Thu, 26 Jan 2023 22:11:50 GMT (envelope-from git) Date: Thu, 26 Jan 2023 22:11:50 GMT Message-Id: <202301262211.30QMBoSR021867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: d829b4ef464d - stable/13 - bhyve: Remove unused vm and vcpu arguments from vm_copy routines. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d829b4ef464d30d0222c365ce9a9e701a1c97e92 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d829b4ef464d30d0222c365ce9a9e701a1c97e92 commit d829b4ef464d30d0222c365ce9a9e701a1c97e92 Author: John Baldwin AuthorDate: 2022-11-18 18:01:44 +0000 Commit: John Baldwin CommitDate: 2023-01-26 21:47:06 +0000 bhyve: Remove unused vm and vcpu arguments from vm_copy routines. The arguments identifying the VM and vCPU are only needed for vm_copy_setup. Reviewed by: corvink, markj Differential Revision: https://reviews.freebsd.org/D37158 (cherry picked from commit 2b4fe856f44ded02f3450bac1782bb49b60b7dd5) --- lib/libvmmapi/vmmapi.c | 14 ++++++++------ lib/libvmmapi/vmmapi.h | 11 ++++------- sys/amd64/include/vmm.h | 9 +++------ sys/amd64/vmm/vmm.c | 11 ++++------- sys/amd64/vmm/vmm_instruction_emul.c | 18 +++++++++--------- usr.sbin/bhyve/inout.c | 4 ++-- usr.sbin/bhyve/task_switch.c | 14 +++++++------- 7 files changed, 37 insertions(+), 44 deletions(-) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 454d7ee21b36..a65b77300b3a 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -1468,14 +1468,17 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, } void -vm_copy_teardown(struct vmctx *ctx __unused, int vcpu __unused, - struct iovec *iov __unused, int iovcnt __unused) +vm_copy_teardown(struct iovec *iov __unused, int iovcnt __unused) { + /* + * Intentionally empty. This is used by the instruction + * emulation code shared with the kernel. The in-kernel + * version of this is non-empty. + */ } void -vm_copyin(struct vmctx *ctx __unused, int vcpu __unused, struct iovec *iov, - void *vp, size_t len) +vm_copyin(struct iovec *iov, void *vp, size_t len) { const char *src; char *dst; @@ -1495,8 +1498,7 @@ vm_copyin(struct vmctx *ctx __unused, int vcpu __unused, struct iovec *iov, } void -vm_copyout(struct vmctx *ctx __unused, int vcpu __unused, const void *vp, - struct iovec *iov, size_t len) +vm_copyout(const void *vp, struct iovec *iov, size_t len) { const char *src; char *dst; diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h index b26f12f7c60e..82c3dcdf3118 100644 --- a/lib/libvmmapi/vmmapi.h +++ b/lib/libvmmapi/vmmapi.h @@ -43,7 +43,7 @@ * API version for out-of-tree consumers like grub-bhyve for making compile * time decisions. */ -#define VMMAPI_VERSION 0103 /* 2 digit major followed by 2 digit minor */ +#define VMMAPI_VERSION 0104 /* 2 digit major followed by 2 digit minor */ struct iovec; struct vmctx; @@ -219,12 +219,9 @@ int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities); int vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *pg, uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt, int *fault); -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); +void vm_copyin(struct iovec *guest_iov, void *host_dst, size_t len); +void vm_copyout(const void *host_src, struct iovec *guest_iov, size_t len); +void vm_copy_teardown(struct iovec *iov, int iovcnt); /* RTC */ int vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value); diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h index 800114151d95..e632a0fbf01e 100644 --- a/sys/amd64/include/vmm.h +++ b/sys/amd64/include/vmm.h @@ -464,12 +464,9 @@ struct vm_copyinfo { int vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo, int num_copyinfo, int *is_fault); -void vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, - int num_copyinfo); -void vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, - void *kaddr, size_t len); -void vm_copyout(struct vm *vm, int vcpuid, const void *kaddr, - struct vm_copyinfo *copyinfo, size_t len); +void vm_copy_teardown(struct vm_copyinfo *copyinfo, int num_copyinfo); +void vm_copyin(struct vm_copyinfo *copyinfo, void *kaddr, size_t len); +void vm_copyout(const void *kaddr, struct vm_copyinfo *copyinfo, size_t len); int vcpu_trace_exceptions(struct vm *vm, int vcpuid); int vcpu_trap_wbinvd(struct vm *vm, int vcpuid); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 715eaaa8ecaf..079577784f52 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -2721,8 +2721,7 @@ vm_segment_name(int seg) } void -vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, - int num_copyinfo) +vm_copy_teardown(struct vm_copyinfo *copyinfo, int num_copyinfo) { int idx; @@ -2771,7 +2770,7 @@ vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, } if (idx != nused) { - vm_copy_teardown(vm, vcpuid, copyinfo, num_copyinfo); + vm_copy_teardown(copyinfo, num_copyinfo); return (EFAULT); } else { *fault = 0; @@ -2780,8 +2779,7 @@ vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, } void -vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, void *kaddr, - size_t len) +vm_copyin(struct vm_copyinfo *copyinfo, void *kaddr, size_t len) { char *dst; int idx; @@ -2797,8 +2795,7 @@ vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo, void *kaddr, } void -vm_copyout(struct vm *vm, int vcpuid, const void *kaddr, - struct vm_copyinfo *copyinfo, size_t len) +vm_copyout(const void *kaddr, struct vm_copyinfo *copyinfo, size_t len) { const char *src; int idx; diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c index 3b48eee2d8ed..0b774e72b0c3 100644 --- a/sys/amd64/vmm/vmm_instruction_emul.c +++ b/sys/amd64/vmm/vmm_instruction_emul.c @@ -835,8 +835,8 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, /* * case (2): read from system memory and write to mmio. */ - vm_copyin(vm, vcpuid, copyinfo, &val, opsize); - vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo)); + vm_copyin(copyinfo, &val, opsize); + vm_copy_teardown(copyinfo, nitems(copyinfo)); error = memwrite(vm, vcpuid, gpa, val, opsize, arg); if (error) goto done; @@ -871,8 +871,8 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, if (error) goto done; - vm_copyout(vm, vcpuid, &val, copyinfo, opsize); - vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo)); + vm_copyout(&val, copyinfo, opsize); + vm_copy_teardown(copyinfo, nitems(copyinfo)); } else { /* * Case (4): read from and write to mmio. @@ -1599,13 +1599,13 @@ emulate_stack_op(void *vm, int vcpuid, uint64_t mmio_gpa, struct vie *vie, if (pushop) { error = memread(vm, vcpuid, mmio_gpa, &val, size, arg); if (error == 0) - vm_copyout(vm, vcpuid, &val, copyinfo, size); + vm_copyout(&val, copyinfo, size); } else { - vm_copyin(vm, vcpuid, copyinfo, &val, size); + vm_copyin(copyinfo, &val, size); error = memwrite(vm, vcpuid, mmio_gpa, val, size, arg); rsp += size; } - vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo)); + vm_copy_teardown(copyinfo, nitems(copyinfo)); if (error == 0) { error = vie_update_register(vm, vcpuid, VM_REG_GUEST_RSP, rsp, @@ -2300,8 +2300,8 @@ vmm_fetch_instruction(struct vm *vm, int vcpuid, struct vm_guest_paging *paging, if (error || *faultptr) return (error); - vm_copyin(vm, vcpuid, copyinfo, vie->inst, inst_length); - vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo)); + vm_copyin(copyinfo, vie->inst, inst_length); + vm_copy_teardown(copyinfo, nitems(copyinfo)); vie->num_valid = inst_length; return (0); } diff --git a/usr.sbin/bhyve/inout.c b/usr.sbin/bhyve/inout.c index 02b38c9b7a99..bdbdd0d1c223 100644 --- a/usr.sbin/bhyve/inout.c +++ b/usr.sbin/bhyve/inout.c @@ -184,14 +184,14 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit) val = 0; if (!in) - vm_copyin(ctx, vcpu, iov, &val, bytes); + vm_copyin(iov, &val, bytes); retval = handler(ctx, vcpu, in, port, bytes, &val, arg); if (retval != 0) break; if (in) - vm_copyout(ctx, vcpu, &val, iov, bytes); + vm_copyout(&val, iov, bytes); /* Update index */ if (vis->rflags & PSL_D) diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/task_switch.c index 78dfb8190e48..0dfb536f09f8 100644 --- a/usr.sbin/bhyve/task_switch.c +++ b/usr.sbin/bhyve/task_switch.c @@ -225,9 +225,9 @@ desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, return (error); if (doread) - vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc)); + vm_copyin(iov, desc, sizeof(*desc)); else - vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc)); + vm_copyout(desc, iov, sizeof(*desc)); return (0); } @@ -464,7 +464,7 @@ tss32_save(struct vmctx *ctx, int vcpu, struct vm_task_switch *task_switch, tss->tss_eip = eip; /* Copy updated old TSS into guest memory */ - vm_copyout(ctx, vcpu, tss, iov, sizeof(struct tss32)); + vm_copyout(tss, iov, sizeof(struct tss32)); } static void @@ -560,7 +560,7 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts, * the previous link field. */ if (nested) - vm_copyout(ctx, vcpu, tss, iov, sizeof(*tss)); + vm_copyout(tss, iov, sizeof(*tss)); /* Validate segment descriptors */ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc, @@ -685,7 +685,7 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging, if (error || *faultptr) return (error); - vm_copyout(ctx, vcpu, &errcode, iov, bytes); + vm_copyout(&errcode, iov, bytes); SETREG(ctx, vcpu, VM_REG_GUEST_RSP, esp); return (0); } @@ -798,7 +798,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) error = vm_copy_setup(ctx, vcpu, &sup_paging, nt.base, minlimit + 1, PROT_READ | PROT_WRITE, nt_iov, nitems(nt_iov), &fault); CHKERR(error, fault); - vm_copyin(ctx, vcpu, nt_iov, &newtss, minlimit + 1); + vm_copyin(nt_iov, &newtss, minlimit + 1); /* Get the old TSS selector from the guest's task register */ ot_sel = GETREG(ctx, vcpu, VM_REG_GUEST_TR); @@ -830,7 +830,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) error = vm_copy_setup(ctx, vcpu, &sup_paging, ot_base, minlimit + 1, PROT_READ | PROT_WRITE, ot_iov, nitems(ot_iov), &fault); CHKERR(error, fault); - vm_copyin(ctx, vcpu, ot_iov, &oldtss, minlimit + 1); + vm_copyin(ot_iov, &oldtss, minlimit + 1); /* * Clear the busy bit in the old TSS descriptor if the task switch