Skip to content

Commit

Permalink
795* intr.c: Fix for xen on i386 (not currently supporting this).
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrace4linux committed Nov 30, 2012
1 parent 8b7634e commit 21b5732
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .release
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
date=Thu Nov 29 20:54:18 GMT 2012
release=dtrace-20121129
build=434
date=Fri Nov 30 23:21:30 GMT 2012
release=dtrace-20121130
build=435
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Fri Nov 30 19:45:05 2012 fox

795* intr.c: Fix for xen on i386 (not currently supporting this).

Thu Nov 29 20:53:05 2012 fox

794* Add 'safe' support - make it work, but turn off by default.
Expand Down
43 changes: 31 additions & 12 deletions driver/dtrace_isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
uint32_t *ignored)
{
int depth;
#if 1 || !defined(HAVE_STACKTRACE_OPS)
#if !defined(HAVE_STACKTRACE_OPS)
int lim;
/***********************************************/
/* This is a basic stack walker - we dont */
/* care about omit-frame-pointer, and we */
Expand All @@ -194,6 +195,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
/***********************************************/
cpu_core_t *this_cpu = cpu_get_this();
struct pt_regs *regs = this_cpu->cpuc_regs;
struct thread_info *context;
uintptr_t *sp;
uintptr_t *spend;

Expand All @@ -204,26 +206,43 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
/* syscall function. */
/***********************************************/
if (regs == NULL)
sp = (uintptr_t *) pcstack;
sp = (uintptr_t *) &depth;
else
sp = (uintptr_t *) regs->r_rsp;

/***********************************************/
/* We might walk off the end of the stack, */
/* so protect us just in case. We should */
/* align the stack against the page */
/* boundary where its allocated, but this */
/* suffices for now. */
/* Daisy chain the interrupt and any other */
/* stacks. Limit ourselves in case of bad */
/* corruptions. */
/***********************************************/
DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
spend = sp + THREAD_SIZE / sizeof(uintptr_t);
for (depth = 0; depth < pcstack_limit && sp < spend; sp++) {
//if (*sp) printk("%d: %p: %p\n", i, sp, *sp);
if (*sp && is_kernel_text((unsigned long) *sp)) {
pcstack[depth++] = *sp;
depth = 0;
for (lim = 0; lim < 3 && depth < pcstack_limit; lim++) {
int ndepth = depth;

context = (struct thread_info *) ((unsigned long) sp & (~(THREAD_SIZE - 1)));
spend = (uintptr_t *) ((unsigned long) sp | (THREAD_SIZE - 1));
for ( ; depth < pcstack_limit && sp < spend; sp++) {
if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
goto end_stack;
if (*sp && is_kernel_text((unsigned long) *sp)) {
pcstack[depth++] = *sp;
}
}
if (depth >= pcstack_limit || ndepth == depth)
break;
if ((sp = (uintptr_t *) context->previous_esp) == NULL)
break;
/***********************************************/
/* Special signal to mark the IRQ stack. */
/***********************************************/
if (depth < pcstack_limit) {
pcstack[depth++] = 1;
}
}
end_stack:
DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_FAULT);
#else

/***********************************************/
Expand Down
19 changes: 12 additions & 7 deletions driver/dtrace_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ enum {
OFFSET_print_modules,
OFFSET_task_exit_notifier,
OFFSET_xtime,
OFFSET_kernel_text_address,
OFFSET_ia32_sys_call_table,
OFFSET_END_SYMS,
};
Expand All @@ -103,7 +102,6 @@ static struct map {
/* find the modules table. */
{"task_exit_notifier", NULL},
{"xtime", NULL}, /* Needed for dtrace_gethrtime, if 2.6.9 */
{"kernel_text_address", NULL}, /* Used for stack walking when no dump_trace available */
{"ia32_sys_call_table", NULL}, /* On 64b kernel, the 32b syscall table. */
{"END_SYMS", NULL}, /* This is a sentinel so we know we are done. */
{0}
Expand Down Expand Up @@ -1134,16 +1132,23 @@ extern caddr_t ktext;
extern caddr_t ketext;
int
is_kernel_text(unsigned long p)
{
int (*func)(unsigned long);
{static int first_time = TRUE;
static caddr_t stext;
static caddr_t etext;

//printk("ktext=%p..%p %p\n", ktext, ketext, p);
if (ktext <= (caddr_t) p && (caddr_t) p < ketext)
return 1;
if (first_time) {
first_time = FALSE;
stext = get_proc_addr("_stext");
etext = get_proc_addr("_etext");
}
if (stext <= (caddr_t) p && (caddr_t) p < etext)
return 1;

func = (int (*)(unsigned long)) syms[OFFSET_kernel_text_address].m_ptr;
if (func) {
return func(p);
if (kernel_text_address_fn) {
return kernel_text_address_fn(p);
}
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions driver/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* */
/* License: CDDL */
/* */
/* $Header: Last edited: 07-Nov-2012 1.16 $ */
/* $Header: Last edited: 30-Nov-2012 1.17 $ */
/**********************************************************************/

#include <linux/mm.h>
Expand Down Expand Up @@ -157,7 +157,7 @@ int dtrace_int_ipi(void);
int dtrace_int_nmi(void);
int dtrace_int_dtrace_ret(void);

#ifdef CONFIG_PARAVIRT
#if defined(CONFIG_PARAVIRT) && defined(__amd64)
int dtrace_int1_xen(void);
int dtrace_int3_xen(void);
int dtrace_page_fault_xen(void);
Expand Down Expand Up @@ -1311,7 +1311,7 @@ static struct x86_descriptor desc1;
set_idt_entry(8, (unsigned long) dtrace_double_fault);
#endif

#ifdef CONFIG_PARAVIRT
#if defined(CONFIG_PARAVIRT) && defined(__amd64)
if (dtrace_is_xen()) {
set_idt_entry(1, (unsigned long) dtrace_int1_xen); // single-step
set_idt_entry(3, (unsigned long) dtrace_int3_xen); // breakpoint
Expand Down
5 changes: 4 additions & 1 deletion driver/xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ extern int nr_cpus;
int
dtrace_is_xen(void)
{ static void **xen_start_info;
static int first_time = TRUE;

// return xen_domain();
if (xen_start_info == NULL)
if (first_time && xen_start_info == NULL) {
xen_start_info = get_proc_addr("xen_start_info");
first_time = FALSE;
}

if (xen_start_info && *xen_start_info)
return TRUE;
Expand Down
12 changes: 9 additions & 3 deletions tools/load.pl
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,15 @@ sub main
# Safely remove the old driver. #
###############################################
if ( -e "/dev/dtrace" ) {
my $rmmod = "/sbin/rmmod";
$rmmod = "/usr/sbin/rmmod" if -x "/usr/sbin/rmmod";
my $rmmod;
foreach my $p ("/sbin", "/usr/sbin", "/usr/bin") {
my $p1 = "$p/rmmod";
$rmmod = $p1 if -x $p1;
}
if (!$rmmod) {
print "ERROR: Strange..cannot locate 'rmmod'\n";
exit(0);
}
spawn("$SUDO $rmmod dtracedrv");
spawn("sync ; sync");
exit(0) if $opts{unload};
Expand Down Expand Up @@ -235,7 +242,6 @@ sub main
ia32_sys_call_table:amd64
syscall_call:optional
xtime:optional
kernel_text_address
__module_text_address
add_timer_on
/) {
Expand Down

0 comments on commit 21b5732

Please sign in to comment.