From 0f31a744ab1718881b8badc87efa5153031139b8 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 29 Jul 2013 14:16:01 -0400 Subject: [PATCH] PR15793: numa addr_to_node(): protect __pa() call with virt_addr_valid() Update test case to tolerate exception that may now be thrown by the tapset function. --- tapset/linux/memory.stp | 9 ++++++++- testsuite/systemtap.examples/memory/numa_faults.stp | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tapset/linux/memory.stp b/tapset/linux/memory.stp index 501f5732e..c62d03ed6 100644 --- a/tapset/linux/memory.stp +++ b/tapset/linux/memory.stp @@ -100,8 +100,15 @@ probe vm.pagefault.return = * node that the given address belongs to in a NUMA system. */ function addr_to_node:long(addr:long) %{ /* pure */ - int pfn = __pa(STAP_ARG_addr) >> PAGE_SHIFT; int nid; + int pfn; + if (! virt_addr_valid((void*) (uintptr_t) STAP_ARG_addr)) { + snprintf (CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), + "invalid kernel virtual address 0x%p", (void *) (uintptr_t) STAP_ARG_addr); + CONTEXT->last_error = CONTEXT->error_buffer; + goto out; + } + pfn = __pa(STAP_ARG_addr) >> PAGE_SHIFT; #ifdef for_each_online_node for_each_online_node(nid) #else diff --git a/testsuite/systemtap.examples/memory/numa_faults.stp b/testsuite/systemtap.examples/memory/numa_faults.stp index 34a0ace77..8b7ca1504 100755 --- a/testsuite/systemtap.examples/memory/numa_faults.stp +++ b/testsuite/systemtap.examples/memory/numa_faults.stp @@ -3,11 +3,14 @@ global execnames, page_faults, node_faults, nodes probe vm.pagefault { - p = pid(); n=addr_to_node(address) + p = pid(); execnames[p] = execname() page_faults[p, write_access ? 1 : 0] <<< 1 - node_faults[p, n] <<< 1 - nodes[n] <<< 1 + try { + n=addr_to_node(address) + node_faults[p, n] <<< 1 + nodes[n] <<< 1 + } catch { } } function print_pf () { -- 2.43.5