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: <1440078822.685.11.camel@BR9GV9YG.de.ibm.com>
Date:	Thu, 20 Aug 2015 15:53:42 +0200
From:	Ursula Braun <ubraun@...ux.vnet.ibm.com>
To:	David Laight <David.Laight@...LAB.COM>
Cc:	"davem@...emloft.net" <davem@...emloft.net>,
	"schwidefsky@...ibm.com" <schwidefsky@...ibm.com>,
	"heiko.carstens@...ibm.com" <heiko.carstens@...ibm.com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
	"ursula.braun@...ibm.com" <ursula.braun@...ibm.com>,
	Vaishali Thakkar <vthakkar1994@...il.com>
Subject: RE: [PATCH net-next 2/3] qeth: Convert use of __constant_htons to
 htons

On Thu, 2015-08-20 at 11:51 +0000, David Laight wrote:
> From: Ursula Braun [mailto:ubraun@...ux.vnet.ibm.com]
> > Sent: 20 August 2015 12:44
> > On Thu, 2015-08-20 at 10:46 +0000, David Laight wrote:
> > > From: Ursula Braun
> > > > Sent: 19 August 2015 09:21
> > > > In little endian cases, the macro htons unfolds to __swab16 which
> > > > provides special case for constants. In big endian cases,
> > > > __constant_htons and htons expand directly to the same expression.
> > > > So, replace __constant_htons with htons with the goal of getting
> > > > rid of the definition of __constant_htons completely.
> > > ...
> > > > diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
> > > > index 70eb2f6..ecfe622 100644
> > > > --- a/drivers/s390/net/qeth_l3_main.c
> > > > +++ b/drivers/s390/net/qeth_l3_main.c
> > > > @@ -1887,13 +1887,13 @@ static inline int qeth_l3_rebuild_skb(struct qeth_card *card,
> > > >  		case QETH_CAST_MULTICAST:
> > > >  			switch (prot) {
> > > >  #ifdef CONFIG_QETH_IPV6
> > > > -			case __constant_htons(ETH_P_IPV6):
> > > > +			case htons(ETH_P_IPV6):
> > >
> > > I didn't think htons() was 'constant enough' to be used as a case label.
> > >
> > > Using byteswapped constants in a case statement can change it from being
> > > implemented as a jump table to a branch tree.
> > > This might be more expensive than byteswapping the value (even on systems
> > > that don't have cheap byteswap instructions).
> > >
> > > 	David
> > >
> > For big endian systems both __constant_htons(x) and htons(x) are
> > resolved to ((__force __be16)(__u16)(x)). Thus I do not see a reason to
> > reject the patch proposal from Vaishali Thakkar.
> 
> Look at a little-endian one (eg amd64).
> I think you'll find a C ?: expression that uses __builtin_constant() to
> select between an expression the compiler can evaluate and a call to an
> inline function that uses some appropriate asm.
> The latter isn't a compile-time constant so can't be used as a case
> label or as an initialiser.
> 
> 	David
> 
> 
qeth is an s390-driver, and s390 is a big-endian architecture. Thus
arguments valid for little-endian do not apply to qeth-code.

Ursula

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