Skip to content

Instantly share code, notes, and snippets.

@nhoriguchi
Created June 25, 2020 07:33
Show Gist options
  • Save nhoriguchi/885e50425e5fac205f306425f710d4d9 to your computer and use it in GitHub Desktop.
Save nhoriguchi/885e50425e5fac205f306425f710d4d9 to your computer and use it in GitHub Desktop.
#! /usr/bin/env stap
# Usage: ./get_dev_mem.stp -g <pfn>
%{
#include "../../../arch/x86/include/asm/page_64.h"
#include "../../../arch/x86/include/asm/io.h"
%}
function get_dev_mem (addr:long) %{
unsigned long addr = (unsigned long)STAP_ARG_addr << 12;
unsigned long virt;
unsigned long tmp = 0;
virt = (unsigned long)phys_to_virt(addr);
for (; tmp < 4096; tmp = tmp + 32) {
_stp_printf("0x%lx %lx %lx %lx %lx\n", addr + tmp,
*(unsigned long *)(virt + tmp),
*(unsigned long *)(virt + tmp + 8),
*(unsigned long *)(virt + tmp + 16),
*(unsigned long*)(virt + tmp + 24));
}
%}
probe begin {
get_dev_mem($1)
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment