summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 16:20:29 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 16:20:29 +0000
commit9bb36bc01cd74565fb879d43a4431edff14a2741 (patch)
treed13dbd135917b1413a63c84119b1555d8a8a6c3c /sys/compat
parent199f40b1517c9acc6831304b9c6feb13f13dcd3f (diff)
downloadFreeBSD-src-9bb36bc01cd74565fb879d43a4431edff14a2741.zip
FreeBSD-src-9bb36bc01cd74565fb879d43a4431edff14a2741.tar.gz
MFC r283427:
Where possible we will use M_LINUX malloc(9) type. Move M_FUTEX defines to the linux_common.ko.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_emul.c6
-rw-r--r--sys/compat/linux/linux_file.c8
-rw-r--r--sys/compat/linux/linux_futex.c3
-rw-r--r--sys/compat/linux/linux_getcwd.c4
-rw-r--r--sys/compat/linux/linux_misc.c8
-rw-r--r--sys/compat/linux/linux_socket.c12
-rw-r--r--sys/compat/linux/linux_sysctl.c8
-rw-r--r--sys/compat/linux/linux_uid16.c10
-rw-r--r--sys/compat/linux/linux_util.c2
-rw-r--r--sys/compat/linux/linux_util.h2
10 files changed, 32 insertions, 31 deletions
diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c
index b9f2373..20eb8d1 100644
--- a/sys/compat/linux/linux_emul.c
+++ b/sys/compat/linux/linux_emul.c
@@ -98,7 +98,7 @@ linux_proc_init(struct thread *td, struct thread *newtd, int flags)
em->em_tid = newtd->td_proc->p_pid;
- pem = malloc(sizeof(*pem), M_TEMP, M_WAITOK | M_ZERO);
+ pem = malloc(sizeof(*pem), M_LINUX, M_WAITOK | M_ZERO);
sx_init(&pem->pem_sx, "lpemlk");
newtd->td_proc->p_emuldata = pem;
}
@@ -134,7 +134,7 @@ linux_proc_exit(void *arg __unused, struct proc *p)
p->p_emuldata = NULL;
sx_destroy(&pem->pem_sx);
- free(pem, M_TEMP);
+ free(pem, M_LINUX);
}
int
@@ -181,7 +181,7 @@ linux_common_execve(struct thread *td, struct image_args *eargs)
PROC_UNLOCK(p);
free(em, M_TEMP);
- free(pem, M_TEMP);
+ free(pem, M_LINUX);
}
return (0);
}
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index ce22660..3e8e818 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -369,8 +369,8 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
buflen = max(LINUX_DIRBLKSIZ, nbytes);
buflen = min(buflen, MAXBSIZE);
- buf = malloc(buflen, M_TEMP, M_WAITOK);
- lbuf = malloc(LINUX_MAXRECLEN, M_TEMP, M_WAITOK | M_ZERO);
+ buf = malloc(buflen, M_LINUX, M_WAITOK);
+ lbuf = malloc(LINUX_MAXRECLEN, M_LINUX, M_WAITOK | M_ZERO);
vn_lock(vp, LK_SHARED | LK_RETRY);
aiov.iov_base = buf;
@@ -521,8 +521,8 @@ out:
VOP_UNLOCK(vp, 0);
foffset_unlock(fp, off, 0);
fdrop(fp, td);
- free(buf, M_TEMP);
- free(lbuf, M_TEMP);
+ free(buf, M_LINUX);
+ free(lbuf, M_LINUX);
return (error);
}
diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index b3d175e..51851d2 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -185,9 +185,6 @@ LIN_SDT_PROBE_DEFINE2(futex, release_futexes, entry, "struct thread *",
LIN_SDT_PROBE_DEFINE1(futex, release_futexes, copyin_error, "int");
LIN_SDT_PROBE_DEFINE0(futex, release_futexes, return);
-static MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes");
-static MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futexes wp");
-
struct futex;
struct waiting_proc {
diff --git a/sys/compat/linux/linux_getcwd.c b/sys/compat/linux/linux_getcwd.c
index 1c7080d..da1c726 100644
--- a/sys/compat/linux/linux_getcwd.c
+++ b/sys/compat/linux/linux_getcwd.c
@@ -186,7 +186,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, td)
dirbuflen = DIRBLKSIZ;
if (dirbuflen < va.va_blocksize)
dirbuflen = va.va_blocksize;
- dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK);
+ dirbuf = malloc(dirbuflen, M_LINUX, M_WAITOK);
#if 0
unionread:
@@ -274,7 +274,7 @@ unionread:
out:
vput(lvp);
*lvpp = NULL;
- free(dirbuf, M_TEMP);
+ free(dirbuf, M_LINUX);
return error;
}
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 2106dcd..e1db59e 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1204,7 +1204,7 @@ linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
ngrp = args->gidsetsize;
if (ngrp < 0 || ngrp >= ngroups_max + 1)
return (EINVAL);
- linux_gidset = malloc(ngrp * sizeof(*linux_gidset), M_TEMP, M_WAITOK);
+ linux_gidset = malloc(ngrp * sizeof(*linux_gidset), M_LINUX, M_WAITOK);
error = copyin(args->grouplist, linux_gidset, ngrp * sizeof(l_gid_t));
if (error)
goto out;
@@ -1243,7 +1243,7 @@ linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
crfree(oldcred);
error = 0;
out:
- free(linux_gidset, M_TEMP);
+ free(linux_gidset, M_LINUX);
return (error);
}
@@ -1275,14 +1275,14 @@ linux_getgroups(struct thread *td, struct linux_getgroups_args *args)
ngrp = 0;
linux_gidset = malloc(bsd_gidsetsz * sizeof(*linux_gidset),
- M_TEMP, M_WAITOK);
+ M_LINUX, M_WAITOK);
while (ngrp < bsd_gidsetsz) {
linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
ngrp++;
}
error = copyout(linux_gidset, args->grouplist, ngrp * sizeof(l_gid_t));
- free(linux_gidset, M_TEMP);
+ free(linux_gidset, M_LINUX);
if (error)
return (error);
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index d2e5777..ad21fe9 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -609,7 +609,7 @@ linux_sendto_hdrincl(struct thread *td, struct linux_sendto_args *linux_args)
linux_args->len > IP_MAXPACKET)
return (EINVAL);
- packet = (struct ip *)malloc(linux_args->len, M_TEMP, M_WAITOK);
+ packet = (struct ip *)malloc(linux_args->len, M_LINUX, M_WAITOK);
/* Make kernel copy of the packet to be sent */
if ((error = copyin(PTRIN(linux_args->msg), packet,
@@ -632,7 +632,7 @@ linux_sendto_hdrincl(struct thread *td, struct linux_sendto_args *linux_args)
error = linux_sendit(td, linux_args->s, &msg, linux_args->flags,
NULL, UIO_SYSSPACE);
goout:
- free(packet, M_TEMP);
+ free(packet, M_LINUX);
return (error);
}
@@ -1119,7 +1119,7 @@ linux_sendmsg(struct thread *td, struct linux_sendmsg_args *args)
free(sa, M_SONAME);
error = ENOBUFS;
- cmsg = malloc(CMSG_HDRSZ, M_TEMP, M_WAITOK | M_ZERO);
+ cmsg = malloc(CMSG_HDRSZ, M_LINUX, M_WAITOK | M_ZERO);
control = m_get(M_WAITOK, MT_CONTROL);
if (control == NULL)
goto bad;
@@ -1197,7 +1197,7 @@ linux_sendmsg(struct thread *td, struct linux_sendmsg_args *args)
bad:
free(iov, M_IOV);
if (cmsg)
- free(cmsg, M_TEMP);
+ free(cmsg, M_LINUX);
return (error);
}
@@ -1270,7 +1270,7 @@ linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args)
outlen = 0;
if (control) {
- linux_cmsg = malloc(L_CMSG_HDRSZ, M_TEMP, M_WAITOK | M_ZERO);
+ linux_cmsg = malloc(L_CMSG_HDRSZ, M_LINUX, M_WAITOK | M_ZERO);
msg.msg_control = mtod(control, struct cmsghdr *);
msg.msg_controllen = control->m_len;
@@ -1363,7 +1363,7 @@ out:
bad:
free(iov, M_IOV);
m_freem(control);
- free(linux_cmsg, M_TEMP);
+ free(linux_cmsg, M_LINUX);
return (error);
}
diff --git a/sys/compat/linux/linux_sysctl.c b/sys/compat/linux/linux_sysctl.c
index decd8f8..27b7a3d 100644
--- a/sys/compat/linux/linux_sysctl.c
+++ b/sys/compat/linux/linux_sysctl.c
@@ -141,12 +141,12 @@ linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
return (ENOTDIR);
}
- mib = malloc(la.nlen * sizeof(l_int), M_TEMP, M_WAITOK);
+ mib = malloc(la.nlen * sizeof(l_int), M_LINUX, M_WAITOK);
error = copyin(PTRIN(la.name), mib, la.nlen * sizeof(l_int));
if (error) {
LIN_SDT_PROBE1(sysctl, linux_sysctl, copyin_error, error);
LIN_SDT_PROBE1(sysctl, linux_sysctl, return, error);
- free(mib, M_TEMP);
+ free(mib, M_LINUX);
return (error);
}
@@ -158,7 +158,7 @@ linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
switch (mib[1]) {
case LINUX_KERN_VERSION:
error = handle_string(&la, version);
- free(mib, M_TEMP);
+ free(mib, M_LINUX);
LIN_SDT_PROBE1(sysctl, linux_sysctl, return, error);
return (error);
default:
@@ -187,7 +187,7 @@ linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
sbuf_delete(sb);
}
- free(mib, M_TEMP);
+ free(mib, M_LINUX);
LIN_SDT_PROBE1(sysctl, linux_sysctl, return, ENOTDIR);
return (ENOTDIR);
diff --git a/sys/compat/linux/linux_uid16.c b/sys/compat/linux/linux_uid16.c
index a2c3214..9acc047 100644
--- a/sys/compat/linux/linux_uid16.c
+++ b/sys/compat/linux/linux_uid16.c
@@ -172,12 +172,12 @@ linux_setgroups16(struct thread *td, struct linux_setgroups16_args *args)
LIN_SDT_PROBE1(uid16, linux_setgroups16, return, EINVAL);
return (EINVAL);
}
- linux_gidset = malloc(ngrp * sizeof(*linux_gidset), M_TEMP, M_WAITOK);
+ linux_gidset = malloc(ngrp * sizeof(*linux_gidset), M_LINUX, M_WAITOK);
error = copyin(args->gidset, linux_gidset, ngrp * sizeof(l_gid16_t));
if (error) {
LIN_SDT_PROBE1(uid16, linux_setgroups16, copyin_error, error);
LIN_SDT_PROBE1(uid16, linux_setgroups16, return, error);
- free(linux_gidset, M_TEMP);
+ free(linux_gidset, M_LINUX);
return (error);
}
newcred = crget();
@@ -219,7 +219,7 @@ linux_setgroups16(struct thread *td, struct linux_setgroups16_args *args)
crfree(oldcred);
error = 0;
out:
- free(linux_gidset, M_TEMP);
+ free(linux_gidset, M_LINUX);
LIN_SDT_PROBE1(uid16, linux_setgroups16, return, error);
return (error);
@@ -260,14 +260,14 @@ linux_getgroups16(struct thread *td, struct linux_getgroups16_args *args)
ngrp = 0;
linux_gidset = malloc(bsd_gidsetsz * sizeof(*linux_gidset),
- M_TEMP, M_WAITOK);
+ M_LINUX, M_WAITOK);
while (ngrp < bsd_gidsetsz) {
linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
ngrp++;
}
error = copyout(linux_gidset, args->gidset, ngrp * sizeof(l_gid16_t));
- free(linux_gidset, M_TEMP);
+ free(linux_gidset, M_LINUX);
if (error) {
LIN_SDT_PROBE1(uid16, linux_getgroups16, copyout_error, error);
LIN_SDT_PROBE1(uid16, linux_getgroups16, return, error);
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
index ac92c28..c4c26ac 100644
--- a/sys/compat/linux/linux_util.c
+++ b/sys/compat/linux/linux_util.c
@@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$");
#include <compat/linux/linux_util.h>
MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
+MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes");
+MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futex waiting proc");
const char linux_emul_path[] = "/compat/linux";
diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h
index 92fc2eb..0683099 100644
--- a/sys/compat/linux/linux_util.h
+++ b/sys/compat/linux/linux_util.h
@@ -45,6 +45,8 @@
#include <sys/uio.h>
MALLOC_DECLARE(M_LINUX);
+MALLOC_DECLARE(M_FUTEX);
+MALLOC_DECLARE(M_FUTEX_WP);
extern const char linux_emul_path[];
OpenPOWER on IntegriCloud