summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-08-10 17:18:21 +0000
committerkib <kib@FreeBSD.org>2015-08-10 17:18:21 +0000
commit9033c894a1c694d3e946571d9e57c05349a235eb (patch)
tree6c5e3b30f16040565000131df5f7348a27c34a56 /sys/i386
parent141883cce0cea307fd0365430906181b1954df86 (diff)
downloadFreeBSD-src-9033c894a1c694d3e946571d9e57c05349a235eb.zip
FreeBSD-src-9033c894a1c694d3e946571d9e57c05349a235eb.tar.gz
Make kstack_pages a tunable on arm, x86, and powepc. On i386, the
initial thread stack is not adjusted by the tunable, the stack is allocated too early to get access to the kernel environment. See TD0_KSTACK_PAGES for the thread0 stack sizing on i386. The tunable was tested on x86 only. From the visual inspection, it seems that it might work on arm and powerpc. The arm USPACE_SVC_STACK_TOP and powerpc USPACE macros seems to be already incorrect for the threads with non-default kstack size. I only changed the macros to use variable instead of constant, since I cannot test. On arm64, mips and sparc64, some static data structures are sized by KSTACK_PAGES, so the tunable is disabled. Sponsored by: The FreeBSD Foundation MFC after: 2 week
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/genassym.c2
-rw-r--r--sys/i386/i386/mp_machdep.c5
-rw-r--r--sys/i386/i386/sys_machdep.c2
3 files changed, 4 insertions, 5 deletions
diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index 6a00d23..3087834 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -101,8 +101,6 @@ ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
-/* ASSYM(UPAGES, UPAGES);*/
-ASSYM(KSTACK_PAGES, KSTACK_PAGES);
ASSYM(TD0_KSTACK_PAGES, TD0_KSTACK_PAGES);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(NPTEPG, NPTEPG);
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index 0942523..4812cb0 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -348,7 +348,7 @@ start_all_aps(void)
/* allocate and set up a boot stack data page */
bootstacks[cpu] =
- (char *)kmem_malloc(kernel_arena, KSTACK_PAGES * PAGE_SIZE,
+ (char *)kmem_malloc(kernel_arena, kstack_pages * PAGE_SIZE,
M_WAITOK | M_ZERO);
dpcpu = (void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
M_WAITOK | M_ZERO);
@@ -360,7 +360,8 @@ start_all_aps(void)
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
#endif
- bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 4;
+ bootSTK = (char *)bootstacks[cpu] + kstack_pages *
+ PAGE_SIZE - 4;
bootAP = cpu;
/* attempt to start the Application Processor */
diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c
index 0928b72..dc367a6 100644
--- a/sys/i386/i386/sys_machdep.c
+++ b/sys/i386/i386/sys_machdep.c
@@ -275,7 +275,7 @@ i386_extend_pcb(struct thread *td)
ext = (struct pcb_ext *)kmem_malloc(kernel_arena, ctob(IOPAGES+1),
M_WAITOK | M_ZERO);
/* -16 is so we can convert a trapframe into vm86trapframe inplace */
- ext->ext_tss.tss_esp0 = td->td_kstack + ctob(KSTACK_PAGES) -
+ ext->ext_tss.tss_esp0 = td->td_kstack + ctob(td->td_kstack_pages) -
sizeof(struct pcb) - 16;
ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
/*
OpenPOWER on IntegriCloud