Bug 18304 - xf86MapVidMem() aborts entire server instead of failing gracefuly
Summary: xf86MapVidMem() aborts entire server instead of failing gracefuly
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: 7.4 (2008.09)
Hardware: All Linux (All)
: medium normal
Assignee: Adam Jackson
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-30 02:50 UTC by Arkadiusz Miskiewicz
Modified: 2017-05-23 15:24 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
proposed patch (567 bytes, patch)
2008-10-30 02:50 UTC, Arkadiusz Miskiewicz
no flags Details | Splinter Review

Description Arkadiusz Miskiewicz 2008-10-30 02:50:21 UTC
Created attachment 19959 [details] [review]
proposed patch

The problem is that linux kernel introduced restrictions on /dev/mem access (ie. 2.6.27 with CONFIG_STRICT_DEVMEM turned on).

Driver sis tries to do:
    if(SISPTR(pScrn)->Primary) {
       base = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, 0, 0x2000);
       if(!base) {
          SISErrorLog(pScrn, "(Could not map BIOS scratch area)\n");
          return ret;
       }

unfortunately xf86MapVidMem() implementation for linux does bad things like:

    if (base == MAP_FAILED) {
        FatalError("xf86MapVidMem: Could not mmap framebuffer"
                   " (0x%08lx,0x%lx) (%s)\n", Base, Size,
                   strerror(errno));
    }

On linux with the restriction xservers ends its life with:

xf86MapVidMem: Could not mmap framebuffer (0x00000000,0x2000) (Operation not permitted)

while driver is fully prepared to handle case where xf86MapVidMem fails.

Proposed patch attached.
Comment 1 Jesse Adkins 2010-10-29 17:04:23 UTC
Can you make a patch generated by git format-patch, and send it to xorg-devel@lists.freedesktop.org?

Patches made by git format-patch are easier to apply (and also preserve ownership, in case that's useful to you later).
Comment 2 Adam Jackson 2017-05-23 15:24:43 UTC
commit 9db2af6f757ef9680c70eb731698b7c9f9aca203
Author: Adam Jackson <ajax@redhat.com>
Date:   Fri May 2 12:14:10 2014 -0400

    xfree86: Remove xf86{Map,Unmap}VidMem
    
    This API sucks.  Fortunately it's mostly unused at this point.  geode,
    sis, and xgi need minor patches to use the corresponding pciaccess code,
    neomagic will (more explicitly) lose its non-PCI support, and newport
    will need to be ported to /dev/mem or the platform bus or something.
    
    This should also make it pretty clear that alpha's sparse memory support
    was basically not a thing anymore, very few tears shed.
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Signed-off-by: Adam Jackson <ajax@redhat.com>


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.