Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Aug 2007 15:22:36 GMT
From:      Jesper Brix Rosenkilde <jbr@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125216 for review
Message-ID:  <200708161522.l7GFMa6s080675@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125216

Change 125216 by jbr@jbr_bob on 2007/08/16 15:21:38

	now with wired page

Affected files ...

.. //depot/projects/soc2007/jbr-syscall/src/sys/kern/kern_exec.c#13 edit
.. //depot/projects/soc2007/jbr-syscall/src/sys/sys/imgact.h#3 edit
.. //depot/projects/soc2007/jbr-syscall/src/sys/sys/proc.h#4 edit
.. //depot/projects/soc2007/jbr-syscall/src/sys/vm/vm_map.c#8 edit

Differences ...

==== //depot/projects/soc2007/jbr-syscall/src/sys/kern/kern_exec.c#13 (text+ko) ====

@@ -158,12 +158,12 @@
 #ifdef SCTL_MASK32
 	if (req->flags & SCTL_MASK32) {
 		unsigned int val;
-		val = (unsigned int)p->p_sysshm;
+		val = (unsigned int)p->p_usrsysshm;
 		error = SYSCTL_OUT(req, &val, sizeof(val));
 	} else
 #endif
-		error = SYSCTL_OUT(req, &p->p_sysshm,
-		    sizeof(p->p_sysshm));
+		error = SYSCTL_OUT(req, &p->p_usrsysshm,
+		    sizeof(p->p_usrsysshm));
 	return error;
 }
 
@@ -789,7 +789,7 @@
 	if (imgp->firstpage != NULL)
 		exec_unmap_first_page(imgp);
 
-	if (imgp->sysshm != NULL)
+	if (p->p_kernsysshm != NULL)
 		exec_unmap_sysshm(imgp);
 
 	if (imgp->vp != NULL) {
@@ -914,24 +914,15 @@
      struct image_params *imgp;
 {
 	int error;
+	struct proc *p = imgp->proc;
 	vm_map_t map = &imgp->proc->p_vmspace->vm_map;
-	vm_offset_t *addr = &imgp->proc->p_sysshm;
-/*
-	vm_map_t tmap;
-	vm_object_t object;
-	vm_map_entry_t entry;
-	vm_pindex_t pindex;
-*/
-	if (imgp->sysshm != NULL)
+	vm_offset_t *addr = &imgp->proc->p_usrsysshm;
+
+	if (p->p_kernsysshm != NULL)
 		exec_unmap_sysshm(imgp);
 
 	error = vm_map_sysshm(map, addr, 42);
-/*
-	tmap = map;
-	vm_map_lookup(&tmap, *addr, VM_PROT_READ, &entry, &object, &pindex, NULL, 
-			NULL);
-	vm_map_lookup_done(tmap, entry);
-*/
+
 	return(error);
 }
 

==== //depot/projects/soc2007/jbr-syscall/src/sys/sys/imgact.h#3 (text+ko) ====

@@ -60,7 +60,6 @@
 	char *interpreter_name;	/* name of the interpreter */
 	void *auxargs;		/* ELF Auxinfo structure pointer */
 	struct sf_buf *firstpage;	/* first page that we mapped */
-	struct sf_buf *sysshm;
 	unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */
 	size_t auxarg_size;
 	struct image_args *args;	/* system call arguments */

==== //depot/projects/soc2007/jbr-syscall/src/sys/sys/proc.h#4 (text+ko) ====

@@ -576,7 +576,8 @@
 	void		*p_emuldata;	/* (c) Emulator state data. */
 	struct label	*p_label;	/* (*) Proc (not subject) MAC label. */
 	struct p_sched	*p_sched;	/* (*) Scheduler-specific data. */
-	vm_offset_t	p_sysshm;
+	vm_offset_t	p_usrsysshm;
+	struct sf_buf 	*p_kernsysshm;
 	STAILQ_HEAD(, ktr_request)	p_ktr;	/* (o) KTR event queue. */
 	LIST_HEAD(, mqueue_notifier)	p_mqnotifier; /* (c) mqueue notifiers.*/
 };

==== //depot/projects/soc2007/jbr-syscall/src/sys/vm/vm_map.c#8 (text+ko) ====

@@ -2989,20 +2989,51 @@
 int
 vm_map_sysshm(vm_map_t map, vm_offset_t *addr, vm_size_t size)
 {
-	int error = 0;
+	vm_object_t object;
+	vm_page_t sysshm_page;
 
 	size = round_page(size);
+	PROC_LOCK(curthread->td_proc);
 
-	PROC_LOCK(curthread->td_proc);
 	*addr = round_page((vm_offset_t)
 	    curthread->td_proc->p_vmspace->vm_daddr) +
 	    lim_cur(curthread->td_proc, RLIMIT_DATA);
 	PROC_UNLOCK(curthread->td_proc);
 	
+	/*
 	error = vm_map_find(map, NULL, 0, addr, size, TRUE, VM_PROT_RW,
-			VM_PROT_RW, 0); 
+			VM_PROT_RW, MAP_NOFAULT); 
+	*/
+	
+	object = vm_object_allocate(OBJT_DEFAULT, 1);
+	if (!object)
+		panic("vm_map_sysshm: cannot allocate object");
+	
+	VM_OBJECT_LOCK(object);
+	sysshm_page = vm_page_alloc(object, 0, VM_ALLOC_NORMAL);
+	if (!sysshm_page)
+		panic("vm_page_alloc: cannot allocate sysshm_page");
+
+	sysshm_page->valid = VM_PAGE_BITS_ALL;
+	VM_OBJECT_UNLOCK(object);
+
+	if (vm_map_findspace(map, *addr, size, addr))
+		return (1);
+
+	if (vm_map_insert(map, object, 0, *addr, *addr + size, VM_PROT_RW, 
+			VM_PROT_RW, 0))
+		panic("vm_map_sysshm: cannot insert object into vm_map.");
+
+	pmap_enter(map->pmap, *addr, sysshm_page, VM_PROT_RW, TRUE);
+
+	VM_OBJECT_LOCK(object);
+	vm_page_lock_queues();
+	vm_page_activate(sysshm_page);
+	vm_page_unlock_queues();
+	vm_page_wakeup(sysshm_page);
+	VM_OBJECT_UNLOCK(object);
 
-	return (error);
+	return (0);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708161522.l7GFMa6s080675>