• V
    x86: fix Xorg crash with xf86MapVidMem error · c26421d0
    Venki Pallipadi 提交于
    Clarify the usage of mtrr_lookup() in PAT code, and to make PAT code
    resilient to mtrr lookup problems.
    
    Specifically, pat_x_mtrr_type() is restructured to highlight, under what
    conditions we look for mtrr hint. pat_x_mtrr_type() uses a default type
    when there are any errors in mtrr lookup (still maintaining the pat
    consistency). And, reserve_memtype() highlights its usage ot mtrr_lookup
    for request type of '-1' and also defaults in a sane way on any mtrr
    lookup failure.
    
    pat.c looks at mtrr type of a range to get a hint on what mapping type
    to request when user/API: (1) hasn't specified any type (/dev/mem
    mapping) and we do not want to take performance hit by always mapping
    UC_MINUS. This will be the case for /dev/mem mappings used to map BIOS
    area or ACPI region which are WB'able. In this case, as long as MTRR is
    not WB, PAT will request UC_MINUS for such mappings.
    
    (2) user/API requests WB mapping while in reality MTRR may have UC or
    WC. In this case, PAT can map as WB (without checking MTRR) and still
    effective type will be UC or WC. But, a subsequent request to map same
    region as UC or WC may fail, as the region will get trackked as WB in
    PAT list. Looking at MTRR hint helps us to track based on effective type
    rather than what user requested. Again, here mtrr_lookup is only used as
    hint and we fallback to WB mapping (as requested by user) as default.
    
    In both cases, after using the mtrr hint, we still go through the
    memtype list to make sure there are no inconsistencies among multiple
    users.
    Signed-off-by: NVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
    Signed-off-by: NSuresh Siddha <suresh.b.siddha@intel.com>
    Tested-by: NRufus &amp; Azrael <rufus-azrael@numericable.fr>
    Signed-off-by: NIngo Molnar <mingo@elte.hu>
    c26421d0
pat.c 14.7 KB