svn commit: r205072 - in head/sys/mips: include mips
Neel Natu
neel at FreeBSD.org
Fri Mar 12 07:08:21 UTC 2010
Author: neel
Date: Fri Mar 12 07:08:20 2010
New Revision: 205072
URL: http://svn.freebsd.org/changeset/base/205072
Log:
- Enable kernel stack guard page.
- Unmap the unused kernel stack page that we cannot use because it is
not aligned on a (PAGE_SIZE * 2) boundary.
Modified:
head/sys/mips/include/param.h
head/sys/mips/mips/vm_machdep.c
Modified: head/sys/mips/include/param.h
==============================================================================
--- head/sys/mips/include/param.h Fri Mar 12 06:57:53 2010 (r205071)
+++ head/sys/mips/include/param.h Fri Mar 12 07:08:20 2010 (r205072)
@@ -128,14 +128,13 @@
#define MAXDUMPPGS 1 /* xxx: why is this only one? */
/*
- * NOTE: In FreeBSD, Uarea's don't have a fixed address.
- * Therefore, any code imported from OpenBSD which depends on
- * UADDR, UVPN and KERNELSTACK requires porting.
- * XXX: 3 stack pages? Not 4 which would be more efficient from a tlb
- * XXX: point of view.
+ * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
+ *
+ * Although we allocate 3 pages for the kernel stack we end up using
+ * only the 2 pages that are aligned on a (PAGE_SIZE * 2) boundary.
*/
#define KSTACK_PAGES 3 /* kernel stack*/
-#define KSTACK_GUARD_PAGES 0 /* pages of kstack guard; 0 disables */
+#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
#define UPAGES 2
Modified: head/sys/mips/mips/vm_machdep.c
==============================================================================
--- head/sys/mips/mips/vm_machdep.c Fri Mar 12 06:57:53 2010 (r205071)
+++ head/sys/mips/mips/vm_machdep.c Fri Mar 12 07:08:20 2010 (r205072)
@@ -214,6 +214,16 @@ cpu_thread_swapin(struct thread *td)
{
pt_entry_t *pte;
int i;
+ vm_offset_t unused_kstack_page;
+
+ /*
+ * Unmap the unused kstack page.
+ */
+ unused_kstack_page = td->td_kstack;
+ if (td->td_md.md_realstack == td->td_kstack)
+ unused_kstack_page += (KSTACK_PAGES - 1) * PAGE_SIZE;
+
+ pmap_kremove(unused_kstack_page);
/*
* The kstack may be at a different physical address now.
@@ -239,13 +249,19 @@ cpu_thread_swapout(struct thread *td)
void
cpu_thread_alloc(struct thread *td)
{
+ vm_offset_t unused_kstack_page;
pt_entry_t *pte;
int i;
- if(td->td_kstack & (1 << PAGE_SHIFT))
+ if (td->td_kstack & (1 << PAGE_SHIFT)) {
td->td_md.md_realstack = td->td_kstack + PAGE_SIZE;
- else
+ unused_kstack_page = td->td_kstack;
+ } else {
td->td_md.md_realstack = td->td_kstack;
+ unused_kstack_page = td->td_kstack +
+ (KSTACK_PAGES - 1) * PAGE_SIZE;
+ }
+ pmap_kremove(unused_kstack_page);
td->td_pcb = (struct pcb *)(td->td_md.md_realstack +
(td->td_kstack_pages - 1) * PAGE_SIZE) - 1;
More information about the svn-src-all
mailing list