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: <CAOJe8K2u3UMwx-oaF6qRHOxgYQtHdvZHG6cxo3JRyVj4TWyRyg@mail.gmail.com>
Date:	Fri, 21 Nov 2014 09:46:06 +0400
From:	Denis Kirjanov <kda@...ux-powerpc.org>
To:	Daniel Borkmann <dborkman@...hat.com>
Cc:	netdev@...r.kernel.org, Alexei Starovoitov <ast@...mgrid.com>
Subject: Re: [PATCH net-next] filter: add bpf_optimize_div()

On 11/21/14, Daniel Borkmann <dborkman@...hat.com> wrote:
> On 11/20/2014 08:42 PM, Denis Kirjanov wrote:
>> optimize_div() found in  mips bpf jit is really usefull
>> for other arches. So let's put it in filter.h
>>
>> CC: Alexei Starovoitov <ast@...mgrid.com>
>> Signed-off-by: Denis Kirjanov <kda@...ux-powerpc.org>
>
> NAK
>
> 1) There's no user of this function (you name MIPS JIT, but
>     don't remove it from there) ...

Right, I wanted to get some feedback before removing/adding it to the
other places.

>
> 2) It's not really specific or tied to the BPF API in particular,
>     so doesn't really belong here, rather some more generic kernel
>     header, iff anything.

I was thinking about the best place to put this helper since this
looks more or less generic...
Actually I had to put the RFC tag to the patch

>
>> ---
>>   include/linux/filter.h | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/include/linux/filter.h b/include/linux/filter.h
>> index ca95abd..b385637 100644
>> --- a/include/linux/filter.h
>> +++ b/include/linux/filter.h
>> @@ -414,6 +414,17 @@ static inline void bpf_jit_dump(unsigned int flen,
>> unsigned int proglen,
>>   		print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
>>   			       16, 1, image, proglen, false);
>>   }
>> +
>> +static inline int bpf_optimize_div(u32 *k)
>> +{
>> +	/* power of 2 divides can be implemented with right shift */
>> +	if (!(*k & (*k-1))) {
>> +		*k = ilog2(*k);
>> +		return 1;
>> +	}
>> +
>> +	return 0;
>> +}
>>   #else
>>   static inline void bpf_jit_compile(struct bpf_prog *fp)
>>   {
>>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ