svn commit: r361284 - in head/sys/amd64: include vmm

Conrad Meyer cem at FreeBSD.org
Wed May 20 17:27:54 UTC 2020


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;


More information about the svn-src-all mailing list