PERFORCE change 114770 for review

Jung-uk Kim jkim at FreeBSD.org
Tue Feb 20 21:17:31 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=114770

Change 114770 by jkim at jkim_hammer on 2007/02/20 21:16:55

	Fix style(9).

Affected files ...

.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#39 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#39 (text+ko) ====

@@ -71,22 +71,6 @@
 #include <compat/linux/linux_util.h>
 #include <compat/linux/linux_emul.h>
 
-/*
- * Memory and System segment descriptors
- */
-struct  segment_descriptor      {
-        unsigned sd_lolimit:16 ;        /* segment extent (lsb) */
-        unsigned sd_lobase:24 __packed; /* segment base address (lsb) */
-        unsigned sd_type:5 ;            /* segment type */
-        unsigned sd_dpl:2 ;             /* segment descriptor priority level */
-        unsigned sd_p:1 ;               /* segment descriptor present */
-        unsigned sd_hilimit:4 ;         /* segment extent (msb) */
-        unsigned sd_xx:2 ;              /* unused */
-        unsigned sd_def32:1 ;           /* default 32 vs 16 bit size */
-        unsigned sd_gran:1 ;            /* limit granularity (byte/page units)*/
-        unsigned sd_hibase:8 ;          /* segment base address  (msb) */
-} ;
-
 struct l_old_select_argv {
 	l_int		nfds;
 	l_uintptr_t	readfds;
@@ -140,7 +124,7 @@
 	 * Allocate temporary demand zeroed space for argument and
 	 *	environment strings
 	 */
-	args->buf = (char *) kmem_alloc_wait(exec_map,
+	args->buf = (char *)kmem_alloc_wait(exec_map,
 	    PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
 	if (args->buf == NULL)
 		return (ENOMEM);
@@ -174,14 +158,14 @@
 		if (error) {
 			if (error == ENAMETOOLONG)
 				error = E2BIG;
-			
+
 			goto err_exit;
 		}
 		args->stringspace -= length;
 		args->endp += length;
 		args->argc++;
 	}
-			
+
 	args->begin_envv = args->endp;
 
 	/*
@@ -238,13 +222,13 @@
 	if (error == 0)
 		error = kern_execve(td, &eargs, NULL);
 	if (error == 0)
-	   	/* linux process can exec fbsd one, dont attempt
+		/* Linux process can execute FreeBSD one, do not attempt
 		 * to create emuldata for such process using
 		 * linux_proc_init, this leads to a panic on KASSERT
-		 * because such process has p->p_emuldata == NULL
+		 * because such process has p->p_emuldata == NULL.
 		 */
 	   	if (td->td_proc->p_sysent == &elf_linux_sysvec)
-   		   	error = linux_proc_init(td, 0, 0);
+			error = linux_proc_init(td, 0, 0);
 	return (error);
 }
 
@@ -485,7 +469,7 @@
 
 	if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2)) != 0)
 		return (error);
-	
+
 	if (error == 0) {
 		td->td_retval[0] = p2->p_pid;
 		td->td_retval[1] = 0;
@@ -520,7 +504,7 @@
 		printf(ARGS(vfork, ""));
 #endif
 
-	/* exclude RFPPWAIT */
+	/* Exclude RFPPWAIT */
 	if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2)) != 0)
 		return (error);
 	if (error == 0) {
@@ -539,7 +523,7 @@
 	PROC_UNLOCK(p2);
 
 	td2 = FIRST_THREAD_IN_PROC(p2);
-	
+
 	/* make it run */
 	mtx_lock_spin(&sched_lock);
 	TD_SET_CAN_RUN(td2);
@@ -551,7 +535,7 @@
 	while (p2->p_flag & P_PPWAIT)
 	   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
 	PROC_UNLOCK(p2);
-	
+
 	return (0);
 }
 
@@ -566,10 +550,9 @@
 
 #ifdef DEBUG
 	if (ldebug(clone)) {
-   	   	printf(ARGS(clone, "flags %x, stack %x, parent tid: %x, child tid: %x"),
-		    (unsigned int)args->flags, (unsigned int)(uintptr_t)args->stack, 
-		    (unsigned int)(uintptr_t)args->parent_tidptr, 
-		    (unsigned int)(uintptr_t)args->child_tidptr);
+		printf(ARGS(clone, "flags %x, stack %p, parent tid: %p, "
+		    "child tid: %p"), (unsigned)args->flags,
+		    args->stack, args->parent_tidptr, args->child_tidptr);
 	}
 #endif
 
@@ -584,11 +567,11 @@
 		ff |= RFMEM;
 	if (args->flags & CLONE_SIGHAND)
 		ff |= RFSIGSHARE;
-	/* 
-	 * XXX: in linux sharing of fs info (chroot/cwd/umask)
-	 * and open files is independant. in fbsd its in one
-	 * structure but in reality it doesnt make any problems
-	 * because both this flags are set at once usually.
+	/*
+	 * XXX: In Linux, sharing of fs info (chroot/cwd/umask)
+	 * and open files is independant.  In FreeBSD, its in one
+	 * structure but in reality it does not make any problems
+	 * because both of these flags are set at once usually.
 	 */
 	if (!(args->flags & (CLONE_FILES | CLONE_FS)))
 		ff |= RFFDG;
@@ -624,7 +607,7 @@
 		PROC_UNLOCK(p2);
 		sx_xunlock(&proctree_lock);
 	}
-	
+
 	/* create the emuldata */
 	error = linux_proc_init(td, p2->p_pid, args->flags);
 	/* reference it - no need to check this */
@@ -638,7 +621,7 @@
 	   	p2->p_pgrp = td->td_proc->p_pgrp;
 	   	PROC_UNLOCK(p2);
 #endif
-	 	exit_signal = 0;
+		exit_signal = 0;
 	}
 
 	if (args->flags & CLONE_CHILD_SETTID)
@@ -654,7 +637,8 @@
 	EMUL_UNLOCK(&emul_lock);
 
 	if (args->flags & CLONE_PARENT_SETTID) {
-		error = copyout(&p2->p_pid, args->parent_tidptr, sizeof(p2->p_pid));
+		error = copyout(&p2->p_pid, args->parent_tidptr,
+		    sizeof(p2->p_pid));
 		if (error)
 			printf(LMSG("copyout failed!"));
 	}
@@ -663,40 +647,47 @@
 	p2->p_sigparent = exit_signal;
 	PROC_UNLOCK(p2);
 	td2 = FIRST_THREAD_IN_PROC(p2);
-	/* 
-	 * in a case of stack = NULL we are supposed to COW calling process stack
-	 * this is what normal fork() does so we just keep the tf_rsp arg intact
+	/*
+	 * In a case of stack = NULL, we are supposed to COW calling process
+	 * stack. This is what normal fork() does, so we just keep tf_rsp arg
+	 * intact.
 	 */
 	if (args->stack)
-   	   	td2->td_frame->tf_rsp = PTROUT(args->stack);
+		td2->td_frame->tf_rsp = PTROUT(args->stack);
 
 	if (args->flags & CLONE_SETTLS) {
 		struct user_segment_descriptor sd;
-   	   	struct l_user_desc info;
+		struct l_user_desc info;
 	   	int a[2];
-   	   	int idx;
+		int idx;
 
-	   	error = copyin((void *)td->td_frame->tf_rsi, &info, sizeof(struct l_user_desc));
+	   	error = copyin((void *)td->td_frame->tf_rsi, &info,
+		    sizeof(struct l_user_desc));
 		if (error) {
 			printf(LMSG("copyin failed!"));
 		} else {
-		
+
 			idx = info.entry_number;
-		
+
 			/* 
-			 * looks like we're getting the idx we returned
-			 * in the set_thread_area() syscall
+			 * It looks like we're getting the idx we returned
+			 * in the set_thread_area() syscall.
 			 */
 			if (idx != 6 && idx != GUGS32_SEL) {
 				printf(LMSG("resetting idx!"));
 				idx = 6;	/* or GUGS32_SEL? */
-			}	
+			}
 
 			/* this doesnt happen in practice */
 			if (idx == 6) {
-			   	/* we might copy out the entry_number as GUGS32_SEL */
+				/*
+				 * We might copy out the entry_number
+				 * as GUGS32_SEL.
+				 */
 			   	info.entry_number = GUGS32_SEL;
-				error = copyout(&info, (void *) td->td_frame->tf_rsi, sizeof(struct l_user_desc));
+				error = copyout(&info,
+				    (void *)td->td_frame->tf_rsi,
+				    sizeof(struct l_user_desc));
 				if (error)
 					printf(LMSG("copyout failed!"));
 			}
@@ -707,21 +698,14 @@
 			memcpy(&sd, &a, sizeof(a));
 #ifdef DEBUG
 			if (ldebug(clone))
-				printf("Segment created in clone with CLONE_SETTLS: "
-				    "lobase: %x, hibase: %x, lolimit: %x, hilimit: %x, "
-				    "type: %i, dpl: %i, p: %i, xx: %i, long: %i, "
-				    "def32: %i, gran: %i\n",
-				    sd.sd_lobase,
-				    sd.sd_hibase,
-				    sd.sd_lolimit,
-				    sd.sd_hilimit,
-				    sd.sd_type,
-				    sd.sd_dpl,
-				    sd.sd_p,
-				    sd.sd_xx,
-				    sd.sd_long,
-				    sd.sd_def32,
-				    sd.sd_gran);
+				printf("Segment created in clone with "
+				    "CLONE_SETTLS: lobase: %x, hibase: %x, "
+				    "lolimit: %x, hilimit: %x, type: %i, "
+				    "dpl: %i, p: %i, xx: %i, long: %i, "
+				    "def32: %i, gran: %i\n", sd.sd_lobase,
+				    sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit,
+				    sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx,
+				    sd.sd_long, sd.sd_def32, sd.sd_gran);
 #endif
 			td2->td_pcb->pcb_gsbase = (register_t)info.base_addr;
 			td2->td_pcb->pcb_gs32sd = sd;
@@ -733,8 +717,9 @@
 
 #ifdef DEBUG
 	if (ldebug(clone))
-		printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"),
-		    (long)p2->p_pid, args->stack, exit_signal);
+		printf(LMSG("clone: successful rfork to %d, "
+		    "stack %p sig = %d"), (int)p2->p_pid, args->stack,
+		    exit_signal);
 #endif
 	if (args->flags & CLONE_VFORK) {
 	   	PROC_LOCK(p2);
@@ -752,12 +737,12 @@
 
 	td->td_retval[0] = p2->p_pid;
 	td->td_retval[1] = 0;
-	
+
 	if (args->flags & CLONE_VFORK) {
-   	   	/* wait for the children to exit, ie. emulate vfork */
-   	   	PROC_LOCK(p2);
+		/* wait for the children to exit, ie. emulate vfork */
+		PROC_LOCK(p2);
 		while (p2->p_flag & P_PPWAIT)
-   		   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+			msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
 		PROC_UNLOCK(p2);
 	}
 
@@ -776,8 +761,8 @@
 
 #ifdef DEBUG
 	if (ldebug(mmap2))
-		printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"),
-		    (void *)(intptr_t)args->addr, args->len, args->prot,
+		printf(ARGS(mmap2, "0x%08x, %d, %d, 0x%08x, %d, %d"),
+		    args->addr, args->len, args->prot,
 		    args->flags, args->fd, args->pgoff);
 #endif
 
@@ -803,10 +788,9 @@
 
 #ifdef DEBUG
 	if (ldebug(mmap))
-		printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
-		    (void *)(intptr_t)linux_args.addr, linux_args.len,
-		    linux_args.prot, linux_args.flags, linux_args.fd,
-		    linux_args.pgoff);
+		printf(ARGS(mmap, "0x%08x, %d, %d, 0x%08x, %d, %d"),
+		    linux_args.addr, linux_args.len, linux_args.prot,
+		    linux_args.flags, linux_args.fd, linux_args.pgoff);
 #endif
 	if ((linux_args.pgoff % PAGE_SIZE) != 0)
 		return (EINVAL);
@@ -891,14 +875,14 @@
 	bsd_args.fd = linux_args->fd;
 
 	if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
-		/* 
-		 * The linux MAP_GROWSDOWN option does not limit auto
+		/*
+		 * The Linux MAP_GROWSDOWN option does not limit auto
 		 * growth of the region.  Linux mmap with this option
 		 * takes as addr the inital BOS, and as len, the initial
 		 * region size.  It can then grow down from addr without
-		 * limit.  However, linux threads has an implicit internal
+		 * limit.  However, Linux threads has an implicit internal
 		 * limit to stack size of STACK_SIZE.  Its just not
-		 * enforced explicitly in linux.  But, here we impose
+		 * enforced explicitly in Linux.  But, here we impose
 		 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack
 		 * region, since we can do this with our mmap.
 		 *
@@ -915,8 +899,8 @@
 
 		if ((caddr_t)PTRIN(linux_args->addr) + linux_args->len >
 		    p->p_vmspace->vm_maxsaddr) {
-			/* 
-			 * Some linux apps will attempt to mmap
+			/*
+			 * Some Linux apps will attempt to mmap
 			 * thread stacks near the top of their
 			 * address space.  If their TOS is greater
 			 * than vm_maxsaddr, vm_map_growstack()
@@ -943,7 +927,7 @@
 		else
 			bsd_args.len  = STACK_SIZE - GUARD_SIZE;
 
-		/* 
+		/*
 		 * This gives us a new BOS.  If we're using VM_STACK, then
 		 * mmap will just map the top SGROWSIZ bytes, and let
 		 * the stack grow down to the limit at BOS.  If we're
@@ -1261,7 +1245,8 @@
 }
 
 int
-linux_set_thread_area(struct thread *td, struct linux_set_thread_area_args *args)
+linux_set_thread_area(struct thread *td,
+    struct linux_set_thread_area_args *args)
 {
 	struct l_user_desc info;
 	struct user_segment_descriptor sd;
@@ -1275,47 +1260,43 @@
 
 #ifdef DEBUG
 	if (ldebug(set_thread_area))
-	   	printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, %i, %i, %i"),
-		      info.entry_number,
-      		      info.base_addr,
-      		      info.limit,
-      		      info.seg_32bit,
-		      info.contents,
-      		      info.read_exec_only,
-      		      info.limit_in_pages,
-      		      info.seg_not_present,
-      		      info.useable);
+	   	printf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, "
+		    "%i, %i, %i"), info.entry_number, info.base_addr,
+		    info.limit, info.seg_32bit, info.contents,
+		    info.read_exec_only, info.limit_in_pages,
+		    info.seg_not_present, info.useable);
 #endif
 
 	idx = info.entry_number;
-	/* 
-	 * Semantics of linux version: every thread in the system has array
-	 * of 3 tls descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. This
-	 * syscall loads one of the selected tls decriptors with a value
-	 * and also loads GDT descriptors 6, 7 and 8 with the content of the per-thread 
-	 * descriptors.
+	/*
+	 * Semantics of Linux version: every thread in the system has array
+	 * of three TLS descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown.
+	 * This syscall loads one of the selected TLS decriptors with a value
+	 * and also loads GDT descriptors 6, 7 and 8 with the content of
+	 * the per-thread descriptors.
 	 *
-	 * Semantics of fbsd version: I think we can ignore that linux has 3 per-thread
-	 * descriptors and use just the 1st one. The tls_array[] is used only in 
-	 * set/get-thread_area() syscalls and for loading the GDT descriptors. In fbsd 
-	 * we use just one GDT descriptor for TLS so we will load just one. 
-	 * XXX: this doesnt work when user-space process tries to use more then 1 TLS segment
-	 * comment in the linux sources says wine might do that.
+	 * Semantics of FreeBSD version: I think we can ignore that Linux has
+	 * three per-thread descriptors and use just the first one.
+	 * The tls_array[] is used only in [gs]et_thread_area() syscalls and
+	 * for loading the GDT descriptors. We use just one GDT descriptor
+	 * for TLS, so we will load just one.
+	 * XXX: This doesnt work when user-space process tries to use more
+	 * than one TLS segment. Comment in the Linux source says wine might
+	 * do that.
 	 */
 
-	/* 
-	 * we support just GLIBC TLS now 
-	 * we should let 4 proceed as well because we use this segment so
-	 * if code does two subsequent calls it should succeed
+	/*
+	 * GLIBC reads current %gs and call set_thread_area() with it.
+	 * We should let GUGS32_SEL proceed as well because we use this
+	 * segment.
 	 */
 	if (idx != 6 && idx != -1 && idx != GUGS32_SEL)
 		return (EINVAL);
 
-	/* 
-	 * we have to copy out the GDT entry we use
-	 * FreeBSD uses GUGS32_SEL for storing %gs so load that 
-	 * XXX: what if userspace program doesnt check this value and tries
-	 * to use 6, 7 or 8? 
+	/*
+	 * We have to copy out the GDT entry we use.
+	 * XXX: What if userspace program does not check return value and
+	 * tries to use 6, 7 or 8?
 	 */
 	idx = info.entry_number = GUGS32_SEL;
 	error = copyout(&info, args->desc, sizeof(struct l_user_desc));


More information about the p4-projects mailing list