Debugfs permissions


#1

Hi folks.
Who can help me with debugfs permissions?

I try debug AMD GPU with umr (https://cgit.freedesktop.org/amd/umr/) and I am sure that debugfs are enabled.

# mount | grep  debugfs
debugfs on /sys/kernel/debug type debugfs (rw,relatime,seclabel)

But when I tried access to /sys/kernel/debug/dri/0/amdgpu_ring_gfx I got EPERM

openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_gca_config", O_RDONLY) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_regs", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_regs_didt", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_regs_pcie", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_regs_smc", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_sensors", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_wave", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_vram", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_gpr", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_iova", O_RDWR) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_iomem", O_RDWR) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/bus/pci/devices/0000:0b:00.0/vbios_version", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
read(3, "xxx-xxx-xxx\n", 4096)          = 12
close(3)                                = 0
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_firmware_info", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "VCE feature version: 0, firmware"..., 4096) = 1059
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_gca_config", O_RDONLY) = -1 EPERM (Operation not permitted)
openat(AT_FDCWD, "/sys/kernel/debug/dri/0/amdgpu_ring_gfx", O_RDWR) = -1 EPERM (Operation not permitted)
write(2, "[ERROR]: Could not open ring deb"..., 41[ERROR]: Could not open ring debugfs file) = 41
munmap(0x7f1a222e0000, 151552)          = 0
munmap(0x7f1a22305000, 368640)          = 0
exit_group(0)                           = ?
+++ exited with 0 +++

AMD developers say that /sys/kernel/debug/dri/0/amdgpu_ring_gfx should be available.

https://lists.freedesktop.org/archives/amd-gfx/2018-December/029897.html


#2

Could you go into more detail on what you’re running? Do you need to run it as sudo? Have you tried sudo setenforce 0 first to see if it’s a policy issue?


#3
  1. I tried use sudo and root account.
 # stat /sys/kernel/debug/dri/0/amdgpu_ring_gfx
   File: /sys/kernel/debug/dri/0/amdgpu_ring_gfx
   Size: 8204            Blocks: 0          IO Block: 4096   regular file
 Device: 7h/7d   Inode: 24866       Links: 1
 Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
 Context: system_u:object_r:debugfs_t:s0
 Access: 2018-12-21 08:20:18.860992904 +0500
 Modify: 2018-12-21 08:20:18.860992904 +0500
 Change: 2018-12-21 08:20:18.860992904 +0500
  Birth: -
 [root@localhost ~]# cat /sys/kernel/debug/dri/0/amdgpu_ring_gfx
 cat: /sys/kernel/debug/dri/0/amdgpu_ring_gfx: Operation not permitted
  1. In order to exclude impact SELinux , I am also tried disable completely SELinux.
 $ cat /etc/selinux/config
 
 # This file controls the state of SELinux on the system.
 # SELINUX= can take one of these three values:
 #     enforcing - SELinux security policy is enforced.
 #     permissive - SELinux prints warnings instead of enforcing.
 #     disabled - No SELinux policy is loaded.
 #SELINUX=enforcing
 SELINUX=disabled
 # SELINUXTYPE= can take one of these three values:
 #     targeted - Targeted processes are protected,
 #     minimum - Modification of targeted policy. Only selected processes are protected.
 #     mls - Multi Level Security protection.
 SELINUXTYPE=targeted

Also I note that not all files not permitted for read from
/sys/kernel/debug/dri/0/*
I was able to dump contents of some files in debugfs.txt
List of available for readind files:

amdgpu_evict_gtt
amdgpu_evict_vram
amdgpu_fence_info
amdgpu_firmware_info
amdgpu_gds_mm
amdgpu_gem_info
amdgpu_gpu_recover
amdgpu_gtt_mm
amdgpu_gws_mm
amdgpu_oa_mm
amdgpu_pm_info
amdgpu_sa_info
amdgpu_test_ib
amdgpu_vbios
amdgpu_vram_mm
clients
framebuffer
gem_names
internal_clients
name
state
ttm_page_pool

May some kernel options restrict access for files in debugfs (for
example to amdgpu_gca_config)?
If yes on which options should I pay attention?
I have no more ideas. I tried everything.