diff --git a/BM/tdx-host/tdx_dpamt_test.sh b/BM/tdx-host/tdx_dpamt_test.sh index 52db5a51..70d469c8 100755 --- a/BM/tdx-host/tdx_dpamt_test.sh +++ b/BM/tdx-host/tdx_dpamt_test.sh @@ -144,13 +144,24 @@ get_dpamt_kb() { # function to start function profiling for a testcase dpamt_profile_start() { - local profile=/sys/kernel/tracing/function_profile_enabled - - if [ ! -w "$profile" ]; then - die "Function profiler control $profile is not writable." - fi + local trace=/sys/kernel/tracing + local profile="$trace/function_profile_enabled" + local filter="$trace/set_ftrace_filter" + local available="$trace/available_filter_functions" + local function + + for function in tdh_phymem_pamt_add tdh_phymem_pamt_remove; do + grep -qw "$function" "$available" || \ + die "Function $function is unavailable for ftrace." + done echo 0 > "$profile" || die "Failed to reset function profiling." + echo nop > "$trace/current_tracer" || die "Failed to select the nop tracer." + : > "$filter" || die "Failed to clear the ftrace function filter." + echo tdh_phymem_pamt_add > "$filter" || \ + die "Failed to add tdh_phymem_pamt_add to the ftrace function filter." + echo tdh_phymem_pamt_remove >> "$filter" || \ + die "Failed to add tdh_phymem_pamt_remove to the ftrace function filter." echo 1 > "$profile" || die "Failed to enable function profiling." trap dpamt_profile_stop EXIT test_print_trc "Function profiling enabled for dynamic PAMT accounting"