From 16c17d669898367c82168b0ca79dd690670c4aab Mon Sep 17 00:00:00 2001 From: Michael Cheng Date: Fri, 10 Apr 2026 21:48:22 -0700 Subject: [PATCH] intel/ds: report when OA metric access is blocked by kernel policy When observation_paranoid (xe) or perf_stream_paranoid (i915) prevents unprivileged access to OA metrics, the existing code silently returns no OA queries. PPS then fails with just a segfault. This patch adds INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY to intel_perf_features, set by both KMD backends when the paranoid sysctl exists but lacks sufficent privilage. PPS checks this flag immediately after initialising intel_perf and returns an error before attempting metric-set selection. Signed-off-by: Michael Cheng Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/ds/intel_pps_driver.cc | 9 +++++++++ src/intel/perf/i915/intel_perf.c | 2 ++ src/intel/perf/intel_perf.h | 5 +++++ src/intel/perf/xe/intel_perf.c | 2 ++ 4 files changed, 18 insertions(+) diff --git a/src/intel/ds/intel_pps_driver.cc b/src/intel/ds/intel_pps_driver.cc index e8e257af60a..ed4c9b36577 100644 --- a/src/intel/ds/intel_pps_driver.cc +++ b/src/intel/ds/intel_pps_driver.cc @@ -78,6 +78,15 @@ bool IntelDriver::init_perfcnt() perf = std::make_unique(drm_device.fd); + if (perf->cfg->features_supported & INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY) { + PPS_LOG_ERROR("OA metrics access blocked by system policy " + "(gpu=%d, driver=%s). " + "Check kernel paranoid settings or run as root.", + drm_device.gpu_num, + drm_device.name.c_str()); + return false; + } + const char *metric_set_name = os_get_option("INTEL_PERFETTO_METRIC_SET"); struct intel_perf_query_info *default_query = nullptr; diff --git a/src/intel/perf/i915/intel_perf.c b/src/intel/perf/i915/intel_perf.c index 14f8053042f..5473f5720f7 100644 --- a/src/intel/perf/i915/intel_perf.c +++ b/src/intel/perf/i915/intel_perf.c @@ -148,6 +148,8 @@ i915_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_regis if (paranoid == 0 || geteuid() == 0) i915_perf_oa_available = true; + else + perf->features_supported |= INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY; } } diff --git a/src/intel/perf/intel_perf.h b/src/intel/perf/intel_perf.h index e0768317f23..4ad5b7e98b2 100644 --- a/src/intel/perf/intel_perf.h +++ b/src/intel/perf/intel_perf.h @@ -430,6 +430,11 @@ enum intel_perf_features { INTEL_PERF_FEATURE_HOLD_PREEMPTION = (1 << 0), INTEL_PERF_FEATURE_GLOBAL_SSEU = (1 << 1), INTEL_PERF_FEATURE_METRIC_SYNC = (1 << 2), + /* OA metrics are supported by the kernel but access is blocked by system + * policy (observation_paranoid on xe, perf_stream_paranoid on i915). + * Set when the sysctl exists but the process lacks the required privilege. + */ + INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY = (1 << 3), }; struct intel_perf_config { diff --git a/src/intel/perf/xe/intel_perf.c b/src/intel/perf/xe/intel_perf.c index 4867ca83d98..64a2a5e17c9 100644 --- a/src/intel/perf/xe/intel_perf.c +++ b/src/intel/perf/xe/intel_perf.c @@ -131,6 +131,8 @@ xe_oa_metrics_available(struct intel_perf_config *perf, int fd, bool use_registe read_file_uint64("/proc/sys/dev/xe/observation_paranoid", ¶noid); if (paranoid == 0 || geteuid() == 0) perf_oa_available = true; + else + perf->features_supported |= INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY; } if (!perf_oa_available)