lkml.org 
[lkml]   [2017]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] x86/alternatives: Fix alt_max_short macro to really be a max()
On 5 October 2017 at 09:58, Mathias Krause <minipli@googlemail.com> wrote:
> On 5 October 2017 at 09:38, Borislav Petkov <bp@alien8.de> wrote:
>> On Wed, Oct 04, 2017 at 08:08:12PM +0200, Mathias Krause wrote:
>>> diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
>>> index c096624137ae..7c553f48f163 100644
>>> --- a/arch/x86/include/asm/alternative.h
>>> +++ b/arch/x86/include/asm/alternative.h
>>> @@ -106,9 +106,9 @@ static inline int alternatives_text_reserved(void *start, void *end)
>>> * max without conditionals. Idea adapted from:
>> ^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> You did read this part, right?

Oh, btw., quoting its counter part from arch/x86/include/asm/alternative-asm.h:

/*
* max without conditionals. Idea adapted from:
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
*/
#define alt_max_short(a, b) ((a) ^ (((a) ^ (b)) & -(-((a) < (b)))))

Note the "<"! ...comment is wrong, though the implementation works!

Cheers,
Mathias

\
 
 \ /
  Last update: 2017-10-05 14:36    [W:0.217 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site