Skip to content

Commit

Permalink
Merge pull request iovisor#1688 from iovisor/yhs_dev
Browse files Browse the repository at this point in the history
fix profile.py with latest net-next
  • Loading branch information
4ast committed Apr 18, 2018
2 parents 895be42 + b5fcb51 commit 84c8873
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tools/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,26 @@ def positive_nonzero_int(val):
struct pt_regs regs = {};
bpf_probe_read(&regs, sizeof(regs), (void *)&ctx->regs);
u64 ip = PT_REGS_IP(&regs);
u64 page_offset;
// if ip isn't sane, leave key ips as zero for later checking
#ifdef CONFIG_RANDOMIZE_MEMORY
if (ip > __PAGE_OFFSET_BASE) {
#if defined(CONFIG_X86_64) && defined(__PAGE_OFFSET_BASE)
// x64, 4.16, ..., 4.11, etc., but some earlier kernel didn't have it
page_offset = __PAGE_OFFSET_BASE;
#elif defined(CONFIG_X86_64) && defined(__PAGE_OFFSET_BASE_L4)
// x64, 4.17, and later
#if defined(CONFIG_DYNAMIC_MEMORY_LAYOUT) && defined(CONFIG_X86_5LEVEL)
page_offset = __PAGE_OFFSET_BASE_L5;
#else
if (ip > PAGE_OFFSET) {
page_offset = __PAGE_OFFSET_BASE_L4;
#endif
#else
// earlier x86_64 kernels, e.g., 4.6, comes here
// arm64, s390, powerpc, x86_32
page_offset = PAGE_OFFSET;
#endif
if (ip > page_offset) {
key.kernel_ip = ip;
}
}
Expand Down

0 comments on commit 84c8873

Please sign in to comment.