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]
Date:	Tue, 03 Mar 2015 10:25:04 -0800
From:	Joe Perches <joe@...ches.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 01/14] etherdevice: Add eth_<foo>_addr
 CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS code

On Tue, 2015-03-03 at 05:19 -0800, Eric Dumazet wrote:
> On Mon, 2015-03-02 at 19:54 -0800, Joe Perches wrote:
> > Make the memset possibly more efficient with the appropriate
> > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS #ifdef
[]
> > diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
[]
> > @@ -192,7 +192,12 @@ static inline void eth_random_addr(u8 *addr)
> >   */
> >  static inline void eth_broadcast_addr(u8 *addr)
> >  {
> > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
> > +	*(u32 *)addr = 0xffffffff;
> > +	*(u16 *)(addr + 4) = 0xffff;
> > +#else
> >  	memset(addr, 0xff, ETH_ALEN);
> > +#endif
> >  }
> >  
> 
> I am pretty sure compiler already does an inline, and might chose to 
> emit equivalent instructions for :
>  *(u16 *) addr = 0xffff;
>  *(u32 *)(addr + 2) = 0xffffffff;
> 
> if (addr % 4) is known to be 2

(cross-compiled on x86)

At least for arm gcc 4.6.3, it emits different code
for net/l2tp/l2tp_eth.o

old:

-    1cc0:	e3a010ff 	mov	r1, #255	; 0xff
-    1cc4:	e3a02006 	mov	r2, #6
-    1cc8:	e3c33001 	bic	r3, r3, #1
-    1ccc:	e3833002 	orr	r3, r3, #2
-    1cd0:	e5c53000 	strb	r3, [r5]
-    1cd4:	ebfffffe 	bl	0 <memset>
-    1cc8:	e3c33001 	bic	r3, r3, #1

new:

+    1cc0:	e3a02f8a 	mov	r2, #552	; 0x228
+    1cc4:	e3c33001 	bic	r3, r3, #1
+    1cc8:	e3833002 	orr	r3, r3, #2
+    1ccc:	e5c53000 	strb	r3, [r5]
+    1cd0:	e3e03000 	mvn	r3, #0
+    1cd4:	e5843224 	str	r3, [r4, #548]	; 0x224
+    1cd8:	e18430b2 	strh	r3, [r4, r2]


--
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