Date: Fri, 8 Feb 2008 09:17:15 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 135027 for review Message-ID: <200802080917.m189HF0o016528@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135027 Change 135027 by imp@imp_lighthouse on 2008/02/08 09:16:43 First cut at implementing gonzo's suggestions for AST handling. Affected files ... .. //depot/projects/mips2-jnpr/src/sys/mips/include/asm.h#10 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/exception.S#12 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#6 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#13 edit .. //depot/projects/mips2-jnpr/src/sys/mips/mips/trap.c#10 edit Differences ... ==== //depot/projects/mips2-jnpr/src/sys/mips/include/asm.h#10 (text+ko) ==== @@ -304,6 +304,26 @@ .align 3 /* + * Call ast if required + */ +#define DO_AST \ + GET_CPU_PCPU(k1) \ + lw k1, PC_CURTHREAD(k1); \ + lw t0, TD_FLAGS(k1); \ + and t0, t0, (TDF_ASTPENDING|TDF_NEEDRESCHED); \ + beq t0, zero, 27f; \ + nop; \ + lw k1, TD_FRAME(k1); \ + lw t0, TF_REG_SR(k1); \ + and t0, t0, SR_KSU_USER; \ + beq t0, zero, 27f; \ + nop; \ + move a0, k1; \ + jal ast; \ + nop; \ +27: + +/* * XXX retain dialects XXX */ #define ALEAF(x) XLEAF(x) ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/exception.S#12 (text+ko) ==== @@ -382,10 +382,14 @@ jalr k0 sw a3, STAND_RA_OFFSET + KERN_REG_SIZE(sp) # for debugging + .set at + /* A call to AST would step on v0, I think, do we need to save it? */ + DO_AST + .set noat + RESTORE_CPU # v0 contains the return address. sync eret - .set at END(MipsKernGenException) @@ -581,6 +585,7 @@ la k0, _C_LABEL(cpu_intr) jalr k0 sw a3, STAND_RA_OFFSET + KERN_REG_SIZE(sp) + /* Why no AST processing here? */ /* * Restore registers and return from the interrupt. */ @@ -666,6 +671,7 @@ jalr k0 sw a3, STAND_RA_OFFSET(sp) # for debugging + DO_AST /* * Since interrupts are enabled at this point, we use a1 instead of * k0 or k1 to store the PCB pointer. This is because k0 and k1 ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/genassym.c#6 (text+ko) ==== @@ -68,6 +68,9 @@ ASSYM(TD_REALKSTACK, offsetof(struct thread, td_md.md_realstack)); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); ASSYM(TD_LOCK, offsetof(struct thread, td_lock)); +ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); + +ASSYM(TF_REG_SR, offsetof(struct trapframe, sr)); ASSYM(U_PCB_REGS, offsetof(struct pcb, pcb_regs.zero)); ASSYM(U_PCB_CONTEXT, offsetof(struct pcb, pcb_context)); ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/swtch.S#13 (text+ko) ==== @@ -161,6 +161,8 @@ jal _C_LABEL(fork_exit) move a2,s2 #BDSlot + DO_AST + /* * Since interrupts are enabled at this point, we use a1 instead of * k0 or k1 to store the PCB pointer. This is because k0 and k1 ==== //depot/projects/mips2-jnpr/src/sys/mips/mips/trap.c#10 (text+ko) ==== @@ -828,49 +828,6 @@ PTRACESTOP_SC(p, td, S_PT_SCX); - /* - * XXX ast still need to happen - * - * Mail from jhb@: - * - * ast() is also still relevant in 7 as well. What - * normally happens is that you have the following in - * assembly: - * - * trap_entry: - * setup regs - * call trap - * jmp exittrap - * - * syscall_entry: - * setup regs - * call syscall - * jmp exittrap - * - * exittrap: - * get ready to return from trap - * disable interrupts - * if returning to kernel jmp kernel - * asts: - * if no ASTs are pending jmp kernel - * enable interrupts - * call ast - * disable interrupts - * jmp asts - * kernel: - * restore registers - * reti - * - * or some such. You could do it in C if you wanted, - * but the idea is you want to only return to userland - * once you've verified you have no ASTs with - * interrupts disabled. If you get any AST's while - * returning to userland it's due to SMP and you will - * get an IPI that will post with 'reti' finishes. - */ - if (curthread->td_flags & (TDF_ASTPENDING|TDF_NEEDRESCHED)) { - ast(trapframe); - } return (trapframe->pc); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802080917.m189HF0o016528>