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 <michael.cheng@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40898>
This commit is contained in:
Michael Cheng 2026-04-10 21:48:22 -07:00 committed by Marge Bot
parent 1950b6c1a7
commit 16c17d6698
4 changed files with 18 additions and 0 deletions

View file

@ -78,6 +78,15 @@ bool IntelDriver::init_perfcnt()
perf = std::make_unique<IntelPerf>(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;

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -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", &paranoid);
if (paranoid == 0 || geteuid() == 0)
perf_oa_available = true;
else
perf->features_supported |= INTEL_PERF_FEATURE_OA_BLOCKED_BY_POLICY;
}
if (!perf_oa_available)