rump.c revision 1.217 1 /* $NetBSD: rump.c,v 1.217 2011/01/06 13:09:17 pooka Exp $ */
2
3 /*
4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
5 *
6 * Development of this software was supported by Google Summer of Code.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.217 2011/01/06 13:09:17 pooka Exp $");
32
33 #include <sys/systm.h>
34 #define ELFSIZE ARCH_ELFSIZE
35
36 #include <sys/param.h>
37 #include <sys/atomic.h>
38 #include <sys/buf.h>
39 #include <sys/callout.h>
40 #include <sys/conf.h>
41 #include <sys/cpu.h>
42 #include <sys/device.h>
43 #include <sys/evcnt.h>
44 #include <sys/event.h>
45 #include <sys/exec_elf.h>
46 #include <sys/filedesc.h>
47 #include <sys/iostat.h>
48 #include <sys/kauth.h>
49 #include <sys/kernel.h>
50 #include <sys/kmem.h>
51 #include <sys/kprintf.h>
52 #include <sys/kthread.h>
53 #include <sys/ksyms.h>
54 #include <sys/msgbuf.h>
55 #include <sys/module.h>
56 #include <sys/once.h>
57 #include <sys/percpu.h>
58 #include <sys/pipe.h>
59 #include <sys/pool.h>
60 #include <sys/queue.h>
61 #include <sys/reboot.h>
62 #include <sys/resourcevar.h>
63 #include <sys/select.h>
64 #include <sys/sysctl.h>
65 #include <sys/syscall.h>
66 #include <sys/syscallvar.h>
67 #include <sys/timetc.h>
68 #include <sys/tty.h>
69 #include <sys/uidinfo.h>
70 #include <sys/vmem.h>
71 #include <sys/xcall.h>
72 #include <sys/simplelock.h>
73
74 #include <rump/rumpuser.h>
75
76 #include <secmodel/suser/suser.h>
77
78 #include <prop/proplib.h>
79
80 #include <uvm/uvm_extern.h>
81 #include <uvm/uvm_readahead.h>
82
83 #include "rump_private.h"
84 #include "rump_net_private.h"
85 #include "rump_vfs_private.h"
86 #include "rump_dev_private.h"
87
88 char machine[] = MACHINE;
89
90 struct proc *initproc;
91
92 struct device rump_rootdev = {
93 .dv_class = DV_VIRTUAL
94 };
95
96 #ifdef RUMP_WITHOUT_THREADS
97 int rump_threads = 0;
98 #else
99 int rump_threads = 1;
100 #endif
101
102 static int rump_proxy_syscall(int, void *, register_t *);
103 static int rump_proxy_rfork(void *, int);
104
105 static char rump_msgbuf[16*1024]; /* 16k should be enough for std rump needs */
106
107 #ifdef LOCKDEBUG
108 const int rump_lockdebug = 1;
109 #else
110 const int rump_lockdebug = 0;
111 #endif
112
113 static void
114 rump_aiodone_worker(struct work *wk, void *dummy)
115 {
116 struct buf *bp = (struct buf *)wk;
117
118 KASSERT(&bp->b_work == wk);
119 bp->b_iodone(bp);
120 }
121
122 static int rump_inited;
123
124 /*
125 * Make sure pnbuf_cache is available even without vfs
126 */
127 struct pool_cache *pnbuf_cache;
128 int rump_initpnbufpool(void);
129 int rump_initpnbufpool(void)
130 {
131
132 pnbuf_cache = pool_cache_init(MAXPATHLEN, 0, 0, 0, "pnbufpl",
133 NULL, IPL_NONE, NULL, NULL, NULL);
134 return EOPNOTSUPP;
135 }
136
137 int rump__unavailable(void);
138 int rump__unavailable() {return EOPNOTSUPP;}
139 __weak_alias(rump_net_init,rump__unavailable);
140 __weak_alias(rump_vfs_init,rump_initpnbufpool);
141 __weak_alias(rump_dev_init,rump__unavailable);
142
143 __weak_alias(rump_vfs_fini,rump__unavailable);
144
145 __weak_alias(biodone,rump__unavailable);
146 __weak_alias(sopoll,rump__unavailable);
147
148 __weak_alias(rump_vfs_drainbufs,rump__unavailable);
149
150 void rump__unavailable_vfs_panic(void);
151 void rump__unavailable_vfs_panic() {panic("vfs component not available");}
152 __weak_alias(usermount_common_policy,rump__unavailable_vfs_panic);
153
154 /* easier to write vfs-less clients */
155 __weak_alias(rump_pub_etfs_register,rump__unavailable);
156 __weak_alias(rump_pub_etfs_remove,rump__unavailable);
157
158 rump_proc_vfs_init_fn rump_proc_vfs_init;
159 rump_proc_vfs_release_fn rump_proc_vfs_release;
160
161 static void add_linkedin_modules(const struct modinfo *const *, size_t);
162
163 static void __noinline
164 messthestack(void)
165 {
166 volatile uint32_t mess[64];
167 uint64_t d1, d2;
168 int i, error;
169
170 for (i = 0; i < 64; i++) {
171 rumpuser_gettime(&d1, &d2, &error);
172 mess[i] = d2;
173 }
174 }
175
176 /*
177 * Create kern.hostname. why only this you ask. well, init_sysctl
178 * is a kitchen sink in need of some gardening. but i want to use
179 * kern.hostname today.
180 */
181 static void
182 mksysctls(void)
183 {
184
185 sysctl_createv(NULL, 0, NULL, NULL,
186 CTLFLAG_PERMANENT, CTLTYPE_NODE, "kern", NULL,
187 NULL, 0, NULL, 0, CTL_KERN, CTL_EOL);
188
189 /* XXX: setting hostnamelen is missing */
190 sysctl_createv(NULL, 0, NULL, NULL,
191 CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_STRING, "hostname",
192 SYSCTL_DESCR("System hostname"), NULL, 0,
193 &hostname, MAXHOSTNAMELEN, CTL_KERN, KERN_HOSTNAME, CTL_EOL);
194 }
195
196 /* there's no convenient kernel entry point for this, so just craft out own */
197 static pid_t
198 spgetpid(void)
199 {
200
201 return curproc->p_pid;
202 }
203
204 static const struct rumpuser_sp_ops spops = {
205 .spop_schedule = rump_schedule,
206 .spop_unschedule = rump_unschedule,
207 .spop_lwproc_switch = rump_lwproc_switch,
208 .spop_lwproc_release = rump_lwproc_releaselwp,
209 .spop_lwproc_rfork = rump_proxy_rfork,
210 .spop_lwproc_newlwp = rump_lwproc_newlwp,
211 .spop_lwproc_curlwp = rump_lwproc_curlwp,
212 .spop_syscall = rump_proxy_syscall,
213 .spop_getpid = spgetpid,
214 };
215
216 int
217 rump_daemonize_begin(void)
218 {
219
220 if (rump_inited)
221 return EALREADY;
222
223 return rumpuser_daemonize_begin();
224 }
225
226 int
227 rump_daemonize_done(int error)
228 {
229
230 return rumpuser_daemonize_done(error);
231 }
232
233 int
234 rump__init(int rump_version)
235 {
236 char buf[256];
237 struct timespec ts;
238 uint64_t sec, nsec;
239 struct lwp *l;
240 int i, numcpu;
241 int error;
242
243 /* not reentrant */
244 if (rump_inited)
245 return 0;
246 else if (rump_inited == -1)
247 panic("rump_init: host process restart required");
248 else
249 rump_inited = 1;
250
251 if (rumpuser_getversion() != RUMPUSER_VERSION) {
252 /* let's hope the ABI of rumpuser_dprintf is the same ;) */
253 rumpuser_dprintf("rumpuser version mismatch: %d vs. %d\n",
254 rumpuser_getversion(), RUMPUSER_VERSION);
255 return EPROGMISMATCH;
256 }
257
258 if (rumpuser_getenv("RUMP_VERBOSE", buf, sizeof(buf), &error) == 0) {
259 if (*buf != '0')
260 boothowto = AB_VERBOSE;
261 }
262
263 if (rumpuser_getenv("RUMP_NCPU", buf, sizeof(buf), &error) == 0)
264 error = 0;
265 if (error == 0) {
266 numcpu = strtoll(buf, NULL, 10);
267 if (numcpu < 1)
268 numcpu = 1;
269 } else {
270 numcpu = rumpuser_getnhostcpu();
271 }
272 rump_cpus_bootstrap(&numcpu);
273
274 rumpuser_gettime(&sec, &nsec, &error);
275 boottime.tv_sec = sec;
276 boottime.tv_nsec = nsec;
277
278 initmsgbuf(rump_msgbuf, sizeof(rump_msgbuf));
279 aprint_verbose("%s%s", copyright, version);
280
281 /*
282 * Seed arc4random() with a "reasonable" amount of randomness.
283 * Yes, this is a quick kludge which depends on the arc4random
284 * implementation.
285 */
286 messthestack();
287 arc4random();
288
289 if (rump_version != RUMP_VERSION) {
290 printf("rump version mismatch, %d vs. %d\n",
291 rump_version, RUMP_VERSION);
292 return EPROGMISMATCH;
293 }
294
295 if (rumpuser_getenv("RUMP_THREADS", buf, sizeof(buf), &error) == 0) {
296 rump_threads = *buf != '0';
297 }
298 rumpuser_thrinit(rump_user_schedule, rump_user_unschedule,
299 rump_threads);
300 rump_intr_init(numcpu);
301 rump_tsleep_init();
302
303 /* init minimal lwp/cpu context */
304 l = &lwp0;
305 l->l_lid = 1;
306 l->l_cpu = l->l_target_cpu = rump_cpu;
307 l->l_fd = &filedesc0;
308 rumpuser_set_curlwp(l);
309
310 mutex_init(&tty_lock, MUTEX_DEFAULT, IPL_NONE);
311 rumpuser_mutex_init(&rump_giantlock);
312 ksyms_init();
313 uvm_init();
314 evcnt_init();
315
316 once_init();
317 kernconfig_lock_init();
318 prop_kern_init();
319
320 pool_subsystem_init();
321 kmem_init();
322
323 uvm_ra_init();
324 uao_init();
325
326 mutex_obj_init();
327 callout_startup();
328
329 kprintf_init();
330 loginit();
331
332 kauth_init();
333
334 procinit();
335 proc0_init();
336 uid_init();
337 chgproccnt(0, 1);
338
339 l->l_proc = &proc0;
340 lwp_update_creds(l);
341
342 lwpinit_specificdata();
343 lwp_initspecific(&lwp0);
344
345 rump_scheduler_init(numcpu);
346 /* revert temporary context and schedule a semireal context */
347 l->l_cpu = NULL;
348 rumpuser_set_curlwp(NULL);
349 initproc = &proc0; /* borrow proc0 before we get initproc started */
350 rump_schedule();
351
352 percpu_init();
353 inittimecounter();
354 ntp_init();
355
356 rumpuser_gettime(&sec, &nsec, &error);
357 ts.tv_sec = sec;
358 ts.tv_nsec = nsec;
359 tc_setclock(&ts);
360
361 /* we are mostly go. do per-cpu subsystem init */
362 for (i = 0; i < numcpu; i++) {
363 struct cpu_info *ci = cpu_lookup(i);
364
365 /* attach non-bootstrap CPUs */
366 if (i > 0) {
367 rump_cpu_attach(ci);
368 ncpu++;
369 }
370
371 callout_init_cpu(ci);
372 softint_init(ci);
373 xc_init_cpu(ci);
374 pool_cache_cpu_init(ci);
375 selsysinit(ci);
376 percpu_init_cpu(ci);
377
378 TAILQ_INIT(&ci->ci_data.cpu_ld_locks);
379 __cpu_simple_lock_init(&ci->ci_data.cpu_ld_lock);
380
381 aprint_verbose("cpu%d at thinair0: rump virtual cpu\n", i);
382 }
383
384 sysctl_init();
385 mksysctls();
386 kqueue_init();
387 iostat_init();
388 fd_sys_init();
389 module_init();
390 devsw_init();
391 pipe_init();
392 resource_init();
393
394 /* start page baroness */
395 if (rump_threads) {
396 if (kthread_create(PRI_PGDAEMON, KTHREAD_MPSAFE, NULL,
397 uvm_pageout, NULL, &uvm.pagedaemon_lwp, "pdaemon") != 0)
398 panic("pagedaemon create failed");
399 } else
400 uvm.pagedaemon_lwp = NULL; /* doesn't match curlwp */
401
402 /* process dso's */
403 rumpuser_dl_bootstrap(add_linkedin_modules, rump_kernelfsym_load);
404
405 rump_component_init(RUMP_COMPONENT_KERN);
406
407 /* these do nothing if not present */
408 rump_vfs_init();
409 rump_net_init();
410 rump_dev_init();
411
412 rump_component_init(RUMP_COMPONENT_KERN_VFS);
413
414 cold = 0;
415
416 /* aieeeedondest */
417 if (rump_threads) {
418 if (workqueue_create(&uvm.aiodone_queue, "aiodoned",
419 rump_aiodone_worker, NULL, 0, 0, WQ_MPSAFE))
420 panic("aiodoned");
421 }
422
423 sysctl_finalize();
424
425 module_init_class(MODULE_CLASS_ANY);
426
427 rumpuser_gethostname(hostname, MAXHOSTNAMELEN, &error);
428 hostnamelen = strlen(hostname);
429
430 sigemptyset(&sigcantmask);
431
432 if (rump_threads)
433 vmem_rehash_start();
434
435 /*
436 * Create init, used to attach implicit threads in rump.
437 * (note: must be done after vfsinit to get cwdi)
438 */
439 (void)rump__lwproc_alloclwp(NULL); /* dummy thread for initproc */
440 mutex_enter(proc_lock);
441 initproc = proc_find_raw(1);
442 mutex_exit(proc_lock);
443 if (initproc == NULL)
444 panic("where in the world is initproc?");
445
446 /*
447 * Adjust syscall vector in case factions were dlopen()'d
448 * before calling rump_init().
449 * (modules will handle dynamic syscalls the usual way)
450 *
451 * Note: this will adjust the function vectors of
452 * syscalls which use a funcalias (getpid etc.), but
453 * it makes no difference.
454 */
455 for (i = 0; i < SYS_NSYSENT; i++) {
456 void *sym;
457
458 if (rump_sysent[i].sy_flags & SYCALL_NOSYS ||
459 *syscallnames[i] == '#' ||
460 rump_sysent[i].sy_call == sys_nomodule)
461 continue;
462
463 /* if present, adjust symbol value */
464 sprintf(buf, "rumpns_sys_%s", syscallnames[i]);
465 if ((sym = rumpuser_dl_globalsym(buf)) != NULL
466 && sym != rump_sysent[i].sy_call) {
467 #if 0
468 rumpuser_dprintf("adjusting %s: %p (old %p)\n",
469 syscallnames[i], sym, rump_sysent[i].sy_call);
470 #endif
471 rump_sysent[i].sy_call = sym;
472 }
473 }
474
475 /* release cpu */
476 rump_unschedule();
477
478 return 0;
479 }
480
481 int
482 rump_init_server(const char *url)
483 {
484
485 return rumpuser_sp_init(url, &spops, ostype, osrelease, MACHINE);
486 }
487
488 void
489 cpu_reboot(int howto, char *bootstr)
490 {
491 int ruhow = 0;
492
493 printf("rump kernel halting...\n");
494 rumpuser_sp_fini();
495
496 /* dump means we really take the dive here */
497 if ((howto & RB_DUMP) || panicstr) {
498 ruhow = RUMPUSER_PANIC;
499 goto out;
500 }
501
502 /* try to sync */
503 if (!((howto & RB_NOSYNC) || panicstr)) {
504 rump_vfs_fini();
505 }
506
507 /* your wish is my command */
508 if (howto & RB_HALT) {
509 printf("rump kernel halted\n");
510 for (;;) {
511 uint64_t sec = 5, nsec = 0;
512 int error;
513
514 rumpuser_nanosleep(&sec, &nsec, &error);
515 }
516 }
517
518 /* this function is __dead, we must exit */
519 out:
520 printf("halted\n");
521 rumpuser_exit(ruhow);
522 }
523
524 struct uio *
525 rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw)
526 {
527 struct uio *uio;
528 enum uio_rw uiorw;
529
530 switch (rw) {
531 case RUMPUIO_READ:
532 uiorw = UIO_READ;
533 break;
534 case RUMPUIO_WRITE:
535 uiorw = UIO_WRITE;
536 break;
537 default:
538 panic("%s: invalid rw %d", __func__, rw);
539 }
540
541 uio = kmem_alloc(sizeof(struct uio), KM_SLEEP);
542 uio->uio_iov = kmem_alloc(sizeof(struct iovec), KM_SLEEP);
543
544 uio->uio_iov->iov_base = buf;
545 uio->uio_iov->iov_len = bufsize;
546
547 uio->uio_iovcnt = 1;
548 uio->uio_offset = offset;
549 uio->uio_resid = bufsize;
550 uio->uio_rw = uiorw;
551 UIO_SETUP_SYSSPACE(uio);
552
553 return uio;
554 }
555
556 size_t
557 rump_uio_getresid(struct uio *uio)
558 {
559
560 return uio->uio_resid;
561 }
562
563 off_t
564 rump_uio_getoff(struct uio *uio)
565 {
566
567 return uio->uio_offset;
568 }
569
570 size_t
571 rump_uio_free(struct uio *uio)
572 {
573 size_t resid;
574
575 resid = uio->uio_resid;
576 kmem_free(uio->uio_iov, sizeof(*uio->uio_iov));
577 kmem_free(uio, sizeof(*uio));
578
579 return resid;
580 }
581
582 kauth_cred_t
583 rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups)
584 {
585 kauth_cred_t cred;
586 int rv;
587
588 cred = kauth_cred_alloc();
589 kauth_cred_setuid(cred, uid);
590 kauth_cred_seteuid(cred, uid);
591 kauth_cred_setsvuid(cred, uid);
592 kauth_cred_setgid(cred, gid);
593 kauth_cred_setgid(cred, gid);
594 kauth_cred_setegid(cred, gid);
595 kauth_cred_setsvgid(cred, gid);
596 rv = kauth_cred_setgroups(cred, groups, ngroups, 0, UIO_SYSSPACE);
597 /* oh this is silly. and by "this" I mean kauth_cred_setgroups() */
598 assert(rv == 0);
599
600 return cred;
601 }
602
603 void
604 rump_cred_put(kauth_cred_t cred)
605 {
606
607 kauth_cred_free(cred);
608 }
609
610 static int compcounter[RUMP_COMPONENT_MAX];
611
612 static void
613 rump_component_init_cb(struct rump_component *rc, int type)
614 {
615
616 KASSERT(type < RUMP_COMPONENT_MAX);
617 if (rc->rc_type == type) {
618 rc->rc_init();
619 compcounter[type]++;
620 }
621 }
622
623 int
624 rump_component_count(enum rump_component_type type)
625 {
626
627 KASSERT(type <= RUMP_COMPONENT_MAX);
628 return compcounter[type];
629 }
630
631 void
632 rump_component_init(enum rump_component_type type)
633 {
634
635 rumpuser_dl_component_init(type, rump_component_init_cb);
636 }
637
638 /*
639 * Initialize a module which has already been loaded and linked
640 * with dlopen(). This is fundamentally the same as a builtin module.
641 */
642 int
643 rump_module_init(const struct modinfo * const *mip, size_t nmodinfo)
644 {
645
646 return module_builtin_add(mip, nmodinfo, true);
647 }
648
649 /*
650 * Finish module (flawless victory, fatality!).
651 */
652 int
653 rump_module_fini(const struct modinfo *mi)
654 {
655
656 return module_builtin_remove(mi, true);
657 }
658
659 /*
660 * Add loaded and linked module to the builtin list. It will
661 * later be initialized with module_init_class().
662 */
663
664 static void
665 add_linkedin_modules(const struct modinfo * const *mip, size_t nmodinfo)
666 {
667
668 module_builtin_add(mip, nmodinfo, false);
669 }
670
671 int
672 rump_kernelfsym_load(void *symtab, uint64_t symsize,
673 char *strtab, uint64_t strsize)
674 {
675 static int inited = 0;
676 Elf64_Ehdr ehdr;
677
678 if (inited)
679 return EBUSY;
680 inited = 1;
681
682 /*
683 * Use 64bit header since it's bigger. Shouldn't make a
684 * difference, since we're passing in all zeroes anyway.
685 */
686 memset(&ehdr, 0, sizeof(ehdr));
687 ksyms_addsyms_explicit(&ehdr, symtab, symsize, strtab, strsize);
688
689 return 0;
690 }
691
692 static int
693 rump_proxy_syscall(int num, void *arg, register_t *retval)
694 {
695 struct lwp *l;
696 struct sysent *callp;
697 int rv;
698
699 if (__predict_false(num >= SYS_NSYSENT))
700 return ENOSYS;
701
702 callp = rump_sysent + num;
703 l = curlwp;
704 rv = sy_call(callp, l, (void *)arg, retval);
705
706 return rv;
707 }
708
709 static int
710 rump_proxy_rfork(void *priv, int flags)
711 {
712 struct vmspace *newspace;
713 int error;
714
715 if ((error = rump_lwproc_rfork(flags)) != 0)
716 return error;
717
718 /*
719 * Since it's a proxy proc, adjust the vmspace.
720 * Refcount will eternally be 1.
721 */
722 newspace = kmem_alloc(sizeof(*newspace), KM_SLEEP);
723 newspace->vm_refcnt = 1;
724 newspace->vm_map.pmap = priv;
725 KASSERT(curproc->p_vmspace == vmspace_kernel());
726 curproc->p_vmspace = newspace;
727
728 return 0;
729 }
730
731 int
732 rump_boot_gethowto()
733 {
734
735 return boothowto;
736 }
737
738 void
739 rump_boot_sethowto(int howto)
740 {
741
742 boothowto = howto;
743 }
744
745 int
746 rump_getversion(void)
747 {
748
749 return __NetBSD_Version__;
750 }
751
752 /*
753 * Note: may be called unscheduled. Not fully safe since no locking
754 * of allevents (currently that's not even available).
755 */
756 void
757 rump_printevcnts()
758 {
759 struct evcnt *ev;
760
761 TAILQ_FOREACH(ev, &allevents, ev_list)
762 rumpuser_dprintf("%s / %s: %" PRIu64 "\n",
763 ev->ev_group, ev->ev_name, ev->ev_count);
764 }
765
766 /*
767 * If you use this interface ... well ... all bets are off.
768 * The original purpose is for the p2k fs server library to be
769 * able to use the same pid/lid for VOPs as the host kernel.
770 */
771 void
772 rump_allbetsareoff_setid(pid_t pid, int lid)
773 {
774 struct lwp *l = curlwp;
775 struct proc *p = l->l_proc;
776
777 l->l_lid = lid;
778 p->p_pid = pid;
779 }
780