Skip to content

Commit 28dbfee

Browse files
committed
Changes for 3.16 kernel. This likely breaks older kernels.
1 parent 563bcff commit 28dbfee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+641
-123
lines changed

.gdbinit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set auto-load safe-path /
12
set confirm no
23
set history expansion 1
34
dir libctf

TODO

Lines changed: 0 additions & 9 deletions
This file was deleted.

archive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NAME=dtrace
22
MAJ_VERSION=1
3-
MIN_VERSION=0153
3+
MIN_VERSION=0154
44
EXCLUDE="*.ko *.o .git"
55
EXCLUDE_DIRS="build-"
6-
#date Sun Mar 23 22:00:18 GMT 2014
6+
#date Sun Feb 22 11:01:19 GMT 2015

driver/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ obj-m := dtracedrv.o
7272

7373
H = dtrace_linux.h dtrace_proto.h
7474
EXTRA_AFLAGS += \
75-
-I$(M)/../../linux
75+
-I$(M)/../../linux $(OLD_RSP)
7676

7777
# Add -gdwarf-2 because gcc-4.8 will cause mkctf.sh to fail due to
7878
# something libdwarf doesnt like.
@@ -83,7 +83,7 @@ EXTRA_CFLAGS += -g -gdwarf-2 \
8383
-I$(M)/../../linux \
8484
-I$(M)/../../common/ctf \
8585
-I$(M)/../../uts/common \
86-
-D_KERNEL -DCTF_OLD_VERSIONS $(PTR32)
86+
-D_KERNEL -DCTF_OLD_VERSIONS $(PTR32) $(OLD_RSP)
8787

8888
######################################################################
8989
# Handle include files which exist or moved around amongst #

driver/ctl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ ctl_linux_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsign
267267
if (child == NULL)
268268
return -ESRCH;
269269
get_task_struct(child);
270+
# if 1
271+
/***********************************************/
272+
/* Fed up trying to make the code below */
273+
/* work across all kernels - lets just */
274+
/* disable it for now. */
275+
/***********************************************/
276+
uid1 = 0;
277+
uid2 = 1; // force failure
278+
# else
270279
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
271280
uid2 = KUIDT_VALUE(child->cred->uid);
272281
#else
@@ -280,6 +289,7 @@ ctl_linux_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsign
280289
#else
281290
uid1 = current->uid;
282291
#endif
292+
# endif
283293
if (uid1 != uid2 && uid1 != 0)
284294
return -EPERM;
285295

driver/dtrace.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,16 @@ dtrace_bcopy(const void *src, void *dst, size_t len)
10351035
static void
10361036
dtrace_strcpy(const void *src, void *dst, size_t len)
10371037
{
1038+
volatile uint16_t *flags;
1039+
1040+
flags = (volatile uint16_t *)&cpu_core[cpu_get_id()].cpuc_dtrace_flags;
1041+
10381042
if (len != 0) {
10391043
uint8_t *s1 = dst, c;
10401044
const uint8_t *s2 = src;
1041-
10421045
do {
10431046
*s1++ = c = dtrace_load8((uintptr_t)s2++);
1044-
} while (--len != 0 && c != '\0');
1047+
} while (--len != 0 && c != '\0' && (*flags & CPU_DTRACE_FAULT) == 0);
10451048
}
10461049
}
10471050

@@ -4559,14 +4562,14 @@ PRINT_CASE(DIF_SUBR_LLTOSTR);
45594562
struct file *fp = (struct file *) tupregs[0].dttk_value;
45604563
if (fp) {
45614564
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
4562-
regs[rd] = (uint64_t *) (void *) d_path(&fp->f_path, buf, sizeof buf);
4565+
regs[rd] = (uint64_t) (void *) d_path(&fp->f_path, buf, sizeof buf);
45634566
#else
45644567
regs[rd] = d_path(&fp->f_dentry, fp->f_vfsmnt, buf, sizeof buf);
45654568
#endif
45664569
/* regs[rd] = d_path(&get_current()->files->fdt->fd[1]->f_path, buf, sizeof buf);*/
45674570
}
45684571
else
4569-
regs[rd] = (uint64_t *) "<unknown>";
4572+
regs[rd] = (uint64_t) "<unknown>";
45704573
break;
45714574
}
45724575
#endif
@@ -6290,6 +6293,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
62906293
/* first probe. Silly me. */
62916294
/***********************************************/
62926295
cpup = cpu_get_this();
6296+
62936297
if (cpup && cpup->cpuc_regs && cpup->cpuc_regs->r_rfl & X86_EFLAGS_IF) {
62946298
if (dtrace_safe) {
62956299
cnt_probe_safe++;
@@ -6365,7 +6369,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
63656369
return;
63666370
}
63676371
}
6368-
//asm("cli\n");
6372+
63696373
cpu_core[cpu].cpuc_probe_level++;
63706374
cpu_core[cpu].cpuc_this_probe = id;
63716375
__dtrace_probe(id, arg0, arg1, arg2, arg3, arg4);
@@ -6396,7 +6400,6 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
63966400
volatile uint16_t *flags;
63976401
hrtime_t now;
63986402

6399-
//dtrace_printf("dtrace_probe(%d)\n", __LINE__);
64006403
cnt_probes++;
64016404
# if linux
64026405
/***********************************************/
@@ -9696,6 +9699,7 @@ dtrace_difo_init(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
96969699
dtrace_difo_hold(dp);
96979700
}
96989701

9702+
#if !defined(linux)
96999703
static dtrace_difo_t *
97009704
dtrace_difo_duplicate(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
97019705
{
@@ -9739,6 +9743,7 @@ dtrace_difo_duplicate(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
97399743
dtrace_difo_init(new, vstate);
97409744
return (new);
97419745
}
9746+
#endif
97429747

97439748
static void
97449749
dtrace_difo_destroy(dtrace_difo_t *dp, dtrace_vstate_t *vstate)
@@ -15385,6 +15390,7 @@ dtrace_helpers_destroy(void)
1538515390
dmutex_exit(&dtrace_lock);
1538615391
}
1538715392

15393+
#if !defined(linux)
1538815394
static void
1538915395
dtrace_helpers_duplicate(proc_t *from, proc_t *to)
1539015396
{
@@ -15466,6 +15472,7 @@ dtrace_helpers_duplicate(proc_t *from, proc_t *to)
1546615472
if (hasprovs)
1546715473
dtrace_helper_provider_register(to, newhelp, NULL);
1546815474
}
15475+
#endif
1546915476

1547015477
#if linux
1547115478
/**********************************************************************/
@@ -15698,6 +15705,7 @@ dtrace_resume(void)
1569815705
dtrace_probe_foreach(offsetof(dtrace_pops_t, dtps_resume));
1569915706
}
1570015707

15708+
#if !defined(linux)
1570115709
static int
1570215710
dtrace_cpu_setup(cpu_setup_t what, processorid_t cpu)
1570315711
{
@@ -15764,6 +15772,7 @@ dtrace_cpu_setup_initial(processorid_t cpu)
1576415772
{
1576515773
(void) dtrace_cpu_setup(CPU_CONFIG, cpu);
1576615774
}
15775+
#endif
1576715776

1576815777
static void
1576915778
dtrace_toxrange_add(uintptr_t base, uintptr_t limit)

driver/dtrace_linux.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ enum {
8989
OFFSET_task_exit_notifier,
9090
OFFSET_xtime,
9191
OFFSET_ia32_sys_call_table,
92+
OFFSET_old_rsp,
9293
OFFSET_END_SYMS,
9394
};
9495
static struct map {
@@ -106,6 +107,7 @@ static struct map {
106107
{"task_exit_notifier", NULL},
107108
{"xtime", NULL}, /* Needed for dtrace_gethrtime, if 2.6.9 */
108109
{"ia32_sys_call_table", NULL}, /* On 64b kernel, the 32b syscall table. */
110+
{"old_rsp", NULL}, /* This has moved to System.map in 3.7 or above */
109111
{"END_SYMS", NULL}, /* This is a sentinel so we know we are done. */
110112
{0}
111113
};
@@ -244,6 +246,7 @@ extern unsigned long cnt_xcall5;
244246
extern unsigned long long cnt_xcall6;
245247
extern unsigned long long cnt_xcall7;
246248
extern unsigned long cnt_xcall8;
249+
extern unsigned long cnt_xcall_slave;
247250
extern unsigned long cnt_nmi1;
248251
extern unsigned long cnt_nmi2;
249252
extern unsigned long long cnt_timer1;
@@ -2850,6 +2853,7 @@ static int proc_dtrace_stats_show(struct seq_file *seq, void *v)
28502853
{TYPE_LONG_LONG, (unsigned long *) &cnt_xcall6, "xcall6(ack_waits)"},
28512854
{TYPE_LONG_LONG, (unsigned long *) &cnt_xcall7, "xcall7(fast)"},
28522855
{TYPE_LONG, (unsigned long *) &cnt_xcall8, "xcall8"},
2856+
{TYPE_LONG, (unsigned long *) &cnt_xcall_slave, "xcall_slave"},
28532857
{TYPE_INT, (unsigned long *) &dtrace_shutdown, "shutdown"},
28542858
{0}
28552859
};

driver/dtrace_linux.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,12 @@ typedef uint32_t ipaddr_t;
9696
# define hz HZ
9797

9898
/**********************************************************************/
99-
/* Code for 3.8.0 kernels which do strict kuid_t type checking. */
100-
/* Actually - its another Linux mess. Centos 6.4 has a 2.6.32 */
101-
/* kernel but with later semantics. */
99+
/* This is nearly impossible to get right for each kernel. We */
100+
/* cheat, because the struct wrapper always has just a */
101+
/* uid_t/gid_t. */
102102
/**********************************************************************/
103-
#if defined(CONFIG_UIDGID_STRICT_TYPE_CHECKS) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
104-
# define KUIDT_VALUE(v) v.val
105-
# define KGIDT_VALUE(v) v.val
106-
#else
107-
# define KUIDT_VALUE(v) v
108-
# define KGIDT_VALUE(v) v
109-
#endif
103+
# define KUIDT_VALUE(v) *(uid_t *) &(v)
104+
# define KGIDT_VALUE(v) *(gid_t *) &(v)
110105

111106
/**********************************************************************/
112107
/* File based on code from FreeBSD to support the missing */

driver/fbt_linux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,14 @@ fbt_provide_function(struct modctl *mp, par_module_t *pmp,
767767
pf_info_t inf;
768768
int io_prov_sdt(pf_info_t *infp, uint8_t *instr, int size, int modrm);
769769

770+
/***********************************************/
771+
/* Ignore these - they tend to result in a */
772+
/* lot of dups, and also tend to be in the */
773+
/* same reusable and unmapped page. */
774+
/***********************************************/
775+
if (strncmp(name, "cleanup_module", 14) == 0)
776+
return;
777+
770778
memset(&inf, 0, sizeof inf);
771779
inf.mp = mp;
772780
inf.pmp = pmp;

driver/instr_linux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,14 @@ instr_provide_function(struct modctl *mp, par_module_t *pmp,
522522
char name_buf[128];
523523
char pred_buf[128];
524524

525+
/***********************************************/
526+
/* Ignore these - they tend to result in a */
527+
/* lot of dups, and also tend to be in the */
528+
/* same reusable and unmapped page. */
529+
/***********************************************/
530+
if (strncmp(name, "cleanup_module", 14) == 0)
531+
return;
532+
525533
# define UNHANDLED_FBT() if (do_print || dtrace_unhandled) { \
526534
printk("instr:unhandled instr %s:%p %02x %02x %02x %02x\n", \
527535
name, instr, instr[0], instr[1], instr[2], instr[3]); \

0 commit comments

Comments
 (0)