• Juergen Gross's avatar
    x86/mtrr: Simplify mtrr_bp_init() · 74069135
    Juergen Gross authored
    In case of the generic cache interface being used (Intel CPUs or a
    64-bit system), the initialization sequence of the boot CPU is more
    complicated than necessary:
    
    - check if MTRR enabled, if yes, call mtrr_bp_pat_init() which will
      disable caching, set the PAT MSR, and reenable caching
    
    - call mtrr_cleanup(), in case that changed anything, call
      cache_cpu_init() doing the same caching disable/enable dance as
      above, but this time with setting the (modified) MTRR state (even
      if MTRR was disabled) AND setting the PAT MSR (again even with
      disabled MTRR)
    
    The sequence can be simplified a lot while removing potential
    inconsistencies:
    
    - check if MTRR enabled, if yes, call mtrr_cleanup() and then
      cache_cpu_init()
    
    This ensures to:
    
    - no longer disable/enable caching more than once
    
    - avoid to set MTRRs and/or the PAT MSR on the boot processor in case
      of MTRR cleanups even if MTRRs meant to be disabled
    
    With that mtrr_bp_pat_init() can be removed.
    Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/20221102074713.21493-10-jgross@suse.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
    74069135
generic.c 21.4 KB