aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi32
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2017-11-08 14:21:52 +0000
committerEd Schouten <ed@FreeBSD.org>2017-11-08 14:21:52 +0000
commit7e6155744d78c5f233af37fefc8f1e576a0fe63f (patch)
tree37276fa420d32a1380a86d37eb54675781f3334c /sys/compat/cloudabi32
parent8c9e09194412512173244881d29da6c8f2d32e56 (diff)
downloadsrc-7e6155744d78c5f233af37fefc8f1e576a0fe63f.tar.gz
src-7e6155744d78c5f233af37fefc8f1e576a0fe63f.zip
Upgrade to CloudABI v0.17.
Compared to the previous version, v0.16, there are a couple of minor changes: - CLOUDABI_AT_PID: Process identifiers for CloudABI processes. Initially, BSD process identifiers weren't exposed inside the runtime, due to them being pretty much useless inside of a cluster computing environment. When jobs are scheduled across systems, the BSD process number doesn't act as an identifier. Even on individual systems they may recycle relatively quickly. With this change, the kernel will now generate a UUIDv4 when executing a process. These UUIDs can be obtained within the process using program_getpid(). Right now, FreeBSD will not attempt to store this value. This should of course happen at some point in time, so that it may be printed by administration tools. - Removal of some unused structure members for polling. With the polling framework being simplified/redesigned, it turns out some of the structure fields were not used by the C library. We can remove these to keep things nice and tidy. Obtained from: https://github.com/NuxiNL/cloudabi
Notes
Notes: svn path=/head/; revision=325555
Diffstat (limited to 'sys/compat/cloudabi32')
-rw-r--r--sys/compat/cloudabi32/cloudabi32_module.c24
-rw-r--r--sys/compat/cloudabi32/cloudabi32_poll.c21
-rw-r--r--sys/compat/cloudabi32/cloudabi32_proto.h2
-rw-r--r--sys/compat/cloudabi32/cloudabi32_systrace_args.c4
4 files changed, 27 insertions, 24 deletions
diff --git a/sys/compat/cloudabi32/cloudabi32_module.c b/sys/compat/cloudabi32/cloudabi32_module.c
index 3e4e4a733971..001c673a7d7a 100644
--- a/sys/compat/cloudabi32/cloudabi32_module.c
+++ b/sys/compat/cloudabi32/cloudabi32_module.c
@@ -63,10 +63,10 @@ cloudabi32_copyout_strings(struct image_params *imgp)
int
cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
{
- char canarybuf[64];
+ char canarybuf[64], pidbuf[16];
Elf32_Auxargs *args;
struct thread *td;
- void *argdata, *canary;
+ void *argdata, *canary, *pid;
size_t argdatalen;
int error;
@@ -79,8 +79,9 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
- /* Store canary for stack smashing protection. */
argdata = *stack_base;
+
+ /* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
@@ -89,6 +90,20 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
return (error);
/*
+ * Generate a random UUID that identifies the process. Right now
+ * we don't store this UUID in the kernel. Ideally, it should be
+ * exposed through ps(1).
+ */
+ arc4rand(pidbuf, sizeof(pidbuf), 0);
+ pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
+ pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
+ *stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
+ pid = *stack_base;
+ error = copyout(pidbuf, pid, sizeof(pidbuf));
+ if (error != 0)
+ return (error);
+
+ /*
* Compute length of program arguments. As the argument data is
* binary safe, we had to add a trailing null byte in
* exec_copyin_data_fds(). Undo this by reducing the length.
@@ -111,9 +126,10 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
- VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_PID, pid),
PTR(CLOUDABI_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base),
+ VAL(CLOUDABI_AT_TID, td->td_tid),
#undef VAL
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
diff --git a/sys/compat/cloudabi32/cloudabi32_poll.c b/sys/compat/cloudabi32/cloudabi32_poll.c
index 9bdd9ecb86a7..02e7e7f9ae4f 100644
--- a/sys/compat/cloudabi32/cloudabi32_poll.c
+++ b/sys/compat/cloudabi32/cloudabi32_poll.c
@@ -78,7 +78,7 @@ convert_signal(int sig)
struct cloudabi32_kevent_args {
const cloudabi32_subscription_t *in;
- cloudabi32_event_t *out;
+ cloudabi_event_t *out;
};
/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */
@@ -145,7 +145,7 @@ cloudabi32_kevent_copyin(void *arg, struct kevent *kevp, int count)
static int
cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count)
{
- cloudabi32_event_t ev;
+ cloudabi_event_t ev;
struct cloudabi32_kevent_args *args;
int error;
@@ -157,19 +157,15 @@ cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count)
switch (kevp->filter) {
case EVFILT_TIMER:
ev.type = CLOUDABI_EVENTTYPE_CLOCK;
- ev.clock.identifier = kevp->ident;
break;
case EVFILT_READ:
ev.type = CLOUDABI_EVENTTYPE_FD_READ;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_WRITE:
ev.type = CLOUDABI_EVENTTYPE_FD_WRITE;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_PROCDESC:
ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE;
- ev.proc_terminate.fd = kevp->ident;
break;
}
@@ -231,7 +227,7 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
*/
if (uap->nsubscriptions == 1) {
cloudabi32_subscription_t sub;
- cloudabi32_event_t ev = {};
+ cloudabi_event_t ev = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -241,7 +237,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
ev.type = sub.type;
if (sub.type == CLOUDABI_EVENTTYPE_CONDVAR) {
/* Wait on a condition variable. */
- ev.condvar.condvar = sub.condvar.condvar;
ev.error = cloudabi_convert_errno(
cloudabi_futex_condvar_wait(
td, TO_PTR(sub.condvar.condvar),
@@ -253,7 +248,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK) {
/* Acquire a read lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_rdlock(
td, TO_PTR(sub.lock.lock),
@@ -263,7 +257,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK) {
/* Acquire a write lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_wrlock(
td, TO_PTR(sub.lock.lock),
@@ -274,7 +267,7 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
}
} else if (uap->nsubscriptions == 2) {
cloudabi32_subscription_t sub[2];
- cloudabi32_event_t ev[2] = {};
+ cloudabi_event_t ev[2] = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -288,8 +281,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Wait for a condition variable with timeout. */
- ev[0].condvar.condvar = sub[0].condvar.condvar;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_condvar_wait(
td, TO_PTR(sub[0].condvar.condvar),
sub[0].condvar.condvar_scope,
@@ -309,8 +300,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a read lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_rdlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
@@ -328,8 +317,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a write lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_wrlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h
index 16a072278267..cd1e774ddb2c 100644
--- a/sys/compat/cloudabi32/cloudabi32_proto.h
+++ b/sys/compat/cloudabi32/cloudabi32_proto.h
@@ -224,7 +224,7 @@ struct cloudabi_sys_mem_unmap_args {
};
struct cloudabi32_sys_poll_args {
char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)];
- char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)];
+ char out_l_[PADL_(cloudabi_event_t *)]; cloudabi_event_t * out; char out_r_[PADR_(cloudabi_event_t *)];
char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)];
};
struct cloudabi_sys_proc_exec_args {
diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
index 4221955ab5e6..cdc98200160c 100644
--- a/sys/compat/cloudabi32/cloudabi32_systrace_args.c
+++ b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
@@ -352,7 +352,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
case 37: {
struct cloudabi32_sys_poll_args *p = params;
uarg[0] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */
- uarg[1] = (intptr_t) p->out; /* cloudabi32_event_t * */
+ uarg[1] = (intptr_t) p->out; /* cloudabi_event_t * */
uarg[2] = p->nsubscriptions; /* size_t */
*n_args = 3;
break;
@@ -1062,7 +1062,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
p = "userland const cloudabi32_subscription_t *";
break;
case 1:
- p = "userland cloudabi32_event_t *";
+ p = "userland cloudabi_event_t *";
break;
case 2:
p = "size_t";