lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 2 Dec 2019 07:42:48 -0300
From:   Pablo Sebastián Greco <pgreco@...tosproject.org>
To:     Kalle Valo <kvalo@...eaurora.org>
Cc:     Felix Fietkau <nbd@....name>,
        Lorenzo Bianconi <lorenzo.bianconi83@...il.com>,
        Ryder Lee <ryder.lee@...iatek.com>,
        Roy Luo <royluo@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Matthias Brugger <matthias.bgg@...il.com>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] mt76: mt7615: Fix build with older compilers


On 2/12/19 06:25, Kalle Valo wrote:
> Pablo Greco <pgreco@...tosproject.org> writes:
>
>> Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
>> FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
>> Convert inline function to a macro.
>>
>> Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
>> signal strength reporting")
>> Reported in https://lkml.org/lkml/2019/9/21/146
>>
>> Reported-by: kbuild test robot <lkp@...el.com>
>> Signed-off-by: Pablo Greco <pgreco@...tosproject.org>
>> ---
>>   drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> index c77adc5d2552..77e395ca2c6a 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> @@ -13,10 +13,7 @@
>>   #include "../dma.h"
>>   #include "mac.h"
>>   
>> -static inline s8 to_rssi(u32 field, u32 rxv)
>> -{
>> -	return (FIELD_GET(field, rxv) - 220) / 2;
>> -}
>> +#define to_rssi(field, rxv)		((FIELD_GET(field, rxv) - 220) / 2)
> What about u32_get_bits() instead of FIELD_GET(), would that work? I
> guess chances for that is slim, but it's always a shame to convert a
> function to a macro so we should try other methods first.
Anything that doesn't check field at build time should work, but between 
losing a check, or turning an inline into a macro, I'd rather use the macro.
> Or even better if we could fix FIELD_GET() to work with older compilers.
>
The problem is not FIELD_GET itself, is that the compiler is trying to 
use "field" as a variable, instead as the macro expansion of GENMASK, as 
if the function wasn't inline.
In the linked page you can see this message

BUILD_BUG_ON failed: (((field) + (1ULL << (__builtin_ffsll(field) - 1))) 
& (((field) + (1ULL << (__builtin_ffsll(field) - 1))) - 1)) != 0
      _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

which is is not right, because "field" should never be used for that check.



Pablo.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ