lkml.org 
[lkml]   [2023]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 6/6] x86/mtrr: drop sanity check in mtrr_type_lookup_fixed()
    Date
    mtrr_type_lookup_fixed() contains a sanity check for the case it is
    being called with a start address above 1 MB. As it is static and it
    is called only iff the start address is below 1MB, this sanity check
    can be dropped.

    This will remove the last case where mtrr_type_lookup() can return
    MTRR_TYPE_INVALID, so adjust the comment in include/uapi/asm/mtrr.h.

    Note that removing the MTRR_TYPE_INVALID #define from that header
    could break user code, so it has to stay.

    Signed-off-by: Juergen Gross <jgross@suse.com>
    ---
    arch/x86/include/uapi/asm/mtrr.h | 6 +++---
    arch/x86/kernel/cpu/mtrr/generic.c | 6 +-----
    2 files changed, 4 insertions(+), 8 deletions(-)

    diff --git a/arch/x86/include/uapi/asm/mtrr.h b/arch/x86/include/uapi/asm/mtrr.h
    index 376563f2bac1..4aa05c2ffa78 100644
    --- a/arch/x86/include/uapi/asm/mtrr.h
    +++ b/arch/x86/include/uapi/asm/mtrr.h
    @@ -115,9 +115,9 @@ struct mtrr_state_type {
    #define MTRR_NUM_TYPES 7

    /*
    - * Invalid MTRR memory type. mtrr_type_lookup() returns this value when
    - * MTRRs are disabled. Note, this value is allocated from the reserved
    - * values (0x7-0xff) of the MTRR memory types.
    + * Invalid MTRR memory type. No longer used outside of MTRR code.
    + * Note, this value is allocated from the reserved values (0x7-0xff) of
    + * the MTRR memory types.
    */
    #define MTRR_TYPE_INVALID 0xff

    diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
    index c749ec4436a1..c17cb00aac6a 100644
    --- a/arch/x86/kernel/cpu/mtrr/generic.c
    +++ b/arch/x86/kernel/cpu/mtrr/generic.c
    @@ -114,16 +114,12 @@ static int check_type_overlap(u8 *prev, u8 *curr)
    * 0xC0000 - 0xFFFFF : This range is divided into sixty-four 4KB sub-ranges
    *
    * Return Values:
    - * MTRR_TYPE_(type) - Matched memory type
    - * MTRR_TYPE_INVALID - Unmatched
    + * MTRR_TYPE_(type) - Memory type
    */
    static u8 mtrr_type_lookup_fixed(u64 start, u64 end)
    {
    int idx;

    - if (start >= 0x100000)
    - return MTRR_TYPE_INVALID;
    -
    /* 0x0 - 0x7FFFF */
    if (start < 0x80000) {
    idx = 0;
    --
    2.35.3
    \
     
     \ /
      Last update: 2023-03-27 00:12    [W:3.351 / U:0.948 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site