Bug 93199

Summary: IGT: Couldn't map MMIO region
Product: DRI Reporter: sean darcy <seandarcy2>
Component: IGTAssignee: Default DRI bug account <dri-devel>
Status: CLOSED NOTOURBUG QA Contact:
Severity: normal    
Priority: low CC: azvedodanilo, dpolivaev, gicmo, intel-gfx-bugs, zhangchi866
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: HSW i915 features:
Attachments:
Description Flags
strace igt none

Description sean darcy 2015-12-01 22:55:26 UTC
Fedora 22. 
intel-gpu-tools-2.99.917-22.intel20152.x86_64
Integrated Graphics Chipset: Intel(R) HD Graphics 4400

# dmesg | grep MMIO
[    0.182300] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0, 0, 0, 0, 0, 0

# intel_gpu_top
(intel_gpu_top:5103) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 1, Operation not permitted
Couldn't map MMIO region
Stack trace:
  #0 [_init+0x7eb9]
  #1 [_init+0x5d96]
  #2 [_init+0x1291]
  #3 [__libc_start_main+0xf0]
  #4 [_init+0x2d11]
  #5 [<unknown>+0x2d11]
Test (null) failed.
**** DEBUG ****
(intel_gpu_top:5103) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 1, Operation not permitted
Couldn't map MMIO region
****  END  ****
Comment 1 Jani Nikula 2015-12-02 12:10:45 UTC
I presume by the '#' prompt you're running as root, but perhaps it's some selinux policy thing...? Can you try without?
Comment 2 sean darcy 2015-12-02 15:11:30 UTC
Originally ran it as a user, but tried root because of the permission warning. In any event, same result as user:

$ intel_gpu_top
(intel_gpu_top:16575) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 13, Permission denied
Couldn't map MMIO region
Stack trace:
  #0 [_init+0x7eb9]
  #1 [_init+0x5d96]
  #2 [_init+0x1291]
  #3 [__libc_start_main+0xf0]
  #4 [_init+0x2d11]
  #5 [<unknown>+0x2d11]
Test (null) failed.
**** DEBUG ****
(intel_gpu_top:16575) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 13, Permission denied
Couldn't map MMIO region
****  END  ****
FAIL (84228.913s)
Comment 3 sean darcy 2015-12-02 15:16:10 UTC
Also, tried setting selinux to permissive. Same result.

# setenforce 0
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      29
Comment 4 Jani Nikula 2015-12-02 15:48:08 UTC
(In reply to sean darcy from comment #2)
> Originally ran it as a user, but tried root because of the permission
> warning. In any event, same result as user:

It needs to be run as root.

(In reply to sean darcy from comment #3)
> Also, tried setting selinux to permissive. Same result.

And after that, did you also try as root?

I eyeballed libpciaccess sources a bit, but I'm not sure where it could reasonably return EPERM. For the fun of it, what does this say:

ls -l /sys/bus/pci/devices/0000:00:02.0/resource*
Comment 5 sean darcy 2015-12-02 20:13:03 UTC
set selinux to permissive , and ran igt as root:

# setenforce 0
# intel_gpu_top
(intel_gpu_top:18404) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 1, Operation not permitted
Couldn't map MMIO region
Stack trace:
  #0 [_init+0x7eb9]
  #1 [_init+0x5d96]
  #2 [_init+0x1291]
  #3 [__libc_start_main+0xf0]
  #4 [_init+0x2d11]
  #5 [<unknown>+0x2d11]
Test (null) failed.
**** DEBUG ****
(intel_gpu_top:18404) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file intel_mmio.c:144:
Failed assertion: !(error != 0)
Last errno: 1, Operation not permitted
Couldn't map MMIO region
****  END  ****

# ls -l /sys/bus/pci/devices/0000:00:02.0/resource*
-r--r--r--. 1 root root      4096 Dec  2 15:09 /sys/bus/pci/devices/0000:00:02.0/resource
-rw-------. 1 root root   4194304 Dec  2 15:09 /sys/bus/pci/devices/0000:00:02.0/resource0
-rw-------. 1 root root 268435456 Dec  2 15:09 /sys/bus/pci/devices/0000:00:02.0/resource2
-rw-------. 1 root root 268435456 Dec  2 15:09 /sys/bus/pci/devices/0000:00:02.0/resource2_wc
-rw-------. 1 root root        64 Dec  2 15:09 /sys/bus/pci/devices/0000:00:02.0/resource4
Comment 6 Jani Nikula 2015-12-03 11:17:12 UTC
I have this distinct feeling someone must have faced this before and knows the answer... anyway, please attach the output of:

# strace intel_gpu_top
Comment 7 sean darcy 2015-12-03 15:16:55 UTC
Created attachment 120302 [details]
strace igt
Comment 8 sean darcy 2015-12-03 15:18:09 UTC
I searched before posting. The only thing I found was a report on fedora:

https://bugzilla.redhat.com/show_bug.cgi?id=1281349
Comment 9 sean darcy 2015-12-03 15:28:06 UTC
messing around, I set vm.mmap_min_addr to zero.

#sysctl vm.mmap_min_addr
vm.mmap_min_addr = 65536
# sysctl -w vm.mmap_min_addr="0"
vm.mmap_min_addr = 0

No joy. Still failed.
Comment 10 Jani Nikula 2015-12-04 11:49:48 UTC
I do not know why mmap would return EPERM in this case.

open("/sys/bus/pci/devices/0000:00:02.0/resource0", O_RDWR|O_CLOEXEC) = 4
mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = -1 EPERM (Operation not permitted)
Comment 11 sean darcy 2015-12-13 17:49:35 UTC
Yes, very puzzling. It doesn't seem a corner case.

This is a standard vanilla HSW lenovo laptop.

Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz

kernel-4.2.6-201.fc22.x86_64

Surprised (amazed ?) this hasn't happened to others.
Comment 12 sean darcy 2016-01-09 19:45:03 UTC
Same issue with 2015Q4 release:

intel-gpu-tools-2.99.917-19.20151206.fc23.x86_64
kernel-4.2.8-300.fc23.x86_64

Maybe kernel 4.3 required ?
Comment 13 Jani Nikula 2016-01-11 07:17:50 UTC
(In reply to sean darcy from comment #12)
> Maybe kernel 4.3 required ?

Shouldn't be. My assumption is it's something about your (distro) environment that we haven't thought of.
Comment 14 Jani Nikula 2016-04-25 09:35:01 UTC
No reports of anyone else experiencing this, and I think it's safe to say we're not working on this. Sorry, worksforme.
Comment 15 Jonathan Briggs 2016-07-14 16:45:01 UTC
I am having exactly this problem.

Fedora 24, 64 bit on a Dell m3800 laptop.

I'm wondering if the driver isn't blocking the mmap of PCI resource0 because it is somehow in use.

Things that I think could be making a difference:
 - Optimus setup with Nvidia secondary GPU
 - DRI 3 is forced on for Intel.
 - X.org is in use
 - resource0 is 4 MB in size but the failed mmap is only for 2 MB.
Comment 16 Dimitry Polivaev 2016-08-21 15:24:26 UTC
I am having the same problem with intel_panel_fitter on fresh installation of ubuntu mate 16.04 . With Linux Mint 18 it had worked on the same computer well but I had some other problems and had to replace it by ubuntu.

$ sudo intel_panel_fitter -p A -x 1200 -y 680
WARNING:
This tool is a workaround for people that don't have a Kernel with overscan compensation properties: it is just a temporary solution that may or may not work. Use it at your own risk.
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Couldn't map MMIO region
Stack trace:
  #0 [_init+0x38d9]
  #1 [_init+0x1536]
  #2 [_init+0x15e1]
  #3 [_init+0xa27]
  #4 [__libc_start_main+0xf0]
  #5 [_init+0x11a1]
  #6 [<unknown>+0x11a1]
Test (null) failed.
**** DEBUG ****
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_panel_fitter:4194) intel-mmio-CRITICAL: Couldn't map MMIO region
****  END  ****
Comment 17 Dimitry Polivaev 2016-08-21 15:27:37 UTC
computer
    description: Desktop Computer
    product: VM42 (SKU)
    vendor: ASUSTeK COMPUTER INC.
    capabilities: smbios-2.7 dmi-2.7 vsyscall32
    configuration: administrator_password=disabled boot=normal chassis=desktop family=Vivo PC frontpanel_password=disabled keyboard_password=disabled power-on_password=disabled sku=SKU uuid=[REMOVED]
  *-core
       description: Motherboard
       product: VM42
       vendor: ASUSTeK COMPUTER INC.
       physical id: 0
       version: To be filled by O.E.M.
       serial: [REMOVED]
       slot: To be filled by O.E.M.
     *-firmware
          description: BIOS
          vendor: ASUSTeK COMPUTER INC. (Licensed from AMI)
          physical id: 0
          version: 1203
          date: 08/28/2015
          size: 64KiB
          capacity: 8128KiB
          capabilities: apm upgrade shadowing cdboot bootselect socketedrom edd int5printscreen int9keyboard acpi usb biosbootspecification uefi
     *-cpu
          description: CPU
          product: Intel(R) Celeron(R) 2957U @ 1.40GHz
          vendor: Intel Corp.
      *-memory
          description: System Memory
          physical id: 2f
          slot: System board or motherboard
          size: 4GiB
        *-bank:0
             description: SODIMM DDR3 Synchronous 1600 MHz (0,6 ns)
             product: M471B5173EB0-YK0
             vendor: Samsung
             physical id: 0
             serial: [REMOVED]
             slot: ChannelA-DIMM0
             size: 4GiB
             width: 64 bits
             clock: 1600MHz (0.6ns)
     *-pci
          description: Host bridge
          product: Haswell-ULT DRAM Controller
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 0b
          width: 32 bits
          clock: 33MHz
          configuration: driver=hsw_uncore
          resources: irq:0
        *-display
             description: VGA compatible controller
             product: Haswell-ULT Integrated Graphics Controller
             vendor: Intel Corporation
             physical id: 2
             bus info: pci@0000:00:02.0
             version: 0b
             width: 64 bits
             clock: 33MHz
             capabilities: msi pm vga_controller bus_master cap_list rom
             configuration: driver=i915 latency=0
             resources: irq:43 memory:f7800000-f7bfffff memory:e0000000-efffffff ioport:f000(size=64)
        *-multimedia:0
             description: Audio device
             product: Haswell-ULT HD Audio Controller
             vendor: Intel Corporation
             physical id: 3
             bus info: pci@0000:00:03.0
             version: 0b
             width: 64 bits
             clock: 33MHz
             capabilities: pm msi pciexpress bus_master cap_list
             configuration: driver=snd_hda_intel latency=0
             resources: irq:46 memory:f7e14000-f7e17fff
Comment 18 Dimitry Polivaev 2016-08-21 15:32:05 UTC
$ apt-show-versions intel-gpu-tools
intel-gpu-tools:amd64/xenial 1.14-1 uptodate
Comment 19 Jani Nikula 2016-08-22 12:26:06 UTC
Does it work from a root shell?
Comment 20 Dimitry Polivaev 2016-08-23 21:14:42 UTC
$ sudo -i
[sudo] password for dimitry: 
root@dimitry-VM42:~# intel_panel_fitter -p A -x 1200 -y 680
WARNING:
This tool is a workaround for people that don't have a Kernel with overscan compensation properties: it is just a temporary solution that may or may not work. Use it at your own risk.
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Couldn't map MMIO region
Stack trace:
  #0 [_init+0x38d9]
  #1 [_init+0x1536]
  #2 [_init+0x15e1]
  #3 [_init+0xa27]
  #4 [__libc_start_main+0xf0]
  #5 [_init+0x11a1]
  #6 [<unknown>+0x11a1]
Test (null) failed.
**** DEBUG ****
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_panel_fitter:4479) intel-mmio-CRITICAL: Couldn't map MMIO region
****  END  ****
FAIL (-1.000s)
root@dimitry-VM42:~#
Comment 21 Dimitry Polivaev 2016-08-30 20:37:22 UTC
As you can see using a root shell does not help either.
If you need any other information please let me know.

Regards,
Dimitry
Comment 22 RamiC. 2016-10-27 07:05:36 UTC
user@Lenovo-G510:~$ apt-show-versions intel-gpu-tools
intel-gpu-tools:amd64/xenial 1.14-1 uptodate

user@Lenovo-G510:~$ sudo intel_gpu_top 
[sudo] password for olokki: 
(intel_gpu_top:24757) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_gpu_top:24757) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_gpu_top:24757) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_gpu_top:24757) intel-mmio-CRITICAL: Couldn't map MMIO region
Stack trace:
  #0 [_init+0x83d9]
  #1 [_init+0x6036]
  #2 [_init+0x1301]
  #3 [__libc_start_main+0xf0]
  #4 [_init+0x2f61]
  #5 [<unknown>+0x2f61]
Test (null) failed.
**** DEBUG ****
(intel_gpu_top:24757) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_gpu_top:24757) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_gpu_top:24757) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_gpu_top:24757) intel-mmio-CRITICAL: Couldn't map MMIO region
****  END  ****
FAIL (-1.000s)
Comment 23 Jari Tahvanainen 2017-03-29 12:39:08 UTC
Moving this from DRM/Intel to IGT, since it seems to be problem with that. Sean, Jonathan, Dimitry and Rami - please check if this problem is still valid with the latest igt.
Comment 24 oskar 2017-10-02 21:34:27 UTC
(In reply to Jari Tahvanainen from comment #23)
> Moving this from DRM/Intel to IGT, since it seems to be problem with that.
> Sean, Jonathan, Dimitry and Rami - please check if this problem is still
> valid with the latest igt.

I've found i have the same issue, running as root:

root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# intel_gpu_top 
(intel_gpu_top:6971) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_gpu_top:6971) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_gpu_top:6971) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_gpu_top:6971) intel-mmio-CRITICAL: Couldn't map MMIO region
Stack trace:
  #0 [_init+0x7369]
  #1 [_init+0x4fd0]
  #2 [_init+0x98e]
  #3 [__libc_start_main+0xf1]
  #4 [_init+0x1752]
  #5 [<unknown>+0x1752]
Test (null) failed.
**** DEBUG ****
(intel_gpu_top:6971) intel-chipset-DEBUG: Test requirement passed: pci_dev
(intel_gpu_top:6971) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
(intel_gpu_top:6971) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
(intel_gpu_top:6971) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
(intel_gpu_top:6971) intel-mmio-CRITICAL: Couldn't map MMIO region
****  END  ****
FAIL (-1.000s)


strace shows failure on opening resource0:
open("/sys/bus/pci/devices/0000:00:02.0/resource", O_RDONLY|O_CLOEXEC) = 4
read(4, "0x00000000e0000000 0x00000000e0f"..., 512) = 512
close(4)                                = 0
open("/sys/bus/pci/devices/0000:00:02.0/resource0", O_RDWR|O_CLOEXEC) = 4
mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = -1 EPERM (Operation not permitted)
close(4)                                = 0
write(2, "(intel_gpu_top:7094) intel-mmio-"..., 131(intel_gpu_top:7094) intel-mmio-CRITICAL: Test assertion failure function intel_mmio_use_pci_bar, file ../../lib/intel_mmio.c:145:
) = 131
write(2, "(intel_gpu_top:7094) intel-mmio-"..., 74(intel_gpu_top:7094) intel-mmio-CRITICAL: Failed assertion: !(error != 0)
) = 74
write(2, "(intel_gpu_top:7094) intel-mmio-"..., 81(intel_gpu_top:7094) intel-mmio-CRITICAL: Last errno: 1, Operation not permitted
) = 81
write(2, "(intel_gpu_top:7094) intel-mmio-"..., 67(intel_gpu_top:7094) intel-mmio-CRITICAL: Couldn't map MMIO region
) = 67

checking if readable with cat:
root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# cat resource
0x00000000e0000000 0x00000000e0ffffff 0x0000000000140204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000c0000000 0x00000000dfffffff 0x000000000014220c
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x000000000000e000 0x000000000000e03f 0x0000000000040101
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000000c0000 0x00000000000dffff 0x0000000000000212
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# cat resource0
cat: resource0: Input/output error
root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# cat resource2
cat: resource2: Input/output error
root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# cat resource2_wc
cat: resource2_wc: Input/output error
root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# cat resource4
cat: resource4: Invalid argument

root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# ls -la resource*
-r--r--r-- 1 root root      4096 okt  2 22:38 resource
-rw------- 1 root root  16777216 okt  2 22:30 resource0
-rw------- 1 root root 536870912 okt  2 22:38 resource2
-rw------- 1 root root 536870912 okt  2 22:38 resource2_wc
-rw------- 1 root root        64 okt  2 22:38 resource4

root@oskar-ThinkPad-X270:/sys/bus/pci/devices/0000:00:02.0# uname -a
Linux oskar-ThinkPad-X270 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


I wonder if it could be related to secure_boot?
Comment 25 oskar 2017-10-02 21:35:34 UTC
Forgot to mention this is ubuntu 17.04 and i intel-gpu-tools are version 1.17-1
Comment 26 Christian Kellner 2018-05-09 21:07:03 UTC
Just stumbled into the same issue, disabled secure boot, and the issue disappeared. Now I am having a different issue, but I think it is just my version being too old.
Comment 27 Jani Nikula 2018-08-31 07:02:11 UTC
Based on an IRC chat with Joonas and Dave, looks like this is indeed kernel lockdown on UEFI secure boot doing its magic. The kernel lockdown patches haven't been merged upstream, so you should not be able to reproduce this on kernel.org upstream kernels. Please file your bugs against your distro if this remains an issue for you.

See e.g. https://mjg59.dreamwidth.org/50577.html for background.

Sorry it took us so long to get this; we're obviously not running non-upstream kernels with lockdown enabled.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.