Module Name:    src
Committed By:   dsl
Date:           Sat Jun 16 20:47:04 UTC 2012

Modified Files:
        src/sys/arch/amd64/amd64: machdep.c
        src/sys/arch/amd64/include: segments.h

Log Message:
memseg_baseaddr() is only called from valid_user_selector() and
both only locally.
Make static, remove one of the functions, and remove the never-set args.
Code is still very dubious.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/segments.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.185 src/sys/arch/amd64/amd64/machdep.c:1.186
--- src/sys/arch/amd64/amd64/machdep.c:1.185	Sat Jun 16 16:42:26 2012
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Jun 16 20:47:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 2012/06/16 16:42:26 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -332,6 +332,8 @@ int dumpsys_seg(paddr_t, paddr_t);
 
 void	init_x86_64(paddr_t);
 
+static int valid_user_selector(struct lwp *, uint64_t);
+
 /*
  * Machine-dependent startup code
  */
@@ -2093,28 +2095,28 @@ cpu_mcontext_validate(struct lwp *l, con
 		return EINVAL;
 
 	if (__predict_false(pmap->pm_ldt != NULL)) {
-		error = valid_user_selector(l, gr[_REG_ES], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_ES]);
 		if (error != 0)
 			return error;
 
-		error = valid_user_selector(l, gr[_REG_FS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_FS]);
 		if (error != 0)
 			return error;
 
-		error = valid_user_selector(l, gr[_REG_GS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_GS]);
 		if (error != 0)
 			return error;
 
 		if ((gr[_REG_DS] & 0xffff) == 0)
 			return EINVAL;
-		error = valid_user_selector(l, gr[_REG_DS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_DS]);
 		if (error != 0)
 			return error;
 
 #ifndef XEN
 		if ((gr[_REG_SS] & 0xffff) == 0)
 			return EINVAL;
-		error = valid_user_selector(l, gr[_REG_SS], NULL, 0);
+		error = valid_user_selector(l, gr[_REG_SS]);
 		if (error != 0)
 			return error;
 #endif
@@ -2169,9 +2171,8 @@ cpu_initclocks(void)
 	(*initclock_func)();
 }
 
-int
-memseg_baseaddr(struct lwp *l, uint64_t seg, char *ldtp, int llen,
-		uint64_t *addr)
+static int
+valid_user_selector(struct lwp *l, uint64_t seg)
 {
 	int off, len;
 	char *dt;
@@ -2182,18 +2183,12 @@ memseg_baseaddr(struct lwp *l, uint64_t 
 
 	seg &= 0xffff;
 
-	if (seg == 0) {
-		if (addr != NULL)
-			*addr = 0;
+	if (seg == 0)
 		return 0;
-	}
 
 	off = (seg & 0xfff8);
 	if (seg & SEL_LDT) {
-		if (ldtp != NULL) {
-			dt = ldtp;
-			len = llen;
-		} else if (pmap->pm_ldt != NULL) {
+		if (pmap->pm_ldt != NULL) {
 			len = pmap->pm_ldt_len; /* XXX broken */
 			dt = (char *)pmap->pm_ldt;
 		} else {
@@ -2220,21 +2215,10 @@ memseg_baseaddr(struct lwp *l, uint64_t 
 	if (base >= VM_MAXUSER_ADDRESS)
 		return EINVAL;
 
-	if (addr == NULL)
-		return 0;
-
-	*addr = base;
-
 	return 0;
 }
 
 int
-valid_user_selector(struct lwp *l, uint64_t seg, char *ldtp, int len)
-{
-	return memseg_baseaddr(l, seg, ldtp, len, NULL);
-}
-
-int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
 	extern int start, __data_start;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.22 src/sys/arch/amd64/include/segments.h:1.23
--- src/sys/arch/amd64/include/segments.h:1.22	Mon Feb  7 03:54:45 2011
+++ src/sys/arch/amd64/include/segments.h	Sat Jun 16 20:47:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.22 2011/02/07 03:54:45 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.23 2012/06/16 20:47:04 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -256,8 +256,6 @@ void idt_vec_free(int);
 #endif
 
 struct lwp;
-int memseg_baseaddr(struct lwp *, uint64_t, char *, int, uint64_t *);
-int valid_user_selector(struct lwp *, uint64_t, char *, int);
 void cpu_fsgs_zero(struct lwp *);
 void cpu_fsgs_reload(struct lwp *, int, int);
 

Reply via email to