• T
    x86/mm/mtrr: Fix MTRR state checks in mtrr_type_lookup() · 9b3aca62
    Toshi Kani 提交于
    'mtrr_state.enabled' contains the FE (fixed MTRRs enabled)
    and E (MTRRs enabled) flags in MSR_MTRRdefType.  Intel SDM,
    section 11.11.2.1, defines these flags as follows:
    
     - All MTRRs are disabled when the E flag is clear.
       The FE flag has no affect when the E flag is clear.
     - The default type is enabled when the E flag is set.
     - MTRR variable ranges are enabled when the E flag is set.
     - MTRR fixed ranges are enabled when both E and FE flags
       are set.
    
    MTRR state checks in __mtrr_type_lookup() do not match with SDM.
    
    Hence, this patch makes the following changes:
     - The current code detects MTRRs disabled when both E and
       FE flags are clear in mtrr_state.enabled.  Fix to detect
       MTRRs disabled when the E flag is clear.
     - The current code does not check if the FE bit is set in
       mtrr_state.enabled when looking at the fixed entries.
       Fix to check the FE flag.
     - The current code returns the default type when the E flag
       is clear in mtrr_state.enabled. However, the default type
       is UC when the E flag is clear.  Remove the code as this
       case is handled as MTRR disabled with the 1st change.
    
    In addition, this patch defines the E and FE flags in
    mtrr_state.enabled as follows.
     - FE flag: MTRR_STATE_MTRR_FIXED_ENABLED
     - E  flag: MTRR_STATE_MTRR_ENABLED
    
    print_mtrr_state() and x86_get_mtrr_mem_range() are also updated
    accordingly.
    Signed-off-by: NToshi Kani <toshi.kani@hp.com>
    Signed-off-by: NBorislav Petkov <bp@suse.de>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Elliott@hp.com
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Luis R. Rodriguez <mcgrof@suse.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: dave.hansen@intel.com
    Cc: linux-mm <linux-mm@kvack.org>
    Cc: pebolle@tiscali.nl
    Link: http://lkml.kernel.org/r/1431714237-880-4-git-send-email-toshi.kani@hp.com
    Link: http://lkml.kernel.org/r/1432628901-18044-4-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
    9b3aca62
mtrr.h 4.6 KB