diff options
41 files changed, 89 insertions, 1955 deletions
@@ -882,8 +882,6 @@ 3ddb79bcZ_2FxINljqNSkqa17ISyJw xen/arch/x86/pci-pc.c 3ddb79bdeJ7_86z03yTAPIeeywOg3Q xen/arch/x86/pci-x86.c 3ddb79bdIKgipvGoqExEQ7jawfVowA xen/arch/x86/pci-x86.h -40a4dfced2dnSzbKgJFlD3chKHexjQ xen/arch/x86/pdb-linux.c -4022a73czgX7d-2zfF_cb33oVemApQ xen/arch/x86/pdb-stub.c 3ddb79bc7KxGCEJsgBnkDX7XjD_ZEQ xen/arch/x86/rwlock.c 3ddb79bcrD6Z_rUvSDgrvjyb4846Eg xen/arch/x86/setup.c 405b8599xI_PoEr3zZoJ2on-jdn7iw xen/arch/x86/shadow.c @@ -914,8 +912,6 @@ 40e96d3akN3Hu_J5Bk-WXD8OGscrYQ xen/arch/x86/x86_64/xen.lds 3ddb79bdff-gj-jFGKjOejeHLqL8Lg xen/common/Makefile 3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c -4022a73c_BbDFd2YJ_NQYVvKX5Oz7w xen/common/debug-linux.c -3fa152581E5KhrAtqZef2Sr5NKTz4w xen/common/debug.c 3ddb79bdLX_P6iB7ILiblRLWvebapg xen/common/dom0_ops.c 3e6377e4i0c9GtKN65e99OtRbw3AZw xen/common/dom_mem_ops.c 3ddb79bdYO5D8Av12NHqPeSviav7cg xen/common/domain.c @@ -1021,7 +1017,6 @@ 41a61536MFhNalgbVmYGXAhQsPTZNw xen/include/asm-x86/multicall.h 3ddb79c3xjYnrv5t3VqYlR4tNEOl4Q xen/include/asm-x86/page.h 3ddb79c3ysKUbxZuwKBRK3WXU2TlEg xen/include/asm-x86/pci.h -4022a73diKn2Ax4-R4gzk59lm1YdDg xen/include/asm-x86/pdb.h 3ddb79c2QF5-pZGzuX4QukPCDAl59A xen/include/asm-x86/processor.h 40cf1596bim9F9DNdV75klgRSZ6Y2A xen/include/asm-x86/regs.h 3ddb79c2plf7ciNgoNjU-RsbUzawsw xen/include/asm-x86/rwlock.h diff --git a/xen/Rules.mk b/xen/Rules.mk index 82599afec0..186f4e3536 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -54,9 +54,9 @@ else CFLAGS += -DVERBOSE endif -ifeq ($(debugger),y) -CFLAGS += -DXEN_DEBUGGER -endif +#ifeq ($(debugger),y) +#CFLAGS += -DXEN_DEBUGGER +#endif ifeq ($(perfc),y) CFLAGS += -DPERF_COUNTERS diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 992d580fef..fe9a39df82 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,11 +1,6 @@ include $(BASEDIR)/Rules.mk -ifneq ($(debugger),y) -OBJS := $(subst pdb-linux.o,,$(OBJS)) -OBJS := $(subst pdb-stub.o,,$(OBJS)) -endif - OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S)) OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c)) OBJS += $(patsubst %.c,%.o,$(wildcard mtrr/*.c)) diff --git a/xen/arch/x86/dom0_ops.c b/xen/arch/x86/dom0_ops.c index c173d043a2..8b06d8bc2c 100644 --- a/xen/arch/x86/dom0_ops.c +++ b/xen/arch/x86/dom0_ops.c @@ -15,7 +15,6 @@ #include <xen/event.h> #include <asm/domain_page.h> #include <asm/msr.h> -#include <asm/pdb.h> #include <xen/trace.h> #include <xen/console.h> #include <asm/shadow.h> diff --git a/xen/arch/x86/pdb-linux.c b/xen/arch/x86/pdb-linux.c deleted file mode 100644 index cb4f0e0e78..0000000000 --- a/xen/arch/x86/pdb-linux.c +++ /dev/null @@ -1,100 +0,0 @@ - -/* - * pervasive debugger - * www.cl.cam.ac.uk/netos/pdb - * - * alex ho - * 2004 - * university of cambridge computer laboratory - * - * linux & i386 dependent code. bleech. - */ - -#include <asm/pdb.h> - -/* offset to the first instruction in the linux system call code - where we can safely set a breakpoint */ -unsigned int pdb_linux_syscall_enter_bkpt_offset = 20; - -/* offset to eflags saved on the stack after an int 80 */ -unsigned int pdb_linux_syscall_eflags_offset = 48; - -/* offset to the instruction pointer saved on the stack after an int 80 */ -unsigned int pdb_linux_syscall_eip_offset = 40; - -unsigned char -pdb_linux_set_bkpt (unsigned long addr) -{ - unsigned char old_instruction = *(unsigned char *)addr; - *(unsigned char *)addr = 0xcc; - return old_instruction; -} - -void -pdb_linux_clr_bkpt (unsigned long addr, unsigned char value) -{ - *(unsigned char *)addr = value; -} - -void -pdb_linux_syscall_enter_bkpt (struct xen_regs *regs, long error_code, - trap_info_t *ti) -{ - /* set at breakpoint at the beginning of the - system call in the target domain */ - - pdb_system_call_enter_instr = pdb_linux_set_bkpt(ti->address + - pdb_linux_syscall_enter_bkpt_offset); - pdb_system_call = 1; -} - -void -pdb_linux_syscall_exit_bkpt (struct xen_regs *regs, struct pdb_context *pdb_ctx) -{ - /* - we've hit an int 0x80 in a user's program, jumped into xen - (traps.c::do_general_protection()) which re-wrote the next - instruction in the os kernel to 0xcc, and then hit that - exception. - - we need to re-write the return instruction in the user's - program so that we know when we have finished the system call - and are back in the user's program. - - at this point our stack should look something like this: - - esp = 0x80a59f0 - esp + 4 = 0x0 - esp + 8 = 0x80485a0 - esp + 12 = 0x2d - esp + 16 = 0x80485f4 - esp + 20 = 0xbffffa48 - esp + 24 = 0xd - esp + 28 = 0xc00a0833 - esp + 32 = 0x833 - esp + 36 = 0xd - esp + 40 = 0x804dcdd saved eip - esp + 44 = 0x82b saved cs - esp + 48 = 0x213392 saved eflags - esp + 52 = 0xbffffa2c saved esp - esp + 56 = 0x833 saved ss - esp + 60 = 0x1000000 - */ - - /* restore the entry instruction for the system call */ - pdb_linux_clr_bkpt(regs->eip - 1, pdb_system_call_enter_instr); - - /* save the address of eflags that was saved on the stack */ - pdb_system_call_eflags_addr = (regs->esp + - pdb_linux_syscall_eflags_offset); - - /* muck with the return instruction so that we trap back into the - debugger when re-entering user space */ - pdb_system_call_next_addr = *(unsigned long *)(regs->esp + - pdb_linux_syscall_eip_offset); - pdb_linux_get_values (&pdb_system_call_leave_instr, 1, - pdb_system_call_next_addr, - pdb_ctx->process, pdb_ctx->ptbr); - pdb_linux_set_values ("cc", 1, pdb_system_call_next_addr, - pdb_ctx->process, pdb_ctx->ptbr); -} diff --git a/xen/arch/x86/pdb-stub.c b/xen/arch/x86/pdb-stub.c deleted file mode 100644 index 568bcea113..0000000000 --- a/xen/arch/x86/pdb-stub.c +++ /dev/null @@ -1,1280 +0,0 @@ - -/* - * pervasive debugger - * www.cl.cam.ac.uk/netos/pdb - * - * alex ho - * 2004 - * university of cambridge computer laboratory - * - * code adapted originally from kgdb, nemesis, & gdbserver - */ - -#include <xen/lib.h> -#include <xen/sched.h> -#include <asm/regs.h> -#include <xen/keyhandler.h> -#include <asm/apic.h> -#include <asm/domain_page.h> /* [un]map_domain_mem */ -#include <asm/processor.h> -#include <asm/pdb.h> -#include <xen/list.h> -#include <xen/serial.h> -#include <xen/softirq.h> -#include <xen/init.h> - -/* opt_pdb: Name of serial port for Xen pervasive debugger (and enable pdb) */ -static unsigned char opt_pdb[10] = "none"; -string_param("pdb", opt_pdb); - -#define PDB_DEBUG_TRACE -#ifdef PDB_DEBUG_TRACE -#define TRC(_x) _x -#else -#define TRC(_x) -#endif - -#define DEBUG_EXCEPTION 0x01 -#define BREAKPT_EXCEPTION 0x03 -#define PDB_LIVE_EXCEPTION 0x58 -#define KEYPRESS_EXCEPTION 0x88 - -#define BUFMAX 400 - -static const char hexchars[] = "0123456789abcdef"; - -static int remote_debug; - -#define PDB_BUFMAX 1024 -static char pdb_in_buffer[PDB_BUFMAX]; -static char pdb_out_buffer[PDB_BUFMAX]; -static char pdb_buffer[PDB_BUFMAX]; - -struct pdb_context pdb_ctx; -int pdb_continue_thread = 0; -int pdb_general_thread = 0; - -void pdb_put_packet (unsigned char *buffer, int ack); -void pdb_bkpt_check (u_char *buffer, int length, - unsigned long cr3, unsigned long addr); - -int pdb_initialized = 0; -int pdb_page_fault_possible = 0; -int pdb_page_fault_scratch = 0; /* just a handy variable */ -int pdb_page_fault = 0; -static int pdb_serhnd = -1; -static int pdb_stepping = 0; - -int pdb_system_call = 0; -unsigned char pdb_system_call_enter_instr = 0; /* original enter instr */ -unsigned char pdb_system_call_leave_instr = 0; /* original next instr */ -unsigned long pdb_system_call_next_addr = 0; /* instr after int 0x80 */ -unsigned long pdb_system_call_eflags_addr = 0; /* saved eflags on stack */ - -static inline void pdb_put_char(unsigned char c) -{ - serial_putc(pdb_serhnd, c); -} - -static inline unsigned char pdb_get_char(void) -{ - return serial_getc(pdb_serhnd); -} - -int -get_char (char *addr) -{ - return *addr; -} - -void -set_char (char *addr, int val) -{ - *addr = val; -} - -void -pdb_process_query (char *ptr) -{ - if (strcmp(ptr, "C") == 0) - { - /* empty string */ - } - else if (strcmp(ptr, "fThreadInfo") == 0) - { -#ifdef PDB_PAST - struct domain *p; -#endif /* PDB_PAST */ - - int buf_idx = 0; - - pdb_out_buffer[buf_idx++] = 'l'; - pdb_out_buffer[buf_idx++] = 0; - -#ifdef PDB_PAST - switch (pdb_level) - { - case PDB_LVL_XEN: /* return a list of domains */ - { - int count = 0; - - read_lock(&domlist_lock); - - pdb_out_buffer[buf_idx++] = 'm'; - for_each_domain ( p ) - { - domid_t domain = p->domain + PDB_ID_OFFSET; - - if (count > 0) - { - pdb_out_buffer[buf_idx++] = ','; - } - if (domain > 15) - { - pdb_out_buffer[buf_idx++] = hexchars[domain >> 4]; - } - pdb_out_buffer[buf_idx++] = hexchars[domain % 16]; - count++; - } - pdb_out_buffer[buf_idx++] = 0; - - read_unlock(&domlist_lock); - break; - } - case PDB_LVL_GUESTOS: /* return a list of processes */ - { - int foobar[20]; - int loop, total; - - /* this cr3 is wrong! */ - total = pdb_linux_process_list(pdb_ctx[pdb_level].info_cr3, - foobar, 20); - - pdb_out_buffer[buf_idx++] = 'm'; - pdb_out_buffer[buf_idx++] = '1'; /* 1 is to go back */ - for (loop = 0; loop < total; loop++) - { - int pid = foobar[loop] + PDB_ID_OFFSET; - - pdb_out_buffer[buf_idx++] = ','; - if (pid > 15) - { - pdb_out_buffer[buf_idx++] = hexchars[pid >> 4]; - } - pdb_out_buffer[buf_idx++] = hexchars[pid % 16]; - } - pdb_out_buffer[buf_idx++] = 0; - break; - } - case PDB_LVL_PROCESS: /* hmmm... */ - { - pdb_out_buffer[buf_idx++] = 'm'; - pdb_out_buffer[buf_idx++] = '1'; /* 1 is to go back */ - break; - } - default: - break; - } -#endif /* PDB_PAST */ - - } - else if (strcmp(ptr, "sThreadInfo") == 0) - { - int buf_idx = 0; - - pdb_out_buffer[buf_idx++] = 'l'; - pdb_out_buffer[buf_idx++] = 0; - } - else if (strncmp(ptr, "ThreadExtraInfo,", 16) == 0) - { - int thread = 0; - char *message = "foobar ?"; - - ptr += 16; - if (hexToInt (&ptr, &thread)) - { - mem2hex (message, pdb_out_buffer, strlen(message) + 1); - } - -#ifdef PDB_PAST - int thread = 0; - char message[16]; - struct domain *p; - - strncpy (message, dom0->name, 16); - - ptr += 16; - if (hexToInt (&ptr, &thread)) - { - mem2hex ((char *)message, pdb_out_buffer, strlen(message) + 1); - } -#endif /* PDB_PAST */ - -#ifdef PDB_FUTURE - { - char string[task_struct_comm_length]; - - string[0] = 0; - pdb_linux_process_details (cr3, pid, string); - printk (" (%s)", string); - } -#endif /* PDB_FUTURE*/ - - } - else if (strcmp(ptr, "Offsets") == 0) - { - /* empty string */ - } - else if (strncmp(ptr, "Symbol", 6) == 0) - { - strcpy (pdb_out_buffer, "OK"); - } - else - { - printk("pdb: error, unknown query [%s]\n", ptr); - } -} - -void -pdb_x86_to_gdb_regs (char *buffer, struct xen_regs *regs) -{ - int idx = 0; - - mem2hex ((char *)®s->eax, &buffer[idx], sizeof(regs->eax)); - idx += sizeof(regs->eax) * 2; - mem2hex ((char *)®s->ecx, &buffer[idx], sizeof(regs->ecx)); - idx += sizeof(regs->ecx) * 2; - mem2hex ((char *)®s->edx, &buffer[idx], sizeof(regs->edx)); - idx += sizeof(regs->edx) * 2; - mem2hex ((char *)®s->ebx, &buffer[idx], sizeof(regs->ebx)); - idx += sizeof(regs->ebx) * 2; - mem2hex ((char *)®s->esp, &buffer[idx], sizeof(regs->esp)); - idx += sizeof(regs->esp) * 2; - mem2hex ((char *)®s->ebp, &buffer[idx], sizeof(regs->ebp)); - idx += sizeof(regs->ebp) * 2; - mem2hex ((char *)®s->esi, &buffer[idx], sizeof(regs->esi)); - idx += sizeof(regs->esi) * 2; - mem2hex ((char *)®s->edi, &buffer[idx], sizeof(regs->edi)); - idx += sizeof(regs->edi) * 2; - mem2hex ((char *)®s->eip, &buffer[idx], sizeof(regs->eip)); - idx += sizeof(regs->eip) * 2; - mem2hex ((char *)®s->eflags, &buffer[idx], sizeof(regs->eflags)); - idx += sizeof(regs->eflags) * 2; - mem2hex ((char *)®s->cs, &buffer[idx], sizeof(regs->cs)); - idx += sizeof(regs->cs) * 2; - mem2hex ((char *)®s->ss, &buffer[idx], sizeof(regs->ss)); - idx += sizeof(regs->ss) * 2; - mem2hex ((char *)®s->ds, &buffer[idx], sizeof(regs->ds)); - idx += sizeof(regs->ds) * 2; - mem2hex ((char *)®s->es, &buffer[idx], sizeof(regs->es)); - idx += sizeof(regs->es) * 2; - mem2hex ((char *)®s->fs, &buffer[idx], sizeof(regs->fs)); - idx += sizeof(regs->fs) * 2; - mem2hex ((char *)®s->gs, &buffer[idx], sizeof(regs->gs)); -} - -/* at this point we allow any register to be changed, caveat emptor */ -void -pdb_gdb_to_x86_regs (struct xen_regs *regs, char *buffer) -{ - hex2mem(buffer, (char *)®s->eax, sizeof(regs->eax)); - buffer += sizeof(regs->eax) * 2; - hex2mem(buffer, (char *)®s->ecx, sizeof(regs->ecx)); - buffer += sizeof(regs->ecx) * 2; - hex2mem(buffer, (char *)®s->edx, sizeof(regs->edx)); - buffer += sizeof(regs->edx) * 2; - hex2mem(buffer, (char *)®s->ebx, sizeof(regs->ebx)); - buffer += sizeof(regs->ebx) * 2; - hex2mem(buffer, (char *)®s->esp, sizeof(regs->esp)); - buffer += sizeof(regs->esp) * 2; - hex2mem(buffer, (char *)®s->ebp, sizeof(regs->ebp)); - buffer += sizeof(regs->ebp) * 2; - hex2mem(buffer, (char *)®s->esi, sizeof(regs->esi)); - buffer += sizeof(regs->esi) * 2; - hex2mem(buffer, (char *)®s->edi, sizeof(regs->edi)); - buffer += sizeof(regs->edi) * 2; - hex2mem(buffer, (char *)®s->eip, sizeof(regs->eip)); - buffer += sizeof(regs->eip) * 2; - hex2mem(buffer, (char *)®s->eflags, sizeof(regs->eflags)); - buffer += sizeof(regs->eflags) * 2; - hex2mem(buffer, (char *)®s->cs, sizeof(regs->cs)); - buffer += sizeof(regs->cs) * 2; - hex2mem(buffer, (char *)®s->ss, sizeof(regs->ss)); - buffer += sizeof(regs->ss) * 2; - hex2mem(buffer, (char *)®s->ds, sizeof(regs->ds)); - buffer += sizeof(regs->ds) * 2; - hex2mem(buffer, (char *)®s->es, sizeof(regs->es)); - buffer += sizeof(regs->es) * 2; - hex2mem(buffer, (char *)®s->fs, sizeof(regs->fs)); - buffer += sizeof(regs->fs) * 2; - hex2mem(buffer, (char *)®s->gs, sizeof(regs->gs)); -} - -int -pdb_process_command (char *ptr, struct xen_regs *regs, unsigned long cr3, - int sigval) -{ - int length; - unsigned long addr; - int ack = 1; /* wait for ack in pdb_put_packet */ - int go = 0; - - TRC(printf("pdb: [%s]\n", ptr)); - - pdb_out_buffer[0] = 0; - - if (pdb_ctx.valid == 1) - { - if (pdb_ctx.domain == -1) /* pdb context: xen */ - { - struct domain *p; - - p = &idle0_task; - if (p->mm.shadow_mode) - pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table); - else - pdb_ctx.ptbr = pagetable_val(p->mm.pagetable); - } - else if (pdb_ctx.process == -1) /* pdb context: guest os */ - { - struct domain *p; - - if (pdb_ctx.domain == -2) - { - p = find_last_domain(); - } - else - { - p = find_domain_by_id(pdb_ctx.domain); - } - if (p == NULL) - { - printk ("pdb error: unknown domain [0x%x]\n", pdb_ctx.domain); - strcpy (pdb_out_buffer, "E01"); - pdb_ctx.domain = -1; - goto exit; - } - if (p->mm.shadow_mode) - pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table); - else - pdb_ctx.ptbr = pagetable_val(p->mm.pagetable); - put_domain(p); - } - else /* pdb context: process */ - { - struct domain *p; - unsigned long domain_ptbr; - - p = find_domain_by_id(pdb_ctx.domain); - if (p == NULL) - { - printk ("pdb error: unknown domain [0x%x][0x%x]\n", - pdb_ctx.domain, pdb_ctx.process); - strcpy (pdb_out_buffer, "E01"); - pdb_ctx.domain = -1; - goto exit; - } - if (p->mm.shadow_mode) - domain_ptbr = pagetable_val(p->mm.shadow_table); - else - domain_ptbr = pagetable_val(p->mm.pagetable); - put_domain(p); - - pdb_ctx.ptbr = domain_ptbr; - /*pdb_ctx.ptbr=pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process);*/ - } - - pdb_ctx.valid = 0; - TRC(printk ("pdb change context (dom:%d, proc:%d) now 0x%lx\n", - pdb_ctx.domain, pdb_ctx.process, pdb_ctx.ptbr)); - } - - switch (*ptr++) - { - case '?': - pdb_out_buffer[0] = 'S'; - pdb_out_buffer[1] = hexchars[sigval >> 4]; - pdb_out_buffer[2] = hexchars[sigval % 16]; - pdb_out_buffer[3] = 0; - break; - case 'S': /* step with signal */ - case 's': /* step */ - { - if ( pdb_system_call_eflags_addr != 0 ) - { - unsigned long eflags; - char eflags_buf[sizeof(eflags)*2]; /* STUPID STUPID STUPID */ - - pdb_linux_get_values((u_char*)&eflags, sizeof(eflags), - pdb_system_call_eflags_addr, - pdb_ctx.process, pdb_ctx.ptbr); - eflags |= X86_EFLAGS_TF; - mem2hex ((u_char *)&eflags, eflags_buf, sizeof(eflags)); - pdb_linux_set_values(eflags_buf, sizeof(eflags), - pdb_system_call_eflags_addr, - pdb_ctx.process, pdb_ctx.ptbr); - } - - regs->eflags |= X86_EFLAGS_TF; - pdb_stepping = 1; - return 1; - /* not reached */ - } - case 'C': /* continue with signal */ - case 'c': /* continue */ - { - if ( pdb_system_call_eflags_addr != 0 ) - { - unsigned long eflags; - char eflags_buf[sizeof(eflags)*2]; /* STUPID STUPID STUPID */ - - pdb_linux_get_values((u_char*)&eflags, sizeof(eflags), - pdb_system_call_eflags_addr, - pdb_ctx.process, pdb_ctx.ptbr); - eflags &= ~X86_EFLAGS_TF; - mem2hex ((u_char *)&eflags, eflags_buf, sizeof(eflags)); - pdb_linux_set_values(eflags_buf, sizeof(eflags), - pdb_system_call_eflags_addr, - pdb_ctx.process, pdb_ctx.ptbr); - } - - regs->eflags &= ~X86_EFLAGS_TF; - return 1; /* jump out before replying to gdb */ - /* not reached */ - } - case 'd': - remote_debug = !(remote_debug); /* toggle debug flag */ - break; - case 'D': /* detach */ - return go; - /* not reached */ - case 'g': /* return the value of the CPU registers */ - { - pdb_x86_to_gdb_regs (pdb_out_buffer, regs); - break; - } - case 'G': /* set the value of the CPU registers - return OK */ - { - pdb_gdb_to_x86_regs (regs, ptr); - break; - } - case 'H': - { - int thread; - char *next = &ptr[1]; - - if (hexToInt (&next, &thread)) - { - if (*ptr == 'c') - { - pdb_continue_thread = thread; - } - else if (*ptr == 'g') - { - pdb_general_thread = thread; - } - else - { - printk ("pdb error: unknown set thread command %c (%d)\n", - *ptr, thread); - strcpy (pdb_out_buffer, "E00"); - break; - } - } - strcpy (pdb_out_buffer, "OK"); - break; - } - case 'k': /* kill request */ - { - strcpy (pdb_out_buffer, "OK"); /* ack for fun */ - printk ("don't kill bill...\n"); - ack = 0; - break; - } - - case 'q': - { - pdb_process_query(ptr); - break; - } - - /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ - case 'm': - { - /* TRY TO READ %x,%x. IF SUCCEED, SET PTR = 0 */ - if (hexToInt (&ptr, (int *)&addr)) - if (*(ptr++) == ',') - if (hexToInt (&ptr, &length)) - { - ptr = 0; - - pdb_page_fault_possible = 1; - pdb_page_fault = 0; - if (addr >= PAGE_OFFSET) - { - mem2hex ((char *) addr, pdb_out_buffer, length); - } - else if (pdb_ctx.process != -1) - { - pdb_linux_get_values(pdb_buffer, length, addr, - pdb_ctx.process, pdb_ctx.ptbr); - mem2hex (pdb_buffer, pdb_out_buffer, length); - } - else - { - pdb_get_values (pdb_buffer, length, - pdb_ctx.ptbr, addr); - mem2hex (pdb_buffer, pdb_out_buffer, length); - } - - pdb_page_fault_possible = 0; - if (pdb_page_fault) - { - strcpy (pdb_out_buffer, "E03"); - } - } - - if (ptr) - { - strcpy (pdb_out_buffer, "E01"); - } - break; - } - - /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ - case 'M': - { - /* TRY TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */ - if (hexToInt (&ptr, (int *)&addr)) - if (*(ptr++) == ',') - if (hexToInt (&ptr, &length)) - if (*(ptr++) == ':') - { - - pdb_page_fault_possible = 1; - pdb_page_fault = 0; - if (addr >= PAGE_OFFSET) - { - hex2mem (ptr, (char *)addr, length); - pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr); - } - else if (pdb_ctx.process != -1) - { - pdb_linux_set_values(ptr, length, addr, - pdb_ctx.process, - pdb_ctx.ptbr); - pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr); - } - else - { - pdb_set_values (ptr, length, - pdb_ctx.ptbr, addr); - pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr); - } - pdb_page_fault_possible = 0; - if (pdb_page_fault) - { - strcpy (pdb_out_buffer, "E03"); - } - else - { - strcpy (pdb_out_buffer, "OK"); - } - - ptr = 0; - } - if (ptr) - { - strcpy (pdb_out_buffer, "E02"); - } - break; - } - case 'T': - { - int id; - - if (hexToInt (&ptr, &id)) - { - strcpy (pdb_out_buffer, "E00"); - -#ifdef PDB_PAST - - switch (pdb_level) /* previous level */ - { - case PDB_LVL_XEN: - { - struct domain *p; - id -= PDB_ID_OFFSET; - if ( (p = find_domain_by_id(id)) == NULL) - strcpy (pdb_out_buffer, "E00"); - else - strcpy (pdb_out_buffer, "OK"); - put_domain(p); - - pdb_level = PDB_LVL_GUESTOS; - pdb_ctx[pdb_level].ctrl = id; - pdb_ctx[pdb_level].info = id; - break; - } - case PDB_LVL_GUESTOS: - { - if (pdb_level == -1) - { - pdb_level = PDB_LVL_XEN; - } - else - { - pdb_level = PDB_LVL_PROCESS; - pdb_ctx[pdb_level].ctrl = id; - pdb_ctx[pdb_level].info = id; - } - break; - } - case PDB_LVL_PROCESS: - { - if (pdb_level == -1) - { - pdb_level = PDB_LVL_GUESTOS; - } - break; - } - default: - { - printk ("pdb internal error: invalid level [%d]\n", - pdb_level); - } - } - -#endif /* PDB_PAST */ - } - break; - } - } - -exit: - /* reply to the request */ - pdb_put_packet (pdb_out_buffer, ack); - - return go; -} - -/* - * process an input character from the serial line. - * - * return "1" if the character is a gdb debug string - * (and hence shouldn't be further processed). - */ - -int pdb_debug_state = 0; /* small parser state machine */ - -int hex(char ch) -{ - if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) return (ch-'0'); - if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10); - return (-1); -} - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -char * -mem2hex (mem, buf, count) - char *mem; - char *buf; - int count; -{ - int i; - unsigned char ch; - - for (i = 0; i < count; i++) - { - ch = get_char (mem++); - *buf++ = hexchars[ch >> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - return (buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ -char * -hex2mem (buf, mem, count) - char *buf; - char *mem; - int count; -{ - int i; - unsigned char ch; - - for (i = 0; i < count; i++) - { - ch = hex (*buf++) << 4; - ch = ch + hex (*buf++); - set_char (mem++, ch); - } - return (mem); -} - -int -hexToInt (char **ptr, int *intValue) -{ - int numChars = 0; - int hexValue; - int negative = 0; - - *intValue = 0; - - if (**ptr == '-') - { - negative = 1; - numChars++; - (*ptr)++; - } - - while (**ptr) - { - hexValue = hex (**ptr); - if (hexValue >= 0) - { - *intValue = (*intValue << 4) | hexValue; - numChars++; - } - else - break; - - (*ptr)++; - } - - if ( negative ) - *intValue *= -1; - - return (numChars); -} - -/***********************************************************************/ -/***********************************************************************/ - - -/* - * Add a breakpoint to the list of known breakpoints. - * For now there should only be two or three breakpoints so - * we use a simple linked list. In the future, maybe a red-black tree? - */ -struct pdb_breakpoint breakpoints; - -void pdb_bkpt_add (unsigned long cr3, unsigned long address) -{ - struct pdb_breakpoint *bkpt = xmalloc(sizeof(*bkpt)); - bkpt->cr3 = cr3; - bkpt->address = address; - list_add(&bkpt->list, &breakpoints.list); -} - -/* - * Check to see of the breakpoint is in the list of known breakpoints - * Return 1 if it has been set, NULL otherwise. - */ -struct pdb_breakpoint* pdb_bkpt_search (unsigned long cr3, - unsigned long address) -{ - struct pdb_breakpoint *bkpt; - - list_for_each_entry ( bkpt, &breakpoints.list, list ) - { - if ( bkpt->cr3 == cr3 && bkpt->address == address ) - return bkpt; - } - - return NULL; -} - -/* - * Remove a breakpoint to the list of known breakpoints. - * Return 1 if the element was not found, otherwise 0. - */ -int pdb_bkpt_remove (unsigned long cr3, unsigned long address) -{ - struct pdb_breakpoint *bkpt; - - list_for_each_entry ( bkpt, &breakpoints.list, list ) - { - if ( bkpt->cr3 == cr3 && bkpt->address == address ) - { - list_del(&bkpt->list); - xfree(bkpt); - return 0; - } - } - - return 1; -} - -/* - * Check to see if a memory write is really gdb setting a breakpoint - */ -void pdb_bkpt_check (u_char *buffer, int length, - unsigned long cr3, unsigned long addr) -{ - if (length == 1 && buffer[0] == 'c' && buffer[1] == 'c') - { - /* inserting a new breakpoint */ - pdb_bkpt_add(cr3, addr); - TRC(printk("pdb breakpoint detected at 0x%lx:0x%lx\n", cr3, addr)); - } - else if ( pdb_bkpt_remove(cr3, addr) == 0 ) - { - /* removing a breakpoint */ - TRC(printk("pdb breakpoint cleared at 0x%lx:0x%lx\n", cr3, addr)); - } -} - -/***********************************************************************/ - -int pdb_change_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr, int rw); -int pdb_change_values_one_page(u_char *buffer, int length, - unsigned long cr3, unsigned long addr, int rw); - -#define __PDB_GET_VAL 1 -#define __PDB_SET_VAL 2 - -/* - * Set memory in a domain's address space - * Set "length" bytes at "address" from "domain" to the values in "buffer". - * Return the number of bytes set, 0 if there was a problem. - */ - -int pdb_set_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr) -{ - int count = pdb_change_values(buffer, length, cr3, addr, __PDB_SET_VAL); - return count; -} - -/* - * Read memory from a domain's address space. - * Fetch "length" bytes at "address" from "domain" into "buffer". - * Return the number of bytes read, 0 if there was a problem. - */ - -int pdb_get_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr) -{ - return pdb_change_values(buffer, length, cr3, addr, __PDB_GET_VAL); -} - -/* - * Read or write memory in an address space - */ -int pdb_change_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr, int rw) -{ - int remaining; /* number of bytes to touch past this page */ - int bytes = 0; - - while ( (remaining = (addr + length - 1) - (addr | (PAGE_SIZE - 1))) > 0) - { - bytes += pdb_change_values_one_page(buffer, length - remaining, - cr3, addr, rw); - buffer = buffer + (2 * (length - remaining)); - length = remaining; - addr = (addr | (PAGE_SIZE - 1)) + 1; - } - - bytes += pdb_change_values_one_page(buffer, length, cr3, addr, rw); - return bytes; -} - -/* - * Change memory in a process' address space in one page - * Read or write "length" bytes at "address" into/from "buffer" - * from the virtual address space referenced by "cr3". - * Return the number of bytes read, 0 if there was a problem. - */ - -int pdb_change_values_one_page(u_char *buffer, int length, - unsigned long cr3, unsigned long addr, int rw) -{ - l2_pgentry_t* l2_table = NULL; /* page directory */ - l1_pgentry_t* l1_table = NULL; /* page table */ - u_char *page; /* 4k page */ - int bytes = 0; - - l2_table = map_domain_mem(cr3); - l2_table += l2_table_offset(addr); - if (!(l2_pgentry_val(*l2_table) & _PAGE_PRESENT)) - { - if (pdb_page_fault_possible == 1) - { - pdb_page_fault = 1; - TRC(printk("pdb: L2 error (0x%lx)\n", addr)); - } - else - { - printk ("pdb error: cr3: 0x%lx dom0cr3: 0x%lx\n", cr3, - dom0->mm.shadow_mode ? pagetable_val(dom0->mm.shadow_table) - : pagetable_val(dom0->mm.pagetable)); - printk ("pdb error: L2:0x%p (0x%lx)\n", - l2_table, l2_pgentry_val(*l2_table)); - } - goto exit2; - } - - if (l2_pgentry_val(*l2_table) & _PAGE_PSE) - { -#define PSE_PAGE_SHIFT L2_PAGETABLE_SHIFT -#define PSE_PAGE_SIZE (1UL << PSE_PAGE_SHIFT) -#define PSE_PAGE_MASK (~(PSE_PAGE_SIZE-1)) - -#define L1_PAGE_BITS ( (ENTRIES_PER_L1_PAGETABLE - 1) << L1_PAGETABLE_SHIFT ) - -#define pse_pgentry_to_phys(_x) (l2_pgentry_val(_x) & PSE_PAGE_MASK) - - page = map_domain_mem(pse_pgentry_to_phys(*l2_table) + /* 10 bits */ - (addr & L1_PAGE_BITS)); /* 10 bits */ - page += addr & (PAGE_SIZE - 1); /* 12 bits */ - } - else - { - l1_table = map_domain_mem(l2_pgentry_to_phys(*l2_table)); - l1_table += l1_table_offset(addr); - if (!(l1_pgentry_val(*l1_table) & _PAGE_PRESENT)) - { - if (pdb_page_fault_possible == 1) - { - pdb_page_fault = 1; - TRC(printk ("pdb: L1 error (0x%lx)\n", addr)); - } - else - { - printk ("L2:0x%p (0x%lx) L1:0x%p (0x%lx)\n", - l2_table, l2_pgentry_val(*l2_table), - l1_table, l1_pgentry_val(*l1_table)); - } - goto exit1; - } - - page = map_domain_mem(l1_pgentry_to_phys(*l1_table)); - page += addr & (PAGE_SIZE - 1); - } - - switch (rw) - { - case __PDB_GET_VAL: /* read */ - memcpy (buffer, page, length); - bytes = length; - break; - case __PDB_SET_VAL: /* write */ - hex2mem (buffer, page, length); - bytes = length; - break; - default: /* unknown */ - printk ("error: unknown RW flag: %d\n", rw); - return 0; - } - - unmap_domain_mem((void *)page); -exit1: - if (l1_table != NULL) - unmap_domain_mem((void *)l1_table); -exit2: - unmap_domain_mem((void *)l2_table); - - return bytes; -} - -/***********************************************************************/ - -void breakpoint(void); - -/* send the packet in buffer. */ -void pdb_put_packet (unsigned char *buffer, int ack) -{ - unsigned char checksum; - int count; - char ch; - - /* $<packet info>#<checksum> */ - /* do */ - { - pdb_put_char ('$'); - checksum = 0; - count = 0; - - while ((ch = buffer[count])) - { - pdb_put_char (ch); - checksum += ch; - count += 1; - } - - pdb_put_char('#'); - pdb_put_char(hexchars[checksum >> 4]); - pdb_put_char(hexchars[checksum % 16]); - } - - if (ack) - { - if ((ch = pdb_get_char()) != '+') - { - printk(" pdb return error: %c 0x%x [%s]\n", ch, ch, buffer); - } - } -} - -void pdb_get_packet(char *buffer) -{ - int count; - char ch; - unsigned char checksum = 0; - unsigned char xmitcsum = 0; - - do - { - while ((ch = pdb_get_char()) != '$'); - - count = 0; - checksum = 0; - - while (count < BUFMAX) - { - ch = pdb_get_char(); - if (ch == '#') break; - checksum += ch; - buffer[count] = ch; - count++; - } - buffer[count] = 0; - - if (ch == '#') - { - xmitcsum = hex(pdb_get_char()) << 4; - xmitcsum += hex(pdb_get_char()); - - if (xmitcsum == checksum) - { - pdb_put_char('+'); - if (buffer[2] == ':') - { - printk ("pdb: obsolete gdb packet (sequence ID)\n"); - } - } - else - { - pdb_put_char('-'); - } - } - } while (checksum != xmitcsum); - - return; -} - -/* - * process a machine interrupt or exception - * Return 1 if pdb is not interested in the exception; it should - * be propagated to the guest os. - */ - -int pdb_handle_exception(int exceptionVector, - struct xen_regs *xen_regs) -{ - int signal = 0; - struct pdb_breakpoint* bkpt; - int watchdog_save; - unsigned long cr3 = read_cr3(); - - /* No vm86 handling here as yet. */ - if ( VM86_MODE(xen_regs) ) - return 1; - - /* If the exception is an int3 from user space then pdb is only - interested if it re-wrote an instruction set the breakpoint. - This occurs when leaving a system call from a domain. - */ - if ( (exceptionVector == 3) && - RING_3(xen_regs) && - (xen_regs->eip != (pdb_system_call_next_addr + 1)) ) - { - TRC(printf("pdb: user bkpt (0x%x) at 0x%x:0x%lx:0x%x\n", - exceptionVector, xen_regs->cs & 3, cr3, xen_regs->eip)); - return 1; - } - - /* - * If PDB didn't set the breakpoint, is not single stepping, - * is not entering a system call in a domain, - * the user didn't press the magic debug key, - * then we don't handle the exception. - */ - bkpt = pdb_bkpt_search(cr3, xen_regs->eip - 1); - if ( (bkpt == NULL) && - !pdb_stepping && - !pdb_system_call && - xen_regs->eip != pdb_system_call_next_addr + 1 && - (exceptionVector != KEYPRESS_EXCEPTION) && - xen_regs->eip < 0xc0000000) /* Linux-specific for now! */ - { - TRC(printf("pdb: user bkpt (0x%x) at 0x%lx:0x%x\n", - exceptionVector, cr3, xen_regs->eip)); - return 1; - } - - printk("pdb_handle_exception [0x%x][0x%lx:0x%x]\n", - exceptionVector, cr3, xen_regs->eip); - - if ( pdb_stepping ) - { - /* Stepped one instruction; now return to normal execution. */ - xen_regs->eflags &= ~X86_EFLAGS_TF; - pdb_stepping = 0; - } - - if ( pdb_system_call ) - { - pdb_system_call = 0; - - pdb_linux_syscall_exit_bkpt (xen_regs, &pdb_ctx); - - /* we don't have a saved breakpoint so we need to rewind eip */ - xen_regs->eip--; - - /* if ther user doesn't care about breaking when entering a - system call then we'll just ignore the exception */ - if ( (pdb_ctx.system_call & 0x01) == 0 ) - { - return 0; - } - } - - if ( exceptionVector == BREAKPT_EXCEPTION && bkpt != NULL) - { - /* Executed Int3: replace breakpoint byte with real program byte. */ - xen_regs->eip--; - } - - /* returning to user space after a system call */ - if ( xen_regs->eip == pdb_system_call_next_addr + 1) - { - u_char instr[2]; /* REALLY REALLY REALLY STUPID */ - - mem2hex (&pdb_system_call_leave_instr, instr, sizeof(instr)); - - pdb_linux_set_values (instr, 1, pdb_system_call_next_addr, - pdb_ctx.process, pdb_ctx.ptbr); - - pdb_system_call_next_addr = 0; - pdb_system_call_leave_instr = 0; - - /* manually rewind eip */ - xen_regs->eip--; - - /* if the user doesn't care about breaking when returning - to user space after a system call then we'll just ignore - the exception */ - if ( (pdb_ctx.system_call & 0x02) == 0 ) - { - return 0; - } - } - - /* Generate a signal for GDB. */ - switch ( exceptionVector ) - { - case KEYPRESS_EXCEPTION: - signal = 2; break; /* SIGINT */ - case DEBUG_EXCEPTION: - signal = 5; break; /* SIGTRAP */ - case BREAKPT_EXCEPTION: - signal = 5; break; /* SIGTRAP */ - default: - printk("pdb: can't generate signal for unknown exception vector %d\n", - exceptionVector); - break; - } - - pdb_out_buffer[0] = 'S'; - pdb_out_buffer[1] = hexchars[signal >> 4]; - pdb_out_buffer[2] = hexchars[signal % 16]; - pdb_out_buffer[3] = 0; - pdb_put_packet(pdb_out_buffer, 1); - - watchdog_save = watchdog_on; - watchdog_on = 0; - - do { - pdb_out_buffer[0] = 0; - pdb_get_packet(pdb_in_buffer); - } - while ( pdb_process_command(pdb_in_buffer, xen_regs, cr3, signal) == 0 ); - - watchdog_on = watchdog_save; - - return 0; -} - -void pdb_key_pressed(unsigned char key) -{ - struct xen_regs *regs = (struct xen_regs *)get_execution_context(); - pdb_handle_exception(KEYPRESS_EXCEPTION, regs); -} - -void pdb_handle_debug_trap(struct xen_regs *regs, long error_code) -{ - unsigned int condition; - struct domain *d = current; - struct trap_bounce *tb = &d->thread.trap_bounce; - - __asm__ __volatile__("movl %%db6,%0" : "=r" (condition)); - if ( (condition & (1 << 14)) != (1 << 14) ) - printk("\nwarning: debug trap w/o BS bit [0x%x]\n\n", condition); - __asm__("movl %0,%%db6" : : "r" (0)); - - if ( pdb_handle_exception(1, regs) != 0 ) - { - d->thread.debugreg[6] = condition; - - tb->flags = TBF_EXCEPTION; - tb->cs = d->thread.traps[1].cs; - tb->eip = d->thread.traps[1].address; - } -} - -void initialize_pdb() -{ - /* Certain state must be initialised even when PDB will not be used. */ - memset((void *) &breakpoints, 0, sizeof(breakpoints)); - INIT_LIST_HEAD(&breakpoints.list); - pdb_stepping = 0; - - if ( strcmp(opt_pdb, "none") == 0 ) - return; - - if ( (pdb_serhnd = parse_serial_handle(opt_pdb)) == -1 ) - { - printk("error: failed to initialize PDB on port %s\n", opt_pdb); - return; - } - - pdb_ctx.valid = 1; - pdb_ctx.domain = -1; - pdb_ctx.process = -1; - pdb_ctx.system_call = 0; - pdb_ctx.ptbr = 0; - - printk("pdb: pervasive debugger (%s) www.cl.cam.ac.uk/netos/pdb\n", - opt_pdb); - - /* Acknowledge any spurious GDB packets. */ - pdb_put_char('+'); - - register_keyhandler('D', pdb_key_pressed, "enter pervasive debugger"); - - pdb_initialized = 1; -} - -void breakpoint(void) -{ - if ( pdb_initialized ) - asm("int $3"); -} diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c31b4be199..e05643be99 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -17,7 +17,6 @@ #include <asm/apic.h> #include <asm/desc.h> #include <asm/domain_page.h> -#include <asm/pdb.h> #include <asm/shadow.h> #include <asm/e820.h> @@ -427,10 +426,6 @@ static void __init start_of_day(void) serial_init_stage2(); -#ifdef XEN_DEBUGGER - initialize_pdb(); /* pervasive debugger */ -#endif - if ( !cpu_has_apic ) { do_timer_lists_from_pit = 1; diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index fb1ded8945..2fc8bb4f55 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -1,4 +1,4 @@ -/* -*- Mode:C++; c-file-style:BSD; c-basic-offset:4; tab-width:4 -*- */ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ #include <xen/config.h> #include <xen/types.h> @@ -495,7 +495,7 @@ unsigned long shadow_l2_table( mk_l2_pgentry((spfn << PAGE_SHIFT) | __PAGE_HYPERVISOR); spl2e[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] = mk_l2_pgentry(__pa(page_get_owner(&frame_table[gpfn])->mm_perdomain_pt) | - __PAGE_HYPERVISOR); + __PAGE_HYPERVISOR); } #endif diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 3ff5e7f135..ebc772dee6 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1,4 +1,4 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- **************************************************************************** * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge * (C) 2002-2003 University of Cambridge diff --git a/xen/common/Makefile b/xen/common/Makefile index eb8d1b1f99..34dbb44175 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -9,11 +9,6 @@ OBJS := $(subst physdev.o,,$(OBJS)) OBJS := $(subst xmalloc.o,,$(OBJS)) endif -ifneq ($(debugger),y) -OBJS := $(subst debug.o,,$(OBJS)) -OBJS := $(subst debug-linux.o,,$(OBJS)) -endif - ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) endif diff --git a/xen/common/ac_timer.c b/xen/common/ac_timer.c index 6896e9945a..22c67aac22 100644 --- a/xen/common/ac_timer.c +++ b/xen/common/ac_timer.c @@ -1,4 +1,4 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- **************************************************************************** * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge * (C) 2002-2003 University of Cambridge diff --git a/xen/common/debug-linux.c b/xen/common/debug-linux.c deleted file mode 100644 index 03c4995eb1..0000000000 --- a/xen/common/debug-linux.c +++ /dev/null @@ -1,267 +0,0 @@ - -/* - * pervasive debugger - * www.cl.cam.ac.uk/netos/pdb - * - * alex ho - * 2004 - * university of cambridge computer laboratory - * - * linux specific pdb stuff - */ - -#include <xen/config.h> -#include <xen/types.h> -#include <xen/lib.h> -#include <public/dom0_ops.h> -#include <asm/pdb.h> - -/* from linux/sched.h */ -#define PIDHASH_SZ (4096 >> 2) -#define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1)) - -/* from asm-xen/pgtable-2level.h */ -#define PGDIR_SHIFT 22 -#define PTRS_PER_PGD 1024 - -/* from asm-xen/page.h */ -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - -#define __PAGE_OFFSET (0xC0000000) -#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) -#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) -#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) - -/* from debug.h */ -#define ENTRIES_PER_L1_PAGETABLE 1024 -#define L1_PAGE_BITS ( (ENTRIES_PER_L1_PAGETABLE - 1) << PAGE_SHIFT ) - -void pdb_linux_process_details (unsigned long cr3, int pid, char *buffer); - -/* adapted from asm-xen/page.h */ -static inline unsigned long machine_to_phys(unsigned long cr3, - unsigned long machine) -{ - unsigned long phys; - pdb_get_values((u_char *) &phys, sizeof(phys), cr3, - (unsigned long) machine_to_phys_mapping + - (machine >> PAGE_SHIFT) * 4); - phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK); - return phys; -} - -unsigned long pdb_pidhash_addr = 0xc01971e0UL; -unsigned long pdb_init_task_union_addr = 0xc0182000UL; - - -unsigned int task_struct_mm_offset = 0x2c; -unsigned int task_struct_next_task_offset = 0x48; -unsigned int task_struct_pid_offset = 0x7c; -unsigned int task_struct_pidhash_next_offset = 0xb0; -unsigned int task_struct_comm_offset = 0x23e; -unsigned int task_struct_comm_length = 0x10; - -unsigned int mm_struct_pgd_offset = 0x0c; - -/* - * find the task structure of a process (pid) - * given the cr3 of the guest os. - */ -unsigned long pdb_linux_pid_task_struct (unsigned long cr3, int pid) -{ - unsigned long task_struct_p = (unsigned long) NULL; - unsigned long task_struct_pid; - - /* find the task_struct of the given process */ - pdb_get_values((u_char *) &task_struct_p, sizeof(task_struct_p), - cr3, pdb_pidhash_addr + pid_hashfn(pid) * 4); - - /* find the correct task struct */ - while (task_struct_p != (unsigned long)NULL) - { - pdb_get_values((u_char *) &task_struct_pid, sizeof(task_struct_pid), - cr3, task_struct_p + task_struct_pid_offset); - if (task_struct_pid == pid) - { - break; - } - - pdb_get_values((u_char *) &task_struct_p, sizeof(task_struct_p), - cr3, task_struct_p + task_struct_pidhash_next_offset); - } - if (task_struct_p == (unsigned long) NULL) - { - /* oops */ - printk ("pdb error: couldn't find process 0x%x (0x%lx)\n", pid, cr3); - } - - return task_struct_p; -} - -/* - * find the ptbr of a process (pid) - * given the cr3 of the guest os. - */ -unsigned long pdb_linux_pid_ptbr (unsigned long cr3, int pid) -{ - unsigned long task_struct_p; - unsigned long mm_p, pgd; - - task_struct_p = pdb_linux_pid_task_struct(cr3, pid); - if (task_struct_p == (unsigned long) NULL) - { - return (unsigned long) NULL; - } - - /* get the mm_struct within the task_struct */ - pdb_get_values((u_char *) &mm_p, sizeof(mm_p), - cr3, task_struct_p + task_struct_mm_offset); - /* get the page global directory (cr3) within the mm_struct */ - pdb_get_values((u_char *) &pgd, sizeof(pgd), - cr3, mm_p + mm_struct_pgd_offset); - - return pgd; -} - - - -/* read a byte from a process - * - * in: pid: process id - * cr3: ptbr for the process' domain - * addr: address to read - */ - -u_char pdb_linux_get_value(int pid, unsigned long cr3, unsigned long addr) -{ - u_char result = 0; - unsigned long pgd; - unsigned long l2tab, page; - - /* get the process' pgd */ - pgd = pdb_linux_pid_ptbr(cr3, pid); - - /* get the l2 table entry */ - pdb_get_values((u_char *) &l2tab, sizeof(l2tab), - cr3, pgd + (addr >> PGDIR_SHIFT) * 4); - l2tab = (unsigned long)__va(machine_to_phys(cr3, l2tab) & PAGE_MASK); - - /* get the page table entry */ - pdb_get_values((u_char *) &page, sizeof(page), - cr3, l2tab + ((addr & L1_PAGE_BITS) >> PAGE_SHIFT) * 4); - page = (unsigned long)__va(machine_to_phys(cr3, page) & PAGE_MASK); - - /* get the byte */ - pdb_get_values((u_char *) &result, sizeof(result), - cr3, page + (addr & ~PAGE_MASK)); - - return result; -} - -void pdb_linux_get_values(char *buffer, int length, unsigned long address, - int pid, unsigned long cr3) -{ - int loop; - - /* yes, this can be optimized... a lot */ - for (loop = 0; loop < length; loop++) - { - buffer[loop] = pdb_linux_get_value(pid, cr3, address + loop); - } -} - - -void pdb_linux_set_value(int pid, unsigned long cr3, unsigned long addr, - u_char *value) -{ - unsigned long pgd; - unsigned long l2tab, page; - - /* get the process' pgd */ - pgd = pdb_linux_pid_ptbr(cr3, pid); - - /* get the l2 table entry */ - pdb_get_values((u_char *) &l2tab, sizeof(l2tab), - cr3, pgd + (addr >> PGDIR_SHIFT) * 4); - l2tab = (unsigned long)__va(machine_to_phys(cr3, l2tab) & PAGE_MASK); - - /* get the page table entry */ - pdb_get_values((u_char *) &page, sizeof(page), - cr3, l2tab + ((addr & L1_PAGE_BITS) >> PAGE_SHIFT) * 4); - page = (unsigned long)__va(machine_to_phys(cr3, page) & PAGE_MASK); - - /* set the byte */ - pdb_set_values(value, sizeof(u_char), cr3, page + (addr & ~PAGE_MASK)); -} - -void pdb_linux_set_values(char *buffer, int length, unsigned long address, - int pid, unsigned long cr3) -{ - int loop; - - /* it's difficult to imagine a more inefficient algorithm */ - for (loop = 0; loop < length; loop++) - { - pdb_linux_set_value(pid, cr3, address + loop, &buffer[loop * 2]); - } -} - -/**********************************************************************/ - -/* - * return 1 if is the virtual address is in the operating system's - * address space, else 0 - */ -int pdb_linux_address_space (unsigned long addr) -{ - return (addr > PAGE_OFFSET); -} - -/* get a list of at most "max" processes - * return: number of threads found - * - * init_task -> init_task_union.task - * while (next_task != init_task) {} - */ -int pdb_linux_process_list (unsigned long cr3, int array[], int max) -{ - unsigned long task_p, next_p; - int pid; - int count = 0; - - /* task_p = init_task->next_task */ - pdb_get_values((u_char *) &task_p, sizeof(task_p), - cr3, pdb_init_task_union_addr + task_struct_next_task_offset); - - while (task_p != pdb_init_task_union_addr) - { - pdb_get_values((u_char *) &pid, sizeof(pid), - cr3, task_p + task_struct_pid_offset); - - array[count % max] = pid; - count++; - - pdb_get_values((u_char *) &next_p, sizeof(next_p), - cr3, task_p + task_struct_next_task_offset); - task_p = next_p; - } - - return count; -} - -/* - * get additional details about a particular process - */ -void pdb_linux_process_details (unsigned long cr3, int pid, char *buffer) -{ - unsigned long task_struct_p; - - task_struct_p = pdb_linux_pid_task_struct(cr3, pid); - - pdb_get_values((u_char *) buffer, task_struct_comm_length, - cr3, task_struct_p + task_struct_comm_offset); - return; -} - diff --git a/xen/common/debug.c b/xen/common/debug.c deleted file mode 100644 index fa99d6bd8f..0000000000 --- a/xen/common/debug.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * debug.c - * - * xen pervasive debugger - */ - -#include <xen/config.h> -#include <xen/types.h> -#include <xen/lib.h> -#include <public/dom0_ops.h> -#include <xen/sched.h> -#include <xen/event.h> -#include <asm/page.h> -#include <asm/pdb.h> -#include <asm/shadow.h> - -#undef DEBUG_TRACE -#ifdef DEBUG_TRACE -#define TRC(_x) _x -#else -#define TRC(_x) -#endif - -/****************************************************************************/ - -extern u_char pdb_linux_get_value(int pid, unsigned long cr3, - unsigned long addr); - -/* - * interactively call pervasive debugger from a privileged domain - */ -void pdb_do_debug (dom0_op_t *op) -{ - op->u.debug.status = 0; - - TRC(printk("PDB: op:%c, dom:%llu, in1:%x, in2:%x, in3:%x, in4:%x\n", - op->u.debug.opcode, op->u.debug.domain, - op->u.debug.in1, op->u.debug.in2, - op->u.debug.in3, op->u.debug.in4)); - - /* NOT NOW - if (op->u.debug.domain == 0) - { - op->u.debug.status = 1; - return; - } - */ - - switch (op->u.debug.opcode) - { - case 'c' : - { - struct domain *d = find_domain_by_id(op->u.debug.domain); - if ( d != NULL ) - { - domain_unpause_by_systemcontroller(d); - put_domain(d); - } - else - { - op->u.debug.status = 2; /* invalid domain */ - } - break; - } - case 'r' : - { - int loop; - u_char x; - unsigned long cr3; - struct domain *d; - - d = find_domain_by_id(op->u.debug.domain); - if ( shadow_mode(d) ) - cr3 = pagetable_val(d->mm.shadow_table); - else - cr3 = pagetable_val(d->mm.pagetable); - - for (loop = 0; loop < op->u.debug.in2; loop++) /* length */ - { - if (loop % 8 == 0) - { - printk ("\n%08x ", op->u.debug.in1 + loop); - } - x = pdb_linux_get_value(op->u.debug.in3, - cr3, op->u.debug.in1 + loop); - printk (" %02x", x); - } - printk ("\n"); - put_domain(d); - break; - } - case 's' : - { - struct domain *d = find_domain_by_id(op->u.debug.domain); - - if ( d != NULL ) - { - domain_pause_by_systemcontroller(d); - put_domain(d); - } - else - { - op->u.debug.status = 2; /* invalid domain */ - } - break; - } - default : - { - printk("PDB error: unknown debug opcode %c (0x%x)\n", - op->u.debug.opcode, op->u.debug.opcode); - } - } -} diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index be3e41769a..e59bed3a3a 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * dom0_ops.c * @@ -14,7 +15,6 @@ #include <xen/sched.h> #include <xen/event.h> #include <asm/domain_page.h> -#include <asm/pdb.h> #include <xen/trace.h> #include <xen/console.h> #include <asm/shadow.h> @@ -374,16 +374,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op) } break; -#ifdef XEN_DEBUGGER - case DOM0_DEBUG: - { - pdb_do_debug(op); - copy_to_user(u_dom0_op, op, sizeof(*op)); - ret = 0; - } - break; -#endif - case DOM0_SETTIME: { do_settime(op->u.settime.secs, diff --git a/xen/common/dom_mem_ops.c b/xen/common/dom_mem_ops.c index ef558a7354..f9fae770fc 100644 --- a/xen/common/dom_mem_ops.c +++ b/xen/common/dom_mem_ops.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * dom_mem_ops.c * @@ -141,7 +142,7 @@ do_dom_mem_op(unsigned long op, else if ( unlikely(!IS_PRIV(current->domain)) ) return -EPERM; else if ( unlikely((d = find_domain_by_id(domid)) == NULL) ) - return -ESRCH; + return -ESRCH; LOCK_BIGLOCK(d); @@ -150,18 +151,18 @@ do_dom_mem_op(unsigned long op, case MEMOP_increase_reservation: rc = alloc_dom_mem( d, extent_list, start_extent, nr_extents, extent_order); - break; + break; case MEMOP_decrease_reservation: rc = free_dom_mem( d, extent_list, start_extent, nr_extents, extent_order); - break; + break; default: rc = -ENOSYS; break; } if ( unlikely(domid != DOMID_SELF) ) - put_domain(d); + put_domain(d); UNLOCK_BIGLOCK(d); diff --git a/xen/common/domain.c b/xen/common/domain.c index b2e6360ddc..a77e77384e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * domain.c * diff --git a/xen/common/elf.c b/xen/common/elf.c index df237af362..7c94dab5e2 100644 --- a/xen/common/elf.c +++ b/xen/common/elf.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * elf.c * diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 304172ba26..a55ea94e85 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * event_channel.c * diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index e6a76c9dd6..2a7b62f9f7 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * common/grant_table.c * @@ -574,7 +575,7 @@ grant_table_create( /* Active grant table. */ if ( (t->active = xmalloc_array(active_grant_entry_t, NR_GRANT_ENTRIES)) - == NULL ) + == NULL ) goto no_mem; memset(t->active, 0, sizeof(active_grant_entry_t) * NR_GRANT_ENTRIES); diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 3b562ed7b7..e02654b053 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * kernel.c * diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index e99d5a6381..1b9527aa89 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * keyhandler.c */ diff --git a/xen/common/lib.c b/xen/common/lib.c index b01d5a1727..d3f11e0fdd 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ #include <xen/ctype.h> #include <xen/lib.h> @@ -394,9 +395,9 @@ __udivdi3(a, b) */ u64 __umoddi3(u64 a, u64 b) { - u64 rem; - __qdivrem(a, b, &rem); - return rem; + u64 rem; + __qdivrem(a, b, &rem); + return rem; } /* @@ -425,19 +426,18 @@ s64 __moddi3(s64 a, s64 b) ub = b, neg2 = 0; __qdivrem(ua, ub, &urem); - /* There 4 different cases: */ - if(neg1) - { - if(neg2) - return -urem; - else - return ub - urem; - } - else - if(neg2) - return -ub + urem; - else - return urem; + /* There 4 different cases: */ + if (neg1) { + if (neg2) + return -urem; + else + return ub - urem; + } else { + if (neg2) + return -ub + urem; + else + return urem; + } } #endif /* BITS_PER_LONG == 32 */ diff --git a/xen/common/multicall.c b/xen/common/multicall.c index 04605ebb2a..112a9f3176 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * multicall.c */ diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 8afa482da1..5fc2a14668 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * page_alloc.c * @@ -262,8 +263,8 @@ struct pfn_info *alloc_heap_pages(unsigned int zone, unsigned int order) /* Find smallest order which can satisfy the request. */ for ( i = order; i <= MAX_ORDER; i++ ) - if ( !list_empty(&heap[zone][i]) ) - goto found; + if ( !list_empty(&heap[zone][i]) ) + goto found; /* No suitable memory blocks. Fail the request. */ spin_unlock(&heap_lock); diff --git a/xen/common/perfc.c b/xen/common/perfc.c index d5384c4af5..511df11a9e 100644 --- a/xen/common/perfc.c +++ b/xen/common/perfc.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ #include <xen/lib.h> #include <xen/smp.h> @@ -22,7 +23,7 @@ static struct { char *name; enum { TYPE_SINGLE, TYPE_CPU, TYPE_ARRAY, - TYPE_S_SINGLE, TYPE_S_CPU, TYPE_S_ARRAY + TYPE_S_SINGLE, TYPE_S_CPU, TYPE_S_ARRAY } type; int nr_elements; } perfc_info[] = { @@ -92,19 +93,19 @@ void perfc_reset(unsigned char key) switch ( perfc_info[i].type ) { case TYPE_SINGLE: - atomic_set(&counters[0],0); + atomic_set(&counters[0],0); case TYPE_S_SINGLE: counters += 1; break; case TYPE_CPU: for ( j = sum = 0; j < smp_num_cpus; j++ ) - atomic_set(&counters[j],0); + atomic_set(&counters[j],0); case TYPE_S_CPU: counters += NR_CPUS; break; case TYPE_ARRAY: for ( j = sum = 0; j < perfc_info[i].nr_elements; j++ ) - atomic_set(&counters[j],0); + atomic_set(&counters[j],0); case TYPE_S_ARRAY: counters += perfc_info[i].nr_elements; break; diff --git a/xen/common/physdev.c b/xen/common/physdev.c index f4d35e3c8b..70181dfe50 100644 --- a/xen/common/physdev.c +++ b/xen/common/physdev.c @@ -1,4 +1,4 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- **************************************************************************** * (c) 2004 - Rolf Neugebauer - Intel Research Cambridge * (c) 2004 - Keir Fraser - University of Cambridge @@ -150,9 +150,9 @@ int physdev_pci_access_modify( /* Make the domain privileged. */ set_bit(DF_PHYSDEV, &p->d_flags); - /* FIXME: MAW for now make the domain REALLY privileged so that it - * can run a backend driver (hw access should work OK otherwise) */ - set_bit(DF_PRIVILEGED, &p->d_flags); + /* FIXME: MAW for now make the domain REALLY privileged so that it + * can run a backend driver (hw access should work OK otherwise) */ + set_bit(DF_PRIVILEGED, &p->d_flags); /* Grant write access to the specified device. */ if ( (pdev = pci_find_slot(bus, PCI_DEVFN(dev, func))) == NULL ) diff --git a/xen/common/resource.c b/xen/common/resource.c index 0f479f068b..7fff4059d9 100644 --- a/xen/common/resource.c +++ b/xen/common/resource.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * linux/kernel/resource.c * diff --git a/xen/common/sched_atropos.c b/xen/common/sched_atropos.c index ab84efa3ce..73e0080281 100644 --- a/xen/common/sched_atropos.c +++ b/xen/common/sched_atropos.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /* * atropos.c * --------- diff --git a/xen/common/sched_bvt.c b/xen/common/sched_bvt.c index f63dabcb50..fb555781f1 100644 --- a/xen/common/sched_bvt.c +++ b/xen/common/sched_bvt.c @@ -1,4 +1,4 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- **************************************************************************** * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge * (C) 2002-2003 University of Cambridge diff --git a/xen/common/sched_rrobin.c b/xen/common/sched_rrobin.c index 73d03bc787..469fa007a2 100644 --- a/xen/common/sched_rrobin.c +++ b/xen/common/sched_rrobin.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /**************************************************************************** * Round Robin Scheduler for Xen * diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 21a1ae25ac..46176cf820 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1,4 +1,4 @@ -/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- **************************************************************************** * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge * (C) 2002-2003 University of Cambridge diff --git a/xen/common/softirq.c b/xen/common/softirq.c index 17e850b3f6..dc635d1ab5 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * common/softirq.c * diff --git a/xen/common/string.c b/xen/common/string.c index 1f51b65ecb..c78652509a 100644 --- a/xen/common/string.c +++ b/xen/common/string.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * linux/lib/string.c * diff --git a/xen/common/trace.c b/xen/common/trace.c index 83bf5ce55e..0fcb8dbfd6 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * common/trace.c * diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index 906e7734db..d710d0bd72 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /* * linux/lib/vsprintf.c * @@ -115,13 +116,13 @@ static int skip_atoi(const char **s) return i; } -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type) { @@ -239,14 +240,14 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) char *str, *end, c; const char *s; - int flags; /* flags to number() */ + int flags; /* flags to number() */ - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier; /* 'h', 'l', or 'L' for integer fields */ - /* 'z' support added 23/7/1999 S.H. */ - /* 'z' changed to 'Z' --davidm 1/25/99 */ + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + /* 'z' support added 23/7/1999 S.H. */ + /* 'z' changed to 'Z' --davidm 1/25/99 */ str = buf; end = buf + size - 1; @@ -267,7 +268,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) /* process flags */ flags = 0; repeat: - ++fmt; /* this also skips first '%' */ + ++fmt; /* this also skips first '%' */ switch (*fmt) { case '-': flags |= LEFT; goto repeat; case '+': flags |= PLUS; goto repeat; @@ -293,12 +294,12 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) /* get the precision */ precision = -1; if (*fmt == '.') { - ++fmt; + ++fmt; if (isdigit(*fmt)) precision = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt; - /* it's the next argument */ + /* it's the next argument */ precision = va_arg(args, int); } if (precision < 0) @@ -381,8 +382,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) case 'n': - /* FIXME: - * What does C99 say about the overflow case here? */ + /* FIXME: + * What does C99 say about the overflow case here? */ if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf); @@ -401,7 +402,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; continue; - /* integer number formats - set up the flags and "break" */ + /* integer number formats - set up the flags and "break" */ case 'o': base = 8; break; diff --git a/xen/common/xmalloc.c b/xen/common/xmalloc.c index 68c1db8345..8addc7e4d0 100644 --- a/xen/common/xmalloc.c +++ b/xen/common/xmalloc.c @@ -1,4 +1,6 @@ -/* Simple allocator for Xen. If larger than a page, simply use the +/* -*- Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ +/****************************************************************************** + * Simple allocator for Xen. If larger than a page, simply use the * page-order allocator. * * Copyright (C) 2005 Rusty Russell IBM Corporation @@ -17,6 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include <xen/mm.h> #include <xen/spinlock.h> #include <xen/ac_timer.h> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 5494db499c..009935efc0 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * console.c * diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c index b085c7400e..9ccad0ff4a 100644 --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -1,3 +1,4 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ /****************************************************************************** * serial.c * @@ -12,7 +13,6 @@ #include <xen/init.h> #include <xen/irq.h> #include <xen/keyhandler.h> -#include <asm/pdb.h> #include <xen/reboot.h> #include <xen/sched.h> #include <xen/serial.h> @@ -33,14 +33,14 @@ string_param("com2", opt_com2); #define MCR 0x04 /* Modem control */ #define LSR 0x05 /* line status */ #define MSR 0x06 /* Modem status */ -#define DLL 0x00 /* divisor latch (ls) ( DLAB=1) */ -#define DLM 0x01 /* divisor latch (ms) ( DLAB=1) */ +#define DLL 0x00 /* divisor latch (ls) (DLAB=1) */ +#define DLM 0x01 /* divisor latch (ms) (DLAB=1) */ /* Interrupt Enable Register */ #define IER_ERDAI 0x01 /* rx data recv'd */ #define IER_ETHREI 0x02 /* tx reg. empty */ #define IER_ELSI 0x04 /* rx line status */ -#define IER_EMSI 0x08 /* MODEM status */ +#define IER_EMSI 0x08 /* MODEM status */ /* FIFO control register */ #define FCR_ENABLE 0x01 /* enable FIFO */ diff --git a/xen/include/asm-x86/pdb.h b/xen/include/asm-x86/pdb.h deleted file mode 100644 index 79b0c4183b..0000000000 --- a/xen/include/asm-x86/pdb.h +++ /dev/null @@ -1,89 +0,0 @@ - -/* - * pervasive debugger - * www.cl.cam.ac.uk/netos/pdb - * - * alex ho - * 2004 - * university of cambridge computer laboratory - */ - - -#ifndef __PDB_H__ -#define __PDB_H__ - -#include <asm/regs.h> -#include <xen/list.h> -#include <public/dom0_ops.h> -#include <public/xen.h> /* for domain id */ - -extern int pdb_initialized; -extern int pdb_com_port; -extern int pdb_high_bit; -extern int pdb_page_fault_possible; -extern int pdb_page_fault_scratch; -extern int pdb_page_fault; - -extern void initialize_pdb(void); - -/* Get/set values from generic debug interface. */ -extern int pdb_set_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr); -extern int pdb_get_values(u_char *buffer, int length, - unsigned long cr3, unsigned long addr); - -/* External entry points. */ -extern int pdb_handle_exception(int exceptionVector, - struct xen_regs *xen_regs); -extern void pdb_do_debug(dom0_op_t *op); - -/* PDB Context. */ -struct pdb_context -{ - int valid; - int domain; - int process; - int system_call; /* 0x01 break on enter, 0x02 break on exit */ - unsigned long ptbr; -}; -extern struct pdb_context pdb_ctx; - -/* Breakpoints. */ -struct pdb_breakpoint -{ - struct list_head list; - unsigned long address; - unsigned long cr3; - domid_t domain; -}; -extern void pdb_bkpt_add (unsigned long cr3, unsigned long address); -extern struct pdb_breakpoint* pdb_bkpt_search (unsigned long cr3, - unsigned long address); -extern int pdb_bkpt_remove (unsigned long cr3, unsigned long address); - -/* Conversions. */ -extern int hex (char); -extern char *mem2hex (char *, char *, int); -extern char *hex2mem (char *, char *, int); -extern int hexToInt (char **ptr, int *intValue); - -/* Temporary Linux specific definitions */ -extern int pdb_system_call; -extern unsigned char pdb_system_call_enter_instr; /* original enter instr */ -extern unsigned char pdb_system_call_leave_instr; /* original next instr */ -extern unsigned long pdb_system_call_next_addr; /* instr after int 0x80 */ -extern unsigned long pdb_system_call_eflags_addr; /* saved eflags on stack */ - -unsigned long pdb_linux_pid_ptbr (unsigned long cr3, int pid); -void pdb_linux_get_values(char *buffer, int length, unsigned long address, - int pid, unsigned long cr3); -void pdb_linux_set_values(char *buffer, int length, unsigned long address, - int pid, unsigned long cr3); -void pdb_linux_syscall_enter_bkpt (struct xen_regs *regs, long error_code, - trap_info_t *ti); -void pdb_linux_syscall_exit_bkpt (struct xen_regs *regs, - struct pdb_context *pdb_ctx); - -void pdb_handle_debug_trap(struct xen_regs *regs, long error_code); - -#endif /* __PDB_H__ */ diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index f566be7809..1fd7b23287 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -13,7 +13,6 @@ #include <asm/cpufeature.h> #include <asm/desc.h> #include <asm/flushtlb.h> -#include <asm/pdb.h> #include <xen/config.h> #include <xen/spinlock.h> #include <xen/cache.h> @@ -453,16 +452,9 @@ extern idt_entry_t *idt_tables[]; (memset(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \ 0, 8)) -#ifdef XEN_DEBUGGER -#define SET_FAST_TRAP(_p) \ - (pdb_initialized ? (void *) 0 : \ - (memcpy(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \ - &((_p)->fast_trap_desc), 8))) -#else #define SET_FAST_TRAP(_p) \ (memcpy(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \ &((_p)->fast_trap_desc), 8)) -#endif long set_fast_trap(struct exec_domain *p, int idx); diff --git a/xen/include/asm-x86/vmx_platform.h b/xen/include/asm-x86/vmx_platform.h index 971f616286..4557e5d083 100644 --- a/xen/include/asm-x86/vmx_platform.h +++ b/xen/include/asm-x86/vmx_platform.h @@ -19,7 +19,8 @@ #ifndef __ASM_X86_VMX_PLATFORM_H__ #define __ASM_X86_VMX_PLATFORM_H__ -#include <asm/e820.h> /* from Linux */ +#include <public/xen.h> +#include <asm/e820.h> #define MAX_OPERAND_NUM 3 #define I_NAME_LEN 16 |