• Juergen Gross's avatar
    x86/mtrr: Construct a memory map with cache modes · 061b984a
    Juergen Gross authored
    After MTRR initialization construct a memory map with cache modes from
    MTRR values. This will speed up lookups via mtrr_lookup_type()
    especially in case of overlapping MTRRs.
    
    This will be needed when switching the semantics of the "uniform"
    parameter of mtrr_lookup_type() from "only covered by one MTRR" to
    "memory range has a uniform cache mode", which is the data the callers
    really want to know. Today this information is not easily available,
    in case MTRRs are not well sorted regarding base address.
    
    The map will be built in __initdata. When memory management is up, the
    map will be moved to dynamically allocated memory, in order to avoid
    the need of an overly large array. The size of this array is calculated
    using the number of variable MTRR registers and the needed size for
    fixed entries.
    
    Only add the map creation and expansion for now. The lookup will be
    added later.
    
    When writing new MTRR entries in the running system rebuild the map
    inside the call from mtrr_rendezvous_handler() in order to avoid nasty
    race conditions with concurrent lookups.
    
      [ bp: Move out rebuild_map() call and rename it. ]
    Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Tested-by: default avatarMichael Kelley <mikelley@microsoft.com>
    Link: https://lore.kernel.org/r/20230502120931.20719-12-jgross@suse.comSigned-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    061b984a
mtrr.h 2.45 KB