Index: arm/arm/cpufunc_asm_armv7.S =================================================================== --- arm/arm/cpufunc_asm_armv7.S (revision 255900) +++ arm/arm/cpufunc_asm_armv7.S (working copy) @@ -57,9 +57,9 @@ #define PT_OUTER_WBWA (1 << 3) #ifdef SMP -#define PT_ATTR (PT_S|PT_INNER_WT|PT_OUTER_WT|PT_NOS) +#define PT_ATTR (PT_S|PT_INNER_WBWA|PT_OUTER_WBWA|PT_NOS) #else -#define PT_ATTR (PT_INNER_WT|PT_OUTER_WT) +#define PT_ATTR (PT_INNER_WBWA|PT_OUTER_WBWA) #endif ENTRY(armv7_setttb) @@ -98,7 +98,7 @@ ldr r1, .Lpage_mask bic r0, r0, r1 #ifdef SMP - mcr p15, 0, r0, c8, c3, 1 /* flush D tlb single entry Inner Shareable*/ + mcr p15, 0, r0, c8, c3, 3 /* flush D tlb single entry Inner Shareable*/ mcr p15, 0, r0, c7, c1, 6 /* flush BTB Inner Shareable */ #else mcr p15, 0, r0, c8, c7, 1 /* flush D tlb single entry */ @@ -113,6 +113,7 @@ ENTRY(armv7_dcache_wbinv_all) stmdb sp!, {r4, r5, r6, r7, r8, r9} + dsb /* Get cache level */ ldr r0, .Lcoherency_level ldr r3, [r0] @@ -188,6 +189,7 @@ and r2, r0, r3 add r1, r1, r2 bic r0, r0, r3 + dsb .Larmv7_wb_next: mcr p15, 0, r0, c7, c10, 1 /* Clean D cache SE with VA */ add r0, r0, ip @@ -203,6 +205,7 @@ and r2, r0, r3 add r1, r1, r2 bic r0, r0, r3 + dsb .Larmv7_wbinv_next: mcr p15, 0, r0, c7, c14, 1 /* Purge D cache SE with VA */ add r0, r0, ip @@ -222,6 +225,7 @@ and r2, r0, r3 add r1, r1, r2 bic r0, r0, r3 + dsb .Larmv7_inv_next: mcr p15, 0, r0, c7, c6, 1 /* Invalidate D cache SE with VA */ add r0, r0, ip @@ -237,6 +241,7 @@ and r2, r0, r3 add r1, r1, r2 bic r0, r0, r3 + dsb .Larmv7_id_wbinv_next: mcr p15, 0, r0, c7, c5, 1 /* Invalidate I cache SE with VA */ mcr p15, 0, r0, c7, c14, 1 /* Purge D cache SE with VA */ Index: arm/arm/copystr.S =================================================================== --- arm/arm/copystr.S (revision 255900) +++ arm/arm/copystr.S (working copy) @@ -51,14 +51,12 @@ .align 0 #ifdef _ARM_ARCH_6 -#define GET_PCB(tmp) \ - mrc p15, 0, tmp, c13, c0, 4; \ - add tmp, tmp, #(PC_CURPCB) +KSTACK_LOCALS #else .Lpcb: .word _C_LABEL(__pcpu) + PC_CURPCB -#define GET_PCB(tmp) \ +#define GET_PCB(tmp, tmp2) \ ldr tmp, .Lpcb #endif @@ -114,8 +112,7 @@ moveq r0, #ENAMETOOLONG beq 2f - GET_PCB(r4) - ldr r4, [r4] + GET_PCB(r4, r5) #ifdef DIAGNOSTIC teq r4, #0x00000000 @@ -162,8 +159,7 @@ moveq r0, #ENAMETOOLONG beq 2f - GET_PCB(r4) - ldr r4, [r4] + GET_PCB(r4, r5) #ifdef DIAGNOSTIC teq r4, #0x00000000 Index: arm/arm/genassym.c =================================================================== --- arm/arm/genassym.c (revision 255900) +++ arm/arm/genassym.c (working copy) @@ -25,6 +25,8 @@ * */ +#include "opt_kstack_max_pages.h" + #include __FBSDID("$FreeBSD$"); #include @@ -69,6 +71,7 @@ ASSYM(PCB_R12, offsetof(struct pcb, un_32.pcb32_r12)); ASSYM(PCB_PC, offsetof(struct pcb, un_32.pcb32_pc)); ASSYM(PCB_SP, offsetof(struct pcb, un_32.pcb32_sp)); +ASSYM(PCB_CURTHREAD, offsetof(struct pcb, un_32.pcb32_curthread)); ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); @@ -138,3 +141,6 @@ ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(NIRQ, NIRQ); + +ASSYM(KSTACK_ADDR_MASK, KSTACK_MAX_PAGES * PAGE_SIZE - 1); +ASSYM(KSTACK_PCB_ADDR, KSTACK_MAX_PAGES * PAGE_SIZE - sizeof(struct pcb)); Index: arm/arm/mp_machdep.c =================================================================== --- arm/arm/mp_machdep.c (revision 255900) +++ arm/arm/mp_machdep.c (working copy) @@ -161,12 +161,13 @@ } extern vm_paddr_t pmap_pa; + +void init_secondary_finish(void); + void init_secondary(int cpu) { struct pcpu *pc; - uint32_t loop_counter; - int start = 0, end = 0; cpu_setup(NULL); setttb(pmap_pa); @@ -196,7 +197,6 @@ ; /* Initialize curthread */ - KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); pc->pc_curthread = pc->pc_idlethread; pc->pc_curpcb = pc->pc_idlethread->td_pcb; #ifdef VFP @@ -204,7 +204,16 @@ vfp_init(); #endif + __asm __volatile("mov sp, %0\n" + "b init_secondary_finish\n" : : "r" (pc->pc_idlethread->td_pcb->un_32.pcb32_sp)); +} +void +init_secondary_finish(void) +{ + int start = 0, end = 0; + uint32_t loop_counter; + mtx_lock_spin(&ap_boot_mtx); atomic_add_rel_32(&smp_cpus, 1); Index: arm/arm/machdep.c =================================================================== --- arm/arm/machdep.c (revision 255900) +++ arm/arm/machdep.c (working copy) @@ -42,6 +42,7 @@ * Updated : 18/04/01 updated for new wscons */ +#include "opt_kstack_max_pages.h" #include "opt_compat.h" #include "opt_ddb.h" #include "opt_platform.h" @@ -106,6 +107,7 @@ #include #endif +#define DEBUG #ifdef DEBUG #define debugf(fmt, args...) printf(fmt, ##args) #else @@ -874,9 +876,9 @@ set_pcpu(pcpup); #endif pcpu_init(pcpup, 0, sizeof(struct pcpu)); - PCPU_SET(curthread, &thread0); + pcpup->pc_curthread = &thread0; #ifdef VFP - PCPU_SET(cpu, 0); + pcpup->pc_cpu = 0; #endif } @@ -1027,7 +1029,9 @@ thread0.td_kstack = kstack; thread0.td_pcb = (struct pcb *) (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + printf("KSTACK IS %p PCB IS %p\n", (void *)thread0.td_kstack, thread0.td_pcb); thread0.td_pcb->pcb_flags = 0; + thread0.td_pcb->un_32.pcb32_curthread = &thread0; thread0.td_frame = &proc0_tf; pcpup->pc_curpcb = thread0.td_pcb; } @@ -1181,6 +1185,12 @@ phys_avail[j + 1] = 0; } +void do_putc(char); +void do_putc(char c) +{ + *(volatile char *)0x48020000 = c; +} + void * initarm(struct arm_boot_params *abp) { @@ -1232,8 +1242,10 @@ /* Grab physical memory regions information from device tree. */ if (fdt_get_mem_regions(memory_regions, &memory_regions_sz, - &memsize) != 0) + &memsize) != 0) { + do_putc('a'); while(1); + } /* Grab physical memory regions information from device tree. */ if (fdt_get_reserved_regions(reserved_regions, &reserved_regions_sz) != 0) @@ -1364,8 +1376,19 @@ valloc_pages(irqstack, IRQ_STACK_SIZE * MAXCPU); valloc_pages(abtstack, ABT_STACK_SIZE * MAXCPU); valloc_pages(undstack, UND_STACK_SIZE * MAXCPU); - valloc_pages(kernelstack, KSTACK_PAGES * MAXCPU); valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE); + if ((KSTACK_MAX_PAGES * PAGE_SIZE) - + (freemempos & (KSTACK_MAX_MASK)) >= KSTACK_PAGES) + freemempos = (freemempos &~ KSTACK_MAX_MASK) + + (KSTACK_MAX_PAGES * PAGE_SIZE) - + (KSTACK_PAGES * PAGE_SIZE); + + else + freemempos = (freemempos &~ KSTACK_MAX_MASK) + + 2 * (KSTACK_MAX_PAGES * PAGE_SIZE) - + (KSTACK_PAGES * PAGE_SIZE); + + valloc_pages(kernelstack, KSTACK_PAGES); /* * Now we start construction of the L1 page table @@ -1486,12 +1509,15 @@ init_proc0(kernelstack.pv_va); arm_intrnames_init(); + printf("hoho\n"); arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL); + printf("hehe\n"); arm_dump_avail_init(memsize, sizeof(dump_avail) / sizeof(dump_avail[0])); + printf("plop\n"); pmap_bootstrap(freemempos, &kernel_l1pt); + printf("unplop\n"); msgbufp = (void *)msgbufpv.pv_va; - msgbufinit(msgbufp, msgbufsize); - mutex_init(); + printf("hophp\n"); /* * Prepare map of physical memory regions available to vm subsystem. @@ -1500,8 +1526,9 @@ init_param2(physmem); kdb_init(); + msgbufinit(msgbufp, msgbufsize); - return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP - - sizeof(struct pcb))); + return ((void *)((kernelstack.pv_va + USPACE_SVC_STACK_TOP - + sizeof(struct pcb)) &~ 7)); } #endif Index: arm/arm/fusu.S =================================================================== --- arm/arm/fusu.S (revision 255900) +++ arm/arm/fusu.S (working copy) @@ -40,14 +40,13 @@ __FBSDID("$FreeBSD$"); #ifdef _ARM_ARCH_6 -#define GET_PCB(tmp) \ - mrc p15, 0, tmp, c13, c0, 4; \ - add tmp, tmp, #(PC_CURPCB) +KSTACK_LOCALS #else .Lcurpcb: .word _C_LABEL(__pcpu) + PC_CURPCB -#define GET_PCB(tmp) \ - ldr tmp, .Lcurpcb +#define GET_PCB(tmp, tmp2) \ + ldr tmp, .Lcurpcb; \ + ldr tmp, [tmp] #endif /* @@ -57,21 +56,28 @@ ENTRY_NP(casuword32) ENTRY(casuword) - GET_PCB(r3) - ldr r3, [r3] - -#ifdef DIAGNOSTIC - teq r3, #0x00000000 - beq .Lfusupcbfault -#endif stmfd sp!, {r4, r5} + GET_PCB(r3, r4) + adr r4, .Lcasuwordfault str r4, [r3, #PCB_ONFAULT] +#ifdef _ARM_ARCH_6 +1: + ldrex r5, [r0] + cmp r5, r1 + movne r0, r5 + bne 2f + strex r5, r2, [r0] + cmp r5, #0 + bne 1b +#else ldrt r5, [r0] cmp r5, r1 movne r0, r5 streqt r2, [r0] +#endif moveq r0, r1 +2: ldmfd sp!, {r4, r5} mov r1, #0x00000000 str r1, [r3, #PCB_ONFAULT] @@ -97,14 +103,8 @@ ENTRY_NP(fuword32) ENTRY(fuword) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r1, .Lfusufault str r1, [r2, #PCB_ONFAULT] @@ -123,14 +123,8 @@ */ ENTRY(fusword) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r1, .Lfusufault str r1, [r2, #PCB_ONFAULT] @@ -159,14 +153,8 @@ mvnne r0, #0x00000000 RETne - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r1, _C_LABEL(fusubailout) str r1, [r2, #PCB_ONFAULT] @@ -199,14 +187,8 @@ */ ENTRY(fubyte) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r1, .Lfusufault str r1, [r2, #PCB_ONFAULT] @@ -242,36 +224,15 @@ mvn r0, #0x00000000 RET -#ifdef DIAGNOSTIC /* - * Handle earlier faults from [fs]u*(), due to no pcb - */ - -.Lfusupcbfault: - mov r1, r0 - adr r0, fusupcbfaulttext - b _C_LABEL(panic) - -fusupcbfaulttext: - .asciz "Yikes - no valid PCB during fusuxxx() addr=%08x\n" - .align 0 -#endif - -/* * suword(caddr_t uaddr, int x); * Store an int in the user's address space. */ ENTRY_NP(suword32) ENTRY(suword) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r3, .Lfusufault str r3, [r2, #PCB_ONFAULT] @@ -296,14 +257,8 @@ mvnne r0, #0x00000000 RETne - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r3, _C_LABEL(fusubailout) str r3, [r2, #PCB_ONFAULT] @@ -327,14 +282,8 @@ */ ENTRY(susword) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r3, .Lfusufault str r3, [r2, #PCB_ONFAULT] @@ -358,15 +307,8 @@ */ ENTRY(subyte) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) - -#ifdef DIAGNOSTIC - teq r2, #0x00000000 - beq .Lfusupcbfault -#endif - adr r3, .Lfusufault str r3, [r2, #PCB_ONFAULT] Index: arm/arm/swtch.S =================================================================== --- arm/arm/swtch.S (revision 255900) +++ arm/arm/swtch.S (working copy) @@ -192,8 +192,9 @@ #endif /* We have a new curthread now so make a note it */ - GET_CURTHREAD_PTR(r6) + GET_PCPU_CURTHREAD_PTR(r6) str r5, [r6] + clrex /* Set the new tp */ ldr r6, [r5, #(TD_MD + MD_TP)] @@ -231,8 +232,9 @@ /* Process is now on a processor. */ /* We have a new curthread now so make a note it */ - GET_CURTHREAD_PTR(r7) + GET_PCPU_CURTHREAD_PTR(r7) str r1, [r7] + clrex /* Hook in a new pcb */ GET_PCPU(r7) @@ -439,7 +441,11 @@ str r6, [r4, #TD_LOCK] #if defined(SCHED_ULE) && defined(SMP) ldr r6, .Lblocked_lock - GET_CURTHREAD_PTR(r3) + /* + * It's fine to use GET_PCPU_CURTHREAD_PTR here, because interrupts + * are disabled, so it will be atomic. + */ + GET_PCPU_CURTHREAD_PTR(r3) 1: ldr r4, [r3, #TD_LOCK] Index: arm/arm/bcopyinout.S =================================================================== --- arm/arm/bcopyinout.S (revision 255900) +++ arm/arm/bcopyinout.S (working copy) @@ -39,6 +39,7 @@ #include "assym.s" #include +#include #include .L_arm_memcpy: @@ -55,14 +56,12 @@ .align 0 #ifdef _ARM_ARCH_6 -#define GET_PCB(tmp) \ - mrc p15, 0, tmp, c13, c0, 4; \ - add tmp, tmp, #(PC_CURPCB) +KSTACK_LOCALS #else .Lcurpcb: .word _C_LABEL(__pcpu) + PC_CURPCB -#define GET_PCB(tmp) \ +#define GET_PCB(tmp, tmp2) \ ldr tmp, .Lcurpcb #endif @@ -116,8 +115,7 @@ .Lnormal: SAVE_REGS - GET_PCB(r4) - ldr r4, [r4] + GET_PCB(r4, r5) ldr r5, [r4, #PCB_ONFAULT] @@ -354,8 +352,7 @@ .Lnormale: SAVE_REGS - GET_PCB(r4) - ldr r4, [r4] + GET_PCB(r4, r5) ldr r5, [r4, #PCB_ONFAULT] adr r3, .Lcopyfault @@ -549,8 +546,7 @@ * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_1) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f @@ -575,8 +571,7 @@ * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_2) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f @@ -601,8 +596,7 @@ * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_4) - GET_PCB(r2) - ldr r2, [r2] + GET_PCB(r2, r3) ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f Index: arm/arm/pmap-v6.c =================================================================== --- arm/arm/pmap-v6.c (revision 255900) +++ arm/arm/pmap-v6.c (working copy) @@ -681,6 +681,7 @@ /* * Returns a pointer to the L2 bucket associated with the specified pmap + M * and VA. * * If no L2 bucket exists, perform the necessary allocations to put an L2 @@ -1815,6 +1816,7 @@ virtual_avail = firstaddr; kernel_pmap->pm_l1 = l1; kernel_l1pa = l1pt->pv_pa; + printf("POUET\n"); /* * Scan the L1 translation table created by initarm() and create @@ -1889,6 +1891,7 @@ "L2 pte @ %p\n", ptep); } } + printf("ca c'est fait\n"); /* @@ -1902,15 +1905,18 @@ "primary L1 @ 0x%x\n", va); } + printf("avant lol\n"); cpu_dcache_wbinv_all(); cpu_l2cache_wbinv_all(); cpu_tlb_flushID(); cpu_cpwait(); + printf("hehe\n"); PMAP_LOCK_INIT(kernel_pmap); CPU_FILL(&kernel_pmap->pm_active); kernel_pmap->pm_domain = PMAP_DOMAIN_KERNEL; TAILQ_INIT(&kernel_pmap->pm_pvchunk); + printf("prout\n"); /* * Initialize the global pv list lock. @@ -1921,6 +1927,7 @@ * Reserve some special page table entries/VA space for temporary * mapping of pages. */ + printf("languidegui\n"); pmap_alloc_specials(&virtual_avail, 1, &csrcp, &csrc_pte); pmap_set_pt_cache_mode(kernel_l1pt, (vm_offset_t)csrc_pte); @@ -1941,18 +1948,24 @@ 1, (vm_offset_t*)&_tmppt, NULL); pmap_alloc_specials(&virtual_avail, MAXDUMPPGS, (vm_offset_t *)&crashdumpmap, NULL); + printf("ouin ouin\n"); SLIST_INIT(&l1_list); TAILQ_INIT(&l1_lru_list); + printf("lala\n"); mtx_init(&l1_lru_lock, "l1 list lock", NULL, MTX_DEF); + printf("loulou\n"); pmap_init_l1(l1, kernel_l1pt); + printf("pouic\n"); cpu_dcache_wbinv_all(); cpu_l2cache_wbinv_all(); + printf("plounch\n"); virtual_avail = round_page(virtual_avail); virtual_end = vm_max_kernel_address; kernel_vm_end = pmap_curmaxkvaddr; arm_nocache_startaddr = vm_max_kernel_address; mtx_init(&cmtx, "TMP mappings mtx", NULL, MTX_DEF); + printf("roflou\n"); pmap_set_pcb_pagedir(kernel_pmap, thread0.td_pcb); } @@ -1976,7 +1989,7 @@ cpu_tlb_flushID(); cpu_cpwait(); if (vector_page < KERNBASE) { - struct pcb *curpcb = PCPU_GET(curpcb); + struct pcb *_curpcb = curpcb; pcb = thread0.td_pcb; if (pmap_is_current(pmap)) { /* @@ -1996,10 +2009,10 @@ * Make sure cpu_switch(), et al, DTRT. This is safe to do * since this process has no remaining mappings of its own. */ - curpcb->pcb_pl1vec = pcb->pcb_pl1vec; - curpcb->pcb_l1vec = pcb->pcb_l1vec; - curpcb->pcb_dacr = pcb->pcb_dacr; - curpcb->pcb_pagedir = pcb->pcb_pagedir; + _curpcb->pcb_pl1vec = pcb->pcb_pl1vec; + _curpcb->pcb_l1vec = pcb->pcb_l1vec; + _curpcb->pcb_dacr = pcb->pcb_dacr; + _curpcb->pcb_pagedir = pcb->pcb_pagedir; } pmap_free_l1(pmap); @@ -2441,6 +2454,8 @@ pmap_kextract(vm_offset_t va) { + if (kernel_vm_end == 0) + return (0); return (pmap_extract_locked(kernel_pmap, va)); } @@ -3295,9 +3310,11 @@ { vm_paddr_t pa; - PMAP_LOCK(pmap); + if (kernel_vm_end != 0) + PMAP_LOCK(pmap); pa = pmap_extract_locked(pmap, va); - PMAP_UNLOCK(pmap); + if (kernel_vm_end != 0) + PMAP_UNLOCK(pmap); return (pa); } @@ -3310,7 +3327,7 @@ vm_paddr_t pa; u_int l1idx; - if (pmap != kernel_pmap) + if (kernel_vm_end != 0 && pmap != kernel_pmap) PMAP_ASSERT_LOCKED(pmap); l1idx = L1_IDX(va); l1pd = pmap->pm_l1->l1_kva[l1idx]; Index: arm/arm/vm_machdep.c =================================================================== --- arm/arm/vm_machdep.c (revision 255900) +++ arm/arm/vm_machdep.c (working copy) @@ -144,11 +144,12 @@ #endif td2->td_pcb = pcb2; bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); + pcb2->un_32.pcb32_curthread = td2; mdp2 = &p2->p_md; bcopy(&td1->td_proc->p_md, mdp2, sizeof(*mdp2)); pcb2->un_32.pcb32_und_sp = td2->td_kstack + USPACE_UNDEF_STACK_TOP; - pcb2->un_32.pcb32_sp = td2->td_kstack + - USPACE_SVC_STACK_TOP - sizeof(*pcb2); + pcb2->un_32.pcb32_sp = (td2->td_kstack + + USPACE_SVC_STACK_TOP - sizeof(*pcb2)) &~ 7; pmap_activate(td2); td2->td_frame = tf = (struct trapframe *)STACKALIGN( pcb2->un_32.pcb32_sp - sizeof(struct trapframe)); @@ -161,6 +162,8 @@ tf->tf_r0 = 0; tf->tf_r1 = 0; pcb2->un_32.pcb32_sp = (u_int)sf; + if (pcb2->un_32.pcb32_sp & 7) + panic("bordel"); KASSERT((pcb2->un_32.pcb32_sp & 7) == 0, ("cpu_fork: Incorrect stack alignment")); @@ -357,6 +360,7 @@ bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); bcopy(td0->td_pcb, td->td_pcb, sizeof(struct pcb)); + td->td_pcb->un_32.pcb32_curthread = td; tf = td->td_frame; sf = (struct switchframe *)tf - 1; sf->sf_r4 = (u_int)fork_return; @@ -366,6 +370,8 @@ tf->tf_r0 = 0; td->td_pcb->un_32.pcb32_sp = (u_int)sf; td->td_pcb->un_32.pcb32_und_sp = td->td_kstack + USPACE_UNDEF_STACK_TOP; + if (td->td_pcb->un_32.pcb32_sp & 7) + panic("roflou"); KASSERT((td->td_pcb->un_32.pcb32_sp & 7) == 0, ("cpu_set_upcall: Incorrect stack alignment")); @@ -419,6 +425,7 @@ { td->td_pcb = (struct pcb *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE) - 1; + td->td_pcb->un_32.pcb32_curthread = td; /* * Ensure td_frame is aligned to an 8 byte boundary as it will be * placed into the stack pointer which must be 8 byte aligned in @@ -461,6 +468,8 @@ sf->sf_r4 = (u_int)func; sf->sf_r5 = (u_int)arg; td->td_pcb->un_32.pcb32_sp = (u_int)sf; + if (td->td_pcb->un_32.pcb32_sp & 7) + panic("mouarf"); KASSERT((td->td_pcb->un_32.pcb32_sp & 7) == 0, ("cpu_set_fork_handler: Incorrect stack alignment")); } Index: arm/arm/cpufunc.c =================================================================== --- arm/arm/cpufunc.c (revision 255900) +++ arm/arm/cpufunc.c (working copy) @@ -1116,10 +1116,10 @@ armv7_tlb_flushID, /* tlb_flushID */ armv7_tlb_flushID_SE, /* tlb_flushID_SE */ - arm11_tlb_flushI, /* tlb_flushI */ - arm11_tlb_flushI_SE, /* tlb_flushI_SE */ - arm11_tlb_flushD, /* tlb_flushD */ - arm11_tlb_flushD_SE, /* tlb_flushD_SE */ + armv7_tlb_flushID, /* tlb_flushI */ + armv7_tlb_flushID_SE, /* tlb_flushI_SE */ + armv7_tlb_flushID, /* tlb_flushD */ + armv7_tlb_flushID_SE, /* tlb_flushD_SE */ /* Cache operations */ @@ -2550,6 +2550,7 @@ /* Clear out the cache */ cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); /* Set the control register */ ctrl = cpuctrl; @@ -2557,6 +2558,7 @@ /* And again. */ cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); #ifdef SMP armv7_auxctrl((1 << 6) | (1 << 0), (1 << 6) | (1 << 0)); /* Enable SMP + TLB broadcasting */ #endif Index: arm/arm/db_trace.c =================================================================== --- arm/arm/db_trace.c (revision 255900) +++ arm/arm/db_trace.c (working copy) @@ -200,8 +200,10 @@ int update_vsp = 0; /* This should never happen */ - if (state->entries == 0) + if (state->entries == 0) { + printf("ptdr\n"); return 1; + } /* Read the next instruction */ insn = db_unwind_exec_read_byte(state); @@ -220,8 +222,10 @@ mask |= (insn & INSN_STD_DATA_MASK) << 8; /* We have a refuse to unwind instruction */ - if (mask == 0) + if (mask == 0) { + printf("OUIN\n"); return 1; + } /* Update SP */ update_vsp = 1; @@ -273,8 +277,10 @@ unsigned int mask, reg; mask = db_unwind_exec_read_byte(state); - if (mask == 0 || (mask & 0xf0) != 0) + if (mask == 0 || (mask & 0xf0) != 0) { + printf("pwned\n"); return 1; + } /* Update SP */ update_vsp = 1; @@ -439,7 +445,8 @@ db_printf("Unable to unwind further\n"); finished = true; } else if (state->registers[PC] < VM_MIN_KERNEL_ADDRESS) { - db_printf("Unable to unwind into user mode\n"); + db_printf("Unable to unwind into user mode %x\n", + state->registers[PC]); finished = true; } else if (state->update_mask == 0) { db_printf("Unwind failure (no registers changed)\n"); Index: arm/arm/vfp.c =================================================================== --- arm/arm/vfp.c (revision 255900) +++ arm/arm/vfp.c (working copy) @@ -182,7 +182,7 @@ #ifdef SMP curpcb->pcb_vfpcpu = PCPU_GET(cpu); #endif - PCPU_SET(vfpcthread, PCPU_GET(curthread)); + PCPU_SET(vfpcthread, curthread); return 0; } @@ -217,7 +217,7 @@ "ldr %0, [%1]\n" /* set old vfpscr */ "mcr p10, 7, %0, cr1, c0, 0\n" : "=&r" (vfpscr) : "r" (vfpsave), "r" (is_d32) : "cc"); - PCPU_SET(vfpcthread, PCPU_GET(curthread)); + PCPU_SET(vfpcthread, curthread); } } Index: arm/arm/pmap.c =================================================================== --- arm/arm/pmap.c (revision 255900) +++ arm/arm/pmap.c (working copy) @@ -2452,7 +2452,7 @@ pmap_tlb_flushID(pmap); cpu_cpwait(); if (vector_page < KERNBASE) { - struct pcb *curpcb = PCPU_GET(curpcb); + struct pcb *_curpcb = curpcb; pcb = thread0.td_pcb; if (pmap_is_current(pmap)) { /* @@ -2472,10 +2472,10 @@ * Make sure cpu_switch(), et al, DTRT. This is safe to do * since this process has no remaining mappings of its own. */ - curpcb->pcb_pl1vec = pcb->pcb_pl1vec; - curpcb->pcb_l1vec = pcb->pcb_l1vec; - curpcb->pcb_dacr = pcb->pcb_dacr; - curpcb->pcb_pagedir = pcb->pcb_pagedir; + _curpcb->pcb_pl1vec = pcb->pcb_pl1vec; + _curpcb->pcb_l1vec = pcb->pcb_l1vec; + _curpcb->pcb_dacr = pcb->pcb_dacr; + _curpcb->pcb_pagedir = pcb->pcb_pagedir; } pmap_free_l1(pmap); Index: arm/arm/locore.S =================================================================== --- arm/arm/locore.S (revision 255900) +++ arm/arm/locore.S (working copy) @@ -226,6 +226,7 @@ /* init arm will return the new stack pointer. */ mov sp, r0 + bl _C_LABEL(mutex_init) bl _C_LABEL(mi_startup) /* call mi_startup()! */ adr r0, .Lmainreturned @@ -261,6 +262,7 @@ MMU_INIT(PHYSADDR, PHYSADDR , 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) /* map VA 0xc0000000..0xc3ffffff to PA */ MMU_INIT(KERNBASE, PHYSADDR, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW)) + MMU_INIT(0x48000000, 0x48000000, 1, L1_TYPE_S|L1_SHARED|L1_S_C|L1_S_AP(AP_KRW)) #else MMU_INIT(PHYSADDR, PHYSADDR , 64, L1_TYPE_S|L1_SHARED|L1_S_C|L1_S_AP(AP_KRW)) /* map VA 0xc0000000..0xc3ffffff to PA */ Index: arm/arm/trap.c =================================================================== --- arm/arm/trap.c (revision 255900) +++ arm/arm/trap.c (working copy) @@ -244,6 +244,7 @@ far = cpu_faultaddress(); fsr = cpu_faultstatus(); #if 0 + if (far > 0xc0000000) printf("data abort: fault address=%p (from pc=%p lr=%p)\n", (void*)far, (void*)tf->tf_pc, (void*)tf->tf_svc_lr); #endif Index: arm/arm/bcopyinout_xscale.S =================================================================== --- arm/arm/bcopyinout_xscale.S (revision 255900) +++ arm/arm/bcopyinout_xscale.S (working copy) @@ -42,13 +42,11 @@ .align 0 #ifdef _ARM_ARCH_6 -#define GET_PCB(tmp) \ - mrc p15, 0, tmp, c13, c0, 4; \ - add tmp, tmp, #(PC_CURPCB) +KSTACK_LOCALS #else .Lcurpcb: .word _C_LABEL(__pcpu) + PC_CURPCB -#define GET_PCB(tmp) \ +#define GET_PCB(tmp, tmp2) \ ldr tmp, .Lcurpcb #endif @@ -88,8 +86,7 @@ .Lnormal: stmfd sp!, {r10-r11, lr} - GET_PCB(r10) - ldr r10, [r10] + GET_PCB(r10, r11) mov r3, #0x00 adr ip, .Lcopyin_fault @@ -530,8 +527,7 @@ .Lnormale: stmfd sp!, {r10-r11, lr} - GET_PCB(r10) - ldr r10, [r10] + GET_PCB(r10, r11) mov r3, #0x00 adr ip, .Lcopyout_fault Index: arm/include/param.h =================================================================== --- arm/include/param.h (revision 255900) +++ arm/include/param.h (working copy) @@ -72,6 +72,12 @@ #endif #define MID_MACHINE MID_ARM6 +#if 0 +#ifndef VM_BCACHE_SIZE_MAX +#define VM_BCACHE_SIZE_MAX (64 * 1024 * 1024) +#endif +#endif + #if defined(SMP) || defined(KLD_MODULE) #ifndef MAXCPU #define MAXCPU 4 @@ -125,6 +131,12 @@ #define KSTACK_GUARD_PAGES 1 #endif /* !KSTACK_GUARD_PAGES */ +#ifndef KSTACK_MAX_PAGES +#define KSTACK_MAX_PAGES 8 +#endif /* !KSTACK_MAX_PAGES */ + +#define KSTACK_MAX_MASK ((KSTACK_MAX_PAGES * PAGE_SIZE) - 1) + #define USPACE_SVC_STACK_TOP KSTACK_PAGES * PAGE_SIZE #define USPACE_SVC_STACK_BOTTOM (USPACE_SVC_STACK_TOP - 0x1000) #define USPACE_UNDEF_STACK_TOP (USPACE_SVC_STACK_BOTTOM - 0x10) Index: arm/include/pcb.h =================================================================== --- arm/include/pcb.h (revision 255900) +++ arm/include/pcb.h (working copy) @@ -63,6 +63,7 @@ u_int pcb32_lr; u_int pcb32_pc; u_int pcb32_und_sp; + void * pcb32_curthread; }; #define pcb_pagedir un_32.pcb32_pagedir #define pcb_pl1vec un_32.pcb32_pl1vec Index: arm/include/asmacros.h =================================================================== --- arm/include/asmacros.h (revision 255900) +++ arm/include/asmacros.h (working copy) @@ -82,9 +82,7 @@ sub sp, sp, #4; /* Align the stack */ \ str lr, [sp, #-4]!; /* Push the return address */ \ sub sp, sp, #(4*17); /* Adjust the stack pointer */ \ - stmia sp, {r0-r12}; /* Push the user mode registers */ \ - add r0, sp, #(4*13); /* Adjust the stack pointer */ \ - stmia r0, {r13-r14}^; /* Push the user mode registers */ \ + stmia sp, {r0-r14}^; /* Push the user mode registers */ \ mov r0, r0; /* NOP for previous instruction */ \ mrs r0, spsr_all; /* Put the SPSR on the stack */ \ str r0, [sp, #-4]!; @@ -182,9 +180,7 @@ msr spsr_all, r3; /* Restore correct spsr */ \ ldmdb r1, {r0-r3}; /* Restore 4 regs from xxx mode */ \ sub sp, sp, #(4*15); /* Adjust the stack pointer */ \ - stmia sp, {r0-r12}; /* Push the user mode registers */ \ - add r0, sp, #(4*13); /* Adjust the stack pointer */ \ - stmia r0, {r13-r14}^; /* Push the user mode registers */ \ + stmia sp, {r0-r14}^; /* Push the user mode registers */ \ mov r0, r0; /* NOP for previous instruction */ \ mrs r0, spsr_all; /* Put the SPSR on the stack */ \ str r0, [sp, #-4]! @@ -234,8 +230,23 @@ name: #ifdef _ARM_ARCH_6 -#define AST_LOCALS -#define GET_CURTHREAD_PTR(tmp) \ +#define KSTACK_LOCALS \ +.Lkstack_consts: \ + .word KSTACK_ADDR_MASK; \ + .word KSTACK_PCB_ADDR; +#define AST_LOCALS KSTACK_LOCALS + +#define GET_PCB(tmp, tmp2) \ + ldr tmp2, .Lkstack_consts; \ + bic tmp, sp, tmp2; \ + ldr tmp2, .Lkstack_consts + 4; \ + add tmp, tmp, tmp2 + +#define GET_CURTHREAD(tmp, tmp2) \ + GET_PCB(tmp, tmp2); \ + ldr tmp, [tmp, #PCB_CURTHREAD] + +#define GET_PCPU_CURTHREAD_PTR(tmp) \ mrc p15, 0, tmp, c13, c0, 4; \ add tmp, tmp, #(PC_CURTHREAD) #else @@ -243,8 +254,12 @@ .Lcurthread: ;\ .word _C_LABEL(__pcpu) + PC_CURTHREAD -#define GET_CURTHREAD_PTR(tmp) \ +#define GET_PCPU_CURTHREAD_PTR(tmp) \ ldr tmp, .Lcurthread + +#define GET_CURTHREAD(tmp, tmp2) \ + ldr tmp, .Lcurthread; \ + ldr tmp, [tmp] #endif #define DO_AST \ @@ -256,8 +271,7 @@ teq r0, #(PSR_USR32_MODE) ;\ bne 2f /* Nope, get out now */ ;\ bic r4, r4, #(I32_bit|F32_bit) ;\ -1: GET_CURTHREAD_PTR(r5) ;\ - ldr r5, [r5] ;\ +1: GET_CURTHREAD(r5, r6) ;\ ldr r1, [r5, #(TD_FLAGS)] ;\ and r1, r1, #(TDF_ASTPENDING|TDF_NEEDRESCHED) ;\ teq r1, #0x00000000 ;\ Index: arm/include/pcpu.h =================================================================== --- arm/include/pcpu.h (revision 255900) +++ arm/include/pcpu.h (working copy) @@ -33,8 +33,14 @@ #ifdef _KERNEL #include +#include #include +#include +#include +#include +#include + #define ALT_STACK_SIZE 128 struct vmspace; @@ -94,15 +100,95 @@ __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls)); } + +/* + * Evaluates to the byte offset of the per-cpu variable name. + */ +#define __pcpu_offset(name) \ + __offsetof(struct pcpu, name) + +/* + * Evaluates to the type of the per-cpu variable name. + */ +#define __pcpu_type(name) \ + __typeof(((struct pcpu *)0)->name) + +/* + * Evaluates to the address of the per-cpu variable name. + */ +#define __PCPU_PTR(name) __extension__ ({ \ + __pcpu_type(name) *__p; \ + int __s; \ + \ + __s = disable_interrupts(I32_bit | F32_bit); \ + __p = &get_pcpu()->name; \ + restore_interrupts(__s); \ + __p; \ +}) + +/* + * Evaluates to the value of the per-cpu variable name. + */ +#define __PCPU_GET(name) __extension__ ({ \ + int __s; \ + __pcpu_type(name) __res; \ + __s = disable_interrupts(I32_bit | F32_bit); \ + __res = get_pcpu()->name; \ + restore_interrupts(__s); \ + __res; \ +}) + +/* + * Adds the value to the per-cpu counter name. The implementation + * must be atomic with respect to interrupts. + */ +#define __PCPU_ADD(name, val) do { \ + int __s ; \ + __s = disable_interrupts(I32_bit | F32_bit); \ + get_pcpu()->name += (val); \ + restore_interrupts(__s); \ +} while (0) + +/* + * Sets the value of the per-cpu variable name to value val. + */ +#define __PCPU_SET(name, val) { \ + int __s; \ + __s = disable_interrupts(I32_bit | F32_bit); \ + get_pcpu()->name = val; \ + restore_interrupts(__s); \ +} + +#define PCPU_GET(member) __PCPU_GET(pc_ ## member) +#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) +#define PCPU_INC(member) PCPU_ADD(member, 1) +#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) +#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) + +static __inline struct pcb * +__curpcb(void) +{ + register_t sp; + + __asm __volatile("mov %0, sp" : "=r" (sp)); + return ((struct pcb *)((sp &~ KSTACK_MAX_MASK) + + (KSTACK_MAX_PAGES * PAGE_SIZE - sizeof(struct pcb)))); +} + + +#define curpcb (__curpcb()) +#define curthread ((struct thread *)(curpcb->un_32.pcb32_curthread)) + + #else #define get_pcpu() pcpup -#endif #define PCPU_GET(member) (get_pcpu()->pc_ ## member) #define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value)) #define PCPU_INC(member) PCPU_ADD(member, 1) #define PCPU_PTR(member) (&get_pcpu()->pc_ ## member) #define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value)) +#endif void pcpu0_init(void); #endif /* _KERNEL */ Index: arm/include/pmap.h =================================================================== --- arm/include/pmap.h (revision 255900) +++ arm/include/pmap.h (working copy) @@ -63,7 +63,7 @@ #endif #define PTE_CACHE 6 #define PTE_DEVICE 2 -#define PTE_PAGETABLE 4 +#define PTE_PAGETABLE 6 #else #define PTE_NOCACHE 1 #define PTE_CACHE 2 @@ -489,7 +489,7 @@ #if (ARM_MMU_SA1 == 1) && (ARM_NMMUS == 1) #define PMAP_NEEDS_PTE_SYNC 1 #define PMAP_INCLUDE_PTE_SYNC -#elif defined(CPU_XSCALE_81342) +#elif defined(CPU_XSCALE_81342) || defined(ARM_ARCH_7A) #define PMAP_NEEDS_PTE_SYNC 1 #define PMAP_INCLUDE_PTE_SYNC #elif (ARM_MMU_SA1 == 0) @@ -559,11 +559,18 @@ #define PMAP_INCLUDE_PTE_SYNC #endif +#ifdef ARM_L2_PIPT +#define _sync_l2(pte, size) cpu_l2cache_wb_range(vtophys(pte), size) +#else +#define _sync_l2(pte, size) cpu_l2_cache_wb_range(pte, size) +#endif + #define PTE_SYNC(pte) \ do { \ if (PMAP_NEEDS_PTE_SYNC) { \ cpu_dcache_wb_range((vm_offset_t)(pte), sizeof(pt_entry_t));\ - cpu_l2cache_wb_range((vm_offset_t)(pte), sizeof(pt_entry_t));\ + cpu_drain_writebuf(); \ + _sync_l2((vm_offset_t)(pte), sizeof(pt_entry_t));\ } else \ cpu_drain_writebuf(); \ } while (/*CONSTCOND*/0) @@ -573,7 +580,8 @@ if (PMAP_NEEDS_PTE_SYNC) { \ cpu_dcache_wb_range((vm_offset_t)(pte), \ (cnt) << 2); /* * sizeof(pt_entry_t) */ \ - cpu_l2cache_wb_range((vm_offset_t)(pte), \ + cpu_drain_writebuf(); \ + _sync_l2((vm_offset_t)(pte), \ (cnt) << 2); /* * sizeof(pt_entry_t) */ \ } else \ cpu_drain_writebuf(); \ @@ -733,6 +741,21 @@ void arm_unmap_nocache(void *, vm_size_t); extern vm_paddr_t dump_avail[]; + +/* + * We want to be able to determine the end address of the kstack, to be able + * to get the PCB address just using the SP. + */ + +static __inline void +pmap_align_stack(vm_offset_t *addr, vm_size_t length) +{ + if (((*addr + length) & (KSTACK_MAX_PAGES * PAGE_SIZE - 1)) == 0) + return; + *addr += (KSTACK_MAX_PAGES * PAGE_SIZE) - ((*addr + length) & + (KSTACK_MAX_PAGES * PAGE_SIZE - 1)); +} + #endif /* _KERNEL */ #endif /* !LOCORE */ Index: arm/conf/PANDABOARD =================================================================== --- arm/conf/PANDABOARD (revision 253741) +++ arm/conf/PANDABOARD (working copy) @@ -20,6 +20,7 @@ ident PANDABOARD +options SMP # This probably wants to move somewhere else. Maybe we can create a basic @@ -30,16 +31,18 @@ include "../ti/omap4/pandaboard/std.pandaboard" +options NO_SWAPPING #To statically compile in device wiring instead of /boot/device.hints makeoptions MODULES_OVERRIDE="" makeoptions WITHOUT_MODULES="ahc" makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols options HZ=100 +#options USB_HOST_ALIGN=32 options SCHED_4BSD #4BSD scheduler options INET #InterNETworking -#options INET6 #IPv6 communications protocols +options INET6 #IPv6 communications protocols options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support options UFS_ACL #Support for access control lists @@ -47,13 +50,16 @@ device snp options BREAK_TO_DEBUGGER +options PRINTF_BUFR_SIZE=128 options NFSCL +#options NFSCLIENT #Network Filesystem Client +#options NFSSERVER #Network Filesystem Server options NFS_ROOT #NFS usable as /, requires NFSCLIENT -#options BOOTP_NFSROOT -#options BOOTP_COMPAT -#options BOOTP -#options BOOTP_NFSV3 -#options BOOTP_WIRED_TO=ue0 +options BOOTP_NFSROOT +options BOOTP_COMPAT +options BOOTP +options BOOTP_NFSV3 +options BOOTP_WIRED_TO=ue0 options MSDOSFS #MSDOS Filesystem #options CD9660 #ISO 9660 Filesystem #options PROCFS #Process filesystem (requires PSEUDOFS) @@ -68,7 +74,7 @@ options KBD_INSTALL_CDEV # install a CDEV entry in /dev options FREEBSD_BOOT_LOADER -options PREEMPTION +#options PREEMPTION # MMC/SD/SDIO Card slot support device mmc # mmc/sd bus @@ -107,7 +113,7 @@ # The following enables MFS as root, this seems similar to an initramfs or initrd # as used in Linux. #options MD_ROOT -#options MD_ROOT_SIZE=7560 +#options MD_ROOT_SIZE=20000 device random # Entropy device Index: arm/ti/omap4/omap4_l2cache.c =================================================================== --- arm/ti/omap4/omap4_l2cache.c (revision 255900) +++ arm/ti/omap4/omap4_l2cache.c (working copy) @@ -90,6 +90,7 @@ * Make sure data prefetch is on */ prefetch |= PREFETCH_CTRL_DATA_PREFETCH; + prefetch &= ~ PREFETCH_CTRL_DL; aux |= AUX_CTRL_DATA_PREFETCH; /* Index: arm/ti/omap4/omap4_mp.c =================================================================== --- arm/ti/omap4/omap4_mp.c (revision 255900) +++ arm/ti/omap4/omap4_mp.c (working copy) @@ -71,7 +71,7 @@ panic("Couldn't map the SCU\n"); /* Enable the SCU */ *(volatile unsigned int *)scu_addr |= 1; - //*(volatile unsigned int *)(scu_addr + 0x30) |= 1; + *(volatile unsigned int *)(scu_addr + 0x30) |= 1; cpu_idcache_wbinv_all(); cpu_l2cache_wbinv_all(); ti_smc0(0x200, 0xfffffdff, MODIFY_AUX_CORE_0); Index: arm/ti/ti_cpuid.c =================================================================== --- arm/ti/ti_cpuid.c (revision 255900) +++ arm/ti/ti_cpuid.c (working copy) @@ -112,7 +112,7 @@ /* FIXME Should we map somewhere else? */ bus_space_map(fdtbus_bs_tag,OMAP44XX_L4_CORE_HWBASE, 0x4000, 0, &bsh); id_code = bus_space_read_4(fdtbus_bs_tag, bsh, OMAP4_ID_CODE); - bus_space_unmap(fdtbus_bs_tag, bsh, 0x4000); + //bus_space_unmap(fdtbus_bs_tag, bsh, 0x4000); hawkeye = ((id_code >> 12) & 0xffff); revision = ((id_code >> 28) & 0xf); Index: conf/kern.pre.mk =================================================================== --- conf/kern.pre.mk (revision 255900) +++ conf/kern.pre.mk (working copy) @@ -26,7 +26,7 @@ SIZE?= size .if defined(DEBUG) -_MINUS_O= -O +_MINUS_O= -O -g CTFFLAGS+= -g .else .if ${MACHINE_CPUARCH} == "powerpc" Index: kern/subr_vmem.c =================================================================== --- kern/subr_vmem.c (revision 255900) +++ kern/subr_vmem.c (working copy) @@ -57,6 +57,7 @@ #include #include #include +#include #include "opt_vm.h" @@ -1133,6 +1134,7 @@ */ if (vm->vm_nfreetags < BT_MAXALLOC && bt_fill(vm, flags) != 0) { + printf("ROUFL\n"); error = ENOMEM; break; } @@ -1268,12 +1270,14 @@ bt_remseg(vm, bt); bt_remseg(vm, t); vm->vm_size -= spansize; - VMEM_CONDVAR_BROADCAST(vm); + if (thread0.td_sleepqueue != NULL) + VMEM_CONDVAR_BROADCAST(vm); bt_freetrim(vm, BT_MAXFREE); (*vm->vm_releasefn)(vm->vm_arg, spanaddr, spansize); } else { bt_insfree(vm, bt); - VMEM_CONDVAR_BROADCAST(vm); + if (thread0.td_sleepqueue != NULL) + VMEM_CONDVAR_BROADCAST(vm); bt_freetrim(vm, BT_MAXFREE); } } Index: vm/vm_map.h =================================================================== --- vm/vm_map.h (revision 255900) +++ vm/vm_map.h (working copy) @@ -349,6 +349,9 @@ #define VMFS_OPTIMAL_SPACE 2 /* find a range with optimal alignment*/ #define VMFS_SUPER_SPACE 3 /* find a superpage-aligned range */ #define VMFS_ALIGNED_SPACE(x) ((x) << 8) /* find a range with fixed alignment */ +#if defined(__arm__) +#define VMFS_STACK_ALIGNED_SPACE 4 /* Align stack so that the last addres is predictable */ +#endif /* * vm_map_wire and vm_map_unwire option flags Index: vm/vm_glue.c =================================================================== --- vm/vm_glue.c (revision 255900) +++ vm/vm_glue.c (working copy) @@ -364,7 +364,26 @@ M_BESTFIT | M_NOWAIT, &ks)) { ks = 0; } +#elif defined(__arm__) +#if 1 + if (vmem_xalloc(kernel_arena, + (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE, + KSTACK_MAX_PAGES * PAGE_SIZE, + (KSTACK_MAX_PAGES - (pages + KSTACK_GUARD_PAGES)) * PAGE_SIZE, 0, + VMEM_ADDR_MIN, VMEM_ADDR_MAX, + M_BESTFIT | M_NOWAIT, &ks)) + ks = 0; #else + ks = kva_alloc(2 * KSTACK_MAX_PAGES * PAGE_SIZE); + if (ks != 0) { + td->td_origkstack = ks; + ks &= ~ (KSTACK_MAX_PAGES * PAGE_SIZE - 1); + ks += KSTACK_MAX_PAGES * PAGE_SIZE; + ks += (KSTACK_MAX_PAGES - + (pages + KSTACK_GUARD_PAGES)) * PAGE_SIZE; + } +#endif +#else ks = kva_alloc((pages + KSTACK_GUARD_PAGES) * PAGE_SIZE); #endif if (ks == 0) {