Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107093813
D35225.id106129.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D35225.id106129.diff
View Options
Index: sys/compat/freebsd32/freebsd32_misc.c
===================================================================
--- sys/compat/freebsd32/freebsd32_misc.c
+++ sys/compat/freebsd32/freebsd32_misc.c
@@ -3310,13 +3310,73 @@
PAIR32TO64(id_t, uap->id), uap->setid));
}
+static int
+copyin32_set(const void *u, void *k, size_t size)
+{
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ int rv;
+ struct bitset *kb = k;
+ int *p;
+
+ rv = copyin(u, k, size);
+
+ if (rv != 0)
+ return (rv);
+
+ p = (int *)kb->__bits;
+ /* Loop through swapping words.
+ * `size' is in bytes, we need bits. */
+ for (int i = 0; i < __bitset_words(size * 8); i++) {
+ int tmp = p[0];
+ p[0] = p[1];
+ p[1] = tmp;
+ p += 2;
+ }
+ return (0);
+#else
+ return (copyin(u, k, size));
+#endif
+}
+
+static int
+copyout32_set(const void *k, void *u, size_t size)
+{
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ const struct bitset *kb = k;
+ struct bitset *ub = u;
+ const int *kp = (const int *)kb->__bits;
+ int *up = (int *)ub->__bits;
+ int rv;
+
+ for (int i = 0; i < __bitset_words(CPU_SETSIZE); i++) {
+ /* `size' is in bytes, we need bits. */
+ for (int i = 0; i < __bitset_words(size * 8); i++) {
+ rv = suword32(up, kp[1]);
+ if (rv == 0)
+ rv = suword32(up + 1, kp[0]);
+ if (rv != 0)
+ return (rv);
+ }
+ }
+ return (0);
+#else
+ return (copyout(k, u, size));
+#endif
+}
+
+struct cpuset_copy_cb cpuset_copy32_cb = {
+ .copyin = copyin32_set,
+ .copyout = copyout32_set
+};
+
int
freebsd32_cpuset_getaffinity(struct thread *td,
struct freebsd32_cpuset_getaffinity_args *uap)
{
return (kern_cpuset_getaffinity(td, uap->level, uap->which,
- PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
+ PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
+ &cpuset_copy32_cb));
}
int
@@ -3325,7 +3385,8 @@
{
return (user_cpuset_setaffinity(td, uap->level, uap->which,
- PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask));
+ PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask,
+ &cpuset_copy32_cb));
}
int
@@ -3334,7 +3395,8 @@
{
return (kern_cpuset_getdomain(td, uap->level, uap->which,
- PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
+ PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy,
+ &cpuset_copy32_cb));
}
int
@@ -3343,7 +3405,8 @@
{
return (kern_cpuset_setdomain(td, uap->level, uap->which,
- PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy));
+ PAIR32TO64(id_t,uap->id), uap->domainsetsize, uap->mask, uap->policy,
+ &cpuset_copy32_cb));
}
int
Index: sys/kern/kern_cpuset.c
===================================================================
--- sys/kern/kern_cpuset.c
+++ sys/kern/kern_cpuset.c
@@ -52,6 +52,7 @@
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/syscallsubr.h>
+#include <sys/sysent.h>
#include <sys/capsicum.h>
#include <sys/cpuset.h>
#include <sys/domainset.h>
@@ -1742,6 +1743,11 @@
return (0);
}
+static struct cpuset_copy_cb copy_set = {
+ .copyin = copyin,
+ .copyout = copyout
+};
+
#ifndef _SYS_SYSPROTO_H_
struct cpuset_args {
cpusetid_t *setid;
@@ -1883,12 +1889,12 @@
{
return (kern_cpuset_getaffinity(td, uap->level, uap->which,
- uap->id, uap->cpusetsize, uap->mask));
+ uap->id, uap->cpusetsize, uap->mask, ©_set));
}
int
kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
- id_t id, size_t cpusetsize, cpuset_t *maskp)
+ id_t id, size_t cpusetsize, cpuset_t *maskp, struct cpuset_copy_cb *cb)
{
struct thread *ttd;
struct cpuset *nset;
@@ -1977,7 +1983,7 @@
goto out;
}
size = min(cpusetsize, sizeof(cpuset_t));
- error = copyout(mask, maskp, size);
+ error = cb->copyout(mask, maskp, size);
if (error != 0)
goto out;
if (cpusetsize > size) {
@@ -2021,7 +2027,7 @@
{
return (user_cpuset_setaffinity(td, uap->level, uap->which,
- uap->id, uap->cpusetsize, uap->mask));
+ uap->id, uap->cpusetsize, uap->mask, ©_set));
}
int
@@ -2109,7 +2115,7 @@
int
user_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which,
- id_t id, size_t cpusetsize, const cpuset_t *maskp)
+ id_t id, size_t cpusetsize, const cpuset_t *maskp, struct cpuset_copy_cb *cb)
{
cpuset_t *mask;
int error;
@@ -2117,7 +2123,7 @@
size = min(cpusetsize, sizeof(cpuset_t));
mask = malloc(sizeof(cpuset_t), M_TEMP, M_WAITOK | M_ZERO);
- error = copyin(maskp, mask, size);
+ error = cb->copyin(maskp, mask, size);
if (error)
goto out;
/*
@@ -2165,12 +2171,13 @@
{
return (kern_cpuset_getdomain(td, uap->level, uap->which,
- uap->id, uap->domainsetsize, uap->mask, uap->policy));
+ uap->id, uap->domainsetsize, uap->mask, uap->policy, ©_set));
}
int
kern_cpuset_getdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
- id_t id, size_t domainsetsize, domainset_t *maskp, int *policyp)
+ id_t id, size_t domainsetsize, domainset_t *maskp, int *policyp,
+ struct cpuset_copy_cb *cb)
{
struct domainset outset;
struct thread *ttd;
@@ -2268,7 +2275,7 @@
}
DOMAINSET_COPY(&outset.ds_mask, mask);
if (error == 0)
- error = copyout(mask, maskp, domainsetsize);
+ error = cb->copyout(mask, maskp, domainsetsize);
if (error == 0)
if (suword32(policyp, outset.ds_policy) != 0)
error = EFAULT;
@@ -2292,12 +2299,13 @@
{
return (kern_cpuset_setdomain(td, uap->level, uap->which,
- uap->id, uap->domainsetsize, uap->mask, uap->policy));
+ uap->id, uap->domainsetsize, uap->mask, uap->policy, ©_set));
}
int
kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
- id_t id, size_t domainsetsize, const domainset_t *maskp, int policy)
+ id_t id, size_t domainsetsize, const domainset_t *maskp, int policy,
+ struct cpuset_copy_cb *cb)
{
struct cpuset *nset;
struct cpuset *set;
@@ -2318,7 +2326,7 @@
return (error);
memset(&domain, 0, sizeof(domain));
mask = malloc(domainsetsize, M_TEMP, M_WAITOK | M_ZERO);
- error = copyin(maskp, mask, domainsetsize);
+ error = cb->copyin(maskp, mask, domainsetsize);
if (error)
goto out;
/*
Index: sys/sys/cpuset.h
===================================================================
--- sys/sys/cpuset.h
+++ sys/sys/cpuset.h
@@ -154,6 +154,15 @@
struct proc;
struct thread;
+/*
+ * Callbacks for copying in/out a cpuset or domainset. Used for alternate
+ * ABIs, like compat32.
+ */
+struct cpuset_copy_cb {
+ int (*copyin)(const void *, void *, size_t);
+ int (*copyout)(const void *, void *, size_t);
+};
+
struct cpuset *cpuset_thread0(void);
struct cpuset *cpuset_ref(struct cpuset *);
void cpuset_rel(struct cpuset *);
Index: sys/sys/syscallsubr.h
===================================================================
--- sys/sys/syscallsubr.h
+++ sys/sys/syscallsubr.h
@@ -39,6 +39,7 @@
#include <sys/_uio.h>
struct __wrusage;
+struct cpuset_copy_cb;
struct file;
struct filecaps;
enum idtype;
@@ -119,18 +120,19 @@
int kern_copy_file_range(struct thread *td, int infd, off_t *inoffp,
int outfd, off_t *outoffp, size_t len, unsigned int flags);
int kern_cpuset_getaffinity(struct thread *td, cpulevel_t level,
- cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t *maskp);
+ cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t *maskp,
+ struct cpuset_copy_cb *cb);
int kern_cpuset_setaffinity(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, cpuset_t *maskp);
int user_cpuset_setaffinity(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, size_t cpusetsize,
- const cpuset_t *maskp);
+ const cpuset_t *maskp, struct cpuset_copy_cb *cb);
int kern_cpuset_getdomain(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, size_t domainsetsize,
- domainset_t *maskp, int *policyp);
+ domainset_t *maskp, int *policyp, struct cpuset_copy_cb *cb);
int kern_cpuset_setdomain(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, size_t domainsetsize,
- const domainset_t *maskp, int policy);
+ const domainset_t *maskp, int policy, struct cpuset_copy_cb *cb);
int kern_cpuset_getid(struct thread *td, cpulevel_t level,
cpuwhich_t which, id_t id, cpusetid_t *setid);
int kern_cpuset_setid(struct thread *td, cpuwhich_t which,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 12:32 AM (14 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15748356
Default Alt Text
D35225.id106129.diff (8 KB)
Attached To
Mode
D35225: cpuset: Byte swap cpuset for compat32 on big endian architectures
Attached
Detach File
Event Timeline
Log In to Comment