Date: Wed, 29 Mar 2006 10:00:00 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94237 for review Message-ID: <200603291000.k2TA003v026574@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94237 Change 94237 by kmacy@kmacy_storage:sun4v_work on 2006/03/29 09:59:01 switch to a decidedly more fail-fast approach to tracking PCB physical addresses track down remaining issue to exec_setregs zeroing all fields in the PCB after it had been initialized in fork Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sparc64/sparc64/genassym.c#16 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/asmacros.h#12 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pcb.h#9 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pcpu.h#9 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#40 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/locore.S#8 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/machdep.c#18 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/swtch.S#15 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/vm_machdep.c#7 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sparc64/sparc64/genassym.c#16 (text+ko) ==== @@ -219,9 +219,8 @@ ASSYM(PC_KWBUF_SP, offsetof(struct pcpu, pc_kwbuf_sp)); ASSYM(PC_KWBUF, offsetof(struct pcpu, pc_kwbuf)); ASSYM(PC_PMAP, offsetof(struct pcpu, pc_curpmap)); -ASSYM(PC_CURPCB_RA, offsetof(struct pcpu, pc_curpcb_ra)); -ASSYM(PCB_RA, offsetof(struct pcb, pcb_ra)); +ASSYM(PCB_KSTACK, offsetof(struct pcb, pcb_kstack)); ASSYM(INTR_REPORT_SIZE, INTR_REPORT_SIZE); #else ASSYM(PC_TLB_CTX, offsetof(struct pcpu, pc_tlb_ctx)); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/asmacros.h#12 (text+ko) ==== @@ -181,9 +181,10 @@ #define GET_PCB_PHYS(tmp, reg) \ - mov PC_CURPCB_RA, reg; \ + mov PC_CURPCB, reg; \ GET_PCPU_PHYS_SCRATCH(tmp); \ - ldxa [PCPU_REG + reg]ASI_REAL, reg; + ldxa [PCPU_REG + reg]ASI_REAL, reg; \ + sub reg, tmp, reg; #define GET_PCB(reg) \ ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pcb.h#9 (text+ko) ==== @@ -45,7 +45,7 @@ uint64_t pcb_nsaved; /* number of windows saved in pcb_rw */ uint64_t pcb_pc; uint64_t pcb_sp; - uint64_t pcb_ra; /* physical address of pcb */ + uint64_t pcb_kstack; /* pcb's kernel stack */ uint64_t pcb_pad[4]; } __aligned(64); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pcpu.h#9 (text+ko) ==== @@ -74,8 +74,7 @@ struct rwindow pc_kwbuf; \ u_long pc_kwbuf_sp; \ u_int pc_kwbuf_full; \ - u_int pc_node; \ - u_long pc_curpcb_ra; + u_int pc_node; /* XXX SUN4V_FIXME - as we access the *_ra and *_size fields in quick * succession we _really_ want them to be L1 cache line size aligned ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/exception.S#40 (text+ko) ==== @@ -929,7 +929,8 @@ mov %l7, %o0 ldx [PCPU_REG + PC_CURPCB], %g6 - sub %g6, CCFSZ + SPOFF + TF_SIZEOF, %sp + ldx [%g6 + PCB_KSTACK], %g6 + sub %g6, TF_SIZEOF, %sp add %sp, REGOFF + SPOFF, %l7 ENTRY(user_rtt) GET_PCPU_SCRATCH @@ -1229,7 +1230,8 @@ #endif GET_PCB(%g6) wrpr %g0, %g5, %cleanwin - sub %g6, SPOFF + CCFSZ + TF_SIZEOF, %g6 + ldx [%g6 + PCB_KSTACK], %g6 + sub %g6, TF_SIZEOF, %g6 save %g6, 0, %sp rdpr %canrestore, %l0 ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/locore.S#8 (text+ko) ==== @@ -80,7 +80,7 @@ /* * Get onto thread0's kstack. */ - sub %g6, SPOFF + CCFSZ, %sp + ldx [%g6 + PCB_KSTACK], %sp /* * And away we go. This doesn't return. ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/machdep.c#18 (text+ko) ==== @@ -106,7 +106,7 @@ #include <machine/tick.h> #include <machine/tlb.h> #include <machine/tstate.h> -#include <machine/upa.h> +#include <machine/asm.h> #include <machine/ver.h> #include <machine/hypervisor_api.h> @@ -398,7 +398,9 @@ thread0.td_kstack = kstack0; thread0.td_pcb = (struct pcb *) - (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + thread0.td_pcb->pcb_kstack = (uint64_t)(((char *)thread0.td_pcb) - (CCFSZ + SPOFF)); + thread0.td_pcb = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)thread0.td_pcb)); pc->pc_curpcb = thread0.td_pcb; /* @@ -766,6 +768,7 @@ struct trapframe *tf; struct pcb *pcb; struct proc *p; + uint64_t kstack; u_long sp; /* XXX no cpu_exec */ @@ -776,12 +779,14 @@ utrap_free(p->p_md.md_utrap); p->p_md.md_utrap = NULL; } - pcb = td->td_pcb; + kstack = pcb->pcb_kstack; tf = td->td_frame; sp = rounddown(stack, 16); bzero(pcb, sizeof(*pcb)); bzero(tf, sizeof(*tf)); + pcb->pcb_kstack = kstack; + tf->tf_out[0] = stack; tf->tf_out[3] = p->p_sysent->sv_psstrings; tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/swtch.S#15 (text+ko) ==== @@ -48,34 +48,15 @@ ba %xcc, .Lsw1 mov %i1, %i0 END(cpu_throw) - - -ENTRY(pcb_ra_miss) - call pmap_kextract - mov PCB_REG, %o0 - mov %o0, %l0 -#ifdef DEBUG - ! sanity check lookup - brnz %o0, 1f - nop - MAGIC_TRAP_ON - MAGIC_EXIT -1: -#endif - ba,pt %xcc, pcb_ra_uptodate - stx %l0, [PCB_REG + PCB_RA] -END(pcb_ra_miss) - - /* * void cpu_switch(struct thread *old, struct thread *new) */ ENTRY(cpu_switch) + save %sp, -CCFSZ, %sp GET_PCB(PCB_REG) - save %sp, -CCFSZ, %sp mov %i1, %i0 - + /* * If the current thread was using floating point in the kernel, save * its context. The userland floating point context has already been @@ -133,7 +114,7 @@ 9: #endif ldx [%i0 + TD_PCB], %i1 - + stx %i0, [PCPU(CURTHREAD)] stx %i1, [PCPU(CURPCB)] @@ -147,18 +128,14 @@ */ ldx [PCB_REG + PCB_SP], %fp ldx [PCB_REG + PCB_PC], %i7 - ldx [PCB_REG + PCB_RA], %l0 sub %fp, CCFSZ, %sp - brz %l0, pcb_ra_miss - nop -pcb_ra_uptodate: + /* * Point to the pmaps of the new process, and of the last non-kernel * process to run. */ - stx %l0, [PCPU(CURPCB_RA)] ldx [%i0 + TD_PROC], %i2 ldx [PCPU(PMAP)], %l2 ldx [%i2 + P_VMSPACE], %i5 ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/vm_machdep.c#7 (text+ko) ==== @@ -86,6 +86,7 @@ #include <machine/tlb.h> #include <machine/tstate.h> #include <machine/wstate.h> +#include <machine/asm.h> #ifndef NSFBUFS #define NSFBUFS (512 + maxusers * 16) @@ -135,9 +136,11 @@ pcb = (struct pcb *)((td->td_kstack + td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x3fUL); - pcb->pcb_ra = vtophys((vm_offset_t)pcb); + pcb->pcb_kstack = (uint64_t)(((char *)pcb) - (CCFSZ + SPOFF)); pcb->pcb_nsaved = 0; td->td_frame = (struct trapframe *)pcb - 1; + + pcb = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)pcb)); td->td_pcb = pcb; } @@ -162,6 +165,7 @@ bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); pcb = td->td_pcb; + tf = td->td_frame; fr = (struct frame *)tf - 1; fr->fr_local[0] = (u_long)fork_return; @@ -216,7 +220,7 @@ struct trapframe *tf; struct frame *fp; struct pcb *pcb1; - struct pcb *pcb2; + struct pcb *pcb2, *pcb2orig; vm_offset_t sp; int error; int i; @@ -232,8 +236,11 @@ /* The pcb must be aligned on a 64-byte boundary. */ pcb1 = td1->td_pcb; - pcb2 = (struct pcb *)((td2->td_kstack + td2->td_kstack_pages * + + pcb2orig = (struct pcb *)((td2->td_kstack + td2->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x3fUL); + pcb2 = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)pcb2orig)); + td2->td_pcb = pcb2; /* @@ -279,7 +286,7 @@ * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ - tf = (struct trapframe *)pcb2 - 1; + tf = (struct trapframe *)pcb2orig - 1; bcopy(td1->td_frame, tf, sizeof(*tf)); tf->tf_out[0] = 0; /* Child returns zero */ @@ -298,7 +305,8 @@ fp->fr_pc = fp->fr_fp = 0; pcb2->pcb_sp = (u_long)fp - SPOFF; pcb2->pcb_pc = (u_long)fork_trampoline - 8; - pcb2->pcb_ra = vtophys((vm_offset_t)pcb2); + pcb2->pcb_kstack = (uint64_t)(((char *)pcb2orig) - (CCFSZ + SPOFF)); + /* Setup to release sched_lock in fork_exit(). */ td2->td_md.md_spinlock_count = 1; td2->td_md.md_saved_pil = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603291000.k2TA003v026574>