From owner-svn-src-head@FreeBSD.ORG Fri Mar 12 03:49:17 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC3D8106566C; Fri, 12 Mar 2010 03:49:17 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 949D98FC1A; Fri, 12 Mar 2010 03:49:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2C3nHvB081215; Fri, 12 Mar 2010 03:49:17 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2C3nHP6081210; Fri, 12 Mar 2010 03:49:17 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201003120349.o2C3nHP6081210@svn.freebsd.org> From: Neel Natu Date: Fri, 12 Mar 2010 03:49:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r205064 - in head/sys/mips: include mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2010 03:49:18 -0000 Author: neel Date: Fri Mar 12 03:49:17 2010 New Revision: 205064 URL: http://svn.freebsd.org/changeset/base/205064 Log: Make the ddb command "show tlb" SMP friendly. It now accepts an argument to dump out the tlb of a particular cpu. Modified: head/sys/mips/include/cpuregs.h head/sys/mips/include/pmap.h head/sys/mips/mips/mp_machdep.c head/sys/mips/mips/pmap.c Modified: head/sys/mips/include/cpuregs.h ============================================================================== --- head/sys/mips/include/cpuregs.h Fri Mar 12 03:08:47 2010 (r205063) +++ head/sys/mips/include/cpuregs.h Fri Mar 12 03:49:17 2010 (r205064) @@ -577,6 +577,8 @@ #define MIPS_CONFIG1_TLBSZ_MASK 0x7E000000 /* bits 30..25 # tlb entries minus one */ #define MIPS_CONFIG1_TLBSZ_SHIFT 25 +#define MIPS_MAX_TLB_ENTRIES 64 + #define MIPS_CONFIG1_IS_MASK 0x01C00000 /* bits 24..22 icache sets per way */ #define MIPS_CONFIG1_IS_SHIFT 22 #define MIPS_CONFIG1_IL_MASK 0x00380000 /* bits 21..19 icache line size */ Modified: head/sys/mips/include/pmap.h ============================================================================== --- head/sys/mips/include/pmap.h Fri Mar 12 03:08:47 2010 (r205063) +++ head/sys/mips/include/pmap.h Fri Mar 12 03:49:17 2010 (r205064) @@ -219,6 +219,11 @@ pmap_map_fpage(vm_paddr_t pa, struct fpa boolean_t check_unmaped); void pmap_unmap_fpage(vm_paddr_t pa, struct fpage *fp); +/* + * Function to save TLB contents so that they may be inspected in the debugger. + */ +extern void pmap_save_tlb(void); + #endif /* _KERNEL */ #endif /* !LOCORE */ Modified: head/sys/mips/mips/mp_machdep.c ============================================================================== --- head/sys/mips/mips/mp_machdep.c Fri Mar 12 03:08:47 2010 (r205063) +++ head/sys/mips/mips/mp_machdep.c Fri Mar 12 03:49:17 2010 (r205064) @@ -128,6 +128,7 @@ mips_ipi_handler(void *arg) CTR0(KTR_SMP, "IPI_STOP or IPI_STOP_HARD"); savectx(&stoppcbs[cpu]); + pmap_save_tlb(); /* Indicate we are stopped */ atomic_set_int(&stopped_cpus, cpumask); Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Fri Mar 12 03:08:47 2010 (r205063) +++ head/sys/mips/mips/pmap.c Fri Mar 12 03:49:17 2010 (r205064) @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -149,6 +150,8 @@ unsigned pmap_max_asid; /* max ASID sup vm_offset_t kernel_vm_end; +static struct tlb tlbstash[MAXCPU][MIPS_MAX_TLB_ENTRIES]; + static void pmap_asid_alloc(pmap_t pmap); /* @@ -3284,17 +3287,6 @@ db_dump_tlb(int first, int last) } } -#ifdef DDB -#include -#include - -DB_SHOW_COMMAND(tlb, ddb_dump_tlb) -{ - db_dump_tlb(0, num_tlbentries - 1); -} - -#endif - /* * Routine: pmap_kextract * Function: @@ -3377,3 +3369,61 @@ pmap_flush_pvcache(vm_page_t m) } } } + +void +pmap_save_tlb(void) +{ + int tlbno, cpu; + + cpu = PCPU_GET(cpuid); + + for (tlbno = 0; tlbno < num_tlbentries; ++tlbno) + MachTLBRead(tlbno, &tlbstash[cpu][tlbno]); +} + +#ifdef DDB +#include + +DB_SHOW_COMMAND(tlb, ddb_dump_tlb) +{ + int cpu, tlbno; + struct tlb *tlb; + + if (have_addr) + cpu = ((addr >> 4) % 16) * 10 + (addr % 16); + else + cpu = PCPU_GET(cpuid); + + if (cpu < 0 || cpu >= mp_ncpus) { + db_printf("Invalid CPU %d\n", cpu); + return; + } else + db_printf("CPU %d:\n", cpu); + + if (cpu == PCPU_GET(cpuid)) + pmap_save_tlb(); + + for (tlbno = 0; tlbno < num_tlbentries; ++tlbno) { + tlb = &tlbstash[cpu][tlbno]; + if (tlb->tlb_lo0 & PTE_V || tlb->tlb_lo1 & PTE_V) { + printf("TLB %2d vad 0x%0lx ", + tlbno, (long)(tlb->tlb_hi & 0xffffff00)); + } else { + printf("TLB*%2d vad 0x%0lx ", + tlbno, (long)(tlb->tlb_hi & 0xffffff00)); + } + printf("0=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo0)); + printf("%c", tlb->tlb_lo0 & PTE_V ? 'V' : '-'); + printf("%c", tlb->tlb_lo0 & PTE_M ? 'M' : '-'); + printf("%c", tlb->tlb_lo0 & PTE_G ? 'G' : '-'); + printf(" atr %x ", (tlb->tlb_lo0 >> 3) & 7); + printf("1=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo1)); + printf("%c", tlb->tlb_lo1 & PTE_V ? 'V' : '-'); + printf("%c", tlb->tlb_lo1 & PTE_M ? 'M' : '-'); + printf("%c", tlb->tlb_lo1 & PTE_G ? 'G' : '-'); + printf(" atr %x ", (tlb->tlb_lo1 >> 3) & 7); + printf(" sz=%x pid=%x\n", tlb->tlb_mask, + (tlb->tlb_hi & 0x000000ff)); + } +} +#endif /* DDB */