aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNeel Natu <neel@FreeBSD.org>2010-03-12 07:08:20 +0000
committerNeel Natu <neel@FreeBSD.org>2010-03-12 07:08:20 +0000
commit28b49236be5ca2e2aee1f49f84406a6723af62fc (patch)
treeef2aebdb13e786c83b9adf700122b5f4f7060605 /sys
parent4af997a87fe5082e60a1a65537a3fd51cb845efa (diff)
downloadsrc-28b49236be5ca2e2aee1f49f84406a6723af62fc.tar.gz
src-28b49236be5ca2e2aee1f49f84406a6723af62fc.zip
- 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.
Notes
Notes: svn path=/head/; revision=205072
Diffstat (limited to 'sys')
-rw-r--r--sys/mips/include/param.h11
-rw-r--r--sys/mips/mips/vm_machdep.c20
2 files changed, 23 insertions, 8 deletions
diff --git a/sys/mips/include/param.h b/sys/mips/include/param.h
index 8edd48ece16a..9d487022439b 100644
--- a/sys/mips/include/param.h
+++ b/sys/mips/include/param.h
@@ -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
diff --git a/sys/mips/mips/vm_machdep.c b/sys/mips/mips/vm_machdep.c
index f76dc4d74f0a..3f8e6cc7f29a 100644
--- a/sys/mips/mips/vm_machdep.c
+++ b/sys/mips/mips/vm_machdep.c
@@ -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;