Date: Wed, 29 Oct 2008 15:03:59 GMT From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 152153 for review Message-ID: <200810291503.m9TF3x2H037752@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=152153 Change 152153 by bz@bz_dumpster on 2008/10/29 15:03:35 Make ddb _compile_ and enable it in GENERIC. Disable MD_ROOT for the moment. We die in dat_init() -- so reworking pmap.c entirely is next. Affected files ... .. //depot/projects/s390/sys/conf/files.s390#7 edit .. //depot/projects/s390/sys/ddb/db_sym.c#5 edit .. //depot/projects/s390/sys/s390/conf/GENERIC#12 edit .. //depot/projects/s390/sys/s390/include/db_machdep.h#2 edit .. //depot/projects/s390/sys/s390/include/setjmp.h#2 edit .. //depot/projects/s390/sys/s390/s390/db_disasm.c#4 edit .. //depot/projects/s390/sys/s390/s390/db_hwatch.c#4 edit .. //depot/projects/s390/sys/s390/s390/db_interface.c#4 edit .. //depot/projects/s390/sys/s390/s390/db_trace.c#4 edit .. //depot/projects/s390/sys/s390/s390/genassym.c#6 edit .. //depot/projects/s390/sys/s390/s390/machdep.c#13 edit .. //depot/projects/s390/sys/s390/s390/mp_machdep.c#4 edit .. //depot/projects/s390/sys/s390/s390/pmap.c#19 edit .. //depot/projects/s390/sys/s390/s390/stack_machdep.c#1 add Differences ... ==== //depot/projects/s390/sys/conf/files.s390#7 (text+ko) ==== @@ -93,6 +93,7 @@ s390/s390/mp_machdep.c optional smp s390/s390/pmap.c standard s390/s390/service.c standard +s390/s390/stack_machdep.c optional ddb | stack s390/s390/support.S standard s390/s390/swtch.S standard s390/s390/sys_machdep.c standard ==== //depot/projects/s390/sys/ddb/db_sym.c#5 (text+ko) ==== @@ -225,7 +225,7 @@ { register unsigned int diff; - size_t newdiff; + db_expr_t newdiff; register int i; c_db_sym_t ret = C_DB_SYM_NULL, sym; ==== //depot/projects/s390/sys/s390/conf/GENERIC#12 (text+ko) ==== @@ -30,10 +30,14 @@ #options ADDRESS_SPACE_2GB # Probably will never be implemented (no reason). -#options INVARIANT_SUPPORT -#options INVARIANTS -#options WITNESS -#options WITNESS_SKIPSPIN +# Debugging for use in -current +options KDB # Enable kernel debugger support. +options DDB # Support DDB. +#options GDB # Support remote GDB. +#options INVARIANTS # Enable calls of extra sanity checking +#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS # Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed #options DIAGNOSTIC #options DEBUG_LOCKS @@ -53,8 +57,10 @@ options PSEUDOFS # Pseudo-filesystem framework options COMPAT_43 # Compatible with BSD 4.3 options COMPAT_FREEBSD4 -options MD_ROOT # MD is potential root device -options MD_ROOT_SIZE=8192 + +# XXX-BZ we want that once we get there but for now it bloats the oco. +#options MD_ROOT # MD is potential root device +#options MD_ROOT_SIZE=8192 #device hhc # Debug feature device hmcsc # HMC system console ==== //depot/projects/s390/sys/s390/include/db_machdep.h#2 (text+ko) ==== @@ -43,18 +43,24 @@ #define DDB_REGS (&ddb_regs) +#ifdef __OLD_FOO #define PC_REGS(regs) ((db_addr_t)(regs)->tf_psw.addr & ~PSW_A) +#endif +#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_ontrap) #define BKPT_INST 0 /* breakpoint instruction */ #define BKPT_SIZE 2 /* size of breakpoint inst */ #define BKPT_SET(inst) BKPT_INST -#define BKPT_SKIP ddb_regs.tf_psw. += 1 +#define BKPT_SKIP \ + do { \ + kdb_frame->tf_psw.addr += 1; \ + } while (0) -#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T) -#define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T) +#define db_clear_single_step kdb_cpu_clear_singlestep +#define db_set_single_step kdb_cpu_set_singlestep -#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) +#define IS_BREAKPOINT_TRAP(type, code) 0 /* * Watchpoints are not supported. The debug exception type is in %dr6 * and not yet in the args to this macro. ==== //depot/projects/s390/sys/s390/include/setjmp.h#2 (text+ko) ==== @@ -32,6 +32,9 @@ * $FreeBSD: src/sys/s390/include/setjmp.h,v 1.0 2000/10/06 11:53:31 tzukanov Exp $ */ +#ifndef _MACHINE_SETJMP_H_ +#define _MACHINE_SETJMP_H_ + /* * word is 32-bit here. * @@ -54,3 +57,5 @@ #endif /* not ANSI */ typedef struct _jmp_buf { int _jb[_JB_LEN]; } jmp_buf[1]; + +#endif ==== //depot/projects/s390/sys/s390/s390/db_disasm.c#4 (text+ko) ==== @@ -4,10 +4,12 @@ * Copyright (c) 2002 Serguei Tzukanov. All rights reserved. */ -#include <sys/cdef.h> +#include <sys/cdefs.h> __FBSDID("$FreeBSD: src/sys/s390/s390/db_disasm.c,v 1.0 2002/07/01 23:51:16 tzukanov Exp $"); +#include <sys/libkern.h> #include <sys/param.h> + #include <ddb/ddb.h> #include <ddb/db_access.h> #include <ddb/db_sym.h> @@ -36,18 +38,18 @@ unsigned shift; unsigned mask; } os[] = { - 52, 0x0000000f, - 48, 0x000000ff, - 48, 0x0000000f, - 44, 0x0000000f, - 32, 0x0000ffff, - 16, 0xffffffff, - 40, 0x0000000f, - 32, 0x00000fff, - 36, 0x0000000f, - 32, 0x0000000f, - 28, 0x0000000f, - 16, 0x00000fff, + { 52, 0x0000000f }, + { 48, 0x000000ff }, + { 48, 0x0000000f }, + { 44, 0x0000000f }, + { 32, 0x0000ffff }, + { 16, 0xffffffff }, + { 40, 0x0000000f }, + { 32, 0x00000fff }, + { 36, 0x0000000f }, + { 32, 0x0000000f }, + { 28, 0x0000000f }, + { 16, 0x00000fff }, }; /* And four bits for type of operand. */ @@ -70,7 +72,12 @@ #define A8 (T_A | O8_S4) #define A12 (T_A | O12_S4) +#define A24 (T_A | O24_S4) +#define A28 (T_A | O28_S4) +#define B16 (T_B | O16_S16) +#define B32 (T_B | O32_S4) + #define C8 (T_C | O8_S4) #define C12 (T_C | O12_S4) @@ -80,9 +87,11 @@ #define F8 (T_F | O8_S4) #define F12 (T_F | O12_S4) #define F16 (T_F | O16_S4) +#define F24 (T_F | O24_S4) #define F28 (T_F | O28_S4) #define I8 (T_I | O8_S8) +#define I12_8 (T_I | O12_S4) /* XXX */ #define I16_16 (T_I | O16_S16) #define I16_32 (T_I | O16_S32) @@ -90,6 +99,7 @@ #define L8_8 (T_I | O8_S8) #define L12 (T_I | O12_S4) +#define M8 (T_M | O8_S4) #define M12 (T_M | O12_S4) #define M16 (T_M | O16_S4) #define M20 (T_M | O20_S4) @@ -100,6 +110,7 @@ #define R16 (T_R | O16_S4) #define R20 (T_R | O20_S4) #define R24 (T_R | O24_S4) +#define R28 (T_R | O28_S4) #define S28 (T_S | O28_S4) @@ -109,6 +120,8 @@ #define V24 (T_V | O24_S4) #define V28 (T_V | O28_S4) +#define X12 (T_X | O12_S4) + #define ESA390 0x1 #define ESAME 0x2 @@ -119,7 +132,7 @@ #endif struct insndesc { - uint16_t opcode, + uint16_t opcode; char mnemonic[6]; uint8_t archmask; uint8_t operand[7]; @@ -894,10 +907,12 @@ static char *gpr_names[16] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "lit", "r14", "sp" -} +}; +static void print_operand(unsigned v, int type, int delim) { + switch(type) { case T_A: db_printf("a%u", v); @@ -922,7 +937,7 @@ db_printf("%u", v); break; case T_R: - db_printf("%s", gpr_names[op]); + db_printf("%s", gpr_names[v]); break; /* It's either the last operand or we have T_T after. */ case T_S: @@ -947,8 +962,8 @@ static int insndesc_cmp(const void *_k, const void *_m) { - struct insndesc *k = (struct insndesc *)_k; - struct insndesc *m = (struct insndesc *)_m; + const struct insndesc *k = (const struct insndesc *)_k; + const struct insndesc *m = (const struct insndesc *)_m; if ((m->archmask & archmask) == 0) return 1; @@ -959,7 +974,7 @@ static struct insndesc * find_insndesc(unsigned opcode, struct insndesc *insndesc, size_t n) { - struct insndesc id = {opcode}; + struct insndesc id = { opcode }; /* Not really necessary but table sorted anyway. */ return bsearch(&id, insndesc, n, sizeof(*insndesc), insndesc_cmp); @@ -967,27 +982,29 @@ /* I ignore altfmt for now. */ db_addr_t -db_disasm(db_addr_t addr, boolean altfmt) +db_disasm(db_addr_t loc, boolean_t altfmt) { uint64_t insn_s; uint8_t *insn = (uint8_t *)&insn_s; unsigned opdesc; + struct insndesc *id; int insnlen; int i; - addr &= ~1ul; + loc &= ~1ul; - db_read_bytes(addr, 2, insn); + db_read_bytes(loc, 2, insn); #define INSNLEN_MASK 0x03 - switch (instr[0] & INSNLEN_MASK) { - case 1: case 2: - db_read_bytes(addr + 2, 2, insn + 2); + switch (insn[0] & INSNLEN_MASK) { + case 1: + case 2: + db_read_bytes(loc + 2, 2, insn + 2); insnlen = 4; break; case 3: - db_read_bytes(addr + 2, 4, insn + 2); + db_read_bytes(loc + 2, 4, insn + 2); insnlen = 6; break; default: @@ -1016,17 +1033,17 @@ break; /* fall through */ case 2: - id = find_insnlen(OPCODE2(insn), FID(xx)); + id = find_insndesc(OPCODE2(insn), FID(xx)); if (id == NULL) { for (i = 0; i < insnlen; i++) db_printf("%2x", insn[i]); db_printf("\n"); - return addr + insnlen; + return loc + insnlen; } } db_printf("%s ", id->mnemonic); - for (i = 0; opdesc = id->operand[i]; i++) { + for (i = 0; (opdesc = id->operand[i]); i++) { int osi; osi = opdesc & O_S_MASK; @@ -1035,14 +1052,14 @@ } db_printf("\n"); - return addr + insnlen; + return loc + insnlen; } /* * Set the disassembler filter. Should also have ESA390|ESAME, * but some vector opcodes intersect with z/Architecture ones. */ -DB_COMMAND(esa390, db_esame) +DB_COMMAND(esa390, db_esa390) { archmask = ESA390; } ==== //depot/projects/s390/sys/s390/s390/db_hwatch.c#4 (text+ko) ==== @@ -8,16 +8,14 @@ __FBSDID("$FreeBSD: src/sys/s390/s390/db_hwatch.c,v 1.0 2002/04/01 23:51:16 tzukanov Exp $"); #include <sys/param.h> + #include <ddb/ddb.h> #include <ddb/db_access.h> #include <ddb/db_sym.h> #include <ddb/db_output.h> + #include <s390/s390/per.h> -int db_md_set_watchpoint(db_expr_t addr, db_expr_t size); -int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size); -void db_md_list_watchpoints(void); - int db_md_set_watchpoint(db_expr_t addr, db_expr_t size) { ==== //depot/projects/s390/sys/s390/s390/db_interface.c#4 (text+ko) ==== @@ -10,57 +10,40 @@ __FBSDID("$FreeBSD: src/sys/s390/s390/db_interface.c,v 1.0 2002/04/01 23:51:16 tzukanov Exp $"); #include <sys/param.h> +#include <sys/kdb.h> +#include <sys/pcpu.h> + +#include <machine/atomic.h> + #include <ddb/ddb.h> #include <ddb/db_access.h> #include <ddb/db_sym.h> #include <ddb/db_output.h> int -kdb_trap(u_int code, struct trapframe *tf) -{ - - ddb_regs = *tf; - - db_trap(code, 0); - - - *tf = ddb_regs; - - /* Let's call it success: we handled the trap. */ - return 1; -} - -void db_read_bytes(vm_offset_t va, size_t size, char *data) { +#if 0 db_nofault = &db_jmpbuf; +#endif - + return (0); } -void +int db_write_bytes(vm_offset_t va, size_t size, char *data) { + +#if 0 db_nofault = &db_jmpbuf; -} +#endif -void -Debugger(const char *msg) -{ - static volatile int in_Debugger; - - if (atomic_cmpset_int(&in_Debugger, 0, 1)) { - db_printf("Debugger('%s')", msg); - /* call debugger */ - ... - atomic_store_rel_int(&in_Debugger, 0); - } + return (0); } void db_show_mdpcpu(struct pcpu *pc) { - db_printf("ipi = 0x%x\n", pc->pc_ipi); } DB_COMMAND(reboot, db_reboot) ==== //depot/projects/s390/sys/s390/s390/db_trace.c#4 (text+ko) ==== @@ -2,42 +2,69 @@ * Support for stack tracing in DDB. * * Copyright (c) 2002 Serguei Tzukanov. + * Copyright (c) 2008 Bjoern A. Zeeb */ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/sys/s390/s390/db_trace.c,v 1.0 2002/04/01 23:51:16 tzukanov Exp $"); #include <sys/param.h> +#include <sys/pcpu.h> +#include <sys/systm.h> + #include <ddb/ddb.h> #include <ddb/db_access.h> +#include <ddb/db_output.h> #include <ddb/db_sym.h> -#include <ddb/db_output.h> +#include <ddb/db_variables.h> + +#include <machine/db_machdep.h> #include <machine/frame.h> +#define DB_OFFSET(x) (db_expr_t *)offsetof(struct trapframe, x) struct db_variable db_regs[] = { - {"r0", &ddb_regs.tf_gpr[0], FCN_NULL}, - {"r1", &ddb_regs.tf_gpr[1], FCN_NULL}, - {"r2", &ddb_regs.tf_gpr[2], FCN_NULL}, - {"r3", &ddb_regs.tf_gpr[3], FCN_NULL}, - {"r4", &ddb_regs.tf_gpr[4], FCN_NULL}, - {"r5", &ddb_regs.tf_gpr[5], FCN_NULL}, - {"r6", &ddb_regs.tf_gpr[6], FCN_NULL}, - {"r7", &ddb_regs.tf_gpr[7], FCN_NULL}, - {"r8", &ddb_regs.tf_gpr[8], FCN_NULL}, - {"r9", &ddb_regs.tf_gpr[9], FCN_NULL}, - {"r10", &ddb_regs.tf_gpr[10], FCN_NULL}, - {"r11", &ddb_regs.tf_gpr[11], FCN_NULL}, - {"r12", &ddb_regs.tf_gpr[12], FCN_NULL}, - {"r13", &ddb_regs.tf_gpr[13], FCN_NULL}, - {"r14", &ddb_regs.tf_gpr[14], FCN_NULL}, - {"r15", &ddb_regs.tf_gpr[15], FCN_NULL}, + {"r0", DB_OFFSET(tf_gpr[0]), FCN_NULL}, + {"r1", DB_OFFSET(tf_gpr[1]), FCN_NULL}, + {"r2", DB_OFFSET(tf_gpr[2]), FCN_NULL}, + {"r3", DB_OFFSET(tf_gpr[3]), FCN_NULL}, + {"r4", DB_OFFSET(tf_gpr[4]), FCN_NULL}, + {"r5", DB_OFFSET(tf_gpr[5]), FCN_NULL}, + {"r6", DB_OFFSET(tf_gpr[6]), FCN_NULL}, + {"r7", DB_OFFSET(tf_gpr[7]), FCN_NULL}, + {"r8", DB_OFFSET(tf_gpr[8]), FCN_NULL}, + {"r9", DB_OFFSET(tf_gpr[9]), FCN_NULL}, + {"r10", DB_OFFSET(tf_gpr[10]), FCN_NULL}, + {"r11", DB_OFFSET(tf_gpr[11]), FCN_NULL}, + {"r12", DB_OFFSET(tf_gpr[12]), FCN_NULL}, + {"r13", DB_OFFSET(tf_gpr[13]), FCN_NULL}, + {"r14", DB_OFFSET(tf_gpr[14]), FCN_NULL}, + {"r15", DB_OFFSET(tf_gpr[15]), FCN_NULL}, }; struct db_variable *db_eregs = db_regs + sizeof(db_regs) / sizeof(db_regs[0]); +static void +db_stack_trace_cmd(db_expr_t addr, db_expr_t count) +{ + +} + +int +db_trace_thread(struct thread *thr, int count) +{ + uint32_t addr; + + if (thr == curthread) + addr = (uint32_t)__builtin_frame_address(0); + else + panic("[%s:%d] fixme", __func__, __LINE__); + db_stack_trace_cmd(addr, -1); + return (0); +} + void -db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, - db_expr_t count, char *modif) +db_trace_self(void) { - + db_trace_thread(curthread, -1); } + ==== //depot/projects/s390/sys/s390/s390/genassym.c#6 (text+ko) ==== @@ -65,8 +65,12 @@ ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); +ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); +ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); +ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread)); +ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); ASSYM(PC_CPUMASK, offsetof(struct pcpu, pc_cpumask)); -ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); +ASSYM(PCPU_SIZE, sizeof(struct pcpu)); ASSYM(PCB_CR7, offsetof(struct pcb, pcb_cr7)); ASSYM(PCB_GPR2, offsetof(struct pcb, pcb_gpr2)); ==== //depot/projects/s390/sys/s390/s390/machdep.c#13 (text+ko) ==== @@ -204,9 +204,6 @@ /* Count number of CPUs. No-op on UP kernel. */ mp_early_probe(); - /* Enable DAT. */ - dat_init(); - #ifndef __s390x__ /* Reserve space for machine check exception. */ sysarea.pcpu += EXTENDED_SAVE_AREA_SIZE; @@ -225,7 +222,16 @@ /* Setup pcpu struct. */ pcpu_init(sysarea.pcpu, 0, sizeof(struct pcpu)); PCPU_SET(curthread, &thread0); + PCPU_SET(curpcb, thread0.td_pcb); + + /* init cons here already for debugging aid */ + cninit(); + printf("[%s:%d] reincarnation revolution rapid - run FreeBSD run!\n", + __func__, __LINE__); + /* Enable DAT. */ + dat_init(); + mutex_init(); /* Setup interruption vectors. */ @@ -242,14 +248,14 @@ css_init(); #endif - /* Now we can init console, even a channel attached one. */ - cninit(); - /* Print info about found subchannels/devices. */ #if 0 css_init_info(); #endif + /* Now we can init console, even a channel attached one. */ + /* cninit(); */ + esa_cpu_model(); } ==== //depot/projects/s390/sys/s390/s390/mp_machdep.c#4 (text+ko) ==== ==== //depot/projects/s390/sys/s390/s390/pmap.c#19 (text+ko) ==== @@ -198,7 +198,7 @@ sk_set(0, SK_RW); avail_end = PAGE_SIZE; - while(tprot(avail_end)) { + while (tprot(avail_end)) { sk_set(avail_end, SK_RW); avail_end += PAGE_SIZE; } @@ -212,6 +212,10 @@ *(*dimp)->vap = dat_init_map((*dimp)->n); } + phys_avail[0] = avail_start; + phys_avail[1] = avail_end; + phys_avail[2] = 0; + #if 0 sysarea.pcpu = (struct pcpu *) (pmap_bootstrap_map(1) + EXTENDED_SAVE_AREA_SIZE); @@ -240,14 +244,12 @@ /* Initialize the kernel pmap. */ kernel_pmap = &kernel_pmap_store; + + PMAP_LOCK_INIT(kernel_pmap); kernel_pmap->pm_sto = proc0sto; - kernel_pmap->pm_active = -1; + kernel_pmap->pm_active = ~0; TAILQ_INIT(&kernel_pmap->pm_pvlist); - phys_avail[0] = avail_start; - phys_avail[1] = avail_end; - phys_avail[2] = 0; - /* Now let's enable DAT. */ cr_write(CR1, STD_PRIMARY(proc0sto));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810291503.m9TF3x2H037752>