• Mathias Krause's avatar
    x86/alternatives: Fix alt_max_short macro to really be a max() · ad505a7b
    Mathias Krause authored
    commit 6b32c126 upstream.
    
    The alt_max_short() macro in asm/alternative.h does not work as
    intended, leading to nasty bugs. E.g. alt_max_short("1", "3")
    evaluates to 3, but alt_max_short("3", "1") evaluates to 1 -- not
    exactly the maximum of 1 and 3.
    
    In fact, I had to learn it the hard way by crashing my kernel in not
    so funny ways by attempting to make use of the ALTENATIVE_2 macro
    with alternatives where the first one was larger than the second
    one.
    
    According to [1] and commit dbe4058a ("x86/alternatives: Fix
    ALTERNATIVE_2 padding generation properly") the right handed side
    should read "-(-(a < b))" not "-(-(a - b))". Fix that, to make the
    macro work as intended.
    
    While at it, fix up the comments regarding the additional "-", too.
    It's not about gas' usage of s32 but brain dead logic of having a
    "true" value of -1 for the < operator ... *sigh*
    
    Btw., the one in asm/alternative-asm.h is correct. And, appa...
    ad505a7b
alternative-asm.h 2.39 KB