From owner-p4-projects@FreeBSD.ORG Fri Feb 8 09:17:16 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5169516A530; Fri, 8 Feb 2008 09:17:16 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05F7F16A4A1 for ; Fri, 8 Feb 2008 09:17:15 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CCDE113C4EF for ; Fri, 8 Feb 2008 09:17:15 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m189HFG8016532 for ; Fri, 8 Feb 2008 09:17:15 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m189HF0o016528 for perforce@freebsd.org; Fri, 8 Feb 2008 09:17:15 GMT (envelope-from imp@freebsd.org) Date: Fri, 8 Feb 2008 09:17:15 GMT Message-Id: <200802080917.m189HF0o016528@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 135027 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2008 09:17:16 -0000 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); }