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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171004152203.2a4f564d@cakuba.netronome.com>
Date:   Wed, 4 Oct 2017 15:22:03 -0700
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     Matthias Kaehlcke <mka@...omium.org>
Cc:     Joe Perches <joe@...ches.com>,
        "David S . Miller" <davem@...emloft.net>,
        Simon Horman <simon.horman@...ronome.com>,
        Dirk van der Merwe <dirk.vandermerwe@...ronome.com>,
        oss-drivers@...ronome.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Renato Golin <renato.golin@...aro.org>,
        Manoj Gupta <manojgupta@...omium.org>,
        Guenter Roeck <groeck@...omium.org>,
        Doug Anderson <dianders@...omium.org>
Subject: Re: [PATCH] nfp: convert nfp_eth_set_bit_config() into a macro

On Wed, 4 Oct 2017 11:49:57 -0700, Matthias Kaehlcke wrote:
> Hi Joe,
> 
> El Wed, Oct 04, 2017 at 11:07:19AM -0700 Joe Perches ha dit:
> 
> > On Tue, 2017-10-03 at 13:05 -0700, Matthias Kaehlcke wrote:  
> > > nfp_eth_set_bit_config() is marked as __always_inline to allow gcc to
> > > identify the 'mask' parameter as known to be constant at compile time,
> > > which is required to use the FIELD_GET() macro.
> > > 
> > > The forced inlining does the trick for gcc, but for kernel builds with
> > > clang it results in undefined symbols:  
> > 
> > Can't you use local different FIELD_PREP/FIELD_GET macros
> > with a different name without the BUILD_BUG tests?
> > 
> > i.e.:
> > 
> > #define NFP_FIELD_PREP(_mask, _val)				\
> > ({								\
> > 	((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask);	\
> > })
> > 
> > #define NFP_FIELD_GET(_mask, _reg)				\
> > ({								\
> > 	(typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask));	\
> > })
> > 
> > Then the __always_inline can be removed from
> > nfp_eth_set_bit_config too.  
> 
> Thanks for the suggestion. This seems a viable alternative if David
> and the NFP owners can live without the extra checking provided by
> __BF_FIELD_CHECK.

The reason the __BF_FIELD_CHECK refuses to compile non-constant masks
is that it will require runtime ffs on the mask, which is potentially
costly.  I would also feel quite stupid adding those macros to the nfp
driver, given that I specifically created the bitfield.h header to not
have to reimplement these in every driver I write/maintain.

Can you please test the patch I provided in the other reply?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ