From owner-svn-src-all@freebsd.org Wed May 20 17:27:54 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8BC02DF9A9; Wed, 20 May 2020 17:27:54 +0000 (UTC) (envelope-from cem@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49S07t5Sftz4V0p; Wed, 20 May 2020 17:27:54 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6D141F92E; Wed, 20 May 2020 17:27:54 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04KHRs6a047063; Wed, 20 May 2020 17:27:54 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04KHRsVL047061; Wed, 20 May 2020 17:27:54 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202005201727.04KHRsVL047061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Wed, 20 May 2020 17:27:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361284 - in head/sys/amd64: include vmm X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys/amd64: include vmm X-SVN-Commit-Revision: 361284 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 17:27:54 -0000 Author: cem Date: Wed May 20 17:27:54 2020 New Revision: 361284 URL: https://svnweb.freebsd.org/changeset/base/361284 Log: vmm(4): Add 12 user ABI compat after r349948 Reported by: kp Reviewed by: jhb, kp Tested by: kp Differential Revision: https://reviews.freebsd.org/D24929 Modified: head/sys/amd64/include/vmm_dev.h head/sys/amd64/vmm/vmm_dev.c Modified: head/sys/amd64/include/vmm_dev.h ============================================================================== --- head/sys/amd64/include/vmm_dev.h Wed May 20 17:27:22 2020 (r361283) +++ head/sys/amd64/include/vmm_dev.h Wed May 20 17:27:54 2020 (r361284) @@ -56,6 +56,13 @@ struct vm_memseg { char name[VM_MAX_SUFFIXLEN + 1]; }; +struct vm_memseg_fbsd12 { + int segid; + size_t len; + char name[64]; +}; +_Static_assert(sizeof(struct vm_memseg_fbsd12) == 80, "COMPAT_FREEBSD12 ABI"); + struct vm_register { int cpuid; int regnum; /* enum vm_reg_name */ @@ -338,8 +345,12 @@ enum { _IOW('v', IOCNUM_SUSPEND, struct vm_suspend) #define VM_REINIT \ _IO('v', IOCNUM_REINIT) +#define VM_ALLOC_MEMSEG_FBSD12 \ + _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg_fbsd12) #define VM_ALLOC_MEMSEG \ _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg) +#define VM_GET_MEMSEG_FBSD12 \ + _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12) #define VM_GET_MEMSEG \ _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg) #define VM_MMAP_MEMSEG \ Modified: head/sys/amd64/vmm/vmm_dev.c ============================================================================== --- head/sys/amd64/vmm/vmm_dev.c Wed May 20 17:27:22 2020 (r361283) +++ head/sys/amd64/vmm/vmm_dev.c Wed May 20 17:27:54 2020 (r361284) @@ -252,7 +252,7 @@ vmmdev_rw(struct cdev *cdev, struct uio *uio, int flag CTASSERT(sizeof(((struct vm_memseg *)0)->name) >= VM_MAX_SUFFIXLEN + 1); static int -get_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg) +get_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg, size_t len) { struct devmem_softc *dsc; int error; @@ -269,17 +269,16 @@ get_memseg(struct vmmdev_softc *sc, struct vm_memseg * } KASSERT(dsc != NULL, ("%s: devmem segment %d not found", __func__, mseg->segid)); - error = copystr(dsc->name, mseg->name, sizeof(mseg->name), - NULL); + error = copystr(dsc->name, mseg->name, len, NULL); } else { - bzero(mseg->name, sizeof(mseg->name)); + bzero(mseg->name, len); } return (error); } static int -alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg) +alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg, size_t len) { char *name; int error; @@ -295,8 +294,8 @@ alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg */ if (VM_MEMSEG_NAME(mseg)) { sysmem = false; - name = malloc(sizeof(mseg->name), M_VMMDEV, M_WAITOK); - error = copystr(mseg->name, name, sizeof(mseg->name), NULL); + name = malloc(len, M_VMMDEV, M_WAITOK); + error = copystr(mseg->name, name, len, NULL); if (error) goto done; } @@ -438,6 +437,9 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t da case VM_MAP_PPTDEV_MMIO: case VM_BIND_PPTDEV: case VM_UNBIND_PPTDEV: +#ifdef COMPAT_FREEBSD12 + case VM_ALLOC_MEMSEG_FBSD12: +#endif case VM_ALLOC_MEMSEG: case VM_MMAP_MEMSEG: case VM_REINIT: @@ -451,6 +453,9 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t da state_changed = 2; break; +#ifdef COMPAT_FREEBSD12 + case VM_GET_MEMSEG_FBSD12: +#endif case VM_GET_MEMSEG: case VM_MMAP_GETNEXT: /* @@ -633,11 +638,25 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t da error = vm_mmap_memseg(sc->vm, mm->gpa, mm->segid, mm->segoff, mm->len, mm->prot, mm->flags); break; +#ifdef COMPAT_FREEBSD12 + case VM_ALLOC_MEMSEG_FBSD12: + error = alloc_memseg(sc, (struct vm_memseg *)data, + sizeof(((struct vm_memseg_fbsd12 *)0)->name)); + break; +#endif case VM_ALLOC_MEMSEG: - error = alloc_memseg(sc, (struct vm_memseg *)data); + error = alloc_memseg(sc, (struct vm_memseg *)data, + sizeof(((struct vm_memseg *)0)->name)); break; +#ifdef COMPAT_FREEBSD12 + case VM_GET_MEMSEG_FBSD12: + error = get_memseg(sc, (struct vm_memseg *)data, + sizeof(((struct vm_memseg_fbsd12 *)0)->name)); + break; +#endif case VM_GET_MEMSEG: - error = get_memseg(sc, (struct vm_memseg *)data); + error = get_memseg(sc, (struct vm_memseg *)data, + sizeof(((struct vm_memseg *)0)->name)); break; case VM_GET_REGISTER: vmreg = (struct vm_register *)data;